From 30d03e12bcfa0b6f2dc53d1f658cd6965a4d815e Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sun, 13 Oct 2013 17:12:36 +0000 Subject: OSX: Get mounted volumes better method by using volume enums --- source/blender/editors/space_file/fsmenu.c | 49 +++++++++++------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 04c68e5ea68..f8c8551726b 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -425,43 +425,30 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) if (err != noErr) continue; - pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle); - - if (!CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingASCII)) - continue; - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED); + /* Get mounted volumes better method see: */ + /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/ + /* we get all volumes here including network and do not relay on user-defined finder visibility anymore -> less confusing */ + /* TODO: find out why network volumes only show up when "touched" once and implement a "mount" perhaps */ + + CFURLEnumeratorResult result = kCFURLEnumeratorSuccess; + CFURLEnumeratorRef volEnum = CFURLEnumeratorCreateForMountedVolumes(NULL, kCFURLEnumeratorSkipInvisibles, NULL); - CFRelease(pathString); - CFRelease(cfURL); + while (result != kCFURLEnumeratorEnd) { + unsigned char defPath[FILE_MAX]; + + result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL); + if (result != kCFURLEnumeratorSuccess) + continue; + + CFURLGetFileSystemRepresentation(cfURL, false, (UInt8*)defPath, FILE_MAX); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)defPath, FS_INSERT_SORTED); + } + CFRelease(volEnum); } CFRelease(pathesArray); CFRelease(list); - /* Then get network volumes */ - err = noErr; - for (i = 1; err != nsvErr; i++) { - FSRef dir; - FSVolumeRefNum volRefNum; - struct GetVolParmsInfoBuffer volParmsBuffer; - unsigned char path[FILE_MAX]; - - err = FSGetVolumeInfo(kFSInvalidVolumeRefNum, i, &volRefNum, kFSVolInfoNone, NULL, NULL, &dir); - if (err != noErr) - continue; - - err = FSGetVolumeParms(volRefNum, &volParmsBuffer, sizeof(volParmsBuffer)); - if ((err != noErr) || (volParmsBuffer.vMServerAdr == 0)) /* Exclude local devices */ - continue; - - - FSRefMakePath(&dir, path, FILE_MAX); - if (strcmp((char *)path, "/home") && strcmp((char *)path, "/net")) { - /* /net and /home are meaningless on OSX, home folders are stored in /Users */ - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED); - } - } - /* Finally get user favorite places */ if (read_bookmarks) { list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL); -- cgit v1.2.3 From 6d54ff5d833c93220b46f051a6955648661be83e Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sun, 13 Oct 2013 18:14:38 +0000 Subject: OSX: Final cleanup for #60729 --- source/blender/editors/space_file/fsmenu.c | 65 +++++++++++------------------- 1 file changed, 23 insertions(+), 42 deletions(-) diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index f8c8551726b..952e8494ef5 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -400,57 +400,38 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) } } #else - /* 10.5 provides ability to retrieve Finder favorite places */ - UInt32 seed; - OSErr err = noErr; - CFArrayRef pathesArray; - LSSharedFileListRef list; - LSSharedFileListItemRef itemRef; - CFIndex i, pathesCount; - CFURLRef cfURL = NULL; - CFStringRef pathString = NULL; + /* Get mounted volumes better method OSX 10.5 and higher, see: */ + /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/ + /* we get all volumes here including network and do not relay on user-defined finder visibility anymore -> less confusing */ + /* TODO: find out why network volumes only show up when "touched" once and implement a "mount" perhaps */ - /* First get local mounted volumes */ - list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteVolumes, NULL); - pathesArray = LSSharedFileListCopySnapshot(list, &seed); - pathesCount = CFArrayGetCount(pathesArray); + CFURLRef cfURL = NULL; + CFURLEnumeratorResult result = kCFURLEnumeratorSuccess; + CFURLEnumeratorRef volEnum = CFURLEnumeratorCreateForMountedVolumes(NULL, kCFURLEnumeratorSkipInvisibles, NULL); - for (i = 0; i < pathesCount; i++) { - itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); - - err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction | - kLSSharedFileListDoNotMountVolumes, - &cfURL, NULL); - if (err != noErr) - continue; - - /* Get mounted volumes better method see: */ - /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/ - /* we get all volumes here including network and do not relay on user-defined finder visibility anymore -> less confusing */ - /* TODO: find out why network volumes only show up when "touched" once and implement a "mount" perhaps */ + while (result != kCFURLEnumeratorEnd) { + unsigned char defPath[FILE_MAX]; - CFURLEnumeratorResult result = kCFURLEnumeratorSuccess; - CFURLEnumeratorRef volEnum = CFURLEnumeratorCreateForMountedVolumes(NULL, kCFURLEnumeratorSkipInvisibles, NULL); + result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL); + if (result != kCFURLEnumeratorSuccess) + continue; - while (result != kCFURLEnumeratorEnd) { - unsigned char defPath[FILE_MAX]; - - result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL); - if (result != kCFURLEnumeratorSuccess) - continue; - - CFURLGetFileSystemRepresentation(cfURL, false, (UInt8*)defPath, FILE_MAX); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)defPath, FS_INSERT_SORTED); + CFURLGetFileSystemRepresentation(cfURL, false, (UInt8*)defPath, FILE_MAX); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)defPath, FS_INSERT_SORTED); } - CFRelease(volEnum); - } - CFRelease(pathesArray); - CFRelease(list); + CFRelease(volEnum); /* Finally get user favorite places */ if (read_bookmarks) { + UInt32 seed; + OSErr err = noErr; + CFArrayRef pathesArray; + LSSharedFileListRef list; + LSSharedFileListItemRef itemRef; + CFIndex i, pathesCount; + CFURLRef cfURL = NULL; + CFStringRef pathString = NULL; list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL); pathesArray = LSSharedFileListCopySnapshot(list, &seed); pathesCount = CFArrayGetCount(pathesArray); -- cgit v1.2.3 From e4b9e28b8691d668095ddd2c20cbd64166213120 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 13 Oct 2013 18:17:46 +0000 Subject: Fix for a bug in StrokeCleaner identified through a discussion for Bug #36425 (freestyle edge marks not working). Many thanks for Anthony Edlin who helped fix the issue. --- release/scripts/freestyle/style_modules/parameter_editor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/release/scripts/freestyle/style_modules/parameter_editor.py b/release/scripts/freestyle/style_modules/parameter_editor.py index dd6206fff99..83bd8dbda5e 100644 --- a/release/scripts/freestyle/style_modules/parameter_editor.py +++ b/release/scripts/freestyle/style_modules/parameter_editor.py @@ -32,7 +32,7 @@ from freestyle import BackboneStretcherShader, BezierCurveShader, BinaryPredicat FalseBP1D, FalseUP1D, GuidingLinesShader, Interface0DIterator, Nature, Noise, Normal2DF0D, Operators, \ PolygonalizationShader, QuantitativeInvisibilityF1D, QuantitativeInvisibilityUP1D, SamplingShader, \ SpatialNoiseShader, StrokeAttribute, StrokeShader, TipRemoverShader, TrueBP1D, TrueUP1D, UnaryPredicate0D, \ - UnaryPredicate1D, VertexOrientation2DF0D, WithinImageBoundaryUP1D, ContextFunctions + UnaryPredicate1D, VertexOrientation2DF0D, WithinImageBoundaryUP1D, ContextFunctions, TVertex from Functions0D import CurveMaterialF0D from PredicatesU1D import pyNatureUP1D from logical_operators import AndUP1D, NotUP1D, OrUP1D @@ -1085,6 +1085,8 @@ def iter_three_segments(stroke): it3.increment() it4.increment() +def is_tvertex(svertex): + return type(svertex.viewvertex) is TVertex class StrokeCleaner(StrokeShader): def shade(self, stroke): @@ -1092,7 +1094,10 @@ class StrokeCleaner(StrokeShader): seg1 = sv2.point - sv1.point seg2 = sv3.point - sv2.point seg3 = sv4.point - sv3.point - if seg1.dot(seg2) < 0.0 and seg2.dot(seg3) < 0.0: + if not ((is_tvertex(sv2.first_svertex) and is_tvertex(sv2.second_svertex)) or + (is_tvertex(sv3.first_svertex) and is_tvertex(sv3.second_svertex))): + continue + if seg1.dot(seg2) < 0.0 and seg2.dot(seg3) < 0.0 and seg2.length < 0.01: #print(sv2.first_svertex.viewvertex) #print(sv2.second_svertex.viewvertex) #print(sv3.first_svertex.viewvertex) -- cgit v1.2.3 From 98d66aeb973f91b8dd13ab082b16f3d45e47636b Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sun, 13 Oct 2013 18:51:21 +0000 Subject: OSX: comment cleanup --- source/blender/editors/space_file/fsmenu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 952e8494ef5..6237492f711 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -402,8 +402,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) #else /* Get mounted volumes better method OSX 10.5 and higher, see: */ /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/ - /* we get all volumes here including network and do not relay on user-defined finder visibility anymore -> less confusing */ - /* TODO: find out why network volumes only show up when "touched" once and implement a "mount" perhaps */ + /* we get all volumes sorted including network and do not relay on user-defined finder visibility, less confusing */ CFURLRef cfURL = NULL; CFURLEnumeratorResult result = kCFURLEnumeratorSuccess; -- cgit v1.2.3 From ee63ef7af17cb793d9c6947e6f47de7c36df58af Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 13 Oct 2013 20:46:02 +0000 Subject: Project Pampa request: option to lock frame selection to the range This means when you've got "Lock Frame Selection" option (which is in the timeline next to the preview range button) you're not able to go to the frames which are out of current frame range with your mouse. TODO: Make it so current frame slider also respects this setting? Not so much important for tonight. --- release/scripts/startup/bl_ui/space_time.py | 4 +++- source/blender/editors/animation/anim_ops.c | 10 +++++++++- source/blender/makesdna/DNA_scene_types.h | 1 + source/blender/makesrna/intern/rna_scene.c | 8 ++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py index de8be9dff99..fb78194d1a4 100644 --- a/release/scripts/startup/bl_ui/space_time.py +++ b/release/scripts/startup/bl_ui/space_time.py @@ -40,7 +40,9 @@ class TIME_HT_header(Header): row.menu("TIME_MT_frame") row.menu("TIME_MT_playback") - layout.prop(scene, "use_preview_range", text="", toggle=True) + row = layout.row(align=True) + row.prop(scene, "use_preview_range", text="", toggle=True) + row.prop(scene, "lock_frame_selection_to_range", text="", toggle=True) row = layout.row(align=True) if not scene.use_preview_range: diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 15a75c57758..af9b58736ef 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -118,13 +118,21 @@ static int change_frame_exec(bContext *C, wmOperator *op) static int frame_from_event(bContext *C, const wmEvent *event) { ARegion *region = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); float viewx; + int frame; /* convert from region coordinates to View2D 'tot' space */ UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &viewx, NULL); /* round result to nearest int (frames are ints!) */ - return (int)floor(viewx + 0.5f); + frame = (int)floor(viewx + 0.5f); + + if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) { + CLAMP(frame, PSFRA, PEFRA); + } + + return frame; } /* Modal Operator init */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 232fe62df31..6ebc604bc7e 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1212,6 +1212,7 @@ typedef struct Scene { /* flag */ /* use preview range */ #define SCER_PRV_RANGE (1<<0) +#define SCER_LOCK_FRAME_SELECTION (1<<1) /* mode (int now) */ #define R_OSA 0x0001 diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 4d35acc84a0..b37c1326205 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -5220,6 +5220,14 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Current Frame Final", "Current frame with subframe and time remapping applied"); + prop = RNA_def_property(srna, "lock_frame_selection_to_range", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_sdna(prop, NULL, "r.flag", SCER_LOCK_FRAME_SELECTION); + RNA_def_property_ui_text(prop, "Lock Frame Selection", + "Don't allow frame to be selected with mouse outside of frame range"); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL); + RNA_def_property_ui_icon(prop, ICON_LOCKED, 0); + /* Preview Range (frame-range for UI playback) */ prop = RNA_def_property(srna, "use_preview_range", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); -- cgit v1.2.3 From 56e326caf1eb912246957b5a4e4b0d3e177b4225 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 13 Oct 2013 22:26:53 +0000 Subject: Properties Editor / Mesh Data: * Give the uiLists a default size of 1, when we don't have any element in it. This saves some space. Vertex Groups and Shape Keys list will jump to 5 as before when we have an element, due to the additional buttons, for the others, just grow with additional elements. --- release/scripts/startup/bl_ui/properties_data_mesh.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index a703222ecd0..b04d91b0fc9 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -191,7 +191,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel): ob = context.object group = ob.vertex_groups.active - rows = 2 + rows = 1 if group: rows = 5 @@ -250,7 +250,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel): row = layout.row() - rows = 2 + rows = 1 if kb: rows = 5 row.template_list("MESH_UL_shape_keys", "", key, "key_blocks", ob, "active_shape_key_index", rows=rows) @@ -329,17 +329,17 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel): layout = self.layout me = context.mesh + lay = me.uv_textures.active row = layout.row() col = row.column() - col.template_list("MESH_UL_uvmaps_vcols", "uvmaps", me, "uv_textures", me.uv_textures, "active_index", rows=2) + col.template_list("MESH_UL_uvmaps_vcols", "uvmaps", me, "uv_textures", me.uv_textures, "active_index", rows=1) col = row.column(align=True) col.operator("mesh.uv_texture_add", icon='ZOOMIN', text="") col.operator("mesh.uv_texture_remove", icon='ZOOMOUT', text="") - - lay = me.uv_textures.active + if lay: layout.prop(lay, "name") @@ -352,17 +352,17 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel): layout = self.layout me = context.mesh + lay = me.vertex_colors.active row = layout.row() col = row.column() - col.template_list("MESH_UL_uvmaps_vcols", "vcols", me, "vertex_colors", me.vertex_colors, "active_index", rows=2) + col.template_list("MESH_UL_uvmaps_vcols", "vcols", me, "vertex_colors", me.vertex_colors, "active_index", rows=1) col = row.column(align=True) col.operator("mesh.vertex_color_add", icon='ZOOMIN', text="") col.operator("mesh.vertex_color_remove", icon='ZOOMOUT', text="") - - lay = me.vertex_colors.active + if lay: layout.prop(lay, "name") -- cgit v1.2.3 From 014318370da2a038bb791aa0ea1c84f0a1e061d8 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 13 Oct 2013 22:33:30 +0000 Subject: * Silence Blender Internal / Volumetric printf. --- source/blender/render/intern/source/volume_precache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index 6912f998e7a..539422a96fb 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -513,7 +513,7 @@ static void vol_precache_part(TaskPool *pool, void *taskdata, int threadid) if (re->test_break && re->test_break(re->tbh)) return; - printf("thread id %d\n", threadid); + //printf("thread id %d\n", threadid); res[0]= pa->res[0]; res[1]= pa->res[1]; -- cgit v1.2.3 From 6e86760de2974483dbd4a2aa4ae8c6dc1dbdea66 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 13 Oct 2013 23:04:39 +0000 Subject: Interface / Template lists: * Make the gap for the filtering options slightly bigger, so 1 row doesn't look so cluttered. * Default Render Layer and Particle System list in the Properties Editor to 1 row as well, to save space. --- release/scripts/startup/bl_ui/properties_particle.py | 2 +- release/scripts/startup/bl_ui/properties_render_layer.py | 3 ++- source/blender/editors/interface/interface_templates.c | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 0d526514b5c..cf90a775275 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -98,7 +98,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): row = layout.row() row.template_list("UI_UL_list", "particle_systems", ob, "particle_systems", - ob.particle_systems, "active_index", rows=2) + ob.particle_systems, "active_index", rows=1) col = row.column(align=True) col.operator("object.particle_system_add", icon='ZOOMIN', text="") diff --git a/release/scripts/startup/bl_ui/properties_render_layer.py b/release/scripts/startup/bl_ui/properties_render_layer.py index 2514cca8c0f..66479b11a2b 100644 --- a/release/scripts/startup/bl_ui/properties_render_layer.py +++ b/release/scripts/startup/bl_ui/properties_render_layer.py @@ -57,7 +57,8 @@ class RENDERLAYER_PT_layers(RenderLayerButtonsPanel, Panel): rd = scene.render row = layout.row() - row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=2) + col = row.column() + col.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=1) col = row.column(align=True) col.operator("scene.render_layer_add", icon='ZOOMIN', text="") diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6b6b7114c84..1a5ab57706f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -3065,11 +3065,11 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co if (ui_list->filter_flag & UILST_FLT_SHOW) { but = uiDefIconButBitI(subblock, TOG, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_DOWN, 0, 0, - UI_UNIT_X, UI_UNIT_Y * 0.6f, &(ui_list->filter_flag), 0, 0, 0, 0, + UI_UNIT_X, UI_UNIT_Y * 0.8f, &(ui_list->filter_flag), 0, 0, 0, 0, TIP_("Hide filtering options")); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ - but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.6f, ui_list, + but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.8f, ui_list, 0.0, 0.0, 0, -1, ""); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ @@ -3083,11 +3083,11 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co } else { but = uiDefIconButBitI(subblock, TOG, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_RIGHT, 0, 0, - UI_UNIT_X, UI_UNIT_Y * 0.6f, &(ui_list->filter_flag), 0, 0, 0, 0, + UI_UNIT_X, UI_UNIT_Y * 0.8f, &(ui_list->filter_flag), 0, 0, 0, 0, TIP_("Show filtering options")); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ - but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.6f, ui_list, + but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.8f, ui_list, 0.0, 0.0, 0, -1, ""); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ -- cgit v1.2.3 From f79eff29849b667770b5c630ad6e44e8581a3297 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 13 Oct 2013 23:24:37 +0000 Subject: Interface / Template Lists: * Reduce the space of more lists, should be all in bl_ui/ --- release/scripts/startup/bl_ui/properties_data_armature.py | 6 +++--- release/scripts/startup/bl_ui/properties_data_mesh.py | 4 ++-- release/scripts/startup/bl_ui/properties_freestyle.py | 2 +- release/scripts/startup/bl_ui/properties_mask_common.py | 2 +- release/scripts/startup/bl_ui/properties_material.py | 2 +- release/scripts/startup/bl_ui/properties_particle.py | 4 ++-- release/scripts/startup/bl_ui/properties_physics_common.py | 2 +- release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py | 2 +- release/scripts/startup/bl_ui/properties_scene.py | 4 ++-- release/scripts/startup/bl_ui/space_clip.py | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index e01764a5496..a274453a472 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -121,9 +121,9 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel): row = layout.row() - rows = 2 + rows = 1 if group: - rows = 5 + rows = 4 row.template_list("UI_UL_list", "bone_groups", pose, "bone_groups", pose.bone_groups, "active_index", rows=rows) col = row.column(align=True) @@ -184,7 +184,7 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel): # list of poses in pose library row = layout.row() row.template_list("UI_UL_list", "pose_markers", poselib, "pose_markers", - poselib.pose_markers, "active_index", rows=5) + poselib.pose_markers, "active_index", rows=3) # column of operators for active pose # - goes beside list diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index b04d91b0fc9..e8d0bec6524 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -193,7 +193,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel): rows = 1 if group: - rows = 5 + rows = 4 row = layout.row() row.template_list("MESH_UL_vgroups", "", ob, "vertex_groups", ob.vertex_groups, "active_index", rows=rows) @@ -252,7 +252,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel): rows = 1 if kb: - rows = 5 + rows = 4 row.template_list("MESH_UL_shape_keys", "", key, "key_blocks", ob, "active_shape_key_index", rows=rows) col = row.column() diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py b/release/scripts/startup/bl_ui/properties_freestyle.py index a96441a26e5..a57567ae79e 100644 --- a/release/scripts/startup/bl_ui/properties_freestyle.py +++ b/release/scripts/startup/bl_ui/properties_freestyle.py @@ -193,7 +193,7 @@ class RENDERLAYER_PT_freestyle_lineset(RenderLayerFreestyleEditorButtonsPanel, P layout.active = rl.use_freestyle row = layout.row() - rows = 5 if lineset else 2 + rows = 4 if lineset else 1 row.template_list("RENDERLAYER_UL_linesets", "", freestyle, "linesets", freestyle.linesets, "active_index", rows=rows) sub = row.column(align=True) diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py index 45f3471ad35..203e5078ee4 100644 --- a/release/scripts/startup/bl_ui/properties_mask_common.py +++ b/release/scripts/startup/bl_ui/properties_mask_common.py @@ -82,7 +82,7 @@ class MASK_PT_layers: mask = sc.mask active_layer = mask.layers.active - rows = 5 if active_layer else 2 + rows = 4 if active_layer else 1 row = layout.row() row.template_list("MASK_UL_layers", "", mask, "layers", diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index bb0b137da0a..344074c5893 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -124,7 +124,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): if ob: row = layout.row() - row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=2) + row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=1) col = row.column(align=True) col.operator("object.material_slot_add", icon='ZOOMIN', text="") diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index cf90a775275..2bf2795ef8a 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -642,7 +642,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, Panel): layout.label(text="Fluid interaction:") row = layout.row() - row.template_list("UI_UL_list", "particle_targets", psys, "targets", psys, "active_particle_target_index") + row.template_list("UI_UL_list", "particle_targets", psys, "targets", psys, "active_particle_target_index", rows=4) col = row.column() sub = col.row() @@ -730,7 +730,7 @@ class PARTICLE_PT_boidbrain(ParticleButtonsPanel, Panel): row.label(text="") row = layout.row() - row.template_list("UI_UL_list", "particle_boids_rules", state, "rules", state, "active_boid_rule_index") + row.template_list("UI_UL_list", "particle_boids_rules", state, "rules", state, "active_boid_rule_index", rows=4) col = row.column() sub = col.row() diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index 22c71c233c2..4b4c331d2d8 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -107,7 +107,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): if not cachetype == 'RIGID_BODY': row = layout.row() row.template_list("UI_UL_list", "point_caches", cache, "point_caches", - cache.point_caches, "active_index", rows=2) + cache.point_caches, "active_index", rows=1) col = row.column(align=True) col.operator("ptcache.add", icon='ZOOMIN', text="") col.operator("ptcache.remove", icon='ZOOMOUT', text="") diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py index 75c4caa57bd..f0c7a532414 100644 --- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py +++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py @@ -80,7 +80,7 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel): row = layout.row() row.template_list("PHYSICS_UL_dynapaint_surfaces", "", canvas, "canvas_surfaces", - canvas.canvas_surfaces, "active_index", rows=2) + canvas.canvas_surfaces, "active_index", rows=1) col = row.column(align=True) col.operator("dpaint.surface_slot_add", icon='ZOOMIN', text="") diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index a04283de8bf..5e9cbbda21f 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -94,7 +94,7 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, Panel): row = layout.row() col = row.column() - col.template_list("UI_UL_list", "keying_sets", scene, "keying_sets", scene.keying_sets, "active_index", rows=2) + col.template_list("UI_UL_list", "keying_sets", scene, "keying_sets", scene.keying_sets, "active_index", rows=1) col = row.column(align=True) col.operator("anim.keying_set_add", icon='ZOOMIN', text="") @@ -138,7 +138,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel): row = layout.row() col = row.column() - col.template_list("SCENE_UL_keying_set_paths", "", ks, "paths", ks.paths, "active_index", rows=2) + col.template_list("SCENE_UL_keying_set_paths", "", ks, "paths", ks.paths, "active_index", rows=1) col = row.column(align=True) col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="") diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 540b707cf93..df48592eb13 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -507,7 +507,7 @@ class CLIP_PT_objects(CLIP_PT_clip_view_panel, Panel): row = layout.row() row.template_list("CLIP_UL_tracking_objects", "", tracking, "objects", - tracking, "active_object_index", rows=3) + tracking, "active_object_index", rows=1) sub = row.column(align=True) @@ -783,7 +783,7 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel): row = layout.row() row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks", - stab, "active_track_index", rows=3) + stab, "active_track_index", rows=2) sub = row.column(align=True) -- cgit v1.2.3 From 0cbdac99b89c0eacf4cf52bb4594e9a1e6653511 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 13 Oct 2013 23:45:41 +0000 Subject: Interface: * More compact and better looking Vertex Groups panel (Particle System). * Smaller uiLists for Cycles as well. --- intern/cycles/blender/addon/ui.py | 4 +- .../scripts/startup/bl_ui/properties_particle.py | 50 ++++++++++++---------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 7a03df4f35a..cbf26fb8d0a 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -324,7 +324,7 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel): rl = rd.layers.active row = layout.row() - row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=2) + row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=1) col = row.column(align=True) col.operator("scene.render_layer_add", icon='ZOOMIN', text="") @@ -503,7 +503,7 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel): if ob: row = layout.row() - row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=2) + row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=1) col = row.column(align=True) col.operator("object.material_slot_add", icon='ZOOMIN', text="") diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 2bf2795ef8a..0b4974832b8 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -1214,28 +1214,34 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel): ob = context.object psys = context.particle_system - split = layout.split(percentage=0.85) - - col = split.column() - col.label(text="Vertex Group:") - col.prop_search(psys, "vertex_group_density", ob, "vertex_groups", text="Density") - col.prop_search(psys, "vertex_group_length", ob, "vertex_groups", text="Length") - col.prop_search(psys, "vertex_group_clump", ob, "vertex_groups", text="Clump") - col.prop_search(psys, "vertex_group_kink", ob, "vertex_groups", text="Kink") - col.prop_search(psys, "vertex_group_roughness_1", ob, "vertex_groups", text="Roughness 1") - col.prop_search(psys, "vertex_group_roughness_2", ob, "vertex_groups", text="Roughness 2") - col.prop_search(psys, "vertex_group_roughness_end", ob, "vertex_groups", text="Roughness End") - - col = split.column() - col.label(text="Negate:") - col.alignment = 'RIGHT' - col.prop(psys, "invert_vertex_group_density", text="") - col.prop(psys, "invert_vertex_group_length", text="") - col.prop(psys, "invert_vertex_group_clump", text="") - col.prop(psys, "invert_vertex_group_kink", text="") - col.prop(psys, "invert_vertex_group_roughness_1", text="") - col.prop(psys, "invert_vertex_group_roughness_2", text="") - col.prop(psys, "invert_vertex_group_roughness_end", text="") + col = layout.column() + row = col.row(align=True) + row.prop_search(psys, "vertex_group_density", ob, "vertex_groups", text="Density") + row.prop(psys, "invert_vertex_group_density", text="", toggle=True, icon='ARROW_LEFTRIGHT') + + row = col.row(align=True) + row.prop_search(psys, "vertex_group_length", ob, "vertex_groups", text="Length") + row.prop(psys, "invert_vertex_group_length", text="", toggle=True, icon='ARROW_LEFTRIGHT') + + row = col.row(align=True) + row.prop_search(psys, "vertex_group_clump", ob, "vertex_groups", text="Clump") + row.prop(psys, "invert_vertex_group_clump", text="", toggle=True, icon='ARROW_LEFTRIGHT') + + row = col.row(align=True) + row.prop_search(psys, "vertex_group_kink", ob, "vertex_groups", text="Kink") + row.prop(psys, "invert_vertex_group_kink", text="", toggle=True, icon='ARROW_LEFTRIGHT') + + row = col.row(align=True) + row.prop_search(psys, "vertex_group_roughness_1", ob, "vertex_groups", text="Roughness 1") + row.prop(psys, "invert_vertex_group_roughness_1", text="", toggle=True, icon='ARROW_LEFTRIGHT') + + row = col.row(align=True) + row.prop_search(psys, "vertex_group_roughness_2", ob, "vertex_groups", text="Roughness 2") + row.prop(psys, "invert_vertex_group_roughness_2", text="", toggle=True, icon='ARROW_LEFTRIGHT') + + row = col.row(align=True) + row.prop_search(psys, "vertex_group_roughness_end", ob, "vertex_groups", text="Roughness End") + row.prop(psys, "invert_vertex_group_roughness_end", text="", toggle=True, icon='ARROW_LEFTRIGHT') # Commented out vertex groups don't work and are still waiting for better implementation # row = layout.row() -- cgit v1.2.3 From 78de5efec1a7a4581c22ae8e3e777cd354a0f054 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Oct 2013 07:10:38 +0000 Subject: fix for array index use before checking range --- source/blender/blenkernel/intern/armature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 6b2b782717d..83161801069 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -405,7 +405,7 @@ static void equalize_bezier(float *data, int desired) dist = ((float)a) * ddist; /* we're looking for location (distance) 'dist' in the array */ - while ((dist >= pdist[nr]) && nr < MAX_BBONE_SUBDIV) + while ((nr < MAX_BBONE_SUBDIV) && (dist >= pdist[nr])) nr++; fac1 = pdist[nr] - pdist[nr - 1]; -- cgit v1.2.3 From 52296b941ebd06e24393bc0c913044b7705c6be7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Oct 2013 07:15:59 +0000 Subject: code cleanup: remove duplicate assignments --- source/blender/blenkernel/intern/sequencer.c | 1 - source/blender/blenkernel/intern/subsurf_ccg.c | 3 --- source/blender/compositor/operations/COM_InpaintOperation.cpp | 1 - 3 files changed, 5 deletions(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index dd7e847feaf..925355d9383 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1854,7 +1854,6 @@ void BKE_sequencer_color_balance_apply(StripColorBalance *cb, ImBuf *ibuf, float init_data.cb = cb; init_data.ibuf = ibuf; init_data.mul = mul; - init_data.mask = NULL; init_data.make_float = make_float; init_data.mask = mask_input; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 9a38a5f87b8..ac11a012347 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -3183,9 +3183,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, /* reuse of ccgDM_getNumTessFaces is intentional here: subsurf polys are just created from tessfaces */ ccgdm->dm.getNumPolys = ccgDM_getNumTessFaces; - ccgdm->dm.getNumGrids = ccgDM_getNumGrids; - ccgdm->dm.getPBVH = ccgDM_getPBVH; - ccgdm->dm.getVert = ccgDM_getFinalVert; ccgdm->dm.getEdge = ccgDM_getFinalEdge; ccgdm->dm.getTessFace = ccgDM_getFinalFace; diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp index edcd1563e03..b64c98be0c7 100644 --- a/source/blender/compositor/operations/COM_InpaintOperation.cpp +++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp @@ -48,7 +48,6 @@ void InpaintSimpleOperation::initExecution() { this->m_inputImageProgram = this->getInputSocketReader(0); - this->m_cached_buffer = NULL; this->m_pixelorder = NULL; this->m_manhatten_distance = NULL; this->m_cached_buffer = NULL; -- cgit v1.2.3 From dfea1dd0d7c2d188a5b29ca9cb883d943aa75086 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Mon, 14 Oct 2013 08:03:53 +0000 Subject: Fix #37057, Detach (Alt + D) doesn't work in nodes editor / compositor. The operator exits early when there are no internal links. This prevents it from removing links which have no internal connection. --- source/blender/blenkernel/intern/node.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index c0df306a3fa..6e2780b48f4 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -959,9 +959,6 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node) { bNodeLink *link, *link_next; - if (node->internal_links.first == NULL) - return; - /* store link pointers in output sockets, for efficient lookup */ for (link = node->internal_links.first; link; link = link->next) link->tosock->link = link; -- cgit v1.2.3 From a90b8ebe48a767b95b9c867518b9b60f9624a5d2 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Mon, 14 Oct 2013 08:03:55 +0000 Subject: Fix for crash from double-freeing in nodes: The way node groups check for localized trees in the ntreeFreeTree_ex function does not work. When the main library is freed on exit it also frees genuine node groups trees (which is correct), but then node groups referencing these trees will not find them in the library and interpret that as a localized group, attempting to free them a second time ... Nicer solution is to just use a special flag on localized node trees so we can clearly distinguish them from genuine trees in main. --- source/blender/blenkernel/intern/node.c | 5 +++-- source/blender/makesdna/DNA_node_types.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 6e2780b48f4..cc4263f4392 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1672,8 +1672,8 @@ static void free_localized_node_groups(bNodeTree *ntree) for (node = ntree->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP && node->id) { bNodeTree *ngroup = (bNodeTree *)node->id; - if (BLI_findindex(&G.main->nodetree, ngroup) == -1) { - /* ntree is not in library, i.e. localized node group: free it */ + if (ngroup->flag & NTREE_IS_LOCALIZED) { + /* ntree is a localized copy: free it */ ntreeFreeTree_ex(ngroup, false); MEM_freeN(ngroup); } @@ -1960,6 +1960,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) * Note: previews are not copied here. */ ltree = ntreeCopyTree_internal(ntree, NULL, FALSE, FALSE, FALSE); + ltree->flag |= NTREE_IS_LOCALIZED; for (node = ltree->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP && node->id) { diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 75b9540f736..451dd20daa6 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -402,6 +402,7 @@ typedef struct bNodeTree { #define NTREE_TWO_PASS 4 /* two pass */ #define NTREE_COM_GROUPNODE_BUFFER 8 /* use groupnode buffers */ #define NTREE_VIEWER_BORDER 16 /* use a border for viewer nodes */ +#define NTREE_IS_LOCALIZED 32 /* tree is localized copy, free when deleting node groups */ /* XXX not nice, but needed as a temporary flags * for group updates after library linking. -- cgit v1.2.3 From 3cfd933d947659c5b7abd8d8521b2ebff312dacc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Oct 2013 08:23:57 +0000 Subject: code cleanup: correct unsigned int in string formatting and use empty() checks for vectors. --- source/blender/compositor/operations/COM_WriteBufferOperation.cpp | 4 ++-- source/blender/makesrna/intern/makesrna.c | 4 ++-- source/blender/render/intern/source/volume_precache.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index cf462607936..c73cb3ae325 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -157,14 +157,14 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device, rcti *rect, this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer); // STEP 4 - while (clMemToCleanUp->size() > 0) { + while (!clMemToCleanUp->empty()) { cl_mem mem = clMemToCleanUp->front(); error = clReleaseMemObject(mem); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } clMemToCleanUp->pop_front(); } - while (clKernelsToCleanUp->size() > 0) { + while (!clKernelsToCleanUp->empty()) { cl_kernel kernel = clKernelsToCleanUp->front(); error = clReleaseKernel(kernel); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 8a4022de104..71e4fd4efd5 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1555,7 +1555,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR } else if (prop->arraydimension && prop->totarraylength) { fprintf(f, "void %sget(PointerRNA *ptr, int values[%u]);\n", func, prop->totarraylength); - fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->totarraylength); + fprintf(f, "void %sset(PointerRNA *ptr, const int values[%u]);\n", func, prop->totarraylength); } else { fprintf(f, "void %sget(PointerRNA *ptr, int values[]);\n", func); @@ -1571,7 +1571,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR } else if (prop->arraydimension && prop->totarraylength) { fprintf(f, "void %sget(PointerRNA *ptr, float values[%u]);\n", func, prop->totarraylength); - fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->totarraylength); + fprintf(f, "void %sset(PointerRNA *ptr, const float values[%u]);\n", func, prop->totarraylength); } else { fprintf(f, "void %sget(PointerRNA *ptr, float values[]);\n", func); diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index 539422a96fb..e5e3aff573d 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -495,7 +495,7 @@ typedef struct VolPrecacheState { int totparts; } VolPrecacheState; -static void vol_precache_part(TaskPool *pool, void *taskdata, int threadid) +static void vol_precache_part(TaskPool *pool, void *taskdata, int UNUSED(threadid)) { VolPrecacheState *state = (VolPrecacheState *)BLI_task_pool_userdata(pool); VolPrecachePart *pa = (VolPrecachePart *)taskdata; -- cgit v1.2.3 From a00c693f995c655dc29d19e6bde1837e6d30881f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Oct 2013 08:45:43 +0000 Subject: note in bisect tooltip that you need to click-drag the plane. --- source/blender/editors/mesh/editmesh_bisect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 5431b1deb1c..7b5a6e50d9f 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -300,7 +300,7 @@ void MESH_OT_bisect(struct wmOperatorType *ot) /* identifiers */ ot->name = "Bisect"; - ot->description = "Cut geometry along a plane"; + ot->description = "Cut geometry along a plane (click-drag to define plane)"; ot->idname = "MESH_OT_bisect"; /* api callbacks */ -- cgit v1.2.3 From bca37c29d8b43f8e3cc85a435b46c4e42f55017b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 14 Oct 2013 11:42:36 +0000 Subject: FIx #37005: Mask tool + "Area" Brush Mapping + "Anchored" Stroke = crash Was caused by area normal calvultion using undo nodes to get coords from and undo nodes does not contain coords whe using mask tool. --- source/blender/editors/sculpt_paint/sculpt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 2a6b6d4b3d9..b41a2d0f4c9 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1082,6 +1082,7 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod float out_flip[3] = {0.0f, 0.0f, 0.0f}; SculptSession *ss = ob->sculpt; + const Brush *brush = BKE_paint_brush(&sd->paint); int n, original; /* Grab brush requires to test on original data (see r33888 and @@ -1090,8 +1091,14 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod TRUE : ss->cache->original); /* In general the original coords are not available with dynamic - * topology */ - if (ss->bm) + * topology + * + * Mask tool could not use undo nodes to get coordinates from + * since the coordinates are not stored in those odes. + * And mask tool is not gonna to modify vertex coordinates, + * so we don't actually need to use modified coords. + */ + if (ss->bm || brush->sculpt_tool == SCULPT_TOOL_MASK) original = FALSE; (void)sd; /* unused w/o openmp */ -- cgit v1.2.3 From ac9f3e33d5ba039615a632ee0cf0ed3bbfacb799 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Mon, 14 Oct 2013 15:37:16 +0000 Subject: OSX/fs_menue: change the availability macros, so ppl could still compile on 10.5 by just also using 10.4 code then --- source/blender/editors/space_file/fsmenu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 6237492f711..172488f2c57 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -350,7 +350,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) #else #ifdef __APPLE__ { -#if (MAC_OS_X_VERSION_MIN_REQUIRED <= 1040) +#if (MAC_OS_X_VERSION_MIN_REQUIRED <= 1050) OSErr err = noErr; int i; const char *home; @@ -399,8 +399,8 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); } } -#else - /* Get mounted volumes better method OSX 10.5 and higher, see: */ +#else /* OSX 10.6+ */ + /* Get mounted volumes better method OSX 10.6 and higher, see: */ /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/ /* we get all volumes sorted including network and do not relay on user-defined finder visibility, less confusing */ @@ -458,7 +458,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) CFRelease(pathesArray); CFRelease(list); } -#endif /* OSX 10.5+ */ +#endif /* OSX 10.6+ */ } #else /* unix */ -- cgit v1.2.3 From e3e21a268324df11861e96299ffb16830b5075b9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 14 Oct 2013 15:56:48 +0000 Subject: Fix #37043: bpy.ops.sequencer.rebuild_proxy() don't release memory --- source/blender/imbuf/intern/indexer.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 93324b94cdc..49a40c461ac 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -656,7 +656,6 @@ static int add_to_proxy_output_ffmpeg( static void free_proxy_output_ffmpeg(struct proxy_output_ctx *ctx, int rollback) { - int i; char fname[FILE_MAX]; char fname_tmp[FILE_MAX]; @@ -674,18 +673,12 @@ static void free_proxy_output_ffmpeg(struct proxy_output_ctx *ctx, avcodec_close(ctx->c); - for (i = 0; i < ctx->of->nb_streams; i++) { - if (&ctx->of->streams[i]) { - av_freep(&ctx->of->streams[i]); - } - } - if (ctx->of->oformat) { if (!(ctx->of->oformat->flags & AVFMT_NOFILE)) { avio_close(ctx->of->pb); } } - av_free(ctx->of); + avformat_free_context(ctx->of); MEM_freeN(ctx->video_buffer); @@ -854,6 +847,9 @@ static void index_rebuild_ffmpeg_finish(FFmpegIndexBuilderContext *context, int } } + avcodec_close(context->iCodecCtx); + avformat_close_input(&context->iFormatCtx); + MEM_freeN(context); } -- cgit v1.2.3 From c72b4016d0c7a8464bc2f0a65ba193768a697ffb Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 14 Oct 2013 16:38:47 +0000 Subject: * Improved Tooltip for Particle Brownian property, patch by Jonathan Williamson. Thanks! --- source/blender/makesrna/intern/rna_particle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 8dafe54e678..5151310cd64 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -2718,7 +2718,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "brownfac"); RNA_def_property_range(prop, 0.0f, 200.0f); RNA_def_property_ui_range(prop, 0, 20, 1, 3); - RNA_def_property_ui_text(prop, "Brownian", "Amount of Brownian motion"); + RNA_def_property_ui_text(prop, "Brownian", "Amount of random, erratic particle movement"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE); -- cgit v1.2.3 From d9f1ca1c3f92b6889a2e067673b9224f4eb4a690 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 14 Oct 2013 17:14:43 +0000 Subject: Interface / Text: * Add "Open" operator to the Text Editor header, it's a common operation next to New. * Add Body Text property to the Font panel for Text objects, so text can easily be pasted into Blender and editing it becomes easier too. This was only accessible via the RNA Data blocks before. --- release/scripts/startup/bl_ui/properties_data_curve.py | 4 ++++ release/scripts/startup/bl_ui/space_text.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index 117a662cd07..5269d151bdc 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -306,6 +306,10 @@ class DATA_PT_font(CurveButtonsPanel, Panel): row.template_ID(text, "font_bold_italic", open="font.open", unlink="font.unlink") #layout.prop(text, "font") + + row = layout.split(percentage=0.25) + row.label(text="Body Text:") + row.prop(text, "body", text="") split = layout.split() diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index 41ded2fe768..32cb1009492 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -49,7 +49,7 @@ class TEXT_HT_header(Header): sub.alert = True sub.operator("text.resolve_conflict", text="", icon='HELP') - row.template_ID(st, "text", new="text.new", unlink="text.unlink") + row.template_ID(st, "text", new="text.new", unlink="text.unlink", open="text.open") row = layout.row(align=True) row.prop(st, "show_line_numbers", text="") -- cgit v1.2.3 From 709ed80487455ca0d5fcba45c5997e9784081995 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 14 Oct 2013 19:36:47 +0000 Subject: UV editor: remove duplicate Select Split entry from UV menu. --- release/scripts/startup/bl_ui/space_image.py | 1 - 1 file changed, 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 17ed7b44cf1..cc2d1dc1e66 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -106,7 +106,6 @@ class IMAGE_MT_select(Menu): layout.operator("uv.select_all").action = 'TOGGLE' layout.operator("uv.select_all", text="Inverse").action = 'INVERT' - layout.operator("uv.select_split") layout.separator() -- cgit v1.2.3 From 95812e1cfcd68e911a03422cb1bf441e29f1dd29 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 14 Oct 2013 19:37:12 +0000 Subject: Fix cycles textured draw mode problem with objects that have an image texture but not UV coordinates, it would show a different color with the object selected and deselected. --- source/blender/editors/space_view3d/drawmesh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 16423c60cac..269b9247c81 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -976,8 +976,8 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); - if (glsl || picking) { - /* draw glsl */ + if (glsl || picking || !CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) { + /* draw glsl or solid */ dm->drawMappedFacesMat(dm, tex_mat_set_material_cb, set_face_cb, &data); -- cgit v1.2.3 From c0d204b91e348a0ff1f97164a0697d38aff72d4c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 14 Oct 2013 19:37:15 +0000 Subject: Fix Brush datablock writing MTex blocks to .blend files twice. Patch by Janis Streib. --- source/blender/blenloader/intern/writefile.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index a2c91969cf8..83122e24b34 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2903,9 +2903,6 @@ static void write_brushes(WriteData *wd, ListBase *idbase) writestruct(wd, ID_BR, "Brush", 1, brush); if (brush->id.properties) IDP_WriteProperty(brush->id.properties, wd); - writestruct(wd, DATA, "MTex", 1, &brush->mtex); - writestruct(wd, DATA, "MTex", 1, &brush->mask_mtex); - if (brush->curve) write_curvemapping(wd, brush->curve); } -- cgit v1.2.3 From 46b807b2318ee03f7a261c6f53d2ad965bf58028 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Oct 2013 19:53:28 +0000 Subject: fix [#37072] Crash on RMB click on bone's custom property --- source/blender/makesrna/intern/rna_access.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 341ba02fd47..9a8533ec6a1 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4901,6 +4901,7 @@ int RNA_collection_length(PointerRNA *ptr, const char *name) bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost) { + prop = rna_ensure_property(prop); if (prop->flag & PROP_IDPROPERTY) { IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier); return ((idprop != NULL) && (use_ghost == false || !(idprop->flag & IDP_FLAG_GHOST))); @@ -4912,6 +4913,7 @@ bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost) bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop) { + prop = rna_ensure_property(prop); if (prop->flag & PROP_IDPROPERTY) { IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier); return ((idprop != NULL) && !(idprop->flag & IDP_FLAG_GHOST)); @@ -4923,6 +4925,7 @@ bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop) void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop) { + prop = rna_ensure_property(prop); if (prop->flag & PROP_IDPROPERTY) { rna_idproperty_free(ptr, prop->identifier); } -- cgit v1.2.3 From 7e64342f4399214ecb86e362cd9990ea527364c9 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Mon, 14 Oct 2013 19:57:16 +0000 Subject: Fix for #37070: LineStyle appears in Outliner by default though Freestyle is not enabled. --- source/blender/editors/space_outliner/outliner_tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 10890a305fb..de97230362b 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -429,7 +429,8 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s outliner_add_element(soops, lb, sce->world, te, 0, 0); - outliner_add_line_styles(soops, lb, sce, te); + if (sce->r.mode & R_EDGE_FRS) + outliner_add_line_styles(soops, lb, sce, te); } // can be inlined if necessary -- cgit v1.2.3 From afce7e071a8658c4f1664532248edebc90534fe5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 14 Oct 2013 20:13:40 +0000 Subject: Fix particle group use count option losing objects for linked groups. There was no reason to go through newlibadr here, go->ob should already have the right pointer. --- source/blender/blenloader/intern/readfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 077b476c408..23686986c7f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3700,7 +3700,7 @@ static void lib_link_particlesettings(FileData *fd, Main *main) /* if we have indexes, let's use them */ for (dw = part->dupliweights.first; dw; dw = dw->next) { GroupObject *go = (GroupObject *)BLI_findlink(&part->dup_group->gobject, dw->index); - dw->ob = go ? newlibadr(fd, part->id.lib, dw->ob) : NULL; + dw->ob = go ? go->ob : NULL; } } else { -- cgit v1.2.3 From 34946e7f045344a43b263f78d001d2ed7ec3c26b Mon Sep 17 00:00:00 2001 From: Jonathan Williamson Date: Mon, 14 Oct 2013 21:03:18 +0000 Subject: Added poll function to disable "Remove Shape key from object". This disables the "-" button when no shape keys exist on the currently selected object. Thanks to Campbell for the help on my first real commit! --- source/blender/editors/object/object_shapekey.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index ea96db514b2..6be4a2fed2c 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -290,6 +290,17 @@ static int shape_key_mode_poll(bContext *C) return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT); } +static int shape_key_mode_exists_poll(bContext *C) +{ + Object *ob = ED_object_context(C); + ID *data = (ob) ? ob->data : NULL; + + /* same as shape_key_mode_poll */ + return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT) && + /* check a keyblock exists */ + (BKE_keyblock_from_object(ob) != NULL); +} + static int shape_key_poll(bContext *C) { Object *ob = ED_object_context(C); @@ -359,6 +370,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot) /* api callbacks */ ot->poll = shape_key_mode_poll; + ot->poll = shape_key_mode_exists_poll; ot->exec = shape_key_remove_exec; /* flags */ -- cgit v1.2.3 From 913a542468d21ce2fecd1159c8261829c0fc3fad Mon Sep 17 00:00:00 2001 From: Jonathan Williamson Date: Mon, 14 Oct 2013 21:41:03 +0000 Subject: Rename "Show Python Tooltips" to "Python Tooltips" This makes the naming more consistent with other options, such as "Tooltips" and "Object Info" --- source/blender/makesrna/intern/rna_userdef.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 20e5083b1c4..2a12194dfa1 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2909,7 +2909,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) prop = RNA_def_property(srna, "show_tooltips_python", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_TOOLTIPS_PYTHON); - RNA_def_property_ui_text(prop, "Show Python Tooltips", "Show Python references in tooltips"); + RNA_def_property_ui_text(prop, "Python Tooltips", "Show Python references in tooltips"); prop = RNA_def_property(srna, "show_object_info", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_DRAWVIEWINFO); -- cgit v1.2.3 From f9f2e2073952cb8abed2eb10bae0d367f7e51e0a Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Mon, 14 Oct 2013 23:08:45 +0000 Subject: A follow-up to Bug #37070: LineStyle appears in Outliner by default though Freestyle is not enabled. Line style data blocks are shown in the outliner only when the Blender Internal is used. --- source/blender/editors/space_outliner/outliner_tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index de97230362b..a93ed2dc6b0 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -428,8 +428,8 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0); outliner_add_element(soops, lb, sce->world, te, 0, 0); - - if (sce->r.mode & R_EDGE_FRS) + + if (STREQ(sce->r.engine, "BLENDER_RENDER") && (sce->r.mode & R_EDGE_FRS)) outliner_add_line_styles(soops, lb, sce, te); } -- cgit v1.2.3 From d4cf5e360558fb8e1cfdc181ec6c8f981c4c5a3d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Oct 2013 00:24:53 +0000 Subject: fix [#37078] Search props don't react on click at the right end (where 'X' is if field not empty) --- source/blender/editors/interface/interface_handlers.c | 11 ++++++++++- source/blender/editors/interface/interface_intern.h | 1 + source/blender/editors/interface/interface_widgets.c | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index c5faa99e067..0d49b08c167 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2648,7 +2648,9 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { /* unlink icon is on right */ - if (ELEM4(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS) { + if (ELEM4(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS && + ui_is_but_search_unlink_visible(but)) + { ARegion *ar = data->region; rcti rect; int x = event->x, y = event->y; @@ -5761,6 +5763,13 @@ bool ui_is_but_interactive(uiBut *but) return true; } +bool ui_is_but_search_unlink_visible(uiBut *but) +{ + BLI_assert(but->type == SEARCH_MENU_UNLINK); + return ((but->editstr == NULL) && + (but->drawstr[0] != '\0')); +} + uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) { uiBlock *block; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 9cc16d82810..46c6e980ccc 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -402,6 +402,7 @@ extern bool ui_is_but_unit(uiBut *but); extern bool ui_is_but_rna_valid(uiBut *but); extern bool ui_is_but_utf8(uiBut *but); extern bool ui_is_but_interactive(uiBut *but); +extern bool ui_is_but_search_unlink_visible(uiBut *but); extern int ui_is_but_push_ex(uiBut *but, double *value); extern int ui_is_but_push(uiBut *but); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 4be8812d68c..215e9df4ae1 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -961,7 +961,7 @@ static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect) if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE; - if (but->type == SEARCH_MENU_UNLINK && !but->editstr) + if ((but->type == SEARCH_MENU_UNLINK) && ui_is_but_search_unlink_visible(but)) okwidth -= BLI_rcti_size_y(rect); okwidth = max_ii(okwidth, 0); @@ -1325,7 +1325,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB } /* unlink icon for this button type */ - if (but->type == SEARCH_MENU_UNLINK && !but->editstr && but->drawstr[0]) { + if ((but->type == SEARCH_MENU_UNLINK) && ui_is_but_search_unlink_visible(but)) { rcti temp = *rect; temp.xmin = temp.xmax - (BLI_rcti_size_y(rect) * 1.08f); -- cgit v1.2.3 From ebc2cc15c0dc6a00f47b951401eaf2c78547ffe6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Oct 2013 02:23:28 +0000 Subject: fix [#37067] Bone Crash Holding Ctrl+RMB is supposed to select objects, while in editmode, however it would end up calling editmode selection as well as pose selection while an armature was in editmode (which caused the crash). Add the ability for view3d_opengl_select() to skip editmode selection. --- source/blender/editors/space_view3d/view3d_select.c | 14 +++++++++++--- source/blender/editors/space_view3d/view3d_view.c | 16 +++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index c48ce8a2343..ff17c2eedc1 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1374,13 +1374,15 @@ static void deselect_all_tracks(MovieTracking *tracking) } /* mval is region coords */ -static bool mouse_select(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle, bool obcenter, short enumerate) +static bool mouse_select(bContext *C, const int mval[2], + bool extend, bool deselect, bool toggle, bool obcenter, bool enumerate, bool object) { ViewContext vc; ARegion *ar = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); Base *base, *startbase = NULL, *basact = NULL, *oldbasact = NULL; + bool is_obedit; float dist = 100.0f; int retval = false; short hits; @@ -1389,6 +1391,12 @@ static bool mouse_select(bContext *C, const int mval[2], bool extend, bool desel /* setup view context for argument to callbacks */ view3d_set_viewcontext(C, &vc); + + is_obedit = (vc.obedit != NULL); + if (object) { + /* signal for view3d_opengl_select to skip editmode objects */ + vc.obedit = NULL; + } /* always start list from basact in wire mode */ startbase = FIRSTBASE; @@ -1564,7 +1572,7 @@ static bool mouse_select(bContext *C, const int mval[2], bool extend, bool desel ED_base_object_select(basact, BA_SELECT); } - if (oldbasact != basact) { + if ((oldbasact != basact) && (is_obedit == false)) { ED_base_object_activate(C, basact); /* adds notifier */ } } @@ -2256,7 +2264,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op) else if (paint_vertsel_test(obact)) retval = mouse_weight_paint_vertex_select(C, location, extend, deselect, toggle, obact); else - retval = mouse_select(C, location, extend, deselect, toggle, center, enumerate); + retval = mouse_select(C, location, extend, deselect, toggle, center, enumerate, object); /* passthrough allows tweaks * FINISHED to signal one operator worked diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 74d72061995..b74527159c2 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -876,10 +876,12 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) } } -/* IGLuint-> GLuint */ -/* Warning: be sure to account for a negative return value - * This is an error, "Too many objects in select buffer" - * and no action should be taken (can crash blender) if this happens +/** + * \warning be sure to account for a negative return value + * This is an error, "Too many objects in select buffer" + * and no action should be taken (can crash blender) if this happens + * + * \note (vc->obedit == NULL) can be set to explicitly skip edit-object selection. */ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int bufsize, rcti *input) { @@ -890,6 +892,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b short code, hits; char dt; short dtx; + const bool use_obedit_skip = (scene->obedit != NULL) && (vc->obedit == NULL); G.f |= G_PICKSEL; @@ -937,8 +940,11 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b for (base = scene->base.first; base; base = base->next) { if (base->lay & v3d->lay) { - if (base->object->restrictflag & OB_RESTRICT_SELECT) + if ((base->object->restrictflag & OB_RESTRICT_SELECT) || + (use_obedit_skip && (scene->obedit->data == base->object->data))) + { base->selcol = 0; + } else { base->selcol = code; glLoadName(code); -- cgit v1.2.3 From 39593b9b11bb4a33fd6e2989485b4f878da04fff Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Oct 2013 05:55:51 +0000 Subject: sphinx docgen wasn't including example scripts for python methods of RNA types. --- .../examples/bpy.types.WindowManager.popup_menu.py | 2 -- doc/python_api/sphinx_doc_gen.py | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py b/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py index df591521440..8d2e101be5f 100644 --- a/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py +++ b/doc/python_api/examples/bpy.types.WindowManager.popup_menu.py @@ -1,6 +1,4 @@ """ -Popup Menus -+++++++++++ Popup menus can be useful for creating menus without having to register menu classes. Note that they will not block the scripts execution, so the caller can't wait for user input. diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index e661bb01e60..e95fa6fef35 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -466,7 +466,9 @@ ClassMethodDescriptorType = type(dict.__dict__['fromkeys']) MethodDescriptorType = type(dict.get) GetSetDescriptorType = type(int.real) StaticMethodType = type(staticmethod(lambda: None)) -from types import MemberDescriptorType +from types import (MemberDescriptorType, + MethodType, + ) _BPY_STRUCT_FAKE = "bpy_struct" _BPY_PROP_COLLECTION_FAKE = "bpy_prop_collection" @@ -629,12 +631,12 @@ def pymethod2sphinx(ident, fw, identifier, py_func): fw("\n") -def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True): +def pyfunc2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_class=True): ''' function or class method to sphinx ''' - if type(py_func) == type(bpy.types.Space.draw_handler_add): + if type(py_func) == MethodType: return arg_str = inspect.formatargspec(*inspect.getargspec(py_func)) @@ -657,6 +659,11 @@ def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True): write_indented_lines(ident + " ", fw, py_func.__doc__) fw("\n") + if is_class: + write_example_ref(ident + " ", fw, module_name + "." + type_name + "." + identifier) + else: + write_example_ref(ident + " ", fw, module_name + "." + identifier) + def py_descr2sphinx(ident, fw, descr, module_name, type_name, identifier): if identifier.startswith("_"): @@ -867,7 +874,7 @@ def pymodule2sphinx(basepath, module_name, module, title): for attribute, value, value_type in module_dir_value_type: if value_type == types.FunctionType: - pyfunc2sphinx("", fw, attribute, value, is_class=False) + pyfunc2sphinx("", fw, module_name, None, attribute, value, is_class=False) elif value_type in (types.BuiltinMethodType, types.BuiltinFunctionType): # both the same at the moment but to be future proof # note: can't get args from these, so dump the string as is # this means any module used like this must have fully formatted docstrings. @@ -1316,7 +1323,7 @@ def pyrna2sphinx(basepath): py_func = None for identifier, py_func in py_funcs: - pyfunc2sphinx(" ", fw, identifier, py_func, is_class=True) + pyfunc2sphinx(" ", fw, "bpy.types", struct_id, identifier, py_func, is_class=True) del py_funcs, py_func py_funcs = struct.get_py_c_functions() -- cgit v1.2.3 From cb659e6e730036cc8e12565d6e057c099553616b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Oct 2013 07:18:23 +0000 Subject: code cleanup: use booleans for projection paint and make some args const. --- .../editors/sculpt_paint/paint_image_proj.c | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 4a2046f6682..2312c013ef2 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -611,7 +611,9 @@ static int project_paint_PickColor(const ProjPaintState *ps, const float pt[2], * 1 : occluded * 2 : occluded with w[3] weights set (need to know in some cases) */ -static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], float v3[4], float w[3], int is_ortho) +static int project_paint_occlude_ptv(const float pt[3], + const float v1[4], const float v2[4], const float v3[4], + float w[3], const bool is_ortho) { /* if all are behind us, return false */ if (v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2]) @@ -642,7 +644,7 @@ static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], floa static int project_paint_occlude_ptv_clip(const ProjPaintState *ps, const MFace *mf, - float pt[3], float v1[4], float v2[4], float v3[4], + const float pt[3], const float v1[4], const float v2[4], const float v3[4], const int side) { float w[3], wco[3]; @@ -671,7 +673,8 @@ static int project_paint_occlude_ptv_clip(const ProjPaintState *ps, const MFace /* Check if a screenspace location is occluded by any other faces * check, pixelScreenCo must be in screenspace, its Z-Depth only needs to be used for comparison * and doesn't need to be correct in relation to X and Y coords (this is the case in perspective view) */ -static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *bucketFace, const int orig_face, float pixelScreenCo[4]) +static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *bucketFace, + const int orig_face, const float pixelScreenCo[4]) { MFace *mf; int face_index; @@ -811,7 +814,7 @@ static int pixel_bounds_uv( const float uv1[2], const float uv2[2], const float uv3[2], const float uv4[2], rcti *bounds_px, const int ibuf_x, const int ibuf_y, - int is_quad + const bool is_quad ) { float min_uv[2], max_uv[2]; /* UV bounds */ @@ -941,7 +944,7 @@ static int check_seam(const ProjPaintState *ps, const int orig_face, const int o * since the outset coords are a margin that keep an even distance from the original UV's, * note that the image aspect is taken into account */ static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const float scaler, - const int ibuf_x, const int ibuf_y, const int is_quad) + const int ibuf_x, const int ibuf_y, const bool is_quad) { float a1, a2, a3, a4 = 0.0f; float puv[4][2]; /* pixelspace uv's */ @@ -2410,7 +2413,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i if (outset_uv[0][0] == FLT_MAX) /* first time initialize */ - uv_image_outset(tf_uv_pxoffset, outset_uv, ps->seam_bleed_px, ibuf->x, ibuf->y, mf->v4); + uv_image_outset(tf_uv_pxoffset, outset_uv, ps->seam_bleed_px, ibuf->x, ibuf->y, mf->v4 != 0); /* ps->faceSeamUVs cant be modified when threading, now this is done we can unlock */ if (ps->thread_tot > 1) @@ -2465,7 +2468,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i interp_v3_v3v3(edge_verts_inset_clip[1], insetCos[fidx1], insetCos[fidx2], fac2); - if (pixel_bounds_uv(seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3], &bounds_px, ibuf->x, ibuf->y, 1)) { + if (pixel_bounds_uv(seam_subsection[0], seam_subsection[1], seam_subsection[2], seam_subsection[3], &bounds_px, ibuf->x, ibuf->y, true)) { /* bounds between the seam rect and the uvspace bucket pixels */ has_isect = 0; @@ -3815,7 +3818,7 @@ static void *do_projectpaint_thread(void *ph_v) float falloff; int bucket_index; - int is_floatbuf = 0; + bool is_floatbuf = false; const short tool = ps->tool; rctf bucket_bounds; @@ -3870,7 +3873,7 @@ static void *do_projectpaint_thread(void *ph_v) last_projIma = projImages + last_index; last_projIma->touch = 1; - is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0; + is_floatbuf = (last_projIma->ibuf->rect_float != NULL); } /* end copy */ @@ -3996,7 +3999,7 @@ static void *do_projectpaint_thread(void *ph_v) last_projIma = projImages + last_index; last_projIma->touch = 1; - is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0; + is_floatbuf = (last_projIma->ibuf->rect_float != NULL); } /* end copy */ -- cgit v1.2.3 From 1d325273da6a1f5930d5fde8077dddd97dab8c42 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Oct 2013 07:35:12 +0000 Subject: code cleanup: project paint, use mod_i() to simplift wrapping, use booleans for static function returns. --- .../editors/sculpt_paint/paint_image_proj.c | 70 +++++++++++----------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 2312c013ef2..0e6c62f40d0 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -514,8 +514,8 @@ static void uvco_to_wrapped_pxco(const float uv[2], int ibuf_x, int ibuf_y, floa } /* Set the top-most face color that the screen space coord 'pt' touches (or return 0 if none touch) */ -static int project_paint_PickColor(const ProjPaintState *ps, const float pt[2], - float *rgba_fp, unsigned char *rgba, const int interp) +static bool project_paint_PickColor(const ProjPaintState *ps, const float pt[2], + float *rgba_fp, unsigned char *rgba, const bool interp) { float w[3], uv[2]; int side; @@ -575,11 +575,8 @@ static int project_paint_PickColor(const ProjPaintState *ps, const float pt[2], //if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return 0; /* wrap */ - xi = ((int)(uv[0] * ibuf->x)) % ibuf->x; - if (xi < 0) xi += ibuf->x; - yi = ((int)(uv[1] * ibuf->y)) % ibuf->y; - if (yi < 0) yi += ibuf->y; - + xi = mod_i((int)(uv[0] * ibuf->x), ibuf->x); + yi = mod_i((int)(uv[1] * ibuf->y), ibuf->y); if (rgba) { if (ibuf->rect_float) { @@ -673,8 +670,8 @@ static int project_paint_occlude_ptv_clip(const ProjPaintState *ps, const MFace /* Check if a screenspace location is occluded by any other faces * check, pixelScreenCo must be in screenspace, its Z-Depth only needs to be used for comparison * and doesn't need to be correct in relation to X and Y coords (this is the case in perspective view) */ -static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *bucketFace, - const int orig_face, const float pixelScreenCo[4]) +static bool project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *bucketFace, + const int orig_face, const float pixelScreenCo[4]) { MFace *mf; int face_index; @@ -705,11 +702,11 @@ static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *buc if (isect_ret >= 1) { /* TODO - we may want to cache the first hit, * it is not possible to swap the face order in the list anymore */ - return 1; + return true; } } } - return 0; + return false; } /* basic line intersection, could move to math_geom.c, 2 points with a horiz line @@ -788,7 +785,7 @@ static int line_isect_x(const float p1[2], const float p2[2], const float x_leve * tile, but do not do this for the adjacent face, it could return a false positive. * This is so unlikely that Id not worry about it. */ #ifndef PROJ_DEBUG_NOSEAMBLEED -static int cmp_uv(const float vec2a[2], const float vec2b[2]) +static bool cmp_uv(const float vec2a[2], const float vec2b[2]) { /* if the UV's are not between 0.0 and 1.0 */ float xa = (float)fmodf(vec2a[0], 1.0f); @@ -810,7 +807,7 @@ static int cmp_uv(const float vec2a[2], const float vec2b[2]) /* set min_px and max_px to the image space bounds of the UV coords * return zero if there is no area in the returned rectangle */ #ifndef PROJ_DEBUG_NOSEAMBLEED -static int pixel_bounds_uv( +static bool pixel_bounds_uv( const float uv1[2], const float uv2[2], const float uv3[2], const float uv4[2], rcti *bounds_px, const int ibuf_x, const int ibuf_y, @@ -840,7 +837,7 @@ static int pixel_bounds_uv( } #endif -static int pixel_bounds_array(float (*uv)[2], rcti *bounds_px, const int ibuf_x, const int ibuf_y, int tot) +static bool pixel_bounds_array(float (*uv)[2], rcti *bounds_px, const int ibuf_x, const int ibuf_y, int tot) { float min_uv[2], max_uv[2]; /* UV bounds */ @@ -871,7 +868,9 @@ static int pixel_bounds_array(float (*uv)[2], rcti *bounds_px, const int ibuf_x, /* This function returns 1 if this face has a seam along the 2 face-vert indices * 'orig_i1_fidx' and 'orig_i2_fidx' */ -static int check_seam(const ProjPaintState *ps, const int orig_face, const int orig_i1_fidx, const int orig_i2_fidx, int *other_face, int *orig_fidx) +static bool check_seam(const ProjPaintState *ps, + const int orig_face, const int orig_i1_fidx, const int orig_i2_fidx, + int *other_face, int *orig_fidx) { LinkNode *node; int face_index; @@ -1342,7 +1341,7 @@ static ProjPixel *project_paint_uvpixel_init( const ProjPaintState *ps, MemArena *arena, const ImBuf *ibuf, - short x_px, short y_px, + int x_px, int y_px, const float mask, const int face_index, const int image_index, @@ -1354,10 +1353,9 @@ static ProjPixel *project_paint_uvpixel_init( ProjPixel *projPixel; /* wrap pixel location */ - x_px = x_px % ibuf->x; - if (x_px < 0) x_px += ibuf->x; - y_px = y_px % ibuf->y; - if (y_px < 0) y_px += ibuf->y; + + x_px = mod_i(x_px, ibuf->x); + y_px = mod_i(y_px, ibuf->y); BLI_assert(ps->pixel_sizeof == project_paint_pixel_sizeof(ps->tool)); projPixel = (ProjPixel *)BLI_memarena_alloc(arena, ps->pixel_sizeof); @@ -1468,7 +1466,7 @@ static ProjPixel *project_paint_uvpixel_init( return projPixel; } -static int line_clip_rect2f( +static bool line_clip_rect2f( rctf *rect, const float l1[2], const float l2[2], float l1_clip[2], float l2_clip[2]) @@ -1684,7 +1682,7 @@ static float len_squared_v2v2_alt(const float *v1, const float v2_1, const float /* note, use a squared value so we can use len_squared_v2v2 * be sure that you have done a bounds check first or this may fail */ /* only give bucket_bounds as an arg because we need it elsewhere */ -static int project_bucket_isect_circle(const float cent[2], const float radius_squared, rctf *bucket_bounds) +static bool project_bucket_isect_circle(const float cent[2], const float radius_squared, rctf *bucket_bounds) { /* Would normally to a simple intersection test, however we know the bounds of these 2 already intersect @@ -1826,9 +1824,11 @@ static float angle_2d_clockwise(const float p1[2], const float p2[2], const floa #define ISECT_ALL4 ((1 << 4) - 1) /* limit must be a fraction over 1.0f */ -static int IsectPT2Df_limit(float pt[2], float v1[2], float v2[2], float v3[2], float limit) +static bool IsectPT2Df_limit(float pt[2], float v1[2], float v2[2], float v3[2], float limit) { - return ((area_tri_v2(pt, v1, v2) + area_tri_v2(pt, v2, v3) + area_tri_v2(pt, v3, v1)) / (area_tri_v2(v1, v2, v3))) < limit; + return ((area_tri_v2(pt, v1, v2) + + area_tri_v2(pt, v2, v3) + + area_tri_v2(pt, v3, v1)) / (area_tri_v2(v1, v2, v3))) < limit; } /* Clip the face by a bucket and set the uv-space bucket_bounds_uv @@ -2139,7 +2139,7 @@ static void project_bucket_clip_face( /* checks if pt is inside a convex 2D polyline, the polyline must be ordered rotating clockwise * otherwise it would have to test for mixed (line_point_side_v2 > 0.0f) cases */ -static int IsectPoly2Df(const float pt[2], float uv[][2], const int tot) +static bool IsectPoly2Df(const float pt[2], float uv[][2], const int tot) { int i; if (line_point_side_v2(uv[tot - 1], uv[0], pt) < 0.0f) @@ -2153,7 +2153,7 @@ static int IsectPoly2Df(const float pt[2], float uv[][2], const int tot) return 1; } -static int IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot) +static bool IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot) { int i; int side = (line_point_side_v2(uv[tot - 1], uv[0], pt) > 0.0f); @@ -2674,7 +2674,7 @@ static void project_bucket_init(const ProjPaintState *ps, const int thread_index * calculated when it might not be needed later, (at the moment at least) * obviously it shouldn't have bugs though */ -static int project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucket_y, const MFace *mf) +static bool project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int bucket_y, const MFace *mf) { /* TODO - replace this with a tricker method that uses sideofline for all screenCoords's edges against the closest bucket corner */ rctf bucket_bounds; @@ -3468,9 +3468,9 @@ static void partial_redraw_array_init(ImagePaintPartialRedraw *pr) } -static int partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPartialRedraw *pr_other, int tot) +static bool partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPartialRedraw *pr_other, int tot) { - int touch = 0; + bool touch = 0; while (tot--) { pr->x1 = min_ii(pr->x1, pr_other->x1); pr->y1 = min_ii(pr->y1, pr_other->y1); @@ -3488,12 +3488,12 @@ static int partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPar } /* Loop over all images on this mesh and update any we have touched */ -static int project_image_refresh_tagged(ProjPaintState *ps) +static bool project_image_refresh_tagged(ProjPaintState *ps) { ImagePaintPartialRedraw *pr; ProjPaintImage *projIma; int a, i; - int redraw = 0; + bool redraw = false; for (a = 0, projIma = ps->projImages; a < ps->image_tot; a++, projIma++) { @@ -3516,7 +3516,7 @@ static int project_image_refresh_tagged(ProjPaintState *ps) } /* run this per painting onto each mouse location */ -static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2]) +static bool project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2]) { if (ps->source == PROJ_SRC_VIEW) { float min_brush[2], max_brush[2]; @@ -3556,7 +3556,7 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2]) } -static int project_bucket_iter_next(ProjPaintState *ps, int *bucket_index, rctf *bucket_bounds, const float mval[2]) +static bool project_bucket_iter_next(ProjPaintState *ps, int *bucket_index, rctf *bucket_bounds, const float mval[2]) { const int diameter = 2 * BKE_brush_size_get(ps->scene, ps->brush); @@ -4078,11 +4078,11 @@ static void *do_projectpaint_thread(void *ph_v) return NULL; } -static int project_paint_op(void *state, const float lastpos[2], const float pos[2]) +static bool project_paint_op(void *state, const float lastpos[2], const float pos[2]) { /* First unpack args from the struct */ ProjPaintState *ps = (ProjPaintState *)state; - int touch_any = 0; + bool touch_any = false; ProjectHandle handles[BLENDER_MAX_THREADS]; ListBase threads; -- cgit v1.2.3 From 885bc95387628ecb5513e8012b69820e524d0ac8 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 15 Oct 2013 08:05:57 +0000 Subject: Style cleanup (defines -> enums, bit flags values as bitshifts, etc.). --- source/blender/makesdna/DNA_windowmanager_types.h | 312 +++++++++++----------- 1 file changed, 161 insertions(+), 151 deletions(-) diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 07a679be571..fd1b0c8ec2d 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -60,42 +60,44 @@ struct ReportList; struct Report; struct uiLayout; -#define OP_MAX_TYPENAME 64 -#define KMAP_MAX_NAME 64 +#define OP_MAX_TYPENAME 64 +#define KMAP_MAX_NAME 64 /* keep in sync with 'wm_report_items' in wm_rna.c */ typedef enum ReportType { - RPT_DEBUG = 1 << 0, - RPT_INFO = 1 << 1, - RPT_OPERATOR = 1 << 2, - RPT_PROPERTY = 1 << 3, - RPT_WARNING = 1 << 4, - RPT_ERROR = 1 << 5, - RPT_ERROR_INVALID_INPUT = 1 << 6, - RPT_ERROR_INVALID_CONTEXT = 1 << 7, - RPT_ERROR_OUT_OF_MEMORY = 1 << 8 + RPT_DEBUG = (1 << 0), + RPT_INFO = (1 << 1), + RPT_OPERATOR = (1 << 2), + RPT_PROPERTY = (1 << 3), + RPT_WARNING = (1 << 4), + RPT_ERROR = (1 << 5), + RPT_ERROR_INVALID_INPUT = (1 << 6), + RPT_ERROR_INVALID_CONTEXT = (1 << 7), + RPT_ERROR_OUT_OF_MEMORY = (1 << 8), } ReportType; -#define RPT_DEBUG_ALL (RPT_DEBUG) -#define RPT_INFO_ALL (RPT_INFO) -#define RPT_OPERATOR_ALL (RPT_OPERATOR) -#define RPT_PROPERTY_ALL (RPT_PROPERTY) -#define RPT_WARNING_ALL (RPT_WARNING) -#define RPT_ERROR_ALL (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY) +#define RPT_DEBUG_ALL (RPT_DEBUG) +#define RPT_INFO_ALL (RPT_INFO) +#define RPT_OPERATOR_ALL (RPT_OPERATOR) +#define RPT_PROPERTY_ALL (RPT_PROPERTY) +#define RPT_WARNING_ALL (RPT_WARNING) +#define RPT_ERROR_ALL (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY) enum ReportListFlags { - RPT_PRINT = 1, - RPT_STORE = 2, - RPT_FREE = 4, - RPT_OP_HOLD = 8 /* don't move them into the operator global list (caller will use) */ + RPT_PRINT = (1 << 0), + RPT_STORE = (1 << 1), + RPT_FREE = (1 << 2), + RPT_OP_HOLD = (1 << 3), /* don't move them into the operator global list (caller will use) */ }; + +/* These two Lines with # tell makesdna this struct can be excluded. */ # # typedef struct Report { struct Report *next, *prev; - short type; /* ReportType */ + short type; /* ReportType */ short flag; - int len; /* strlen(message), saves some time calculating the word wrap */ + int len; /* strlen(message), saves some time calculating the word wrap */ const char *typestr; const char *message; } Report; @@ -103,13 +105,14 @@ typedef struct Report { /* saved in the wm, don't remove */ typedef struct ReportList { ListBase list; - int printlevel; /* ReportType */ - int storelevel; /* ReportType */ + int printlevel; /* ReportType */ + int storelevel; /* ReportType */ int flag, pad; struct wmTimer *reporttimer; } ReportList; /* timer customdata to control reports display */ +/* These two Lines with # tell makesdna this struct can be excluded. */ # # typedef struct ReportTimerInfo { @@ -124,84 +127,86 @@ typedef struct ReportTimerInfo { /* windowmanager is saved, tag WMAN */ typedef struct wmWindowManager { ID id; - - struct wmWindow *windrawable, *winactive; /* separate active from drawable */ + + struct wmWindow *windrawable, *winactive; /* separate active from drawable */ ListBase windows; - - int initialized; /* set on file read */ - short file_saved; /* indicator whether data was saved */ - short op_undo_depth; /* operator stack depth to avoid nested undo pushes */ - - ListBase operators; /* operator registry */ - - ListBase queue; /* refresh/redraw wmNotifier structs */ - - struct ReportList reports; /* information and error reports */ - - ListBase jobs; /* threaded jobs manager */ - - ListBase paintcursors; /* extra overlay cursors to draw, like circles */ - - ListBase drags; /* active dragged items */ - - ListBase keyconfigs; /* known key configurations */ - struct wmKeyConfig *defaultconf; /* default configuration */ - struct wmKeyConfig *addonconf; /* addon configuration */ - struct wmKeyConfig *userconf; /* user configuration */ - - ListBase timers; /* active timers */ - struct wmTimer *autosavetimer; /* timer for auto save */ + + int initialized; /* set on file read */ + short file_saved; /* indicator whether data was saved */ + short op_undo_depth; /* operator stack depth to avoid nested undo pushes */ + + ListBase operators; /* operator registry */ + + ListBase queue; /* refresh/redraw wmNotifier structs */ + + struct ReportList reports; /* information and error reports */ + + ListBase jobs; /* threaded jobs manager */ + + ListBase paintcursors; /* extra overlay cursors to draw, like circles */ + + ListBase drags; /* active dragged items */ + + ListBase keyconfigs; /* known key configurations */ + struct wmKeyConfig *defaultconf; /* default configuration */ + struct wmKeyConfig *addonconf; /* addon configuration */ + struct wmKeyConfig *userconf; /* user configuration */ + + ListBase timers; /* active timers */ + struct wmTimer *autosavetimer; /* timer for auto save */ } wmWindowManager; /* wmWindowManager.initialized */ -#define WM_INIT_WINDOW (1<<0) -#define WM_INIT_KEYMAP (1<<1) +enum { + WM_INIT_WINDOW = (1<<0), + WM_INIT_KEYMAP = (1<<1), +}; /* the savable part, rest of data is local in ghostwinlay */ typedef struct wmWindow { struct wmWindow *next, *prev; - - void *ghostwin; /* don't want to include ghost.h stuff */ - - int winid; /* winid also in screens, is for retrieving this window after read */ - short grabcursor; /* cursor grab mode */ + void *ghostwin; /* don't want to include ghost.h stuff */ + + int winid; /* winid also in screens, is for retrieving this window after read */ + + short grabcursor; /* cursor grab mode */ short pad; - - struct bScreen *screen; /* active screen */ - struct bScreen *newscreen; /* temporary when switching */ - char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */ - - short posx, posy, sizex, sizey; /* window coords */ - short windowstate; /* borderless, full */ - short monitor; /* multiscreen... no idea how to store yet */ - short active; /* set to 1 if an active window, for quick rejects */ - short cursor; /* current mouse cursor type */ - short lastcursor; /* previous cursor when setting modal one */ - short modalcursor; /* the current modal cursor */ - short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */ + + struct bScreen *screen; /* active screen */ + struct bScreen *newscreen; /* temporary when switching */ + char screenname[64]; /* MAX_ID_NAME for matching window with active screen after file read */ + + short posx, posy, sizex, sizey; /* window coords */ + short windowstate; /* borderless, full */ + short monitor; /* multiscreen... no idea how to store yet */ + short active; /* set to 1 if an active window, for quick rejects */ + short cursor; /* current mouse cursor type */ + short lastcursor; /* previous cursor when setting modal one */ + short modalcursor; /* the current modal cursor */ + short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */ short pad2; - struct wmEvent *eventstate; /* storage for event system */ - - struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */ - - struct wmGesture *tweak; /* internal for wm_operators.c */ - - int drawmethod, drawfail; /* internal for wm_draw.c only */ - void *drawdata; /* internal for wm_draw.c only */ - - ListBase queue; /* all events (ghost level events were handled) */ - ListBase handlers; /* window+screen handlers, handled last */ - ListBase modalhandlers; /* priority handlers, handled first */ - - ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */ - ListBase gesture; /* gesture stuff */ + struct wmEvent *eventstate; /* storage for event system */ + + struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */ + + struct wmGesture *tweak; /* internal for wm_operators.c */ + + int drawmethod, drawfail; /* internal for wm_draw.c only */ + void *drawdata; /* internal for wm_draw.c only */ + + ListBase queue; /* all events (ghost level events were handled) */ + ListBase handlers; /* window+screen handlers, handled last */ + ListBase modalhandlers; /* priority handlers, handled first */ + + ListBase subwindows; /* opengl stuff for sub windows, see notes in wm_subwindow.c */ + ListBase gesture; /* gesture stuff */ } wmWindow; +/* These two Lines with # tell makesdna this struct can be excluded. */ /* should be something like DNA_EXCLUDE * but the preprocessor first removes all comments, spaces etc */ - # # typedef struct wmOperatorTypeMacro { @@ -210,37 +215,36 @@ typedef struct wmOperatorTypeMacro { /* operator id */ char idname[64]; /* rna pointer to access properties, like keymap */ - struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */ + struct IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */ struct PointerRNA *ptr; - } wmOperatorTypeMacro; /* partial copy of the event, for matching by eventhandler */ typedef struct wmKeyMapItem { struct wmKeyMapItem *next, *prev; - + /* operator */ - char idname[64]; /* used to retrieve operator type pointer */ - IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */ - + char idname[64]; /* used to retrieve operator type pointer */ + IDProperty *properties; /* operator properties, assigned to ptr->data and can be written to a file */ + /* modal */ - char propvalue_str[64]; /* runtime temporary storage for loading */ - short propvalue; /* if used, the item is from modal map */ + char propvalue_str[64]; /* runtime temporary storage for loading */ + short propvalue; /* if used, the item is from modal map */ /* event */ - short type; /* event code itself */ - short val; /* KM_ANY, KM_PRESS, KM_NOTHING etc */ - short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ - short keymodifier; /* rawkey modifier */ - + short type; /* event code itself */ + short val; /* KM_ANY, KM_PRESS, KM_NOTHING etc */ + short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ + short keymodifier; /* rawkey modifier */ + /* flag: inactive, expanded */ short flag; /* runtime */ - short maptype; /* keymap editor */ - short id; /* unique identifier. Positive for kmi that override builtins, negative otherwise */ + short maptype; /* keymap editor */ + short id; /* unique identifier. Positive for kmi that override builtins, negative otherwise */ short pad; - struct PointerRNA *ptr; /* rna pointer to access properties */ + struct PointerRNA *ptr; /* rna pointer to access properties */ } wmKeyMapItem; /* used instead of wmKeyMapItem for diff keymaps */ @@ -252,52 +256,58 @@ typedef struct wmKeyMapDiffItem { } wmKeyMapDiffItem; /* wmKeyMapItem.flag */ -#define KMI_INACTIVE 1 -#define KMI_EXPANDED 2 -#define KMI_USER_MODIFIED 4 -#define KMI_UPDATE 8 +enum { + KMI_INACTIVE = (1 << 0), + KMI_EXPANDED = (1 << 1), + KMI_USER_MODIFIED = (1 << 2), + KMI_UPDATE = (1 << 3), +}; /* stored in WM, the actively used keymaps */ typedef struct wmKeyMap { struct wmKeyMap *next, *prev; - + ListBase items; ListBase diff_items; - - char idname[64]; /* global editor keymaps, or for more per space/region */ - short spaceid; /* same IDs as in DNA_space_types.h */ - short regionid; /* see above */ - - short flag; /* general flags */ - short kmi_id; /* last kmi id */ - + + char idname[64]; /* global editor keymaps, or for more per space/region */ + short spaceid; /* same IDs as in DNA_space_types.h */ + short regionid; /* see above */ + + short flag; /* general flags */ + short kmi_id; /* last kmi id */ + /* runtime */ - int (*poll)(struct bContext *); /* verify if enabled in the current context */ - void *modal_items; /* for modal, EnumPropertyItem for now */ + int (*poll)(struct bContext *); /* verify if enabled in the current context */ + void *modal_items; /* for modal, EnumPropertyItem for now */ } wmKeyMap; /* wmKeyMap.flag */ -#define KEYMAP_MODAL 1 /* modal map, not using operatornames */ -#define KEYMAP_USER 2 /* user keymap */ -#define KEYMAP_EXPANDED 4 -#define KEYMAP_CHILDREN_EXPANDED 8 -#define KEYMAP_DIFF 16 /* diff keymap for user preferences */ -#define KEYMAP_USER_MODIFIED 32 /* keymap has user modifications */ -#define KEYMAP_UPDATE 64 +enum { + KEYMAP_MODAL = (1 << 0), /* modal map, not using operatornames */ + KEYMAP_USER = (1 << 1), /* user keymap */ + KEYMAP_EXPANDED = (1 << 2), + KEYMAP_CHILDREN_EXPANDED = (1 << 3), + KEYMAP_DIFF = (1 << 4), /* diff keymap for user preferences */ + KEYMAP_USER_MODIFIED = (1 << 5), /* keymap has user modifications */ + KEYMAP_UPDATE = (1 << 6), +}; typedef struct wmKeyConfig { struct wmKeyConfig *next, *prev; - char idname[64]; /* unique name */ - char basename[64]; /* idname of configuration this is derives from, "" if none */ - + char idname[64]; /* unique name */ + char basename[64]; /* idname of configuration this is derives from, "" if none */ + ListBase keymaps; int actkeymap, flag; } wmKeyConfig; /* wmKeyConfig.flag */ -#define KEYCONF_USER (1 << 1) -#define KEYCONF_INIT_DEFAULT (1 << 2) +enum { + KEYCONF_USER = (1 << 1), /* And what about (1 << 0)? */ + KEYCONF_INIT_DEFAULT = (1 << 2), +}; /* this one is the operator itself, stored in files for macros etc */ /* operator + operatortype should be able to redo entirely, but for different contextes */ @@ -305,46 +315,46 @@ typedef struct wmOperator { struct wmOperator *next, *prev; /* saved */ - char idname[64];/* used to retrieve type pointer */ - IDProperty *properties; /* saved, user-settable properties */ + char idname[64]; /* used to retrieve type pointer */ + IDProperty *properties; /* saved, user-settable properties */ /* runtime */ - struct wmOperatorType *type;/* operator type definition from idname */ - void *customdata; /* custom storage, only while operator runs */ - void *py_instance; /* python stores the class instance here */ + struct wmOperatorType *type; /* operator type definition from idname */ + void *customdata; /* custom storage, only while operator runs */ + void *py_instance; /* python stores the class instance here */ - struct PointerRNA *ptr; /* rna pointer to access properties */ - struct ReportList *reports; /* errors and warnings storage */ + struct PointerRNA *ptr; /* rna pointer to access properties */ + struct ReportList *reports; /* errors and warnings storage */ - ListBase macro; /* list of operators, can be a tree */ - struct wmOperator *opm; /* current running macro, not saved */ - struct uiLayout *layout; /* runtime for drawing */ + ListBase macro; /* list of operators, can be a tree */ + struct wmOperator *opm; /* current running macro, not saved */ + struct uiLayout *layout; /* runtime for drawing */ short flag, pad[3]; } wmOperator; - /* operator type return flags: exec(), invoke() modal(), return values */ -#define OPERATOR_RUNNING_MODAL (1<<0) -#define OPERATOR_CANCELLED (1<<1) -#define OPERATOR_FINISHED (1<<2) +enum { + OPERATOR_RUNNING_MODAL = (1 << 0), + OPERATOR_CANCELLED = (1 << 1), + OPERATOR_FINISHED = (1 << 2), /* add this flag if the event should pass through */ -#define OPERATOR_PASS_THROUGH (1<<3) + OPERATOR_PASS_THROUGH = (1 << 3), /* in case operator got executed outside WM code... like via fileselect */ -#define OPERATOR_HANDLED (1<<4) - -#define OPERATOR_FLAGS_ALL ((1<<5)-1) + OPERATOR_HANDLED = (1 << 4), +}; +#define OPERATOR_FLAGS_ALL (OPERATOR_RUNNING_MODAL | OPERATOR_CANCELLED | OPERATOR_FINISHED | \ + OPERATOR_PASS_THROUGH | OPERATOR_HANDLED) /* sanity checks for debug mode only */ #define OPERATOR_RETVAL_CHECK(ret) (void)ret, BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret) /* wmOperator flag */ enum { - OP_GRAB_POINTER = (1 << 0), - + OP_GRAB_POINTER = (1 << 0), /* low level flag so exec() operators can tell if they were invoked, use with care. * typically this shouldn't make any difference, but it rare cases its needed (see smooth-view) */ - OP_IS_INVOKE = (1 << 1), + OP_IS_INVOKE = (1 << 1), }; #endif /* __DNA_WINDOWMANAGER_TYPES_H__ */ -- cgit v1.2.3 From faafd7b7e2fa549bf2b51d43790b5c0e25f4f40a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Oct 2013 08:44:13 +0000 Subject: fix [#37082] Texture paint artefact --- source/blender/editors/sculpt_paint/paint_image_proj.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 0e6c62f40d0..66d09c77cea 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -164,6 +164,7 @@ BLI_INLINE unsigned char f_to_char(const float val) /* used for testing doubles, if a point is on a line etc */ #define PROJ_GEOM_TOLERANCE 0.00075f +#define PROJ_PIXEL_TOLERANCE 0.01f /* vert flags */ #define PROJ_VERT_CULL 1 @@ -2007,8 +2008,8 @@ static void project_bucket_clip_face( /* remove doubles */ /* first/last check */ - if (fabsf(isectVCosSS[0][0] - isectVCosSS[(*tot) - 1][0]) < PROJ_GEOM_TOLERANCE && - fabsf(isectVCosSS[0][1] - isectVCosSS[(*tot) - 1][1]) < PROJ_GEOM_TOLERANCE) + if (fabsf(isectVCosSS[0][0] - isectVCosSS[(*tot) - 1][0]) < PROJ_PIXEL_TOLERANCE && + fabsf(isectVCosSS[0][1] - isectVCosSS[(*tot) - 1][1]) < PROJ_PIXEL_TOLERANCE) { (*tot)--; } @@ -2024,8 +2025,8 @@ static void project_bucket_clip_face( while (doubles == TRUE) { doubles = FALSE; for (i = 1; i < (*tot); i++) { - if (fabsf(isectVCosSS[i - 1][0] - isectVCosSS[i][0]) < PROJ_GEOM_TOLERANCE && - fabsf(isectVCosSS[i - 1][1] - isectVCosSS[i][1]) < PROJ_GEOM_TOLERANCE) + if (fabsf(isectVCosSS[i - 1][0] - isectVCosSS[i][0]) < PROJ_PIXEL_TOLERANCE && + fabsf(isectVCosSS[i - 1][1] - isectVCosSS[i][1]) < PROJ_PIXEL_TOLERANCE) { int j; for (j = i + 1; j < (*tot); j++) { -- cgit v1.2.3 From 4f05cecbcd882d3ec2da9308b7cda4a083336b8e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 15 Oct 2013 09:08:08 +0000 Subject: Fix duplicated key in ghash assert caused by object orco Code was rather confusing, get_object_orco was only checking for orco in cache for some objects and was actually allocating orco for other objects. Now made it so get_object_orco always only checks the cache and only call set_object_orco if there's no orco for it yet. --- .../blender/render/intern/source/convertblender.c | 69 ++++++++++++---------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 18f658fb169..b37489d70b3 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -860,28 +860,13 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[4][4], int /* Orco hash and Materials */ /* ------------------------------------------------------------------------- */ -static float *get_object_orco(Render *re, Object *ob) +static float *get_object_orco(Render *re, void *ob) { - float *orco; - - if (!re->orco_hash) - re->orco_hash = BLI_ghash_ptr_new("get_object_orco gh"); - - orco = BLI_ghash_lookup(re->orco_hash, ob); - - if (!orco) { - if (ELEM(ob->type, OB_CURVE, OB_FONT)) { - orco = BKE_curve_make_orco(re->scene, ob, NULL); - } - else if (ob->type==OB_SURF) { - orco = BKE_curve_surf_make_orco(ob); - } - - if (orco) - BLI_ghash_insert(re->orco_hash, ob, orco); + if (!re->orco_hash) { + return NULL; } - return orco; + return BLI_ghash_lookup(re->orco_hash, ob); } static void set_object_orco(Render *re, void *ob, float *orco) @@ -1676,8 +1661,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if (path_nbr) { if (!ELEM(ma->material_type, MA_TYPE_HALO, MA_TYPE_WIRE)) { - sd.orco = MEM_mallocN(3*sizeof(float)*(totpart+totchild), "particle orcos"); - set_object_orco(re, psys, sd.orco); + sd.orco = get_object_orco(re, psys); + if (!sd.orco) { + sd.orco = MEM_mallocN(3*sizeof(float)*(totpart+totchild), "particle orcos"); + set_object_orco(re, psys, sd.orco); + } } } @@ -2829,9 +2817,12 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) if (dm) { if (need_orco) { - orco= BKE_displist_make_orco(re->scene, ob, dm, 1, 1); - if (orco) { - set_object_orco(re, ob, orco); + orco = get_object_orco(re, ob); + if (!orco) { + orco= BKE_displist_make_orco(re->scene, ob, dm, 1, 1); + if (orco) { + set_object_orco(re, ob, orco); + } } } @@ -2840,7 +2831,11 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) } else { if (need_orco) { - orco= get_object_orco(re, ob); + orco = get_object_orco(re, ob); + if (!orco) { + orco = BKE_curve_surf_make_orco(ob); + set_object_orco(re, ob, orco); + } } /* walk along displaylist and create rendervertices/-faces */ @@ -2900,9 +2895,12 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) if (dm) { if (need_orco) { - orco= BKE_displist_make_orco(re->scene, ob, dm, 1, 1); - if (orco) { - set_object_orco(re, ob, orco); + orco = get_object_orco(re, ob); + if (!orco) { + orco = BKE_displist_make_orco(re->scene, ob, dm, 1, 1); + if (orco) { + set_object_orco(re, ob, orco); + } } } @@ -2912,6 +2910,10 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) else { if (need_orco) { orco = get_object_orco(re, ob); + if (!orco) { + orco = BKE_curve_make_orco(re->scene, ob, NULL); + set_object_orco(re, ob, orco); + } } while (dl) { @@ -3401,10 +3403,13 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) if (dm==NULL) return; /* in case duplicated object fails? */ if (mask & CD_MASK_ORCO) { - orco= dm->getVertDataArray(dm, CD_ORCO); - if (orco) { - orco= MEM_dupallocN(orco); - set_object_orco(re, ob, orco); + orco = get_object_orco(re, ob); + if (!orco) { + orco= dm->getVertDataArray(dm, CD_ORCO); + if (orco) { + orco= MEM_dupallocN(orco); + set_object_orco(re, ob, orco); + } } } -- cgit v1.2.3 From 23612a8598bc4cb3ed3a21be6a9c181b8866112b Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Tue, 15 Oct 2013 13:45:27 +0000 Subject: Final fix for #36905. Enforce redraw of window once before sampling. Thanks to Brecht for the solution! --- source/blender/editors/sculpt_paint/paint_image.c | 30 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a5d4ff98b4b..f3f12464528 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -936,11 +936,23 @@ static int sample_color_exec(bContext *C, wmOperator *op) Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = BKE_paint_brush(paint); ARegion *ar = CTX_wm_region(C); + wmWindow *win = CTX_wm_window(C); + bool show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0); int location[2]; + paint->flags &= ~PAINT_SHOW_BRUSH; + + /* force redraw without cursor */ + WM_paint_cursor_tag_redraw(win, ar); + WM_redraw_windows(C); + RNA_int_get_array(op->ptr, "location", location); paint_sample_color(C, ar, location[0], location[1]); + if(show_cursor) { + paint->flags |= PAINT_SHOW_BRUSH; + } + WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush); return OPERATOR_FINISHED; @@ -950,14 +962,20 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event { Paint *paint = BKE_paint_get_active_from_context(C); SampleColorData *data = MEM_mallocN(sizeof(SampleColorData), "sample color custom data"); + ARegion *ar = CTX_wm_region(C); + wmWindow *win = CTX_wm_window(C); data->event_type = event->type; data->show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0); op->customdata = data; paint->flags &= ~PAINT_SHOW_BRUSH; + /* force redraw without cursor */ + WM_paint_cursor_tag_redraw(win, ar); + WM_redraw_windows(C); + RNA_int_set_array(op->ptr, "location", event->mval); - sample_color_exec(C, op); + paint_sample_color(C, ar, event->mval[0], event->mval[1]); WM_event_add_modal_handler(C, op); @@ -967,10 +985,10 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) { SampleColorData *data = op->customdata; + Paint *paint = BKE_paint_get_active_from_context(C); + Brush *brush = BKE_paint_brush(paint); if ((event->type == data->event_type) && (event->val == KM_RELEASE)) { - Paint *paint = BKE_paint_get_active_from_context(C); - if(data->show_cursor) { paint->flags |= PAINT_SHOW_BRUSH; } @@ -981,9 +999,13 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) switch (event->type) { case MOUSEMOVE: + { + ARegion *ar = CTX_wm_region(C); RNA_int_set_array(op->ptr, "location", event->mval); - sample_color_exec(C, op); + paint_sample_color(C, ar, event->mval[0], event->mval[1]); + WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush); break; + } } return OPERATOR_RUNNING_MODAL; -- cgit v1.2.3 From ef765b3606754bd639b48995900d01258c71f002 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 15 Oct 2013 13:55:06 +0000 Subject: Fix [#37077] User prefs > Input and Outliner Keymaps mismatch in representation. Remove KeyMap mode from outliner, was an old half-finished features redondant with user preferences settings... Also moved key map item's "event type to map type" and map type defines at WM level, this is too much generic to be at RNA level. Also added a check in versionning code to convert all outdated outliner modes to a valid one (seems old 'verse' ones were not handled as well). Thanks to Brecht for reviews and advices! --- source/blender/blenloader/intern/readfile.c | 24 ++ source/blender/editors/animation/keyframing.c | 2 +- .../blender/editors/space_outliner/outliner_draw.c | 291 +-------------------- .../editors/space_outliner/outliner_select.c | 2 +- .../blender/editors/space_outliner/outliner_tree.c | 8 - source/blender/makesdna/DNA_space_types.h | 4 +- source/blender/makesdna/DNA_windowmanager_types.h | 10 + source/blender/makesrna/intern/rna_space.c | 1 - source/blender/makesrna/intern/rna_wm.c | 15 +- source/blender/windowmanager/WM_keymap.h | 1 + source/blender/windowmanager/intern/wm_keymap.c | 23 ++ 11 files changed, 65 insertions(+), 316 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 23686986c7f..c4db8b188b2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9724,6 +9724,30 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } FOREACH_NODETREE_END } + { + bScreen *sc; + ScrArea *sa; + SpaceLink *sl; + + /* Update files using invalid (outdated) outlinevis Outliner values. */ + for (sc = main->screen.first; sc; sc = sc->id.next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_OUTLINER) { + SpaceOops *so = (SpaceOops *)sl; + + if (!ELEM11(so->outlinevis, SO_ALL_SCENES, SO_CUR_SCENE, SO_VISIBLE, SO_SELECTED, SO_ACTIVE, + SO_SAME_TYPE, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_DATABLOCKS, + SO_USERDEF)) + { + so->outlinevis = SO_ALL_SCENES; + } + } + } + } + } + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */ diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 6b9200afb75..513085e9a64 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1225,7 +1225,7 @@ static int modify_key_op_poll(bContext *C) /* if Outliner, don't allow in some views */ if (so) { - if (ELEM5(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_USERDEF, SO_KEYMAP)) { + if (ELEM4(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_USERDEF)) { return 0; } } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index fe706ce2365..fda8c19d21b 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -765,286 +765,6 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa uiBlockSetEmboss(block, UI_EMBOSS); } -static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2) -{ - wmOperatorType *ot = arg2; - wmKeyMapItem *kmi = arg_kmi; - - if (ot) - BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME); -} - -static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), - const char *str, uiSearchItems *items) -{ - GHashIterator *iter = WM_operatortype_iter(); - - for (; !BLI_ghashIterator_done(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot = BLI_ghashIterator_getValue(iter); - - if (BLI_strcasestr(ot->idname, str)) { - char name[OP_MAX_TYPENAME]; - - /* display name for menu */ - WM_operator_py_idname(name, ot->idname); - - if (false == uiSearchItemAdd(items, name, ot, 0)) - break; - } - } - BLI_ghashIterator_free(iter); -} - -/* operator Search browse menu, open */ -static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) -{ - static char search[OP_MAX_TYPENAME]; - wmEvent event; - wmWindow *win = CTX_wm_window(C); - wmKeyMapItem *kmi = arg_kmi; - wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); - uiBlock *block; - uiBut *but; - - /* clear initial search string, then all items show */ - search[0] = 0; - - block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); - - /* fake button, it holds space for search items */ - uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL); - - but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, UI_UNIT_Y, 0, 0, ""); - uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot); - - uiBoundsBlock(block, 6); - uiBlockSetDirection(block, UI_DOWN); - uiEndBlock(C, block); - - wm_event_init_from_window(win, &event); - event.type = EVT_BUT_OPEN; - event.val = KM_PRESS; - event.customdata = but; - event.customdatafree = FALSE; - wm_event_add(win, &event); - - return block; -} - -#define OL_KM_KEYBOARD 0 -#define OL_KM_MOUSE 1 -#define OL_KM_TWEAK 2 -#define OL_KM_SPECIALS 3 - -static short keymap_menu_type(short type) -{ - if (ISKEYBOARD(type)) return OL_KM_KEYBOARD; - if (ISTWEAK(type)) return OL_KM_TWEAK; - if (ISMOUSE(type)) return OL_KM_MOUSE; -// return OL_KM_SPECIALS; - return 0; -} - -static const char *keymap_type_menu(void) -{ - static const char string[] = - "Event Type%t" - "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) - "|Mouse%x" STRINGIFY(OL_KM_MOUSE) - "|Tweak%x" STRINGIFY(OL_KM_TWEAK) -// "|Specials%x" STRINGIFY(OL_KM_SPECIALS) - ; - - return string; -} - -static const char *keymap_mouse_menu(void) -{ - static const char string[] = - "Mouse Event%t" - "|Left Mouse%x" STRINGIFY(LEFTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) - "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) - "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) - "|Select Mouse%x" STRINGIFY(SELECTMOUSE) - "|Mouse Move%x" STRINGIFY(MOUSEMOVE) - "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) - "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) - "|Wheel In%x" STRINGIFY(WHEELINMOUSE) - "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) - "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) - "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) - "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) - ; - - return string; -} - -static const char *keymap_tweak_menu(void) -{ - static const char string[] = - "Tweak Event%t" - "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) - "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) - "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) - "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) - "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) - ; - - return string; -} - -static const char *keymap_tweak_dir_menu(void) -{ - static const char string[] = - "Tweak Direction%t" - "|Any%x" STRINGIFY(KM_ANY) - "|North%x" STRINGIFY(EVT_GESTURE_N) - "|North-East%x" STRINGIFY(EVT_GESTURE_NE) - "|East%x" STRINGIFY(EVT_GESTURE_E) - "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) - "|South%x" STRINGIFY(EVT_GESTURE_S) - "|South-West%x" STRINGIFY(EVT_GESTURE_SW) - "|West%x" STRINGIFY(EVT_GESTURE_W) - "|North-West%x" STRINGIFY(EVT_GESTURE_NW) - ; - - return string; -} - - -static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v)) -{ - wmKeyMapItem *kmi = kmi_v; - short maptype = keymap_menu_type(kmi->type); - - if (maptype != kmi->maptype) { - switch (kmi->maptype) { - case OL_KM_KEYBOARD: - kmi->type = AKEY; - kmi->val = KM_PRESS; - break; - case OL_KM_MOUSE: - kmi->type = LEFTMOUSE; - kmi->val = KM_PRESS; - break; - case OL_KM_TWEAK: - kmi->type = EVT_TWEAK_L; - kmi->val = KM_ANY; - break; - case OL_KM_SPECIALS: - kmi->type = AKEY; - kmi->val = KM_PRESS; - break; - } - ED_region_tag_redraw(CTX_wm_region(C)); - } -} - -static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soops, ListBase *lb) -{ - TreeElement *te; - TreeStoreElem *tselem; - - uiBlockSetEmboss(block, UI_EMBOSST); - - for (te = lb->first; te; te = te->next) { - tselem = TREESTORE(te); - if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { - uiBut *but; - const char *str; - int xstart = 240; - int butw1 = UI_UNIT_X; /* operator */ - int butw2 = 90; /* event type, menus */ - int butw3 = 43; /* modifiers */ - - if (tselem->type == TSE_KEYMAP_ITEM) { - wmKeyMapItem *kmi = te->directdata; - - /* modal map? */ - if (kmi->propvalue) { - /* pass */ - } - else { - uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, te->ys + 1, butw1, UI_UNIT_Y - 1, - TIP_("Assign new Operator")); - } - xstart += butw1 + 10; - - /* map type button */ - kmi->maptype = keymap_menu_type(kmi->type); - - str = keymap_type_menu(); - but = uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->maptype, - 0, 0, 0, 0, TIP_("Event type")); - uiButSetFunc(but, keymap_type_cb, kmi, NULL); - xstart += butw2 + 5; - - /* edit actual event */ - switch (kmi->maptype) { - case OL_KM_KEYBOARD: - uiDefKeyevtButS(block, 0, "", xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, - TIP_("Key code")); - xstart += butw2 + 5; - break; - case OL_KM_MOUSE: - str = keymap_mouse_menu(); - uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, - 0, 0, 0, 0, TIP_("Mouse button")); - xstart += butw2 + 5; - break; - case OL_KM_TWEAK: - str = keymap_tweak_menu(); - uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, - 0, 0, 0, 0, TIP_("Tweak gesture")); - xstart += butw2 + 5; - str = keymap_tweak_dir_menu(); - uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->val, - 0, 0, 0, 0, TIP_("Tweak gesture direction")); - xstart += butw2 + 5; - break; - } - - /* modifiers */ - uiDefButS(block, OPTION, 0, IFACE_("Shift"), xstart, te->ys + 1, butw3 + 5, UI_UNIT_Y - 1, - &kmi->shift, 0, 0, 0, 0, TIP_("Modifier")); - xstart += butw3 + 5; - uiDefButS(block, OPTION, 0, IFACE_("Ctrl"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->ctrl, - 0, 0, 0, 0, TIP_("Modifier")); - xstart += butw3; - uiDefButS(block, OPTION, 0, IFACE_("Alt"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->alt, - 0, 0, 0, 0, TIP_("Modifier")); - xstart += butw3; - uiDefButS(block, OPTION, 0, IFACE_("OS"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->oskey, - 0, 0, 0, 0, TIP_("Modifier")); - xstart += butw3 + 5; - uiDefKeyevtButS(block, 0, "", xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->keymodifier, - TIP_("Key Modifier code")); - xstart += butw3 + 5; - - /* rna property */ - if (kmi->ptr && kmi->ptr->data) { - uiDefBut(block, LABEL, 0, IFACE_("(RNA property)"), xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, - NULL, 0, 0, 0, 0, ""); - xstart += butw2; - } - - (void)xstart; - } - } - - if (TSELEM_OPEN(tselem, soops)) outliner_draw_keymapbuts(block, ar, soops, &te->subtree); - } - - uiBlockSetEmboss(block, UI_EMBOSS); -} - - static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, TreeElement *te) { uiBut *bt; @@ -1864,7 +1584,7 @@ void draw_outliner(const bContext *C) /* get extents of data */ outliner_height(soops, &soops->tree, &sizey); - if (ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP)) { + if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { /* RNA has two columns: * - column 1 is (max_width + OL_RNA_COL_SPACEX) or * (OL_RNA_COL_X), whichever is wider... @@ -1878,11 +1598,7 @@ void draw_outliner(const bContext *C) sizex_rna = max_ii(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX); /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ - if (soops->outlinevis == SO_KEYMAP) - // XXX this is only really a quick hack to make this wide enough... - sizex = sizex_rna + OL_RNA_COL_SIZEX * 3 + 50; - else - sizex = sizex_rna + OL_RNA_COL_SIZEX + 50; + sizex = sizex_rna + OL_RNA_COL_SIZEX + 50; } else { /* width must take into account restriction columns (if visible) so that entries will still be visible */ @@ -1918,9 +1634,6 @@ void draw_outliner(const bContext *C) outliner_draw_rnacols(ar, sizex_rna); outliner_draw_rnabuts(block, scene, ar, soops, sizex_rna, &soops->tree); } - else if (soops->outlinevis == SO_KEYMAP) { - outliner_draw_keymapbuts(block, ar, soops, &soops->tree); - } else if (!(soops->flag & SO_HIDE_RESTRICTCOLS)) { /* draw restriction columns */ outliner_draw_restrictcols(ar); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 41ad75bb14f..d1d512409ee 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -902,7 +902,7 @@ int outliner_item_do_activate(bContext *C, int x, int y, bool extend, bool recur UI_view2d_region_to_view(&ar->v2d, x, y, fmval, fmval + 1); - if (!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && + if (!ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF) && !(soops->flag & SO_HIDE_RESTRICTCOLS) && (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)) { diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index a93ed2dc6b0..036db3bae91 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1676,14 +1676,6 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) tselem->flag &= ~TSE_CLOSED; } } - else if (soops->outlinevis == SO_KEYMAP) { - wmWindowManager *wm = mainvar->wm.first; - wmKeyMap *km; - - for (km = wm->defaultconf->keymaps.first; km; km = km->next) { - /* ten = */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0); - } - } else { ten = outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); if (ten) ten->directdata = BASACT; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 5befaa87e7f..f71516af5e6 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -286,11 +286,11 @@ typedef enum eSpaceOutliner_Mode { SO_GROUPS = 6, SO_LIBRARIES = 7, /* SO_VERSE_SESSION = 8, */ /* deprecated! */ - /* SO_VERSE_MS = 9, */ /* deprecated!*/ + /* SO_VERSE_MS = 9, */ /* deprecated! */ SO_SEQUENCE = 10, SO_DATABLOCKS = 11, SO_USERDEF = 12, - SO_KEYMAP = 13, + /* SO_KEYMAP = 13, */ /* deprecated! */ } eSpaceOutliner_Mode; /* SpaceOops->storeflag */ diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index fd1b0c8ec2d..ff43cc31b9a 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -263,6 +263,16 @@ enum { KMI_UPDATE = (1 << 3), }; +/* wmKeyMapItem.maptype */ +enum { + KMI_TYPE_KEYBOARD = 0, + KMI_TYPE_MOUSE = 1, + KMI_TYPE_TWEAK = 2, + KMI_TYPE_TEXTINPUT = 3, + KMI_TYPE_TIMER = 4, + KMI_TYPE_NDOF = 5, +}; + /* stored in WM, the actively used keymaps */ typedef struct wmKeyMap { struct wmKeyMap *next, *prev; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 41ea74ebb8c..77f5957641e 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1490,7 +1490,6 @@ static void rna_def_space_outliner(BlenderRNA *brna) {SO_LIBRARIES, "LIBRARIES", 0, "Blender File", "Display data of current file and linked libraries"}, {SO_DATABLOCKS, "DATABLOCKS", 0, "Datablocks", "Display all raw datablocks"}, {SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", "Display the user preference datablocks"}, - {SO_KEYMAP, "KEYMAPS", 0, "Key Maps", "Display keymap datablocks"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index c6366745c55..dd338713d3e 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -442,13 +442,6 @@ EnumPropertyItem wm_report_items[] = { {0, NULL, 0, NULL, NULL} }; -#define KMI_TYPE_KEYBOARD 0 -#define KMI_TYPE_MOUSE 1 -#define KMI_TYPE_TWEAK 2 -#define KMI_TYPE_TEXTINPUT 3 -#define KMI_TYPE_TIMER 4 -#define KMI_TYPE_NDOF 5 - #ifdef RNA_RUNTIME #include @@ -625,13 +618,7 @@ static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr) { wmKeyMapItem *kmi = ptr->data; - if (ISTIMER(kmi->type)) return KMI_TYPE_TIMER; - if (ISKEYBOARD(kmi->type)) return KMI_TYPE_KEYBOARD; - if (ISTWEAK(kmi->type)) return KMI_TYPE_TWEAK; - if (ISMOUSE(kmi->type)) return KMI_TYPE_MOUSE; - if (ISNDOF(kmi->type)) return KMI_TYPE_NDOF; - if (kmi->type == KM_TEXTINPUT) return KMI_TYPE_TEXTINPUT; - return KMI_TYPE_KEYBOARD; + return WM_keymap_map_type_get(kmi); } static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value) diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index eab27286709..ce6481c8929 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -91,6 +91,7 @@ void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname); void WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct bContext *C); void WM_keymap_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties); void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi); +int WM_keymap_map_type_get(struct wmKeyMapItem *kmi); /* Key Event */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index f6ba3a29344..06719514483 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -139,6 +139,29 @@ void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties wm_keymap_item_properties_set(kmi); } +int WM_keymap_map_type_get(wmKeyMapItem *kmi) { + if (ISTIMER(kmi->type)) { + return KMI_TYPE_TIMER; + } + if (ISKEYBOARD(kmi->type)) { + return KMI_TYPE_KEYBOARD; + } + if (ISTWEAK(kmi->type)) { + return KMI_TYPE_TWEAK; + } + if (ISMOUSE(kmi->type)) { + return KMI_TYPE_MOUSE; + } + if (ISNDOF(kmi->type)) { + return KMI_TYPE_NDOF; + } + if (kmi->type == KM_TEXTINPUT) { + return KMI_TYPE_TEXTINPUT; + } + return KMI_TYPE_KEYBOARD; +} + + /**************************** Keymap Diff Item ********************************* * Item in a diff keymap, used for saving diff of keymaps in user preferences */ -- cgit v1.2.3 From ef60ab19f792c6d9a328e1eca8ad4c8d20940377 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 15 Oct 2013 14:32:33 +0000 Subject: removing PSD from the fileformat list fix [#37080] The file which I stored in PSD file format in Blender cannot open by Photoshop PSD writing is not supported at the moment --- source/blender/makesrna/intern/rna_scene.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b37c1326205..3e42abf376a 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -219,14 +219,6 @@ EnumPropertyItem snap_uv_element_items[] = { # define R_IMF_ENUM_TIFF #endif -#ifdef WITH_OPENIMAGEIO -# define R_IMF_ENUM_PSD {R_IMF_IMTYPE_PSD, "PSD", ICON_FILE_IMAGE, "Photosp PSD", \ - "Output image in Photoshop PSD format"}, -#else -# define R_IMF_ENUM_PSD -#endif - - #define IMAGE_TYPE_ITEMS_IMAGE_ONLY \ R_IMF_ENUM_BMP \ /* DDS save not supported yet R_IMF_ENUM_DDS */ \ @@ -243,7 +235,6 @@ EnumPropertyItem snap_uv_element_items[] = { R_IMF_ENUM_EXR \ R_IMF_ENUM_HDR \ R_IMF_ENUM_TIFF \ - R_IMF_ENUM_PSD \ EnumPropertyItem image_only_type_items[] = { -- cgit v1.2.3 From 22c019a96261a37ef2af439cdab60ae4cd210882 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 15 Oct 2013 14:54:12 +0000 Subject: Fix [#37085] Hook modifier work when created with Ctrl+H, but not when created via modifier panel "transform matrix" of the hook was not inited (reset) when assinging and object to it, now use same code for both OBJECT_OT_hook_reset operator and RNA object assignement. Reviewed by Brecht, thanks. --- source/blender/editors/include/ED_object.h | 4 ++++ source/blender/editors/object/object_hook.c | 32 ++++++++++++++++----------- source/blender/makesrna/intern/rna_modifier.c | 11 +++++++++ 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index eae2141e527..13fdbf374bb 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -51,6 +51,7 @@ struct Main; struct Mesh; struct MetaElem; struct ModifierData; +struct HookModifierData; struct Nurb; struct Object; struct ReportList; @@ -218,6 +219,9 @@ struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( int *free, const unsigned int selection_mask); +/* object_hook.c */ +void ED_object_hook_reset_do(struct Object *ob, struct HookModifierData *hmd); + #ifdef __cplusplus } #endif diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 37656f82b25..d6f3bf0c262 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -65,6 +65,7 @@ #include "ED_curve.h" #include "ED_mesh.h" #include "ED_screen.h" +#include "ED_object.h" #include "WM_types.h" #include "WM_api.h" @@ -689,19 +690,8 @@ void OBJECT_OT_hook_remove(wmOperatorType *ot) ot->prop = prop; } -static int object_hook_reset_exec(bContext *C, wmOperator *op) +void ED_object_hook_reset_do(Object *ob, HookModifierData *hmd) { - PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); - int num = RNA_enum_get(op->ptr, "modifier"); - Object *ob = NULL; - HookModifierData *hmd = NULL; - - object_hook_from_context(C, &ptr, num, &ob, &hmd); - if (hmd == NULL) { - BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); - return OPERATOR_CANCELLED; - } - /* reset functionality */ if (hmd->object) { bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget); @@ -720,7 +710,23 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) mul_m4_m4m4(hmd->parentinv, hmd->object->imat, ob->obmat); } } - +} + +static int object_hook_reset_exec(bContext *C, wmOperator *op) +{ + PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + int num = RNA_enum_get(op->ptr, "modifier"); + Object *ob = NULL; + HookModifierData *hmd = NULL; + + object_hook_from_context(C, &ptr, num, &ob, &hmd); + if (hmd == NULL) { + BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); + return OPERATOR_CANCELLED; + } + + ED_object_hook_reset_do(ob, hmd); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 34f138cd7c5..ca3ebff5455 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -120,6 +120,8 @@ EnumPropertyItem modifier_type_items[] = { #include "BKE_modifier.h" #include "BKE_particle.h" +#include "ED_object.h" + static void rna_UVProject_projectors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { UVProjectModifierData *uvp = (UVProjectModifierData *)ptr->data; @@ -536,6 +538,14 @@ static int rna_MultiresModifier_filepath_length(PointerRNA *ptr) return strlen((external) ? external->filename : ""); } +static void rna_HookModifier_object_set(PointerRNA *ptr, PointerRNA value) +{ + HookModifierData *hmd = ptr->data; + + hmd->object = (Object *)value.data; + ED_object_hook_reset_do((Object *)ptr->id.data, hmd); +} + static void modifier_object_set(Object *self, Object **ob_p, int type, PointerRNA value) { Object *ob = value.data; @@ -1434,6 +1444,7 @@ static void rna_def_modifier_hook(BlenderRNA *brna) prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Object", "Parent Object for hook, also recalculates and clears offset"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_pointer_funcs(prop, NULL, "rna_HookModifier_object_set", NULL, NULL); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); -- cgit v1.2.3 From d2abc2282346a156d2ffd4c5442f03b949c69243 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 15 Oct 2013 15:21:28 +0000 Subject: Code cleanup: use bools instead of ints for tracking utility functions --- .../blender/editors/space_clip/clip_graph_draw.c | 12 ++++++++--- source/blender/editors/space_clip/clip_graph_ops.c | 24 ++++++++++++++-------- source/blender/editors/space_clip/clip_intern.h | 4 ++-- source/blender/editors/space_clip/clip_utils.c | 4 ++-- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 173d65ee4fc..22b70b82902 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -163,19 +163,25 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) userdata.sel = false; userdata.act_track = act_track; UI_view2d_getscale(v2d, &userdata.xscale, &userdata.yscale); - clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN, + clip_graph_tracking_values_iterate(sc, + (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0, + (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, &userdata, tracking_segment_knot_cb, NULL, NULL); /* draw graph lines */ glEnable(GL_BLEND); - clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN, + clip_graph_tracking_values_iterate(sc, + (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0, + (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, act_track, tracking_segment_point_cb, tracking_segment_start_cb, tracking_segment_end_cb); glDisable(GL_BLEND); /* selected knot handles on top of curves */ userdata.sel = TRUE; - clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN, + clip_graph_tracking_values_iterate(sc, + (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) !=0, + (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, &userdata, tracking_segment_knot_cb, NULL, NULL); } diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 393f92f5af5..d1c44693995 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -190,8 +190,10 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend) if (!extend) { SelectUserData selectdata = {SEL_DESELECT}; - clip_graph_tracking_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, - sc->flag & SC_SHOW_GRAPH_HIDDEN, &selectdata, + clip_graph_tracking_iterate(sc, + (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0, + (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, + &selectdata, toggle_selection_cb); } @@ -217,7 +219,9 @@ static bool mouse_select_curve(bContext *C, float co[2], bool extend) MouseSelectUserData userdata; mouse_select_init_data(&userdata, co); - clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN, + clip_graph_tracking_values_iterate(sc, + (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0, + (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, &userdata, find_nearest_tracking_segment_cb, NULL, find_nearest_tracking_segment_end_cb); @@ -237,9 +241,10 @@ static bool mouse_select_curve(bContext *C, float co[2], bool extend) BKE_tracking_track_select(tracksbase, userdata.track, TRACK_AREA_ALL, TRUE); /* deselect all knots on newly selected curve */ - clip_graph_tracking_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, - sc->flag & SC_SHOW_GRAPH_HIDDEN, &selectdata, - toggle_selection_cb); + clip_graph_tracking_iterate(sc, + (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0, + (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, + &selectdata, toggle_selection_cb); } return true; @@ -565,9 +570,10 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) userdata.max = -FLT_MAX; userdata.min = FLT_MAX; - clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, - sc->flag & SC_SHOW_GRAPH_HIDDEN, &userdata, - view_all_cb, NULL, NULL); + clip_graph_tracking_values_iterate(sc, + (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0, + (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, + &userdata, view_all_cb, NULL, NULL); /* set extents of view to start/end frames */ v2d->cur.xmin = (float) SFRA; diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 39af856d280..513014a2d0d 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -126,12 +126,12 @@ void clip_graph_tracking_values_iterate_track(struct SpaceClip *sc, struct Movie void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord), void (*segment_end)(void *userdata)); -void clip_graph_tracking_values_iterate(struct SpaceClip *sc, int selected_only, int include_hidden, void *userdata, +void clip_graph_tracking_values_iterate(struct SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata, void (*func)(void *userdata, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int coord, int scene_framenr, float val), void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord), void (*segment_end)(void *userdata)); -void clip_graph_tracking_iterate(struct SpaceClip *sc, int selected_only, int include_hidden, void *userdata, +void clip_graph_tracking_iterate(struct SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata, void (*func)(void *userdata, struct MovieTrackingMarker *marker)); void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct MovieTrackingTrack *track); diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 635aa388541..dfd2b6e259d 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -125,7 +125,7 @@ void clip_graph_tracking_values_iterate_track( } void clip_graph_tracking_values_iterate( - SpaceClip *sc, int selected_only, int include_hidden, void *userdata, + SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata, void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord, int scene_framenr, float val), void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord), @@ -147,7 +147,7 @@ void clip_graph_tracking_values_iterate( } } -void clip_graph_tracking_iterate(SpaceClip *sc, int selected_only, int include_hidden, void *userdata, +void clip_graph_tracking_iterate(SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata, void (*func)(void *userdata, MovieTrackingMarker *marker)) { MovieClip *clip = ED_space_clip_get_clip(sc); -- cgit v1.2.3 From eaf0d267f219d58afb91818c28305ef889dc3dbf Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 15 Oct 2013 15:21:33 +0000 Subject: Code cleanup: move hardcoded structure to a typedef --- source/blender/editors/space_clip/clip_graph_draw.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 22b70b82902..9beb8edd914 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -123,10 +123,16 @@ static void tracking_segment_end_cb(void *UNUSED(userdata)) glLineWidth(1.0f); } +typedef struct TrackMotionCurveUserData { + MovieTrackingTrack *act_track; + bool sel; + float xscale, yscale, hsize; +} TrackMotionCurveUserData; + static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord, int scene_framenr, float val) { - struct { MovieTrackingTrack *act_track; bool sel; float xscale, yscale, hsize; } *data = userdata; + TrackMotionCurveUserData *data = (TrackMotionCurveUserData *) userdata; int sel = 0, sel_flag; if (track != data->act_track) @@ -151,7 +157,7 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); int width, height; - struct { MovieTrackingTrack *act_track; bool sel; float xscale, yscale, hsize; } userdata; + TrackMotionCurveUserData userdata; BKE_movieclip_get_size(clip, &sc->user, &width, &height); -- cgit v1.2.3 From eb69cb7de343843880809f25457c0cb1698dffde Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 15 Oct 2013 15:21:41 +0000 Subject: Get rid of Allow Fallback option It was rather confusing from the user usage point of view and didn't get so much improvement after new bundle adjuster was added. In the future we might want to switch resection to PPnP algorithm, which could also might be a nice alternative to fallback option. --- extern/libmv/libmv-capi.cc | 11 ++------- extern/libmv/libmv-capi.h | 3 --- .../libmv/libmv/multiview/euclidean_resection.cc | 26 +++++++--------------- extern/libmv/libmv/multiview/euclidean_resection.h | 9 ++------ extern/libmv/libmv/simple_pipeline/pipeline.cc | 26 ++++++++-------------- extern/libmv/libmv/simple_pipeline/pipeline.h | 10 +-------- .../libmv/libmv/simple_pipeline/reconstruction.h | 11 --------- extern/libmv/libmv/simple_pipeline/resect.cc | 17 ++++---------- extern/libmv/libmv/simple_pipeline/resect.h | 6 +---- release/scripts/startup/bl_ui/space_clip.py | 8 ------- source/blender/blenkernel/intern/tracking.c | 10 --------- source/blender/blenloader/intern/readfile.c | 11 --------- source/blender/makesdna/DNA_tracking_types.h | 5 ++--- source/blender/makesrna/intern/rna_tracking.c | 16 ------------- 14 files changed, 29 insertions(+), 140 deletions(-) diff --git a/extern/libmv/libmv-capi.cc b/extern/libmv/libmv-capi.cc index 11608318a40..91a3b845815 100644 --- a/extern/libmv/libmv-capi.cc +++ b/extern/libmv/libmv-capi.cc @@ -498,7 +498,6 @@ static bool selectTwoKeyframesBasedOnGRICAndVariance( libmv::Tracks &tracks, libmv::Tracks &normalized_tracks, libmv::CameraIntrinsics &camera_intrinsics, - libmv::ReconstructionOptions &reconstruction_options, int &keyframe1, int &keyframe2) { @@ -542,8 +541,7 @@ static bool selectTwoKeyframesBasedOnGRICAndVariance( /* get a solution from two keyframes only */ libmv::EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction); libmv::EuclideanBundle(keyframe_tracks, &reconstruction); - libmv::EuclideanCompleteReconstruction(reconstruction_options, - keyframe_tracks, + libmv::EuclideanCompleteReconstruction(keyframe_tracks, &reconstruction, NULL); double current_error = @@ -585,10 +583,6 @@ struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks /* Retrieve reconstruction options from C-API to libmv API */ cameraIntrinsicsFromOptions(libmv_camera_intrinsics_options, &camera_intrinsics); - libmv::ReconstructionOptions reconstruction_options; - reconstruction_options.success_threshold = libmv_reconstruction_options->success_threshold; - reconstruction_options.use_fallback_reconstruction = libmv_reconstruction_options->use_fallback_reconstruction; - /* Invert the camera intrinsics */ libmv::Tracks normalized_tracks = getNormalizedTracks(tracks, camera_intrinsics); @@ -604,7 +598,6 @@ struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks selectTwoKeyframesBasedOnGRICAndVariance(tracks, normalized_tracks, camera_intrinsics, - reconstruction_options, keyframe1, keyframe2); @@ -625,7 +618,7 @@ struct libmv_Reconstruction *libmv_solveReconstruction(const struct libmv_Tracks libmv::EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction); libmv::EuclideanBundle(normalized_tracks, &reconstruction); - libmv::EuclideanCompleteReconstruction(reconstruction_options, normalized_tracks, + libmv::EuclideanCompleteReconstruction(normalized_tracks, &reconstruction, &update_callback); /* refinement */ diff --git a/extern/libmv/libmv-capi.h b/extern/libmv/libmv-capi.h index a872eeb60a1..9541f411ba0 100644 --- a/extern/libmv/libmv-capi.h +++ b/extern/libmv/libmv-capi.h @@ -94,9 +94,6 @@ typedef struct libmv_ReconstructionOptions { int keyframe1, keyframe2; int refine_intrinsics; - - double success_threshold; - int use_fallback_reconstruction; } libmv_ReconstructionOptions; typedef void (*reconstruct_progress_update_cb) (void *customdata, double progress, const char *message); diff --git a/extern/libmv/libmv/multiview/euclidean_resection.cc b/extern/libmv/libmv/multiview/euclidean_resection.cc index d5421b9691e..b8c0a56005e 100644 --- a/extern/libmv/libmv/multiview/euclidean_resection.cc +++ b/extern/libmv/libmv/multiview/euclidean_resection.cc @@ -37,23 +37,21 @@ typedef unsigned int uint; bool EuclideanResectionPPnP(const Mat2X &x_camera, const Mat3X &X_world, - Mat3 *R, Vec3 *t, - double tolerance); + Mat3 *R, Vec3 *t); bool EuclideanResection(const Mat2X &x_camera, const Mat3X &X_world, Mat3 *R, Vec3 *t, - ResectionMethod method, - double success_threshold) { + ResectionMethod method) { switch (method) { case RESECTION_ANSAR_DANIILIDIS: EuclideanResectionAnsarDaniilidis(x_camera, X_world, R, t); break; case RESECTION_EPNP: - return EuclideanResectionEPnP(x_camera, X_world, R, t, success_threshold); + return EuclideanResectionEPnP(x_camera, X_world, R, t); break; case RESECTION_PPNP: - return EuclideanResectionPPnP(x_camera, X_world, R, t, success_threshold); + return EuclideanResectionPPnP(x_camera, X_world, R, t); break; default: LOG(FATAL) << "Unknown resection method."; @@ -444,8 +442,7 @@ static void ComputePointsCoordinatesInCameraFrame( bool EuclideanResectionEPnP(const Mat2X &x_camera, const Mat3X &X_world, - Mat3 *R, Vec3 *t, - double success_threshold) { + Mat3 *R, Vec3 *t) { CHECK(x_camera.cols() == X_world.cols()); CHECK(x_camera.cols() > 3); size_t num_points = X_world.cols(); @@ -553,13 +550,7 @@ bool EuclideanResectionEPnP(const Mat2X &x_camera, // // TODO(keir): Decide if setting this to infinity, effectively disabling the // check, is the right approach. So far this seems the case. - // - // TODO(sergey): Made it an option for now, in some cases it makes sense to - // still fallback to reprojection solution - // For details see bug [#32765] from Blender bug tracker - - // double kSuccessThreshold = std::numeric_limits::max(); - double kSuccessThreshold = success_threshold; + double kSuccessThreshold = std::numeric_limits::max(); // Find the first possible solution for R, t corresponding to: // Betas = [b00 b01 b11 b02 b12 b22 b03 b13 b23 b33] @@ -728,8 +719,7 @@ bool EuclideanResectionEPnP(const Mat2X &x_camera, // other hand, it did work on the first try. bool EuclideanResectionPPnP(const Mat2X &x_camera, const Mat3X &X_world, - Mat3 *R, Vec3 *t, - double tolerance) { + Mat3 *R, Vec3 *t) { int n = x_camera.cols(); Mat Z = Mat::Zero(n, n); Vec e = Vec::Ones(n); @@ -750,7 +740,7 @@ bool EuclideanResectionPPnP(const Mat2X &x_camera, Mat E(n, 3); int iteration = 0; - tolerance = 1e-5; + double tolerance = 1e-5; // TODO(keir): The limit of 100 can probably be reduced, but this will require // some investigation. while (error > tolerance && iteration < 100) { diff --git a/extern/libmv/libmv/multiview/euclidean_resection.h b/extern/libmv/libmv/multiview/euclidean_resection.h index ff9bccdd5c9..8a34f471df9 100644 --- a/extern/libmv/libmv/multiview/euclidean_resection.h +++ b/extern/libmv/libmv/multiview/euclidean_resection.h @@ -49,14 +49,11 @@ enum ResectionMethod { * \param R Solution for the camera rotation matrix * \param t Solution for the camera translation vector * \param method The resection method to use. - * \param success_threshold Threshold of an error which is still considered a success - * (currently used by EPnP algorithm only) */ bool EuclideanResection(const Mat2X &x_camera, const Mat3X &X_world, Mat3 *R, Vec3 *t, - ResectionMethod method = RESECTION_EPNP, - double success_threshold = 1e-3); + ResectionMethod method = RESECTION_EPNP); /** * Computes the extrinsic parameters, R and t for a calibrated camera @@ -117,7 +114,6 @@ void EuclideanResectionAnsarDaniilidis(const Mat2X &x_camera, * \param X_world 3D points in the world coordinate system * \param R Solution for the camera rotation matrix * \param t Solution for the camera translation vector - * \param success_threshold Threshold of an error which is still considered a success * * This is the algorithm described in: * "{EP$n$P: An Accurate $O(n)$ Solution to the P$n$P Problem", by V. Lepetit @@ -126,8 +122,7 @@ void EuclideanResectionAnsarDaniilidis(const Mat2X &x_camera, */ bool EuclideanResectionEPnP(const Mat2X &x_camera, const Mat3X &X_world, - Mat3 *R, Vec3 *t, - double success_threshold = 1e-3); + Mat3 *R, Vec3 *t); } // namespace euclidean_resection } // namespace libmv diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.cc b/extern/libmv/libmv/simple_pipeline/pipeline.cc index 20f82e43262..41dd3251f10 100644 --- a/extern/libmv/libmv/simple_pipeline/pipeline.cc +++ b/extern/libmv/libmv/simple_pipeline/pipeline.cc @@ -51,10 +51,9 @@ struct EuclideanPipelineRoutines { EuclideanBundle(tracks, reconstruction); } - static bool Resect(const ReconstructionOptions &options, - const vector &markers, + static bool Resect(const vector &markers, EuclideanReconstruction *reconstruction, bool final_pass) { - return EuclideanResect(options, markers, reconstruction, final_pass); + return EuclideanResect(markers, reconstruction, final_pass); } static bool Intersect(const vector &markers, @@ -90,10 +89,8 @@ struct ProjectivePipelineRoutines { ProjectiveBundle(tracks, reconstruction); } - static bool Resect(const ReconstructionOptions &options, - const vector &markers, + static bool Resect(const vector &markers, ProjectiveReconstruction *reconstruction, bool final_pass) { - (void) options; // Ignored. (void) final_pass; // Ignored. return ProjectiveResect(markers, reconstruction); @@ -144,7 +141,6 @@ static void CompleteReconstructionLogProgress( template void InternalCompleteReconstruction( - const ReconstructionOptions &options, const Tracks &tracks, typename PipelineRoutines::Reconstruction *reconstruction, ProgressUpdateCallback *update_callback = NULL) { @@ -217,7 +213,7 @@ void InternalCompleteReconstruction( if (reconstructed_markers.size() >= 5) { CompleteReconstructionLogProgress(update_callback, (double)tot_resects/(max_image)); - if (PipelineRoutines::Resect(options, reconstructed_markers, + if (PipelineRoutines::Resect(reconstructed_markers, reconstruction, false)) { num_resects++; tot_resects++; @@ -254,7 +250,7 @@ void InternalCompleteReconstruction( if (reconstructed_markers.size() >= 5) { CompleteReconstructionLogProgress(update_callback, (double)tot_resects/(max_image)); - if (PipelineRoutines::Resect(options, reconstructed_markers, + if (PipelineRoutines::Resect(reconstructed_markers, reconstruction, true)) { num_resects++; LG << "Ran final Resect() for image " << image; @@ -341,21 +337,17 @@ double ProjectiveReprojectionError( intrinsics); } -void EuclideanCompleteReconstruction(const ReconstructionOptions &options, - const Tracks &tracks, +void EuclideanCompleteReconstruction(const Tracks &tracks, EuclideanReconstruction *reconstruction, ProgressUpdateCallback *update_callback) { - InternalCompleteReconstruction(options, - tracks, + InternalCompleteReconstruction(tracks, reconstruction, update_callback); } -void ProjectiveCompleteReconstruction(const ReconstructionOptions &options, - const Tracks &tracks, +void ProjectiveCompleteReconstruction(const Tracks &tracks, ProjectiveReconstruction *reconstruction) { - InternalCompleteReconstruction(options, - tracks, + InternalCompleteReconstruction(tracks, reconstruction); } diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.h b/extern/libmv/libmv/simple_pipeline/pipeline.h index d8489012b95..4d1bd00c51f 100644 --- a/extern/libmv/libmv/simple_pipeline/pipeline.h +++ b/extern/libmv/libmv/simple_pipeline/pipeline.h @@ -39,9 +39,6 @@ namespace libmv { repeated until all points and cameras are estimated. Periodically, bundle adjustment is run to ensure a quality reconstruction. - \a options are used to define some specific befaviours based on settings - see documentation for ReconstructionOptions - \a tracks should contain markers used in the reconstruction. \a reconstruction should contain at least some 3D points or some estimated cameras. The minimum number of cameras is two (with no 3D points) and the @@ -50,7 +47,6 @@ namespace libmv { \sa EuclideanResect, EuclideanIntersect, EuclideanBundle */ void EuclideanCompleteReconstruction( - const ReconstructionOptions &options, const Tracks &tracks, EuclideanReconstruction *reconstruction, ProgressUpdateCallback *update_callback = NULL); @@ -68,9 +64,6 @@ void EuclideanCompleteReconstruction( repeated until all points and cameras are estimated. Periodically, bundle adjustment is run to ensure a quality reconstruction. - \a options are used to define some specific befaviours based on settings - see documentation for ReconstructionOptions - \a tracks should contain markers used in the reconstruction. \a reconstruction should contain at least some 3D points or some estimated cameras. The minimum number of cameras is two (with no 3D points) and the @@ -78,8 +71,7 @@ void EuclideanCompleteReconstruction( \sa ProjectiveResect, ProjectiveIntersect, ProjectiveBundle */ -void ProjectiveCompleteReconstruction(const ReconstructionOptions &options, - const Tracks &tracks, +void ProjectiveCompleteReconstruction(const Tracks &tracks, ProjectiveReconstruction *reconstruction); diff --git a/extern/libmv/libmv/simple_pipeline/reconstruction.h b/extern/libmv/libmv/simple_pipeline/reconstruction.h index 1610029b9d2..947a0636476 100644 --- a/extern/libmv/libmv/simple_pipeline/reconstruction.h +++ b/extern/libmv/libmv/simple_pipeline/reconstruction.h @@ -26,17 +26,6 @@ namespace libmv { -struct ReconstructionOptions { - // threshold value of reconstruction error which is still considered successful - // if reconstruction error bigger than this value, fallback reconstruction - // algorithm would be used (if enabled) - double success_threshold; - - // use fallback reconstruction algorithm in cases main reconstruction algorithm - // failed to reconstruct - bool use_fallback_reconstruction; -}; - /*! A EuclideanCamera is the location and rotation of the camera viewing \a image. diff --git a/extern/libmv/libmv/simple_pipeline/resect.cc b/extern/libmv/libmv/simple_pipeline/resect.cc index 941c95cf237..e73fc44df2a 100644 --- a/extern/libmv/libmv/simple_pipeline/resect.cc +++ b/extern/libmv/libmv/simple_pipeline/resect.cc @@ -91,8 +91,7 @@ struct EuclideanResectCostFunction { } // namespace -bool EuclideanResect(const ReconstructionOptions &options, - const vector &markers, +bool EuclideanResect(const vector &markers, EuclideanReconstruction *reconstruction, bool final_pass) { if (markers.size() < 5) { return false; @@ -107,23 +106,15 @@ bool EuclideanResect(const ReconstructionOptions &options, Mat3 R; Vec3 t; - double success_threshold = std::numeric_limits::max(); - - if (options.use_fallback_reconstruction) - success_threshold = options.success_threshold; - if (0 || !euclidean_resection::EuclideanResection( points_2d, points_3d, &R, &t, - euclidean_resection::RESECTION_EPNP, - success_threshold)) { + euclidean_resection::RESECTION_EPNP)) { // printf("Resection for image %d failed\n", markers[0].image); LG << "Resection for image " << markers[0].image << " failed;" << " trying fallback projective resection."; - if (!options.use_fallback_reconstruction) { - LG << "No fallback; failing resection for " << markers[0].image; - return false; - } + LG << "No fallback; failing resection for " << markers[0].image; + return false; if (!final_pass) return false; // Euclidean resection failed. Fall back to projective resection, which is diff --git a/extern/libmv/libmv/simple_pipeline/resect.h b/extern/libmv/libmv/simple_pipeline/resect.h index 47a6c6b60ea..7ca3237437e 100644 --- a/extern/libmv/libmv/simple_pipeline/resect.h +++ b/extern/libmv/libmv/simple_pipeline/resect.h @@ -35,9 +35,6 @@ namespace libmv { reconstruction object, and solves for the pose and orientation of the camera for that frame. - \a options are used to define some specific befaviours based on settings - see documentation for ReconstructionOptions - \a markers should contain \l Marker markers \endlink belonging to tracks visible in the one frame to be resectioned. Each of the tracks associated with the markers must have a corresponding reconstructed 3D position in the @@ -54,8 +51,7 @@ namespace libmv { \sa EuclideanIntersect, EuclideanReconstructTwoFrames */ -bool EuclideanResect(const ReconstructionOptions &options, - const vector &markers, +bool EuclideanResect(const vector &markers, EuclideanReconstruction *reconstruction, bool final_pass); /*! diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index df48592eb13..3247d2f5e4c 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -352,14 +352,6 @@ class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel): col.label(text="Refine:") col.prop(settings, "refine_intrinsics", text="") - col = layout.column(align=True) - col.active = not settings.use_tripod_solver - col.prop(settings, "use_fallback_reconstruction", - text="Allow Fallback") - sub = col.column(align=True) - sub.active = settings.use_fallback_reconstruction - sub.prop(settings, "reconstruction_success_threshold") - class CLIP_PT_tools_cleanup(CLIP_PT_tracking_panel, Panel): bl_space_type = 'CLIP_EDITOR' diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index b8711f6e5f6..c7fea98d7cf 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -212,7 +212,6 @@ void BKE_tracking_settings_init(MovieTracking *tracking) tracking->settings.default_algorithm_flag |= TRACK_ALGORITHM_FLAG_USE_BRUTE; tracking->settings.dist = 1; tracking->settings.object_distance = 1; - tracking->settings.reconstruction_success_threshold = 1e-3f; tracking->stabilization.scaleinf = 1.0f; tracking->stabilization.locinf = 1.0f; @@ -3473,9 +3472,6 @@ typedef struct MovieReconstructContext { TracksMap *tracks_map; - float success_threshold; - bool use_fallback_reconstruction; - int sfra, efra; } MovieReconstructContext; @@ -3780,9 +3776,6 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking * context->k2 = camera->k2; context->k3 = camera->k3; - context->success_threshold = tracking->settings.reconstruction_success_threshold; - context->use_fallback_reconstruction = tracking->settings.reconstruction_flag & TRACKING_USE_FALLBACK_RECONSTRUCTION; - context->tracks_map = tracks_map_new(context->object_name, context->is_camera, num_tracks, 0); track = tracksbase->first; @@ -3877,9 +3870,6 @@ static void reconstructionOptionsFromContext(libmv_ReconstructionOptions *recons reconstruction_options->keyframe2 = context->keyframe2; reconstruction_options->refine_intrinsics = context->refine_flags; - - reconstruction_options->success_threshold = context->success_threshold; - reconstruction_options->use_fallback_reconstruction = context->use_fallback_reconstruction; } /* Solve camera/object motion and reconstruct 3D markers position diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c4db8b188b2..2cc5aa33ab6 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9089,17 +9089,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } - - /* fallbck resection method settings */ - { - MovieClip *clip; - - for (clip = main->movieclip.first; clip; clip = clip->id.next) { - if (clip->tracking.settings.reconstruction_success_threshold == 0.0f) { - clip->tracking.settings.reconstruction_success_threshold = 1e-3f; - } - } - } } if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 7)) { diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 49c1e3ed35d..65d36adde18 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -207,8 +207,7 @@ typedef struct MovieTrackingSettings { * were moved to per-tracking object settings */ - float reconstruction_success_threshold; - int reconstruction_flag; + int reconstruction_flag, pad; /* which camera intrinsics to refine. uses on the REFINE_* flags */ short refine_camera_intrinsics, pad2; @@ -409,7 +408,7 @@ enum { /* MovieTrackingSettings->reconstruction_flag */ enum { - TRACKING_USE_FALLBACK_RECONSTRUCTION = (1 << 0), + /* TRACKING_USE_FALLBACK_RECONSTRUCTION = (1 << 0), */ /* DEPRECATED */ TRACKING_USE_KEYFRAME_SELECTION = (1 << 1) }; diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 97f5c24dc56..8e26bb96a1f 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -767,22 +767,6 @@ static void rna_def_trackingSettings(BlenderRNA *brna) "Limit speed of tracking to make visual feedback easier " "(this does not affect the tracking quality)"); - /* reconstruction success_threshold */ - prop = RNA_def_property(srna, "reconstruction_success_threshold", PROP_FLOAT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_float_default(prop, 0.001f); - RNA_def_property_range(prop, 0, FLT_MAX); - RNA_def_property_ui_text(prop, "Success Threshold", - "Threshold value of reconstruction error which is still considered successful"); - - /* use fallback reconstruction */ - prop = RNA_def_property(srna, "use_fallback_reconstruction", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_boolean_sdna(prop, NULL, "reconstruction_flag", TRACKING_USE_FALLBACK_RECONSTRUCTION); - RNA_def_property_ui_text(prop, "Use Fallback", - "Use fallback reconstruction algorithm in cases main reconstruction algorithm failed " - "(could give better solution with bad tracks)"); - /* use keyframe selection */ prop = RNA_def_property(srna, "use_keyframe_selection", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); -- cgit v1.2.3 From dc46febec83fce671898251dcd69a283c73c4551 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 15 Oct 2013 15:21:44 +0000 Subject: Code cleanup: move function prototype to header file --- extern/libmv/libmv/multiview/euclidean_resection.cc | 4 ---- extern/libmv/libmv/multiview/euclidean_resection.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/extern/libmv/libmv/multiview/euclidean_resection.cc b/extern/libmv/libmv/multiview/euclidean_resection.cc index b8c0a56005e..245b027fb7c 100644 --- a/extern/libmv/libmv/multiview/euclidean_resection.cc +++ b/extern/libmv/libmv/multiview/euclidean_resection.cc @@ -34,10 +34,6 @@ namespace libmv { namespace euclidean_resection { typedef unsigned int uint; - -bool EuclideanResectionPPnP(const Mat2X &x_camera, - const Mat3X &X_world, - Mat3 *R, Vec3 *t); bool EuclideanResection(const Mat2X &x_camera, const Mat3X &X_world, diff --git a/extern/libmv/libmv/multiview/euclidean_resection.h b/extern/libmv/libmv/multiview/euclidean_resection.h index 8a34f471df9..28eae92611c 100644 --- a/extern/libmv/libmv/multiview/euclidean_resection.h +++ b/extern/libmv/libmv/multiview/euclidean_resection.h @@ -124,6 +124,23 @@ bool EuclideanResectionEPnP(const Mat2X &x_camera, const Mat3X &X_world, Mat3 *R, Vec3 *t); +/** + * Computes the extrinsic parameters, R and t for a calibrated camera from 4 or + * more 3D points and their images. + * + * \param x_camera Image points in normalized camera coordinates, + * e.g. x_camera = inv(K) * x_image + * \param X_world 3D points in the world coordinate system + * \param R Solution for the camera rotation matrix + * \param t Solution for the camera translation vector + * + * Straight from the paper: + * http://www.diegm.uniud.it/fusiello/papers/3dimpvt12-b.pdf + */ +bool EuclideanResectionPPnP(const Mat2X &x_camera, + const Mat3X &X_world, + Mat3 *R, Vec3 *t); + } // namespace euclidean_resection } // namespace libmv -- cgit v1.2.3 From 70efa7f1aa43d3f35b614a94c493e89d51272d42 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 15 Oct 2013 15:34:14 +0000 Subject: renaming "Beautify Fill" to "Beautify Faces" changing the ot->name only, not the ot->idname (to avoid breaking scripts) The tool requires the selection to be fill previously, the original name was confusing if we consider we have "Fill" with the "Beauty" option. Discussed with Bastien Montagne and Brecht van Lommel. --- source/blender/editors/mesh/editmesh_tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 9e5782c12f2..5c9858fee58 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3124,7 +3124,7 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) void MESH_OT_beautify_fill(wmOperatorType *ot) { /* identifiers */ - ot->name = "Beautify Fill"; + ot->name = "Beautify Faces"; ot->idname = "MESH_OT_beautify_fill"; ot->description = "Rearrange some faces to try to get less degenerated geometry"; -- cgit v1.2.3 From f7a38811750237a05baeac58246482d409f0ab83 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 15 Oct 2013 15:56:00 +0000 Subject: 3D view: textured draw mode now has a Shadeless option in the Shading panel, to draw textures without shading. For Cycles this was not possible yet, and for Blender Internal you had to move away all lights which was also not ideal. (Caminandes feature request) --- release/scripts/startup/bl_ui/space_view3d.py | 4 ++++ source/blender/editors/space_view3d/drawmesh.c | 10 ++++++++-- source/blender/makesdna/DNA_view3d_types.h | 1 + source/blender/makesrna/intern/rna_space.c | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 2ede23325a6..cf6b2523787 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2633,10 +2633,14 @@ class VIEW3D_PT_view3d_shading(Panel): if not scene.render.use_shading_nodes: col.prop(gs, "material_mode", text="") col.prop(view, "show_textured_solid") + if view.viewport_shade == 'SOLID': col.prop(view, "use_matcap") if view.use_matcap: col.template_icon_view(view, "matcap_icon") + elif view.viewport_shade == 'TEXTURED': + col.prop(view, "show_textured_shadeless") + col.prop(view, "show_backface_culling") if obj and obj.mode == 'EDIT' and view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'}: col.prop(view, "show_occlude_wire") diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 269b9247c81..dc62005f760 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -345,7 +345,10 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O else { /* draw with lights in the scene otherwise */ solidtex = false; - Gtexdraw.is_lit = GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp); + if(v3d->flag2 & V3D_SHADELESS_TEX) + Gtexdraw.is_lit = 0; + else + Gtexdraw.is_lit = GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp); } rgba_float_to_uchar(obcol, ob->col); @@ -955,7 +958,10 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW); else glFrontFace(GL_CCW); - glEnable(GL_LIGHTING); + if ((v3d->drawtype == OB_TEXTURE) && (v3d->flag2 & V3D_SHADELESS_TEX)) + glColor3f(1.0f, 1.0f, 1.0f); + else + glEnable(GL_LIGHTING); { Mesh *me = ob->data; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 5436b9debfa..c724340f5ea 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -280,6 +280,7 @@ typedef struct View3D { #define V3D_SOLID_MATCAP 4096 /* user flag */ #define V3D_SHOW_SOLID_MATCAP 8192 /* runtime flag */ #define V3D_OCCLUDE_WIRE 16384 +#define V3D_SHADELESS_TEX 32768 /* View3D->around */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 77f5957641e..167590d4c2e 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1949,6 +1949,11 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Backface Culling", "Use back face culling to hide the back side of faces"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_textured_shadeless", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHADELESS_TEX); + RNA_def_property_ui_text(prop, "Shadeless", "Show shadeless texture without lighting in textured draw mode"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_OCCLUDE_WIRE); RNA_def_property_ui_text(prop, "Hidden Wire", "Use hidden wireframe display"); -- cgit v1.2.3 From e99586fee2eab049e416c0676a8a97604bce20bd Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 15 Oct 2013 17:11:15 +0000 Subject: Fix #37090: Blender crashes on "Make single user" option issue was caused by id->mewid pointing to an invalid memory after file load. The rule here: all the tools need to reset it to NULL (or other value they need) in the beginning. Currently some tools are doing newid clear in the beginning and some does it in the end. We need to clean it up so clear only happens in the beginning. But ideal we need some kind NewIDContext to make duplication safe for threading. --- source/blender/editors/object/object_relations.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index be4948d8a80..c70a70c47b2 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -2211,6 +2211,8 @@ static int make_single_user_exec(bContext *C, wmOperator *op) int flag = RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */ bool copy_groups = false; + clear_id_newpoins(); + if (RNA_boolean_get(op->ptr, "object")) single_object_users(bmain, scene, v3d, flag, copy_groups); @@ -2227,6 +2229,11 @@ static int make_single_user_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "animation")) single_object_action_users(scene, flag); + /* TODO(sergey): This should not be needed, however some tool still could rely + * on the fact, that id->newid is kept NULL by default. + * Need to make sure all the guys are learing newid before they're + * using it, not after. + */ clear_id_newpoins(); WM_event_add_notifier(C, NC_WINDOW, NULL); -- cgit v1.2.3 From cd6477eee008146c81f7963e52563277ed0b2eac Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 15 Oct 2013 17:19:02 +0000 Subject: Fix stubs for player --- source/blenderplayer/bad_level_call_stubs/stubs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index f55f307e095..b4e30beb308 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -85,6 +85,7 @@ struct MetaBall; struct ModifierData; struct MovieClip; struct MultiresModifierData; +struct HookModifierData; struct NodeBlurData; struct Nurb; struct Object; @@ -232,6 +233,7 @@ void object_test_constraints(struct Object *owner) {STUB_ASSERT(0);} void ED_armature_ebone_to_mat4(struct EditBone *ebone, float mat[4][4]) {STUB_ASSERT(0);} void ED_object_parent(struct Object *ob, struct Object *par, int type, const char *substr) {STUB_ASSERT(0);} void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con) {STUB_ASSERT(0);} +void ED_object_hook_reset_do(struct Object *ob, struct HookModifierData *hmd) {STUB_ASSERT(0);} void ED_node_composit_default(struct bContext *C, struct Scene *scene) {STUB_ASSERT(0);} void *ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *custumdata, int type) {STUB_ASSERT(0); return 0;} /* XXX this one looks weird */ void *ED_region_draw_cb_customdata(void *handle) {STUB_ASSERT(0); return 0;} /* XXX This one looks wrong also */ @@ -284,6 +286,7 @@ void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keym void WM_keymap_properties_reset(struct wmKeyMapItem *kmi) {STUB_ASSERT(0);} void WM_keyconfig_update_tag(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi) {STUB_ASSERT(0);} int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2) {STUB_ASSERT(0); return 0;} +int WM_keymap_map_type_get(struct wmKeyMapItem *kmi) {STUB_ASSERT(0); return 0;} /* rna editors */ -- cgit v1.2.3 From ac602142d3a50157f91d9106dfbf2b39814ac648 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Oct 2013 18:30:49 +0000 Subject: add 'Extrude Region, Vertex Normal' to the extrude menu, equivalent of 'Extrude, Escape, Alt+S' --- release/scripts/startup/bl_operators/view3d.py | 32 ++++++++++++++++++++++---- release/scripts/startup/bl_ui/space_view3d.py | 16 +++++++++---- source/blender/editors/mesh/mesh_ops.c | 7 ++++++ 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py index e0b5526e220..27d2a2361a1 100644 --- a/release/scripts/startup/bl_operators/view3d.py +++ b/release/scripts/startup/bl_operators/view3d.py @@ -62,7 +62,8 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator): bl_label = "Extrude and Move on Normals" bl_idname = "view3d.edit_mesh_extrude_move_normal" - def execute(self, context): + @staticmethod + def extrude_region(context, use_vert_normals): mesh = context.object.data totface = mesh.total_face_sel @@ -70,10 +71,15 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator): #~ totvert = mesh.total_vert_sel if totface >= 1: - bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', - TRANSFORM_OT_translate={ - "constraint_orientation": 'NORMAL', - "constraint_axis": (False, False, True)}) + if use_vert_normals: + bpy.ops.mesh.extrude_region_shrink_fatten('INVOKE_REGION_WIN', + TRANSFORM_OT_shrink_fatten={}) + else: + bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', + TRANSFORM_OT_translate={ + "constraint_orientation": 'NORMAL', + "constraint_axis": (False, False, True)}) + elif totedge == 1: bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={ @@ -88,6 +94,22 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator): # and cause this one not to be freed. [#24671] return {'FINISHED'} + def execute(self, context): + return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, False) + + def invoke(self, context, event): + return self.execute(context) + + + +class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator): + "Extrude and move along individual normals" + bl_label = "Extrude and Move on Individual Normals" + bl_idname = "view3d.edit_mesh_extrude_move_shrink_fatten" + + def execute(self, context): + return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True) + def invoke(self, context, event): return self.execute(context) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index cf6b2523787..09719433102 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1909,10 +1909,16 @@ class VIEW3D_MT_edit_mesh_extrude(Menu): bl_label = "Extrude" _extrude_funcs = { - 'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"), - 'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"), - 'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"), - 'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"), + 'VERT': lambda layout: + layout.operator("mesh.extrude_vertices_move", text="Vertices Only"), + 'EDGE': lambda layout: + layout.operator("mesh.extrude_edges_move", text="Edges Only"), + 'FACE': lambda layout: + layout.operator("mesh.extrude_faces_move", text="Individual Faces"), + 'REGION': lambda layout: + layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"), + 'REGION_VERT_NORMAL': lambda layout: + layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Region (Vertex Normals)"), } @staticmethod @@ -1922,7 +1928,7 @@ class VIEW3D_MT_edit_mesh_extrude(Menu): menu = [] if mesh.total_face_sel: - menu += ['REGION', 'FACE'] + menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE'] if mesh.total_edge_sel and (select_mode[0] or select_mode[1]): menu += ['EDGE'] if mesh.total_vert_sel and select_mode[0]: diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index c98ad13acf6..86f69ab8538 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -244,6 +244,13 @@ void ED_operatormacros_mesh(void) RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", false); + ot = WM_operatortype_append_macro("MESH_OT_extrude_region_shrink_fatten", "Extrude Region and Shrink/Fatten", + "Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER); + otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region"); + otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten"); + RNA_enum_set(otmacro->ptr, "proportional", 0); + RNA_boolean_set(otmacro->ptr, "mirror", false); + ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", "Extrude faces and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv"); -- cgit v1.2.3 From e7f1e1aed1a9a83763baaccc26498ad5aa1b5757 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Oct 2013 20:15:45 +0000 Subject: edits to r60777 - move ED_object_hook_reset_do into BKE object (if RNA needs to call ED_* functions its a hint they might be better in BKE). --- source/blender/blenkernel/BKE_object.h | 3 +++ source/blender/blenkernel/intern/object.c | 22 +++++++++++++++++++++ source/blender/editors/include/ED_object.h | 3 --- source/blender/editors/object/object_hook.c | 24 +---------------------- source/blender/makesrna/intern/rna_modifier.c | 5 ++--- source/blenderplayer/bad_level_call_stubs/stubs.c | 1 - 6 files changed, 28 insertions(+), 30 deletions(-) diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index e99eb2a64f2..434175624b7 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -48,6 +48,7 @@ struct rctf; struct MovieClip; struct Main; struct RigidBodyWorld; +struct HookModifierData; void BKE_object_workob_clear(struct Object *workob); void BKE_object_workob_calc_parent(struct Scene *scene, struct Object *ob, struct Object *workob); @@ -66,6 +67,8 @@ void BKE_object_update_base_layer(struct Scene *scene, struct Object *ob); void BKE_object_free(struct Object *ob); void BKE_object_free_derived_caches(struct Object *ob); +void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData *hmd); + bool BKE_object_support_modifier_type_check(struct Object *ob, int modifier_type); void BKE_object_link_modifiers(struct Object *ob, struct Object *from); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 8c2475369de..94744866a17 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -194,6 +194,28 @@ void BKE_object_free_modifiers(Object *ob) BKE_object_free_softbody(ob); } +void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd) +{ + /* reset functionality */ + if (hmd->object) { + bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget); + + if (hmd->subtarget[0] && pchan) { + float imat[4][4], mat[4][4]; + + /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */ + mul_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat); + + invert_m4_m4(imat, mat); + mul_m4_m4m4(hmd->parentinv, imat, ob->obmat); + } + else { + invert_m4_m4(hmd->object->imat, hmd->object->obmat); + mul_m4_m4m4(hmd->parentinv, hmd->object->imat, ob->obmat); + } + } +} + bool BKE_object_support_modifier_type_check(Object *ob, int modifier_type) { ModifierTypeInfo *mti; diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 13fdbf374bb..0d11108d81f 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -219,9 +219,6 @@ struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( int *free, const unsigned int selection_mask); -/* object_hook.c */ -void ED_object_hook_reset_do(struct Object *ob, struct HookModifierData *hmd); - #ifdef __cplusplus } #endif diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index d6f3bf0c262..7f97aa0b4c1 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -690,28 +690,6 @@ void OBJECT_OT_hook_remove(wmOperatorType *ot) ot->prop = prop; } -void ED_object_hook_reset_do(Object *ob, HookModifierData *hmd) -{ - /* reset functionality */ - if (hmd->object) { - bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget); - - if (hmd->subtarget[0] && pchan) { - float imat[4][4], mat[4][4]; - - /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */ - mul_m4_m4m4(mat, hmd->object->obmat, pchan->pose_mat); - - invert_m4_m4(imat, mat); - mul_m4_m4m4(hmd->parentinv, imat, ob->obmat); - } - else { - invert_m4_m4(hmd->object->imat, hmd->object->obmat); - mul_m4_m4m4(hmd->parentinv, hmd->object->imat, ob->obmat); - } - } -} - static int object_hook_reset_exec(bContext *C, wmOperator *op) { PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); @@ -725,7 +703,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - ED_object_hook_reset_do(ob, hmd); + BKE_object_modifier_hook_reset(ob, hmd); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index ca3ebff5455..57eeba61a73 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -118,10 +118,9 @@ EnumPropertyItem modifier_type_items[] = { #include "BKE_depsgraph.h" #include "BKE_library.h" #include "BKE_modifier.h" +#include "BKE_object.h" #include "BKE_particle.h" -#include "ED_object.h" - static void rna_UVProject_projectors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { UVProjectModifierData *uvp = (UVProjectModifierData *)ptr->data; @@ -543,7 +542,7 @@ static void rna_HookModifier_object_set(PointerRNA *ptr, PointerRNA value) HookModifierData *hmd = ptr->data; hmd->object = (Object *)value.data; - ED_object_hook_reset_do((Object *)ptr->id.data, hmd); + BKE_object_modifier_hook_reset((Object *)ptr->id.data, hmd); } static void modifier_object_set(Object *self, Object **ob_p, int type, PointerRNA value) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index b4e30beb308..7c01058ec31 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -233,7 +233,6 @@ void object_test_constraints(struct Object *owner) {STUB_ASSERT(0);} void ED_armature_ebone_to_mat4(struct EditBone *ebone, float mat[4][4]) {STUB_ASSERT(0);} void ED_object_parent(struct Object *ob, struct Object *par, int type, const char *substr) {STUB_ASSERT(0);} void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con) {STUB_ASSERT(0);} -void ED_object_hook_reset_do(struct Object *ob, struct HookModifierData *hmd) {STUB_ASSERT(0);} void ED_node_composit_default(struct bContext *C, struct Scene *scene) {STUB_ASSERT(0);} void *ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *custumdata, int type) {STUB_ASSERT(0); return 0;} /* XXX this one looks weird */ void *ED_region_draw_cb_customdata(void *handle) {STUB_ASSERT(0); return 0;} /* XXX This one looks wrong also */ -- cgit v1.2.3 From 4ae564bfa68dec93e07057ec42c5c4362abf1b73 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 16 Oct 2013 01:49:11 +0000 Subject: Fix part of #37087, brush curve becomes inverted when using the reset curve button. From the bug report it also seems that positive slope curve presets are not always reset correctly. However I haven't seen any place where positive slope curve presets are used. This will fix the initial brush problem, however it might be good to investigate further if curve presets are to be used elsewhere. It looks like the issue is related to bezier curve calculation. --- source/blender/editors/interface/interface_templates.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1a5ab57706f..c343115be30 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1921,7 +1921,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) case UICURVE_FUNC_RESET_NEG: case UICURVE_FUNC_RESET_POS: /* reset */ curvemap_reset(cuma, &cumap->clipr, cumap->preset, - (event == -1) ? CURVEMAP_SLOPE_NEGATIVE : CURVEMAP_SLOPE_POSITIVE); + (event == UICURVE_FUNC_RESET_NEG) ? CURVEMAP_SLOPE_NEGATIVE : CURVEMAP_SLOPE_POSITIVE); curvemapping_changed(cumap, FALSE); break; case UICURVE_FUNC_RESET_VIEW: -- cgit v1.2.3 From 1ae0de2f3af194153e73103ea3067283269d0350 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Oct 2013 03:21:55 +0000 Subject: fix [#37013] Mesh > bisect can't fill the cut if it lines up with two or more adjacent vertices --- source/blender/bmesh/tools/bmesh_bisect_plane.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c index 9cfe17d6413..c3c2924ea8e 100644 --- a/source/blender/bmesh/tools/bmesh_bisect_plane.c +++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c @@ -372,7 +372,7 @@ void BM_mesh_bisect_plane(BMesh *bm, float plane[4], BM_VERT_DIR(v_new) = 0; BM_VERT_DIST(v_new) = 0.0f; } - else { + else if (side[0] == 0 || side[1] == 0) { /* check if either edge verts are aligned, * if so - tag and push all faces that use it into the stack */ unsigned int j; @@ -394,6 +394,13 @@ void BM_mesh_bisect_plane(BMesh *bm, float plane[4], } } } + + /* if both verts are on the center - tag it */ + if (oflag_center) { + if (side[0] == 0 && side[1] == 0) { + BMO_elem_flag_enable(bm, e, oflag_center); + } + } } } -- cgit v1.2.3 From fe93d4a3d848abd59a1de43a51142c3e2f3c961f Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 16 Oct 2013 03:24:38 +0000 Subject: split operators/bmo_beautify.c into tools/bmesh_beautify.c This is a proper design if we want to use the beautify routine elsewhere (e.g., in the triangulate modifier) --- source/blender/bmesh/CMakeLists.txt | 2 + source/blender/bmesh/bmesh_tools.h | 1 + source/blender/bmesh/operators/bmo_beautify.c | 412 +----------------------- source/blender/bmesh/tools/bmesh_beautify.c | 441 ++++++++++++++++++++++++++ source/blender/bmesh/tools/bmesh_beautify.h | 37 +++ 5 files changed, 484 insertions(+), 409 deletions(-) create mode 100644 source/blender/bmesh/tools/bmesh_beautify.c create mode 100644 source/blender/bmesh/tools/bmesh_beautify.h diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index 67f95cca6aa..b80a10b43fe 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -119,6 +119,8 @@ set(SRC intern/bmesh_operator_api.h intern/bmesh_error.h + tools/bmesh_beautify.c + tools/bmesh_beautify.h tools/bmesh_bevel.c tools/bmesh_bevel.h tools/bmesh_bisect_plane.c diff --git a/source/blender/bmesh/bmesh_tools.h b/source/blender/bmesh/bmesh_tools.h index b2dac810bce..baffeb774b6 100644 --- a/source/blender/bmesh/bmesh_tools.h +++ b/source/blender/bmesh/bmesh_tools.h @@ -34,6 +34,7 @@ extern "C" { #endif +#include "tools/bmesh_beautify.h" #include "tools/bmesh_bevel.h" #include "tools/bmesh_bisect_plane.h" #include "tools/bmesh_decimate.h" diff --git a/source/blender/bmesh/operators/bmo_beautify.c b/source/blender/bmesh/operators/bmo_beautify.c index bd20e384234..b0b3e723603 100644 --- a/source/blender/bmesh/operators/bmo_beautify.c +++ b/source/blender/bmesh/operators/bmo_beautify.c @@ -25,426 +25,19 @@ * * Beautify the mesh by rotating edges between triangles * to more attractive positions until no more rotations can be made. - * - * In principle this is very simple however there is the possibility of - * going into an eternal loop where edges keep rotating. - * To avoid this - each edge stores a set of it previous - * states so as not to rotate back. - * - * TODO - * - Take face normals into account. */ #include "BLI_math.h" -#include "BLI_heap.h" #include "MEM_guardedalloc.h" #include "bmesh.h" +#include "bmesh_tools.h" #include "intern/bmesh_operators_private.h" -#include "BLI_strict_flags.h" - -// #define DEBUG_TIME - -#ifdef DEBUG_TIME -# include "PIL_time.h" -# include "PIL_time_utildefines.h" -#endif - -enum { - VERT_RESTRICT_TAG = (1 << 0), -}; - -/* -------------------------------------------------------------------- */ -/* GSet for edge rotation */ - -typedef struct EdRotState { - int v1, v2; /* edge vert, small -> large */ - int f1, f2; /* face vert, small -> large */ -} EdRotState; - -static unsigned int erot_gsetutil_hash(const void *ptr) -{ - const EdRotState *e_state = (const EdRotState *)ptr; - unsigned int - hash = BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->v1)); - hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->v2)); - hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f1)); - hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f2)); - return hash; -} -static int erot_gsetutil_cmp(const void *a, const void *b) -{ - const EdRotState *e_state_a = (const EdRotState *)a; - const EdRotState *e_state_b = (const EdRotState *)b; - if (e_state_a->v1 < e_state_b->v1) return -1; - else if (e_state_a->v1 > e_state_b->v1) return 1; - else if (e_state_a->v2 < e_state_b->v2) return -1; - else if (e_state_a->v2 > e_state_b->v2) return 1; - else if (e_state_a->f1 < e_state_b->f1) return -1; - else if (e_state_a->f1 > e_state_b->f1) return 1; - else if (e_state_a->f2 < e_state_b->f2) return -1; - else if (e_state_a->f2 > e_state_b->f2) return 1; - else return 0; -} - -static GSet *erot_gset_new(void) -{ - return BLI_gset_new(erot_gsetutil_hash, erot_gsetutil_cmp, __func__); -} - -/* ensure v0 is smaller */ -#define EDGE_ORD(v0, v1) \ - if (v0 > v1) { \ - v0 ^= v1; \ - v1 ^= v0; \ - v0 ^= v1; \ - } (void)0 - -static void erot_state_ex(const BMEdge *e, int v_index[2], int f_index[2]) -{ - BLI_assert(BM_edge_is_manifold((BMEdge *)e)); - BLI_assert(BM_vert_in_edge(e, e->l->prev->v) == false); - BLI_assert(BM_vert_in_edge(e, e->l->radial_next->prev->v) == false); - - /* verts of the edge */ - v_index[0] = BM_elem_index_get(e->v1); - v_index[1] = BM_elem_index_get(e->v2); - EDGE_ORD(v_index[0], v_index[1]); - - /* verts of each of the 2 faces attached to this edge - * (that are not apart of this edge) */ - f_index[0] = BM_elem_index_get(e->l->prev->v); - f_index[1] = BM_elem_index_get(e->l->radial_next->prev->v); - EDGE_ORD(f_index[0], f_index[1]); -} - -static void erot_state_current(const BMEdge *e, EdRotState *e_state) -{ - erot_state_ex(e, &e_state->v1, &e_state->f1); -} - -static void erot_state_alternate(const BMEdge *e, EdRotState *e_state) -{ - erot_state_ex(e, &e_state->f1, &e_state->v1); -} - -/* -------------------------------------------------------------------- */ -/* Calculate the improvement of rotating the edge */ - -/** - * \return a negative value means the edge can be rotated. - */ -static float bm_edge_calc_rotate_beauty__area( - const float v1[3], const float v2[3], const float v3[3], const float v4[3]) -{ - /* not a loop (only to be able to break out) */ - do { - float v1_xy[2], v2_xy[2], v3_xy[2], v4_xy[2]; - - /* first get the 2d values */ - { - bool is_zero_a, is_zero_b; - float no[3]; - float axis_mat[3][3]; - - // printf("%p %p %p %p - %p %p\n", v1, v2, v3, v4, e->l->f, e->l->radial_next->f); - BLI_assert((ELEM3(v1, v2, v3, v4) == false) && - (ELEM3(v2, v1, v3, v4) == false) && - (ELEM3(v3, v1, v2, v4) == false) && - (ELEM3(v4, v1, v2, v3) == false)); - - is_zero_a = area_tri_v3(v2, v3, v4) <= FLT_EPSILON; - is_zero_b = area_tri_v3(v2, v4, v1) <= FLT_EPSILON; - - if (LIKELY(is_zero_a == false && is_zero_b == false)) { - float no_a[3], no_b[3]; - normal_tri_v3(no_a, v2, v3, v4); /* a */ - normal_tri_v3(no_b, v2, v4, v1); /* b */ - add_v3_v3v3(no, no_a, no_b); - if (UNLIKELY(normalize_v3(no) <= FLT_EPSILON)) { - break; - } - } - else if (is_zero_a == false) { - normal_tri_v3(no, v2, v3, v4); /* a */ - } - else if (is_zero_b == false) { - normal_tri_v3(no, v2, v4, v1); /* b */ - } - else { - /* both zero area, no useful normal can be calculated */ - break; - } - - // { float a = angle_normalized_v3v3(no_a, no_b); printf("~ %.7f\n", a); fflush(stdout);} - - axis_dominant_v3_to_m3(axis_mat, no); - mul_v2_m3v3(v1_xy, axis_mat, v1); - mul_v2_m3v3(v2_xy, axis_mat, v2); - mul_v2_m3v3(v3_xy, axis_mat, v3); - mul_v2_m3v3(v4_xy, axis_mat, v4); - } - - // printf("%p %p %p %p - %p %p\n", v1, v2, v3, v4, e->l->f, e->l->radial_next->f); - - if (is_quad_convex_v2(v1_xy, v2_xy, v3_xy, v4_xy)) { - /* testing rule: the area divided by the perimeter, - * check if (1-3) beats the existing (2-4) edge rotation */ - float area_a, area_b; - float prim_a, prim_b; - float fac_24, fac_13; - - float len_12, len_23, len_34, len_41, len_24, len_13; - - /* edges around the quad */ - len_12 = len_v2v2(v1_xy, v2_xy); - len_23 = len_v2v2(v2_xy, v3_xy); - len_34 = len_v2v2(v3_xy, v4_xy); - len_41 = len_v2v2(v4_xy, v1_xy); - /* edges crossing the quad interior */ - len_13 = len_v2v2(v1_xy, v3_xy); - len_24 = len_v2v2(v2_xy, v4_xy); - - /* edge (2-4), current state */ - area_a = area_tri_v2(v2_xy, v3_xy, v4_xy); - area_b = area_tri_v2(v2_xy, v4_xy, v1_xy); - prim_a = len_23 + len_34 + len_24; - prim_b = len_24 + len_41 + len_12; - fac_24 = (area_a / prim_a) + (area_b / prim_b); - - /* edge (1-3), new state */ - area_a = area_tri_v2(v1_xy, v2_xy, v3_xy); - area_b = area_tri_v2(v1_xy, v3_xy, v4_xy); - prim_a = len_12 + len_23 + len_13; - prim_b = len_34 + len_41 + len_13; - fac_13 = (area_a / prim_a) + (area_b / prim_b); - - /* negative number if (1-3) is an improved state */ - return fac_24 - fac_13; - } - } while (false); - - return FLT_MAX; -} - -static float bm_edge_calc_rotate_beauty__angle( - const float v1[3], const float v2[3], const float v3[3], const float v4[3]) -{ - /* not a loop (only to be able to break out) */ - do { - float no_a[3], no_b[3]; - float angle_24, angle_13; - - /* edge (2-4), current state */ - normal_tri_v3(no_a, v2, v3, v4); - normal_tri_v3(no_b, v2, v4, v1); - angle_24 = angle_normalized_v3v3(no_a, no_b); - - /* edge (1-3), new state */ - /* only check new state for degenerate outcome */ - if ((normal_tri_v3(no_a, v1, v2, v3) == 0.0f) || - (normal_tri_v3(no_b, v1, v3, v4) == 0.0f)) - { - break; - } - angle_13 = angle_normalized_v3v3(no_a, no_b); - - return angle_13 - angle_24; - } while (false); - - return FLT_MAX; -} - -static float bm_edge_calc_rotate_beauty(const BMEdge *e, const short flag, const short method) -{ - /* not a loop (only to be able to break out) */ - do { - const float *v1, *v2, *v3, *v4; - - v1 = e->l->prev->v->co; /* first face co */ - v2 = e->l->v->co; /* e->v1 or e->v2*/ - v3 = e->l->radial_next->prev->v->co; /* second face co */ - v4 = e->l->next->v->co; /* e->v1 or e->v2*/ - - if (flag & VERT_RESTRICT_TAG) { - BMVert *v_a = e->l->prev->v, *v_b = e->l->radial_next->prev->v; - if (BM_elem_flag_test(v_a, BM_ELEM_TAG) == BM_elem_flag_test(v_b, BM_ELEM_TAG)) { - break; - } - } - - if (UNLIKELY(v1 == v3)) { - // printf("This should never happen, but does sometimes!\n"); - break; - } - - switch (method) { - case 0: - return bm_edge_calc_rotate_beauty__area(v1, v2, v3, v4); - default: - return bm_edge_calc_rotate_beauty__angle(v1, v2, v3, v4); - } - } while (false); - - return FLT_MAX; -} - -/* -------------------------------------------------------------------- */ -/* Update the edge cost of rotation in the heap */ - -/* recalc an edge in the heap (surrounding geometry has changed) */ -static void bm_edge_update_beauty_cost_single(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GSet **edge_state_arr, - const short flag, const short method) -{ - if (BM_elem_flag_test(e, BM_ELEM_TAG)) { - const int i = BM_elem_index_get(e); - GSet *e_state_set = edge_state_arr[i]; - - if (eheap_table[i]) { - BLI_heap_remove(eheap, eheap_table[i]); - eheap_table[i] = NULL; - } - - /* check if we can add it back */ - BLI_assert(BM_edge_is_manifold(e) == true); - //BLI_assert(BMO_elem_flag_test(bm, e->l->f, FACE_MARK) && - // BMO_elem_flag_test(bm, e->l->radial_next->f, FACE_MARK)); - - /* check we're not moving back into a state we have been in before */ - if (e_state_set != NULL) { - EdRotState e_state_alt; - erot_state_alternate(e, &e_state_alt); - if (BLI_gset_haskey(e_state_set, (void *)&e_state_alt)) { - // printf(" skipping, we already have this state\n"); - return; - } - } - - { - /* recalculate edge */ - const float cost = bm_edge_calc_rotate_beauty(e, flag, method); - if (cost < 0.0f) { - eheap_table[i] = BLI_heap_insert(eheap, cost, e); - } - else { - eheap_table[i] = NULL; - } - } - } -} - -/* we have rotated an edge, tag other edges and clear this one */ -static void bm_edge_update_beauty_cost(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GSet **edge_state_arr, - const short flag, const short method) -{ - BMLoop *l; - BLI_assert(e->l->f->len == 3 && - e->l->radial_next->f->len == 3); - - l = e->l; - bm_edge_update_beauty_cost_single(l->next->e, eheap, eheap_table, edge_state_arr, flag, method); - bm_edge_update_beauty_cost_single(l->prev->e, eheap, eheap_table, edge_state_arr, flag, method); - l = l->radial_next; - bm_edge_update_beauty_cost_single(l->next->e, eheap, eheap_table, edge_state_arr, flag, method); - bm_edge_update_beauty_cost_single(l->prev->e, eheap, eheap_table, edge_state_arr, flag, method); -} - -/* -------------------------------------------------------------------- */ -/* Beautify Fill */ - #define ELE_NEW 1 #define FACE_MARK 2 -/** - * \note All edges in \a edge_array must be tagged and - * have their index values set according to their position in the array. - */ -static void bm_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_len, - const short flag, const short method) -{ - Heap *eheap; /* edge heap */ - HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */ - - GSet **edge_state_arr = MEM_callocN((size_t)edge_array_len * sizeof(GSet *), __func__); - BLI_mempool *edge_state_pool = BLI_mempool_create(sizeof(EdRotState), 512, 512, BLI_MEMPOOL_SYSMALLOC); - int i; - -#ifdef DEBUG_TIME - TIMEIT_START(beautify_fill); -#endif - - eheap = BLI_heap_new_ex((unsigned int)edge_array_len); - eheap_table = MEM_mallocN(sizeof(HeapNode *) * (size_t)edge_array_len, __func__); - - /* build heap */ - for (i = 0; i < edge_array_len; i++) { - BMEdge *e = edge_array[i]; - const float cost = bm_edge_calc_rotate_beauty(e, flag, method); - if (cost < 0.0f) { - eheap_table[i] = BLI_heap_insert(eheap, cost, e); - } - else { - eheap_table[i] = NULL; - } - } - - while (BLI_heap_is_empty(eheap) == false) { - BMEdge *e = BLI_heap_popmin(eheap); - i = BM_elem_index_get(e); - eheap_table[i] = NULL; - - e = BM_edge_rotate(bm, e, false, BM_EDGEROT_CHECK_EXISTS); - if (LIKELY(e)) { - GSet *e_state_set = edge_state_arr[i]; - - /* add the new state into the set so we don't move into this state again - * note: we could add the previous state too but this isn't essential) - * for avoiding eternal loops */ - EdRotState *e_state = BLI_mempool_alloc(edge_state_pool); - erot_state_current(e, e_state); - if (UNLIKELY(e_state_set == NULL)) { - edge_state_arr[i] = e_state_set = erot_gset_new(); /* store previous state */ - } - BLI_assert(BLI_gset_haskey(e_state_set, (void *)e_state) == false); - BLI_gset_insert(e_state_set, e_state); - - - // printf(" %d -> %d, %d\n", i, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2)); - - /* maintain the index array */ - edge_array[i] = e; - BM_elem_index_set(e, i); - - /* recalculate faces connected on the heap */ - bm_edge_update_beauty_cost(e, eheap, eheap_table, edge_state_arr, flag, method); - - /* update flags */ - BMO_elem_flag_enable(bm, e, ELE_NEW); - BMO_elem_flag_enable(bm, e->l->f, FACE_MARK | ELE_NEW); - BMO_elem_flag_enable(bm, e->l->radial_next->f, FACE_MARK | ELE_NEW); - } - } - - BLI_heap_free(eheap, NULL); - MEM_freeN(eheap_table); - - for (i = 0; i < edge_array_len; i++) { - if (edge_state_arr[i]) { - BLI_gset_free(edge_state_arr[i], NULL); - } - } - - MEM_freeN(edge_state_arr); - BLI_mempool_destroy(edge_state_pool); - -#ifdef DEBUG_TIME - TIMEIT_END(beautify_fill); -#endif -} - - void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) { BMIter iter; @@ -486,9 +79,10 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) } bm->elem_index_dirty |= BM_EDGE; - bm_mesh_beautify_fill(bm, edge_array, edge_array_len, flag, method); + BM_mesh_beautify_fill(bm, edge_array, edge_array_len, flag, method); MEM_freeN(edge_array); BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW); } + diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c new file mode 100644 index 00000000000..fa39d6bb05a --- /dev/null +++ b/source/blender/bmesh/tools/bmesh_beautify.c @@ -0,0 +1,441 @@ +/* + * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Joseph Eagar. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/bmesh/tools/bmesh_beautify.c + * \ingroup bmesh + * + * Beautify the mesh by rotating edges between triangles + * to more attractive positions until no more rotations can be made. + * + * In principle this is very simple however there is the possibility of + * going into an eternal loop where edges keep rotating. + * To avoid this - each edge stores a set of it previous + * states so as not to rotate back. + * + * TODO + * - Take face normals into account. + */ + +#include "BLI_math.h" +#include "BLI_heap.h" + +#include "MEM_guardedalloc.h" + +#include "bmesh.h" +#include "bmesh_beautify.h" /* own include */ + + +// #define DEBUG_TIME + +#ifdef DEBUG_TIME +# include "PIL_time.h" +# include "PIL_time_utildefines.h" +#endif + +/* -------------------------------------------------------------------- */ +/* GSet for edge rotation */ + +typedef struct EdRotState { + int v1, v2; /* edge vert, small -> large */ + int f1, f2; /* face vert, small -> large */ +} EdRotState; + +static unsigned int erot_gsetutil_hash(const void *ptr) +{ + const EdRotState *e_state = (const EdRotState *)ptr; + unsigned int + hash = BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->v1)); + hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->v2)); + hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f1)); + hash ^= BLI_ghashutil_inthash(SET_INT_IN_POINTER(e_state->f2)); + return hash; +} +static int erot_gsetutil_cmp(const void *a, const void *b) +{ + const EdRotState *e_state_a = (const EdRotState *)a; + const EdRotState *e_state_b = (const EdRotState *)b; + if (e_state_a->v1 < e_state_b->v1) return -1; + else if (e_state_a->v1 > e_state_b->v1) return 1; + else if (e_state_a->v2 < e_state_b->v2) return -1; + else if (e_state_a->v2 > e_state_b->v2) return 1; + else if (e_state_a->f1 < e_state_b->f1) return -1; + else if (e_state_a->f1 > e_state_b->f1) return 1; + else if (e_state_a->f2 < e_state_b->f2) return -1; + else if (e_state_a->f2 > e_state_b->f2) return 1; + else return 0; +} + +static GSet *erot_gset_new(void) +{ + return BLI_gset_new(erot_gsetutil_hash, erot_gsetutil_cmp, __func__); +} + +/* ensure v0 is smaller */ +#define EDGE_ORD(v0, v1) \ + if (v0 > v1) { \ + v0 ^= v1; \ + v1 ^= v0; \ + v0 ^= v1; \ + } (void)0 + +static void erot_state_ex(const BMEdge *e, int v_index[2], int f_index[2]) +{ + BLI_assert(BM_edge_is_manifold((BMEdge *)e)); + BLI_assert(BM_vert_in_edge(e, e->l->prev->v) == false); + BLI_assert(BM_vert_in_edge(e, e->l->radial_next->prev->v) == false); + + /* verts of the edge */ + v_index[0] = BM_elem_index_get(e->v1); + v_index[1] = BM_elem_index_get(e->v2); + EDGE_ORD(v_index[0], v_index[1]); + + /* verts of each of the 2 faces attached to this edge + * (that are not apart of this edge) */ + f_index[0] = BM_elem_index_get(e->l->prev->v); + f_index[1] = BM_elem_index_get(e->l->radial_next->prev->v); + EDGE_ORD(f_index[0], f_index[1]); +} + +static void erot_state_current(const BMEdge *e, EdRotState *e_state) +{ + erot_state_ex(e, &e_state->v1, &e_state->f1); +} + +static void erot_state_alternate(const BMEdge *e, EdRotState *e_state) +{ + erot_state_ex(e, &e_state->f1, &e_state->v1); +} + +/* -------------------------------------------------------------------- */ +/* Calculate the improvement of rotating the edge */ + +/** + * \return a negative value means the edge can be rotated. + */ +static float bm_edge_calc_rotate_beauty__area( + const float v1[3], const float v2[3], const float v3[3], const float v4[3]) +{ + /* not a loop (only to be able to break out) */ + do { + float v1_xy[2], v2_xy[2], v3_xy[2], v4_xy[2]; + + /* first get the 2d values */ + { + bool is_zero_a, is_zero_b; + float no[3]; + float axis_mat[3][3]; + + // printf("%p %p %p %p - %p %p\n", v1, v2, v3, v4, e->l->f, e->l->radial_next->f); + BLI_assert((ELEM3(v1, v2, v3, v4) == false) && + (ELEM3(v2, v1, v3, v4) == false) && + (ELEM3(v3, v1, v2, v4) == false) && + (ELEM3(v4, v1, v2, v3) == false)); + + is_zero_a = area_tri_v3(v2, v3, v4) <= FLT_EPSILON; + is_zero_b = area_tri_v3(v2, v4, v1) <= FLT_EPSILON; + + if (LIKELY(is_zero_a == false && is_zero_b == false)) { + float no_a[3], no_b[3]; + normal_tri_v3(no_a, v2, v3, v4); /* a */ + normal_tri_v3(no_b, v2, v4, v1); /* b */ + add_v3_v3v3(no, no_a, no_b); + if (UNLIKELY(normalize_v3(no) <= FLT_EPSILON)) { + break; + } + } + else if (is_zero_a == false) { + normal_tri_v3(no, v2, v3, v4); /* a */ + } + else if (is_zero_b == false) { + normal_tri_v3(no, v2, v4, v1); /* b */ + } + else { + /* both zero area, no useful normal can be calculated */ + break; + } + + // { float a = angle_normalized_v3v3(no_a, no_b); printf("~ %.7f\n", a); fflush(stdout);} + + axis_dominant_v3_to_m3(axis_mat, no); + mul_v2_m3v3(v1_xy, axis_mat, v1); + mul_v2_m3v3(v2_xy, axis_mat, v2); + mul_v2_m3v3(v3_xy, axis_mat, v3); + mul_v2_m3v3(v4_xy, axis_mat, v4); + } + + // printf("%p %p %p %p - %p %p\n", v1, v2, v3, v4, e->l->f, e->l->radial_next->f); + + if (is_quad_convex_v2(v1_xy, v2_xy, v3_xy, v4_xy)) { + /* testing rule: the area divided by the perimeter, + * check if (1-3) beats the existing (2-4) edge rotation */ + float area_a, area_b; + float prim_a, prim_b; + float fac_24, fac_13; + + float len_12, len_23, len_34, len_41, len_24, len_13; + + /* edges around the quad */ + len_12 = len_v2v2(v1_xy, v2_xy); + len_23 = len_v2v2(v2_xy, v3_xy); + len_34 = len_v2v2(v3_xy, v4_xy); + len_41 = len_v2v2(v4_xy, v1_xy); + /* edges crossing the quad interior */ + len_13 = len_v2v2(v1_xy, v3_xy); + len_24 = len_v2v2(v2_xy, v4_xy); + + /* edge (2-4), current state */ + area_a = area_tri_v2(v2_xy, v3_xy, v4_xy); + area_b = area_tri_v2(v2_xy, v4_xy, v1_xy); + prim_a = len_23 + len_34 + len_24; + prim_b = len_24 + len_41 + len_12; + fac_24 = (area_a / prim_a) + (area_b / prim_b); + + /* edge (1-3), new state */ + area_a = area_tri_v2(v1_xy, v2_xy, v3_xy); + area_b = area_tri_v2(v1_xy, v3_xy, v4_xy); + prim_a = len_12 + len_23 + len_13; + prim_b = len_34 + len_41 + len_13; + fac_13 = (area_a / prim_a) + (area_b / prim_b); + + /* negative number if (1-3) is an improved state */ + return fac_24 - fac_13; + } + } while (false); + + return FLT_MAX; +} + +static float bm_edge_calc_rotate_beauty__angle( + const float v1[3], const float v2[3], const float v3[3], const float v4[3]) +{ + /* not a loop (only to be able to break out) */ + do { + float no_a[3], no_b[3]; + float angle_24, angle_13; + + /* edge (2-4), current state */ + normal_tri_v3(no_a, v2, v3, v4); + normal_tri_v3(no_b, v2, v4, v1); + angle_24 = angle_normalized_v3v3(no_a, no_b); + + /* edge (1-3), new state */ + /* only check new state for degenerate outcome */ + if ((normal_tri_v3(no_a, v1, v2, v3) == 0.0f) || + (normal_tri_v3(no_b, v1, v3, v4) == 0.0f)) + { + break; + } + angle_13 = angle_normalized_v3v3(no_a, no_b); + + return angle_13 - angle_24; + } while (false); + + return FLT_MAX; +} + +static float bm_edge_calc_rotate_beauty(const BMEdge *e, const short flag, const short method) +{ + /* not a loop (only to be able to break out) */ + do { + const float *v1, *v2, *v3, *v4; + + v1 = e->l->prev->v->co; /* first face co */ + v2 = e->l->v->co; /* e->v1 or e->v2*/ + v3 = e->l->radial_next->prev->v->co; /* second face co */ + v4 = e->l->next->v->co; /* e->v1 or e->v2*/ + + if (flag & VERT_RESTRICT_TAG) { + BMVert *v_a = e->l->prev->v, *v_b = e->l->radial_next->prev->v; + if (BM_elem_flag_test(v_a, BM_ELEM_TAG) == BM_elem_flag_test(v_b, BM_ELEM_TAG)) { + break; + } + } + + if (UNLIKELY(v1 == v3)) { + // printf("This should never happen, but does sometimes!\n"); + break; + } + + switch (method) { + case 0: + return bm_edge_calc_rotate_beauty__area(v1, v2, v3, v4); + default: + return bm_edge_calc_rotate_beauty__angle(v1, v2, v3, v4); + } + } while (false); + + return FLT_MAX; +} + +/* -------------------------------------------------------------------- */ +/* Update the edge cost of rotation in the heap */ + +/* recalc an edge in the heap (surrounding geometry has changed) */ +static void bm_edge_update_beauty_cost_single(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GSet **edge_state_arr, + const short flag, const short method) +{ + if (BM_elem_flag_test(e, BM_ELEM_TAG)) { + const int i = BM_elem_index_get(e); + GSet *e_state_set = edge_state_arr[i]; + + if (eheap_table[i]) { + BLI_heap_remove(eheap, eheap_table[i]); + eheap_table[i] = NULL; + } + + /* check if we can add it back */ + BLI_assert(BM_edge_is_manifold(e) == true); + //BLI_assert(BMO_elem_flag_test(bm, e->l->f, FACE_MARK) && + // BMO_elem_flag_test(bm, e->l->radial_next->f, FACE_MARK)); + + /* check we're not moving back into a state we have been in before */ + if (e_state_set != NULL) { + EdRotState e_state_alt; + erot_state_alternate(e, &e_state_alt); + if (BLI_gset_haskey(e_state_set, (void *)&e_state_alt)) { + // printf(" skipping, we already have this state\n"); + return; + } + } + + { + /* recalculate edge */ + const float cost = bm_edge_calc_rotate_beauty(e, flag, method); + if (cost < 0.0f) { + eheap_table[i] = BLI_heap_insert(eheap, cost, e); + } + else { + eheap_table[i] = NULL; + } + } + } +} + +/* we have rotated an edge, tag other edges and clear this one */ +static void bm_edge_update_beauty_cost(BMEdge *e, Heap *eheap, HeapNode **eheap_table, GSet **edge_state_arr, + const short flag, const short method) +{ + BMLoop *l; + BLI_assert(e->l->f->len == 3 && + e->l->radial_next->f->len == 3); + + l = e->l; + bm_edge_update_beauty_cost_single(l->next->e, eheap, eheap_table, edge_state_arr, flag, method); + bm_edge_update_beauty_cost_single(l->prev->e, eheap, eheap_table, edge_state_arr, flag, method); + l = l->radial_next; + bm_edge_update_beauty_cost_single(l->next->e, eheap, eheap_table, edge_state_arr, flag, method); + bm_edge_update_beauty_cost_single(l->prev->e, eheap, eheap_table, edge_state_arr, flag, method); +} + +/* -------------------------------------------------------------------- */ +/* Beautify Fill */ + +#define ELE_NEW 1 +#define FACE_MARK 2 + +/** + * \note All edges in \a edge_array must be tagged and + * have their index values set according to their position in the array. + */ +void BM_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_len, + const short flag, const short method) +{ + Heap *eheap; /* edge heap */ + HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */ + + GSet **edge_state_arr = MEM_callocN((size_t)edge_array_len * sizeof(GSet *), __func__); + BLI_mempool *edge_state_pool = BLI_mempool_create(sizeof(EdRotState), 512, 512, BLI_MEMPOOL_SYSMALLOC); + int i; + +#ifdef DEBUG_TIME + TIMEIT_START(beautify_fill); +#endif + + eheap = BLI_heap_new_ex((unsigned int)edge_array_len); + eheap_table = MEM_mallocN(sizeof(HeapNode *) * (size_t)edge_array_len, __func__); + + /* build heap */ + for (i = 0; i < edge_array_len; i++) { + BMEdge *e = edge_array[i]; + const float cost = bm_edge_calc_rotate_beauty(e, flag, method); + if (cost < 0.0f) { + eheap_table[i] = BLI_heap_insert(eheap, cost, e); + } + else { + eheap_table[i] = NULL; + } + } + + while (BLI_heap_is_empty(eheap) == false) { + BMEdge *e = BLI_heap_popmin(eheap); + i = BM_elem_index_get(e); + eheap_table[i] = NULL; + + e = BM_edge_rotate(bm, e, false, BM_EDGEROT_CHECK_EXISTS); + if (LIKELY(e)) { + GSet *e_state_set = edge_state_arr[i]; + + /* add the new state into the set so we don't move into this state again + * note: we could add the previous state too but this isn't essential) + * for avoiding eternal loops */ + EdRotState *e_state = BLI_mempool_alloc(edge_state_pool); + erot_state_current(e, e_state); + if (UNLIKELY(e_state_set == NULL)) { + edge_state_arr[i] = e_state_set = erot_gset_new(); /* store previous state */ + } + BLI_assert(BLI_gset_haskey(e_state_set, (void *)e_state) == false); + BLI_gset_insert(e_state_set, e_state); + + + // printf(" %d -> %d, %d\n", i, BM_elem_index_get(e->v1), BM_elem_index_get(e->v2)); + + /* maintain the index array */ + edge_array[i] = e; + BM_elem_index_set(e, i); + + /* recalculate faces connected on the heap */ + bm_edge_update_beauty_cost(e, eheap, eheap_table, edge_state_arr, flag, method); + + /* update flags */ + BMO_elem_flag_enable(bm, e, ELE_NEW); + BMO_elem_flag_enable(bm, e->l->f, FACE_MARK | ELE_NEW); + BMO_elem_flag_enable(bm, e->l->radial_next->f, FACE_MARK | ELE_NEW); + } + } + + BLI_heap_free(eheap, NULL); + MEM_freeN(eheap_table); + + for (i = 0; i < edge_array_len; i++) { + if (edge_state_arr[i]) { + BLI_gset_free(edge_state_arr[i], NULL); + } + } + + MEM_freeN(edge_state_arr); + BLI_mempool_destroy(edge_state_pool); + +#ifdef DEBUG_TIME + TIMEIT_END(beautify_fill); +#endif +} + diff --git a/source/blender/bmesh/tools/bmesh_beautify.h b/source/blender/bmesh/tools/bmesh_beautify.h new file mode 100644 index 00000000000..0ce8ddee2b6 --- /dev/null +++ b/source/blender/bmesh/tools/bmesh_beautify.h @@ -0,0 +1,37 @@ +/* + * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BMESH_BEAUTIFY_H__ +#define __BMESH_BEAUTIFY_H__ + +/** \file blender/bmesh/tools/bmesh_beautify.h + * \ingroup bmesh + */ + +enum { + VERT_RESTRICT_TAG = (1 << 0), +}; + +void BM_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_len, + const short flag, const short method); + +#endif /* __BMESH_BEAUTIFY_H__ */ -- cgit v1.2.3 From 859dfccb589a099e0b3032b52c3b528f5e1f2568 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 16 Oct 2013 03:24:50 +0000 Subject: beautify: passing edge/face flags as arguments no functional change, just preparing the ground for the beautify in triangulate modifier changes. --- source/blender/bmesh/operators/bmo_beautify.c | 2 +- source/blender/bmesh/tools/bmesh_beautify.c | 12 ++++++++---- source/blender/bmesh/tools/bmesh_beautify.h | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_beautify.c b/source/blender/bmesh/operators/bmo_beautify.c index b0b3e723603..d9ab30bfcfa 100644 --- a/source/blender/bmesh/operators/bmo_beautify.c +++ b/source/blender/bmesh/operators/bmo_beautify.c @@ -79,7 +79,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) } bm->elem_index_dirty |= BM_EDGE; - BM_mesh_beautify_fill(bm, edge_array, edge_array_len, flag, method); + BM_mesh_beautify_fill(bm, edge_array, edge_array_len, flag, method, ELE_NEW, FACE_MARK | ELE_NEW); MEM_freeN(edge_array); diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c index fa39d6bb05a..af9345b903c 100644 --- a/source/blender/bmesh/tools/bmesh_beautify.c +++ b/source/blender/bmesh/tools/bmesh_beautify.c @@ -357,7 +357,8 @@ static void bm_edge_update_beauty_cost(BMEdge *e, Heap *eheap, HeapNode **eheap_ * have their index values set according to their position in the array. */ void BM_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_len, - const short flag, const short method) + const short flag, const short method, + const short oflag_edge, const short oflag_face) { Heap *eheap; /* edge heap */ HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */ @@ -416,9 +417,12 @@ void BM_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_ bm_edge_update_beauty_cost(e, eheap, eheap_table, edge_state_arr, flag, method); /* update flags */ - BMO_elem_flag_enable(bm, e, ELE_NEW); - BMO_elem_flag_enable(bm, e->l->f, FACE_MARK | ELE_NEW); - BMO_elem_flag_enable(bm, e->l->radial_next->f, FACE_MARK | ELE_NEW); + if (oflag_edge) + BMO_elem_flag_enable(bm, e, oflag_edge); + if (oflag_face) { + BMO_elem_flag_enable(bm, e->l->f, oflag_face); + BMO_elem_flag_enable(bm, e->l->radial_next->f, oflag_face); + } } } diff --git a/source/blender/bmesh/tools/bmesh_beautify.h b/source/blender/bmesh/tools/bmesh_beautify.h index 0ce8ddee2b6..210e265d706 100644 --- a/source/blender/bmesh/tools/bmesh_beautify.h +++ b/source/blender/bmesh/tools/bmesh_beautify.h @@ -32,6 +32,7 @@ enum { }; void BM_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_len, - const short flag, const short method); + const short flag, const short method, + const short oflag_edge, const short oflag_face); #endif /* __BMESH_BEAUTIFY_H__ */ -- cgit v1.2.3 From ecf2eeef231ea5b615232070209af308257d9bfb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Oct 2013 04:08:20 +0000 Subject: style cleanup --- release/scripts/modules/bpy/utils.py | 2 +- source/blender/editors/screen/screendump.c | 2 +- source/blender/editors/sculpt_paint/paint_image.c | 4 ++-- source/blender/editors/space_view3d/drawmesh.c | 2 +- source/blender/gpu/intern/gpu_codegen.c | 2 +- source/blender/makesrna/intern/rna_key.c | 4 ++-- source/blender/render/intern/source/bake.c | 24 ++++++++++++---------- .../blender/render/intern/source/render_texture.c | 2 +- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index ab35d774719..608cd920865 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -677,7 +677,7 @@ def make_rna_paths(struct_name, prop_name, enum_name): if prop_name: src = src_rna = ".".join((struct_name, prop_name)) if enum_name: - src = src_enum = "{}:'{}'".format(src_rna, enum_name) + src = src_enum = "%s:'%s'" % (src_rna, enum_name) else: src = src_rna = struct_name return src, src_rna, src_enum diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index dbe1197436b..06581fb3c11 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -105,7 +105,7 @@ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy) dumprect = MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect"); glReadBuffer(GL_FRONT); - screenshot_read_pixels(x, y, *dumpsx, *dumpsy, (unsigned char*)dumprect); + screenshot_read_pixels(x, y, *dumpsx, *dumpsy, (unsigned char *)dumprect); glReadBuffer(GL_BACK); } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index f3f12464528..9e8a8fd3ecc 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -949,7 +949,7 @@ static int sample_color_exec(bContext *C, wmOperator *op) RNA_int_get_array(op->ptr, "location", location); paint_sample_color(C, ar, location[0], location[1]); - if(show_cursor) { + if (show_cursor) { paint->flags |= PAINT_SHOW_BRUSH; } @@ -989,7 +989,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) Brush *brush = BKE_paint_brush(paint); if ((event->type == data->event_type) && (event->val == KM_RELEASE)) { - if(data->show_cursor) { + if (data->show_cursor) { paint->flags |= PAINT_SHOW_BRUSH; } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index dc62005f760..d169fc58260 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -345,7 +345,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O else { /* draw with lights in the scene otherwise */ solidtex = false; - if(v3d->flag2 & V3D_SHADELESS_TEX) + if (v3d->flag2 & V3D_SHADELESS_TEX) Gtexdraw.is_lit = 0; else Gtexdraw.is_lit = GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp); diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index d7919125fee..8e0d0e55709 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -65,7 +65,7 @@ static char *glsl_material_library = NULL; /* structs and defines */ -static const char* GPU_DATATYPE_STR[17] = {"", "float", "vec2", "vec3", "vec4", +static const char *GPU_DATATYPE_STR[17] = {"", "float", "vec2", "vec3", "vec4", NULL, NULL, NULL, NULL, "mat3", NULL, NULL, NULL, NULL, NULL, NULL, "mat4"}; #define LINK_IMAGE_BLENDER 1 diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index a20cb73b3aa..6d6f516ecac 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -405,7 +405,7 @@ static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point) } /* determine where end of array is - * - elemsize is in bytes, so use char* cast to get array in terms of bytes + * - elemsize is in bytes, so use (char *) cast to get array in terms of bytes */ end = (float *)((char *)start + (key->elemsize * kb->totelem)); @@ -422,7 +422,7 @@ static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point) static int rna_ShapeKeyPoint_get_index(Key *key, KeyBlock *kb, float *point) { - /* if we frame the data array and point pointers as char*, then the difference between + /* if we frame the data array and point pointers as (char *), then the difference between * them will be in bytes. Thus, dividing through by key->elemsize (number of bytes per point) * gives us the offset of point from start of array. */ diff --git a/source/blender/render/intern/source/bake.c b/source/blender/render/intern/source/bake.c index 72e47f89bb2..cb6ca0e30ac 100644 --- a/source/blender/render/intern/source/bake.c +++ b/source/blender/render/intern/source/bake.c @@ -1141,7 +1141,7 @@ struct Image *RE_bake_shade_get_image(void) static void add_single_heights_margin(const ImBuf *ibuf, const char *mask, float *heights_buffer) { - int x ,y; + int x, y; for (y = 0; y < ibuf->y; y++) { for (x = 0; x < ibuf->x; x++) { @@ -1200,11 +1200,11 @@ float RE_bake_make_derivative(ImBuf *ibuf, float *heights_buffer, const char *ma if (auto_range_fit) { /* If automatic range fitting is enabled. */ for (y = 0; y < ibuf->y; y++) { - const int Yu = y == (ibuf->y - 1) ? (ibuf->y - 1) : (y+1); + const int Yu = y == (ibuf->y - 1) ? (ibuf->y - 1) : (y + 1); const int Yc = y; const int Yd = y == 0 ? 0 : (y - 1); - for (x= 0; x < ibuf->x; x++) { + for (x = 0; x < ibuf->x; x++) { const int Xl = x == 0 ? 0 : (x - 1); const int Xc = x; const int Xr = x == (ibuf->x - 1) ? (ibuf->x - 1) : (x + 1); @@ -1244,11 +1244,11 @@ float RE_bake_make_derivative(ImBuf *ibuf, float *heights_buffer, const char *ma /* Output derivatives. */ auto_range_fit &= (max_num_deriv > 0); for (y = 0; y < ibuf->y; y++) { - const int Yu= y==(ibuf->y-1) ? (ibuf->y-1) : (y+1); - const int Yc= y; - const int Yd= y==0 ? 0 : (y-1); + const int Yu = y == (ibuf->y - 1) ? (ibuf->y - 1) : (y + 1); + const int Yc = y; + const int Yd = y == 0 ? 0 : (y - 1); - for(x= 0; xx; x++) { + for (x = 0; x < ibuf->x; x++) { const int Xl = x == 0 ? 0 : (x - 1); const int Xc = x; const int Xr = x == (ibuf->x - 1) ? (ibuf->x - 1) : (x + 1); @@ -1269,14 +1269,15 @@ float RE_bake_make_derivative(ImBuf *ibuf, float *heights_buffer, const char *ma /* Early out. */ index = ibuf->x * y + x; - if (mask[index] != FILTER_MASK_USED){ + if (mask[index] != FILTER_MASK_USED) { continue; } if (auto_range_fit) { deriv_x /= max_num_deriv; deriv_y /= max_num_deriv; - } else { + } + else { deriv_x *= (fmult / denom); deriv_y *= (fmult / denom); } @@ -1296,8 +1297,9 @@ float RE_bake_make_derivative(ImBuf *ibuf, float *heights_buffer, const char *ma rrgbf[1] = deriv_y; rrgbf[2] = 0.0f; rrgbf[3] = 1.0f; - } else { - char *rrgb = (char*)ibuf->rect + index * 4; + } + else { + char *rrgb = (char *)ibuf->rect + index * 4; rrgb[0] = FTOCHAR(deriv_x); rrgb[1] = FTOCHAR(deriv_y); diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 49052150fe3..e8127b0e6b9 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1724,7 +1724,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, const float bf = -0.04f*Tnor*mtex->norfac; int rgbnor; /* disable internal bump eval */ - float* nvec = texres->nor; + float *nvec = texres->nor; texres->nor = NULL; /* du & dv estimates, constant value defaults */ du = dv = 0.01f; -- cgit v1.2.3 From f12ac5b23f27882446ea6620216d9be863183e50 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Oct 2013 05:24:55 +0000 Subject: fix [#37100] Segfault when I rotate an edge --- source/blender/bmesh/operators/bmo_utils.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index c89fee71cbc..600386893dd 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -145,19 +145,23 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_test(bm, fb, FACE_TAINT) == false) { + /* don't touch again (faces will be freed so run before rotating the edge) */ + BMO_elem_flag_enable(bm, fa, FACE_TAINT); + BMO_elem_flag_enable(bm, fb, FACE_TAINT); + if (!(e2 = BM_edge_rotate(bm, e, use_ccw, check_flag))) { + + BMO_elem_flag_disable(bm, fa, FACE_TAINT); + BMO_elem_flag_disable(bm, fb, FACE_TAINT); #if 0 BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Could not rotate edge"); return; #endif + continue; } BMO_elem_flag_enable(bm, e2, EDGE_OUT); - - /* don't touch again */ - BMO_elem_flag_enable(bm, fa, FACE_TAINT); - BMO_elem_flag_enable(bm, fb, FACE_TAINT); } } } -- cgit v1.2.3 From 089d0ad8f9d227b3cadd56184578e163ac5589f8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Oct 2013 05:29:28 +0000 Subject: add IDP_FreeFromGroup(), replaces IDP_RemFromGroup(), IDP_FreeProperty(), MEM_freeN(). --- source/blender/blenkernel/BKE_idprop.h | 3 ++- source/blender/blenkernel/intern/idprop.c | 12 +++++++++++- source/blender/blenkernel/intern/writeffmpeg.c | 4 +--- source/blender/makesrna/intern/rna_access.c | 16 ++++------------ source/blender/python/generic/idprop_py_api.c | 6 ++---- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 71fd163a8ee..bd90960eced 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -94,7 +94,8 @@ void IDP_MergeGroup(IDProperty *dest, IDProperty *src, const int do_overwrite) A int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL(); int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous, struct IDProperty *pnew) ATTR_NONNULL(1 /* group */, 3 /* pnew */); -void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL(); +void IDP_RemoveFromGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL(); +void IDP_FreeFromGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL(); IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 6f275e4ec75..594c918b4c2 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -641,7 +641,7 @@ int IDP_InsertToGroup(IDProperty *group, IDProperty *previous, IDProperty *pnew) * IDP_FreeProperty(prop); //free all subdata * MEM_freeN(prop); //free property struct itself */ -void IDP_RemFromGroup(IDProperty *group, IDProperty *prop) +void IDP_RemoveFromGroup(IDProperty *group, IDProperty *prop) { BLI_assert(group->type == IDP_GROUP); @@ -649,6 +649,16 @@ void IDP_RemFromGroup(IDProperty *group, IDProperty *prop) BLI_remlink(&group->data.group, prop); } +/** + * Removes the property from the group and frees it. + */ +void IDP_FreeFromGroup(IDProperty *group, IDProperty *prop) +{ + IDP_RemoveFromGroup(group, prop); + IDP_FreeProperty(prop); + MEM_freeN(prop); +} + IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name) { BLI_assert(prop->type == IDP_GROUP); diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 538c98cc899..ebd6bc01bea 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1254,9 +1254,7 @@ void BKE_ffmpeg_property_del(RenderData *rd, void *type, void *prop_) group = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, type); if (group && prop) { - IDP_RemFromGroup(group, prop); - IDP_FreeProperty(prop); - MEM_freeN(prop); + IDP_FreeFromGroup(group, prop); } } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 9a8533ec6a1..fe457a14718 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -290,9 +290,7 @@ static void rna_idproperty_free(PointerRNA *ptr, const char *name) if (group) { IDProperty *idprop = IDP_GetPropertyFromGroup(group, name); if (idprop) { - IDP_RemFromGroup(group, idprop); - IDP_FreeProperty(idprop); - MEM_freeN(idprop); + IDP_FreeFromGroup(group, idprop); } } } @@ -423,9 +421,7 @@ IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr) if (idprop && !rna_idproperty_verify_valid(ptr, *prop, idprop)) { IDProperty *group = RNA_struct_idprops(ptr, 0); - IDP_RemFromGroup(group, idprop); - IDP_FreeProperty(idprop); - MEM_freeN(idprop); + IDP_FreeFromGroup(group, idprop); return NULL; } @@ -596,9 +592,7 @@ bool RNA_struct_idprops_unset(PointerRNA *ptr, const char *identifier) if (group) { IDProperty *idp = IDP_GetPropertyFromGroup(group, identifier); if (idp) { - IDP_RemFromGroup(group, idp); - IDP_FreeProperty(idp); - MEM_freeN(idp); + IDP_FreeFromGroup(group, idp); return true; } @@ -2771,9 +2765,7 @@ void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop) group = RNA_struct_idprops(ptr, 0); if (group) { - IDP_RemFromGroup(group, idprop); - IDP_FreeProperty(idprop); - MEM_freeN(idprop); + IDP_FreeFromGroup(group, idprop); } } else diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index f7ed5fec891..92e9f49769d 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -496,9 +496,7 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val) if (val == NULL) { /* del idprop[key] */ IDProperty *pkey = IDP_GetPropertyFromGroup(prop, _PyUnicode_AsString(key)); if (pkey) { - IDP_RemFromGroup(prop, pkey); - IDP_FreeProperty(pkey); - MEM_freeN(pkey); + IDP_FreeFromGroup(prop, pkey); return 0; } else { @@ -670,7 +668,7 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value) return NULL; } - IDP_RemFromGroup(self->prop, idprop); + IDP_RemoveFromGroup(self->prop, idprop); return pyform; } -- cgit v1.2.3 From 78efff5f4251f1f4cf0ae3cd60d84ac5f78e332a Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 16 Oct 2013 07:55:52 +0000 Subject: Fix #37084, Backdrop not invalidating inside node groups. Extended the is_active_group flag such that both the current edittree as well as the base node tree in Scene do a viewer node update. --- source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index 9516deee7e3..3f8c432a004 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -45,7 +45,10 @@ void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_star vector& nodes = system.getNodes(); vector& links = system.getConnections(); - bool is_active_group = (parent_key.value == system.getContext().getbNodeTree()->active_viewer_key.value); + const bNodeTree *basetree = system.getContext().getbNodeTree(); + /* update viewers in the active edittree as well the base tree (for backdrop) */ + bool is_active_group = (parent_key.value == basetree->active_viewer_key.value + || tree == basetree); /* add all nodes of the tree to the node list */ bNode *node = (bNode *)tree->nodes.first; -- cgit v1.2.3 From af6636bbedac5ae36bfa00b934817c75799fe359 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 16 Oct 2013 17:48:33 +0000 Subject: Project Pampa request: copy-paste for curve mapping widgets Use C-c for copy, C-v for paste over the widget. --- source/blender/editors/interface/interface.c | 1 + .../blender/editors/interface/interface_handlers.c | 32 +++++++++++++++++++++- .../blender/editors/interface/interface_intern.h | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3bad2577409..9f6d326cd95 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -4186,5 +4186,6 @@ void UI_reinit_font(void) void UI_exit(void) { ui_resources_free(); + ui_button_clipboard_free(); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 0d49b08c167..296db88dce8 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -242,6 +242,11 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *userd static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type); static void button_timers_tooltip_remove(bContext *C, uiBut *but); +/* buttons clipboard */ +static ColorBand but_copypaste_coba = {0}; +static CurveMapping but_copypaste_curve = {0}; +static bool but_copypaste_curve_alive = false; + /* ******************** menu navigation helpers ************** */ /* assumes event type is MOUSEPAN */ @@ -1324,7 +1329,6 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB /* c = copy, v = paste */ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char mode) { - static ColorBand but_copypaste_coba = {0}; char buf[UI_MAX_DRAW_STR + 1] = {0}; if (mode == 'v' && but->lock == TRUE) { @@ -1458,6 +1462,28 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, button_activate_state(C, but, BUTTON_STATE_EXIT); } } + else if (but->type == BUT_CURVE) { + if (mode == 'c') { + if (but->poin == NULL) + return; + + but_copypaste_curve_alive = true; + curvemapping_free_data(&but_copypaste_curve); + curvemapping_copy_data(&but_copypaste_curve, (CurveMapping *) but->poin); + } + else { + if (!but_copypaste_curve_alive) + return; + + if (!but->poin) + but->poin = MEM_callocN(sizeof(CurveMapping), "curvemapping"); + + button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); + curvemapping_free_data((CurveMapping *) but->poin); + curvemapping_copy_data((CurveMapping *) but->poin, &but_copypaste_curve); + button_activate_state(C, but, BUTTON_STATE_EXIT); + } + } /* operator button (any type) */ else if (but->optype) { if (mode == 'c') { @@ -7851,3 +7877,7 @@ bool UI_textbutton_activate_event(const bContext *C, ARegion *ar, } } +void ui_button_clipboard_free(void) +{ + curvemapping_free_data(&but_copypaste_curve); +} diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 46c6e980ccc..be0a2810d2e 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -523,6 +523,7 @@ extern void ui_button_active_free(const struct bContext *C, uiBut *but); extern bool ui_button_is_active(struct ARegion *ar); extern int ui_button_open_menu_direction(uiBut *but); extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, int restore); +void ui_button_clipboard_free(void); /* interface_widgets.c */ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); -- cgit v1.2.3 From 1ce5978805a7231fee57a16609dc4569316f1e23 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 16 Oct 2013 17:54:12 +0000 Subject: BGE: Fix to allow render options such display framerate and profile to work when launching the Blenderplayer from Blender. This bug was reported and fixed by SolarLune. --- release/scripts/startup/bl_operators/wm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 5a249159d86..4b954e81ee1 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1298,10 +1298,10 @@ class WM_OT_blenderplayer_start(Operator): # handle some UI options as command line arguments args.extend([ - "-g", "show_framerate=%d" % gs.show_framerate_profile, - "-g", "show_profile=%d" % gs.show_framerate_profile, - "-g", "show_properties=%d" % gs.show_debug_properties, - "-g", "ignore_deprecation_warnings=%d" % (not gs.use_deprecation_warnings), + "-g", "show_framerate", "=", "%d" % gs.show_framerate_profile, + "-g", "show_profile", "=", "%d" % gs.show_framerate_profile, + "-g", "show_properties", "=", "%d" % gs.show_debug_properties, + "-g", "ignore_deprecation_warnings", "=", "%d" % (not gs.use_deprecation_warnings), ]) # finish the call with the path to the blend file -- cgit v1.2.3 From bd2d7bedbd1e3e11608a5304e1725f56b33c4e45 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 16 Oct 2013 17:58:00 +0000 Subject: Triangulate modifier - beauty option is back Patch reviewed and with collaborations from Campbell Barton --- source/blender/bmesh/intern/bmesh_polygon.c | 96 ++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 14 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index e4c1180d433..d50b56e6d4a 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -37,6 +37,7 @@ #include "BLI_listbase.h" #include "bmesh.h" +#include "bmesh_tools.h" #include "intern/bmesh_private.h" @@ -803,13 +804,13 @@ bool BM_face_point_inside_test(BMFace *f, const float co[3]) /** * \brief BMESH TRIANGULATE FACE * - * Currently repeatedly find the best triangle (i.e. the most "open" one), provided it does not - * produces a "remaining" face with too much wide/narrow angles - * (using cos (i.e. dot product of normalized vectors) of angles). + * Breaks all quads and ngons down to triangles. + * It uses scanfill for the ngons splitting, and + * the beautify operator when use_beauty is true. * * \param r_faces_new if non-null, must be an array of BMFace pointers, - * with a length equal to (f->len - 2). It will be filled with the new - * triangles. + * with a length equal to (f->len - 3). It will be filled with the new + * triangles (not including the original triangle). * * \note use_tag tags new flags and edges. */ @@ -817,11 +818,14 @@ bool BM_face_point_inside_test(BMFace *f, const float co[3]) void BM_face_triangulate(BMesh *bm, BMFace *f, BMFace **r_faces_new, MemArena *sf_arena, - const bool UNUSED(use_beauty), const bool use_tag) + const bool use_beauty, const bool use_tag) { - int nf_i = 0; BMLoop *l_iter, *l_first, *l_new; BMFace *f_new; + int orig_f_len = f->len; + int nf_i = 0; + BMEdge **edge_array; + int edge_array_len; BLI_assert(BM_face_is_normal_valid(f)); @@ -904,32 +908,96 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, if (use_tag) { BM_elem_flag_enable(f_new, BM_ELEM_TAG); } - if (r_faces_new && sf_tri->next) { + if (r_faces_new) { r_faces_new[nf_i++] = f_new; } } } - if (use_tag) { + if (use_beauty || use_tag) { ScanFillEdge *sf_edge; + edge_array = BLI_array_alloca(edge_array, orig_f_len - 3); + edge_array_len = 0; + for (sf_edge = sf_ctx.filledgebase.first; sf_edge; sf_edge = sf_edge->next) { + BMLoop *l1 = sf_edge->v1->tmp.p; + BMLoop *l2 = sf_edge->v2->tmp.p; + + BMEdge *e = BM_edge_exists(l1->v, l2->v); if (sf_edge->tmp.c != SF_EDGE_IS_BOUNDARY) { - BMLoop *l1 = sf_edge->v1->tmp.p; - BMLoop *l2 = sf_edge->v2->tmp.p; - BMEdge *e = BM_edge_exists(l1->v, l2->v); - BM_elem_flag_enable(e, BM_ELEM_TAG); + if (use_beauty) { + BM_elem_index_set(e, edge_array_len); /* set_dirty */ + edge_array[edge_array_len] = e; + edge_array_len++; + } + + if (use_tag) { + BM_elem_flag_enable(e, BM_ELEM_TAG); + } + } + else if (use_tag) { + BM_elem_flag_disable(e, BM_ELEM_TAG); } } + } - if (sf_ctx.fillfacebase.first) { + if ((!use_beauty) || (!r_faces_new)){ /* we can't delete the real face, because some of the callers expect it to remain valid. * so swap data and delete the last created tri */ bmesh_face_swap_data(bm, f, f_new); BM_face_kill(bm, f_new); } + if (use_beauty) { + bm->elem_index_dirty |= BM_EDGE; + BM_mesh_beautify_fill(bm, edge_array, edge_array_len, 0, 0, 0, 0); + + if (r_faces_new) { + /* beautify deletes and creates new faces + * we need to re-populate the r_faces_new array + * with the new faces + */ + BMEdge *e; + BMFace *fa, *fb; + int i; + + nf_i = 0; + for (i = 0; i < edge_array_len; i++) { + e = edge_array[i]; + BLI_assert(BM_edge_face_pair(e, &fa, &fb)); + + if (i == edge_array_len - 1) { + if (BM_elem_index_get(fa) != -2) + f_new = fa; + else if (BM_elem_index_get(fb) != -2) + f_new = fb; + else + BLI_assert(false); + } + else { + if (BM_elem_index_get(fa) != -2) { + r_faces_new[nf_i++] = fa; + BM_elem_index_set(fa, -2); + } + + if (BM_elem_index_get(fb) != -2) { + r_faces_new[nf_i++] = fb; + BM_elem_index_set(fb, -2); + } + } + } + /* nf_i doesn't include the last face */ + BLI_assert(nf_i == orig_f_len - 3); + + /* we can't delete the real face, because some of the callers expect it to remain valid. + * so swap data and delete the last created tri */ + bmesh_face_swap_data(bm, f, f_new); + BM_face_kill(bm, f_new); + } + } + /* garbage collection */ BLI_scanfill_end_arena(&sf_ctx, sf_arena); } -- cgit v1.2.3 From 234626f9e185294e910e371f0d8b551f4ce6fe50 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Oct 2013 22:07:16 +0000 Subject: correct BM_edge_face_pair() being called inside BLI_assert() - this needed to run every time. also other minor changes. --- source/blender/bmesh/intern/bmesh_polygon.c | 48 +++++++++++++++++++---------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index d50b56e6d4a..46810f4dc8c 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -814,7 +814,6 @@ bool BM_face_point_inside_test(BMFace *f, const float co[3]) * * \note use_tag tags new flags and edges. */ -#define SF_EDGE_IS_BOUNDARY 0xff void BM_face_triangulate(BMesh *bm, BMFace *f, BMFace **r_faces_new, MemArena *sf_arena, @@ -827,6 +826,8 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, BMEdge **edge_array; int edge_array_len; +#define SF_EDGE_IS_BOUNDARY 0xff + BLI_assert(BM_face_is_normal_valid(f)); @@ -959,35 +960,47 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, * we need to re-populate the r_faces_new array * with the new faces */ - BMEdge *e; - BMFace *fa, *fb; int i; + +#define FACE_USED_TEST(f) (BM_elem_index_get(f) == -2) +#define FACE_USED_SET(f) BM_elem_index_set(f, -2) + nf_i = 0; for (i = 0; i < edge_array_len; i++) { - e = edge_array[i]; - BLI_assert(BM_edge_face_pair(e, &fa, &fb)); + BMFace *f_a, *f_b; + BMEdge *e = edge_array[i]; + const bool ok = BM_edge_face_pair(e, &f_a, &f_b); + + BLI_assert(ok); if (i == edge_array_len - 1) { - if (BM_elem_index_get(fa) != -2) - f_new = fa; - else if (BM_elem_index_get(fb) != -2) - f_new = fb; - else + if (FACE_USED_TEST(f_a) == false) { + f_new = f_a; + } + else if (FACE_USED_TEST(f_b) == false) { + f_new = f_b; + } + else { BLI_assert(false); + } } else { - if (BM_elem_index_get(fa) != -2) { - r_faces_new[nf_i++] = fa; - BM_elem_index_set(fa, -2); + if (FACE_USED_TEST(f_a) == false) { + FACE_USED_SET(f_a); + r_faces_new[nf_i++] = f_a; } - if (BM_elem_index_get(fb) != -2) { - r_faces_new[nf_i++] = fb; - BM_elem_index_set(fb, -2); + if (FACE_USED_TEST(f_b) == false) { + FACE_USED_SET(f_b); + r_faces_new[nf_i++] = f_b; } } } + +#undef FACE_USED_TEST +#undef FACE_USED_SET + /* nf_i doesn't include the last face */ BLI_assert(nf_i == orig_f_len - 3); @@ -1001,6 +1014,9 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, /* garbage collection */ BLI_scanfill_end_arena(&sf_ctx, sf_arena); } + +#undef SF_EDGE_IS_BOUNDARY + } /** -- cgit v1.2.3 From 69d66f98a8a3d9b40d9bcb1c6bbfb641b6b1b9b4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Oct 2013 23:42:44 +0000 Subject: patch [#37114] copypaste for NORMAL buttons (BUT_NORMAL) from Philipp Oeser (lichtwerk) --- .../blender/editors/interface/interface_handlers.c | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 296db88dce8..ad36958f6f8 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1376,6 +1376,32 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } } + /* NORMAL button */ + else if (but->type == BUT_NORMAL) { + float xyz[3]; + + if (but->poin == NULL && but->rnapoin.data == NULL) { + /* pass */ + } + else if (mode == 'c') { + ui_get_but_vectorf(but, xyz); + BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f]", xyz[0], xyz[1], xyz[2]); + WM_clipboard_text_set(buf, 0); + } + else { + if (sscanf(buf, "[%f, %f, %f]", &xyz[0], &xyz[1], &xyz[2]) == 3) { + if (normalize_v3(xyz) == 0.0f) { + /* better set Z up then have a zero vector */ + xyz[2] = 1.0; + } + button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); + ui_set_but_vectorf(but, xyz); + button_activate_state(C, but, BUTTON_STATE_EXIT); + } + } + } + + /* RGB triple */ else if (but->type == COLOR) { float rgba[4]; -- cgit v1.2.3 From f5660a05b10c776fbbbf978c596e4b80153d1e3a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Oct 2013 02:36:33 +0000 Subject: fix [#37105] Long int IDproperties produces errors at weird spots. --- source/blender/python/generic/idprop_py_api.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 92e9f49769d..9d4b0433f20 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -351,7 +351,10 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty prop = IDP_New(IDP_DOUBLE, &val, name); } else if (PyLong_Check(ob)) { - val.i = (int)PyLong_AsLong(ob); + val.i = _PyLong_AsInt(ob); + if (val.i == -1 && PyErr_Occurred()) { + return "error converting to an int"; + } prop = IDP_New(IDP_INT, &val, name); } else if (PyUnicode_Check(ob)) { @@ -409,7 +412,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty prop = IDP_New(IDP_ARRAY, &val, name); for (i = 0; i < val.array.len; i++) { item = PySequence_Fast_GET_ITEM(ob_seq_fast, i); - ((int *)IDP_Array(prop))[i] = (int)PyLong_AsLong(item); + ((int *)IDP_Array(prop))[i] = _PyLong_AsInt(item); } break; case IDP_IDPARRAY: @@ -1052,10 +1055,6 @@ static PyObject *BPy_IDArray_GetItem(BPy_IDArray *self, int index) static int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *value) { - int i; - float f; - double d; - if (index < 0 || index >= self->prop->len) { PyErr_SetString(PyExc_RuntimeError, "index out of range!"); return -1; @@ -1063,30 +1062,33 @@ static int BPy_IDArray_SetItem(BPy_IDArray *self, int index, PyObject *value) switch (self->prop->subtype) { case IDP_FLOAT: - f = (float)PyFloat_AsDouble(value); + { + const float f = (float)PyFloat_AsDouble(value); if (f == -1 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "expected a float"); return -1; } ((float *)IDP_Array(self->prop))[index] = f; break; + } case IDP_DOUBLE: - d = PyFloat_AsDouble(value); + { + const double d = PyFloat_AsDouble(value); if (d == -1 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "expected a float"); return -1; } ((double *)IDP_Array(self->prop))[index] = d; break; + } case IDP_INT: - i = PyLong_AsLong(value); + { + const int i = _PyLong_AsInt(value); if (i == -1 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "expected an int type"); return -1; } ((int *)IDP_Array(self->prop))[index] = i; break; + } } return 0; } -- cgit v1.2.3 From a619de52cfc4aaa7371e418730a84d0dbd317673 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Oct 2013 02:57:59 +0000 Subject: simplify & improve error handling for id-property python-api. --- source/blender/python/generic/idprop_py_api.c | 68 +++++++++++++++++---------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 9d4b0433f20..93dc5b8397c 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -25,15 +25,16 @@ * \ingroup pygen */ - #include -#include "idprop_py_api.h" #include "MEM_guardedalloc.h" #include "BLI_string.h" #include "BLI_utildefines.h" +#include "idprop_py_api.h" + + #include "BKE_idprop.h" @@ -329,22 +330,30 @@ static int idp_sequence_type(PyObject *seq_fast) return type; } -/* note: group can be a pointer array or a group. - * assume we already checked key is a string. */ -const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group, PyObject *ob) +/** + * \note group can be a pointer array or a group. + * assume we already checked key is a string. + * + * \return success. + */ +bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group, PyObject *ob) { IDProperty *prop = NULL; IDPropertyTemplate val = {0}; - const char *name = ""; + const char *name; if (name_obj) { Py_ssize_t name_size; name = _PyUnicode_AsStringAndSize(name_obj, &name_size); if (name_size > MAX_IDPROP_NAME) { - return "the length of IDProperty names is limited to 63 characters"; + PyErr_SetString(PyExc_KeyError, "the length of IDProperty names is limited to 63 characters"); + return false; } } + else { + name = ""; + } if (PyFloat_Check(ob)) { val.d = PyFloat_AsDouble(ob); @@ -353,7 +362,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty else if (PyLong_Check(ob)) { val.i = _PyLong_AsInt(ob); if (val.i == -1 && PyErr_Occurred()) { - return "error converting to an int"; + return false; } prop = IDP_New(IDP_INT, &val, name); } @@ -384,14 +393,13 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty int i; if (ob_seq_fast == NULL) { - PyErr_Print(); - PyErr_Clear(); - return "error converting the sequence"; + return false; } if ((val.array.type = idp_sequence_type(ob_seq_fast)) == -1) { Py_DECREF(ob_seq_fast); - return "only floats, ints and dicts are allowed in ID property arrays"; + PyErr_SetString(PyExc_TypeError, "only floats, ints and dicts are allowed in ID property arrays"); + return false; } /* validate sequence and derive type. @@ -418,19 +426,21 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty case IDP_IDPARRAY: prop = IDP_NewIDPArray(name); for (i = 0; i < val.array.len; i++) { - const char *error; + bool ok; item = PySequence_Fast_GET_ITEM(ob_seq_fast, i); - error = BPy_IDProperty_Map_ValidateAndCreate(NULL, prop, item); + ok = BPy_IDProperty_Map_ValidateAndCreate(NULL, prop, item); - if (error) { + if (ok == false) { Py_DECREF(ob_seq_fast); - return error; + return ok; } } break; default: + /* should never happen */ Py_DECREF(ob_seq_fast); - return "internal error with idp array.type"; + PyErr_SetString(PyExc_RuntimeError, "internal error with idp array.type"); + return false; } Py_DECREF(ob_seq_fast); @@ -456,16 +466,20 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty Py_XDECREF(vals); Py_XDECREF(key); Py_XDECREF(pval); - return "invalid element in subgroup dict template!"; + PyErr_Format(PyExc_TypeError, + "invalid id-property key type expected a string, not %.200s", + Py_TYPE(key)->tp_name); + return false; } - if (BPy_IDProperty_Map_ValidateAndCreate(key, prop, pval)) { + if (BPy_IDProperty_Map_ValidateAndCreate(key, prop, pval) == false) { IDP_FreeProperty(prop); MEM_freeN(prop); Py_XDECREF(keys); Py_XDECREF(vals); Py_XDECREF(key); Py_XDECREF(pval); - return "invalid element in subgroup dict template!"; + /* error is already set */ + return false; } Py_XDECREF(key); Py_XDECREF(pval); @@ -474,7 +488,10 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty Py_XDECREF(vals); } else { - return "invalid property value"; + PyErr_Format(PyExc_TypeError, + "invalid id-property type %.200s not supported", + Py_TYPE(ob)->tp_name); + return false; } if (group->type == IDP_IDPARRAY) { @@ -486,7 +503,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty IDP_ReplaceInGroup(group, prop); } - return NULL; + return true; } int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val) @@ -508,16 +525,15 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val) } } else { - const char *err; + bool ok; if (!PyUnicode_Check(key)) { PyErr_SetString(PyExc_TypeError, "only strings are allowed as subgroup keys"); return -1; } - err = BPy_IDProperty_Map_ValidateAndCreate(key, prop, val); - if (err) { - PyErr_SetString(PyExc_KeyError, err); + ok = BPy_IDProperty_Map_ValidateAndCreate(key, prop, val); + if (ok == false) { return -1; } -- cgit v1.2.3 From d3a89fc9b7acbc394799904795e30cbead3a458e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Oct 2013 03:18:21 +0000 Subject: add typechecks when assigning id-property arrays from python (overflows and errors weren't detected) reduce/simplify exceptions more. --- source/blender/python/generic/idprop_py_api.c | 52 +++++++++++++++------------ source/blender/python/generic/idprop_py_api.h | 2 +- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 93dc5b8397c..88a56fac93b 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -346,6 +346,14 @@ bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group, if (name_obj) { Py_ssize_t name_size; name = _PyUnicode_AsStringAndSize(name_obj, &name_size); + + if (name == NULL) { + PyErr_Format(PyExc_KeyError, + "invalid id-property key, expected a string, not a %.200s", + Py_TYPE(name_obj)->tp_name); + return false; + } + if (name_size > MAX_IDPROP_NAME) { PyErr_SetString(PyExc_KeyError, "the length of IDProperty names is limited to 63 characters"); return false; @@ -410,32 +418,47 @@ bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group, switch (val.array.type) { case IDP_DOUBLE: + { + double *prop_data; + prop = IDP_New(IDP_ARRAY, &val, name); + prop_data = IDP_Array(prop); for (i = 0; i < val.array.len; i++) { item = PySequence_Fast_GET_ITEM(ob_seq_fast, i); - ((double *)IDP_Array(prop))[i] = (float)PyFloat_AsDouble(item); + if (((prop_data[i] = PyFloat_AsDouble(item)) == -1.0) && PyErr_Occurred()) { + Py_DECREF(ob_seq_fast); + return false; + } } break; + } case IDP_INT: + { + int *prop_data; prop = IDP_New(IDP_ARRAY, &val, name); + prop_data = IDP_Array(prop); for (i = 0; i < val.array.len; i++) { item = PySequence_Fast_GET_ITEM(ob_seq_fast, i); - ((int *)IDP_Array(prop))[i] = _PyLong_AsInt(item); + if (((prop_data[i] = _PyLong_AsInt(item)) == -1) && PyErr_Occurred()) { + Py_DECREF(ob_seq_fast); + return false; + } } break; + } case IDP_IDPARRAY: + { prop = IDP_NewIDPArray(name); for (i = 0; i < val.array.len; i++) { - bool ok; item = PySequence_Fast_GET_ITEM(ob_seq_fast, i); - ok = BPy_IDProperty_Map_ValidateAndCreate(NULL, prop, item); - if (ok == false) { + if (BPy_IDProperty_Map_ValidateAndCreate(NULL, prop, item) == false) { Py_DECREF(ob_seq_fast); - return ok; + return false; } } break; + } default: /* should never happen */ Py_DECREF(ob_seq_fast); @@ -459,18 +482,6 @@ bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group, for (i = 0; i < len; i++) { key = PySequence_GetItem(keys, i); pval = PySequence_GetItem(vals, i); - if (!PyUnicode_Check(key)) { - IDP_FreeProperty(prop); - MEM_freeN(prop); - Py_XDECREF(keys); - Py_XDECREF(vals); - Py_XDECREF(key); - Py_XDECREF(pval); - PyErr_Format(PyExc_TypeError, - "invalid id-property key type expected a string, not %.200s", - Py_TYPE(key)->tp_name); - return false; - } if (BPy_IDProperty_Map_ValidateAndCreate(key, prop, pval) == false) { IDP_FreeProperty(prop); MEM_freeN(prop); @@ -527,11 +538,6 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val) else { bool ok; - if (!PyUnicode_Check(key)) { - PyErr_SetString(PyExc_TypeError, "only strings are allowed as subgroup keys"); - return -1; - } - ok = BPy_IDProperty_Map_ValidateAndCreate(key, prop, val); if (ok == false) { return -1; diff --git a/source/blender/python/generic/idprop_py_api.h b/source/blender/python/generic/idprop_py_api.h index cb82676c4d9..279dad40456 100644 --- a/source/blender/python/generic/idprop_py_api.h +++ b/source/blender/python/generic/idprop_py_api.h @@ -71,7 +71,7 @@ int BPy_Wrap_SetMapItem(struct IDProperty *prop, PyObject *key, PyObject *val); PyObject *BPy_IDGroup_WrapData(struct ID *id, struct IDProperty *prop, struct IDProperty *parent); -const char *BPy_IDProperty_Map_ValidateAndCreate(PyObject *key, struct IDProperty *group, PyObject *ob); +bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *key, struct IDProperty *group, PyObject *ob); void IDProp_Init_Types(void); -- cgit v1.2.3 From bf462838b346e93ca2c149dde0762ead9634d141 Mon Sep 17 00:00:00 2001 From: Irie Shinsuke Date: Thu, 17 Oct 2013 06:40:35 +0000 Subject: Fix build failure with VS2012 + SCons, caused by redefinition of the bool type. --- source/blender/blenlib/BLI_sys_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenlib/BLI_sys_types.h b/source/blender/blenlib/BLI_sys_types.h index e544006fd69..0b7f07e3d36 100644 --- a/source/blender/blenlib/BLI_sys_types.h +++ b/source/blender/blenlib/BLI_sys_types.h @@ -116,7 +116,7 @@ typedef uint64_t u_int64_t; * use (bool, true / false) instead */ #ifdef HAVE_STDBOOL_H # include -#else +#elif !defined(__bool_true_false_are_defined) && !defined(__BOOL_DEFINED) # ifndef HAVE__BOOL # ifdef __cplusplus typedef bool _BLI_Bool; -- cgit v1.2.3 From 6e9c3a9abf9b75f87b98ad30560d4d62e954498e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 17 Oct 2013 06:52:26 +0000 Subject: i18n utils: check not only that the number of printf markers are the same in msgid and msgstr, but also that they are of the same type and order. Sorry, should have done that from the beginning... :/ This should prevent any bug like [#37095] Timeline crash when chose any keying set then press keyframe-insert, to appear again. --- release/scripts/modules/bl_i18n_utils/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index 1b6d65d89d0..bef7de00126 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -462,9 +462,10 @@ class I18nMessages: elif fix: tmp[real_key] = msg done_keys.add(key) - if '%' in msgid and msgstr and len(_format(msgid)) != len(_format(msgstr)): + if '%' in msgid and msgstr and _format(msgid) != _format(msgstr): if not msg.is_fuzzy: - ret.append("Error! msg's format entities are not matched in msgid and msgstr ({})".format(real_key)) + ret.append("Error! msg's format entities are not matched in msgid and msgstr ({} / {})" + "".format(real_key, msgstr)) if fix: msg.msgstr = "" for k in rem: -- cgit v1.2.3 From 71dae0cf40aed60e4eac1e1e4207ae2fc5cfc9a0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 09:19:03 +0000 Subject: Fix #37119: MCE: Prefetching doesn't fetch last frame of an image-sequence. Silly mistake in final condition. Now it works fine. Would be nice to have this for the final release, simple oneliner. --- source/blender/editors/space_clip/clip_editor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index f5db34d87d7..3d7450a3132 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -711,7 +711,7 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip current_frame = prefetch_find_uncached_frame(clip, queue->current_frame + 1, queue->end_frame, queue->render_size, queue->render_flag, 1); /* switch direction if read frames from current up to scene end frames */ - if (current_frame >= queue->end_frame) { + if (current_frame > queue->end_frame) { queue->current_frame = queue->initial_frame; queue->direction = -1; } -- cgit v1.2.3 From 992902cee0a4f22dc115bbe8dbce4064c35c74cf Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 09:44:08 +0000 Subject: Fix #37118: MCEr: Prefetch frames doesn't respect input color space --- source/blender/editors/space_clip/clip_editor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 3d7450a3132..f393e2b6a07 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -752,6 +752,7 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip static void *do_prefetch_thread(void *data_v) { PrefetchThread *data = (PrefetchThread *) data_v; + MovieClip *clip = data->clip; unsigned char *mem; size_t size; int current_frame; @@ -766,7 +767,7 @@ static void *do_prefetch_thread(void *data_v) user.render_size = data->queue->render_size; user.render_flag = data->queue->render_flag; - ibuf = IMB_ibImageFromMemory(mem, size, flag, NULL, "prefetch frame"); + ibuf = IMB_ibImageFromMemory(mem, size, flag, clip->colorspace_settings.name, "prefetch frame"); result = BKE_movieclip_put_frame_if_possible(data->clip, &user, ibuf); -- cgit v1.2.3 From 6d5024828b064d07b1f85c8053ad26a593b36188 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Oct 2013 09:58:36 +0000 Subject: add local _PyLong_AsInt() needed for python older then 3.3.2 --- source/blender/python/generic/py_capi_utils.c | 16 ++++++++++++++++ source/blender/python/generic/py_capi_utils.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 63f66afd8a8..8e90d484a9d 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -887,3 +887,19 @@ PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag) return ret; } + +/* compat only */ +#if PY_VERSION_HEX < 0x03030200 +int +_PyLong_AsInt(PyObject *obj) +{ + int overflow; + long result = PyLong_AsLongAndOverflow(obj, &overflow); + if (overflow || result > INT_MAX || result < INT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "Python int too large to convert to C int"); + return -1; + } + return (int)result; +} +#endif diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index 8928642bc3e..c6792ddfc79 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -72,4 +72,8 @@ int PyC_FlagSet_ValueFromID(PyC_FlagSet *item, const char *identifier, int int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix); PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag); +#if PY_VERSION_HEX < 0x03030200 +int _PyLong_AsInt(PyObject *obj); +#endif + #endif /* __PY_CAPI_UTILS_H__ */ -- cgit v1.2.3 From 023b25b57e9b001d457830665b50870dbd3b1e0b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 10:42:47 +0000 Subject: Fix #37106: Hair Length vanishes when Advanced is enabled Seems to be just a missing case from r34687. Could not see a reason why hair length is to be hidden in advanced settings mode. --- release/scripts/startup/bl_ui/properties_particle.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 0b4974832b8..4d5d3e6936a 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -211,12 +211,12 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, Panel): row.active = part.distribution != 'GRID' row.prop(part, "count") - if part.type == 'HAIR' and not part.use_advanced_hair: + if part.type == 'HAIR': row.prop(part, "hair_length") - - row = layout.row() - row.prop(part, "use_modifier_stack") - return + if not part.use_advanced_hair: + row = layout.row() + row.prop(part, "use_modifier_stack") + return if part.type != 'HAIR': split = layout.split() -- cgit v1.2.3 From c4e7a229589debe81bd4b0eb481a8eb5212ab9bb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 10:50:54 +0000 Subject: Fix #37091: Reset to default of Sky Texture's Dot freezes it at 0,0,0 --- source/blender/makesrna/intern/rna_nodetree.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index bb8e8d87252..7fc53395e61 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3256,6 +3256,7 @@ static void def_sh_tex_sky(StructRNA *srna) {SHD_SKY_NEW, "HOSEK_WILKIE", 0, "Hosek / Wilkie", ""}, {0, NULL, 0, NULL, NULL} }; + static float default_dir[3] = {0.0f, 0.0f, 1.0f}; PropertyRNA *prop; @@ -3270,6 +3271,8 @@ static void def_sh_tex_sky(StructRNA *srna) prop = RNA_def_property(srna, "sun_direction", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_ui_text(prop, "Sun Direction", "Direction from where the sun is shining"); + RNA_def_property_array(prop, 3); + RNA_def_property_float_array_default(prop, default_dir); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "turbidity", PROP_FLOAT, PROP_NONE); -- cgit v1.2.3 From 47f365419f7903671f1e18ddf9d2ede4ae61e833 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 12:28:32 +0000 Subject: Fix #37117: MCE prefetching fails with non-ascii characters in path --- source/blender/editors/space_clip/clip_editor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index f393e2b6a07..0e1a2f98d40 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -639,7 +639,7 @@ static unsigned char *prefetch_read_file_to_memory(MovieClip *clip, int current_ BKE_movieclip_filename_for_frame(clip, &user, name); - file = open(name, O_BINARY | O_RDONLY, 0); + file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file < 0) { return NULL; } -- cgit v1.2.3 From 31b38a6736af734d66f09caf6298d94f138b55f9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 12:53:37 +0000 Subject: Fix #37122: Text Editor: New Open-Shortcut different from Text > Open Text Block Seems no user counter tricks are needed from r23598. Also, r33453 is obviously wrong, because new ID's user counter is 1, and could not exceed this value. --- source/blender/editors/space_text/text_ops.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index c078e612d68..4f53d033029 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -174,12 +174,6 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op)) uiIDContextProperty(C, &ptr, &prop); if (prop) { - /* when creating new ID blocks, use is already 1, but RNA - * pointer se also increases user, so this compensates it */ - /* doesnt always seem to happen... (ton) */ - if (text->id.us > 1) - text->id.us--; - RNA_id_pointer_create(&text->id, &idptr); RNA_property_pointer_set(&ptr, prop, idptr); RNA_property_update(C, &ptr, prop); @@ -252,10 +246,6 @@ static int text_open_exec(bContext *C, wmOperator *op) pprop = op->customdata; if (pprop->prop) { - /* when creating new ID blocks, use is already 1, but RNA - * pointer se also increases user, so this compensates it */ - text->id.us--; - RNA_id_pointer_create(&text->id, &idptr); RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); RNA_property_update(C, &pprop->ptr, pprop->prop); -- cgit v1.2.3 From abee8a871718a99708100c0ad591b76d8f5767da Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 17 Oct 2013 14:04:10 +0000 Subject: Fix #37109: missing cycles texture display in edit mode. My previous fix for uninitialized texture coordinates was not working well, and in fact there was a bigger issue with GLSL drawing and missing attributes with immediate draw mode. Now it will explicitly pass zero rather than having it use whatever value was set last. --- source/blender/blenkernel/intern/DerivedMesh.c | 71 +++++++---- source/blender/blenkernel/intern/cdderivedmesh.c | 140 +++++++++++++-------- source/blender/blenkernel/intern/editderivedmesh.c | 82 ++++++------ source/blender/blenkernel/intern/subsurf_ccg.c | 110 +++++++++------- source/blender/editors/space_view3d/drawmesh.c | 2 +- 5 files changed, 241 insertions(+), 164 deletions(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 368c1e517ef..884e7a813a8 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2859,14 +2859,19 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, else layer = CustomData_get_active_layer_index(ldata, CD_MLOOPUV); - if (layer != -1) { - a = attribs->tottface++; + a = attribs->tottface++; + if (layer != -1) { attribs->tface[a].array = tfdata->layers[layer].data; attribs->tface[a].em_offset = ldata->layers[layer].offset; - attribs->tface[a].gl_index = gattribs->layer[b].glindex; - attribs->tface[a].gl_texco = gattribs->layer[b].gltexco; } + else { + attribs->tface[a].array = NULL; + attribs->tface[a].em_offset = -1; + } + + attribs->tface[a].gl_index = gattribs->layer[b].glindex; + attribs->tface[a].gl_texco = gattribs->layer[b].gltexco; } else { if (gattribs->layer[b].name[0]) @@ -2875,14 +2880,19 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, else layer = CustomData_get_active_layer_index(tfdata, CD_MTFACE); - if (layer != -1) { - a = attribs->tottface++; + a = attribs->tottface++; + if (layer != -1) { attribs->tface[a].array = tfdata->layers[layer].data; attribs->tface[a].em_offset = tfdata->layers[layer].offset; - attribs->tface[a].gl_index = gattribs->layer[b].glindex; - attribs->tface[a].gl_texco = gattribs->layer[b].gltexco; } + else { + attribs->tface[a].array = NULL; + attribs->tface[a].em_offset = -1; + } + + attribs->tface[a].gl_index = gattribs->layer[b].glindex; + attribs->tface[a].gl_texco = gattribs->layer[b].gltexco; } } else if (gattribs->layer[b].type == CD_MCOL) { @@ -2896,14 +2906,19 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, else layer = CustomData_get_active_layer_index(ldata, CD_MLOOPCOL); - if (layer != -1) { - a = attribs->totmcol++; + a = attribs->totmcol++; + if (layer != -1) { attribs->mcol[a].array = tfdata->layers[layer].data; /* odd, store the offset for a different layer type here, but editmode draw code expects it */ attribs->mcol[a].em_offset = ldata->layers[layer].offset; - attribs->mcol[a].gl_index = gattribs->layer[b].glindex; } + else { + attribs->mcol[a].array = NULL; + attribs->mcol[a].em_offset = -1; + } + + attribs->mcol[a].gl_index = gattribs->layer[b].glindex; } else { /* vertex colors */ @@ -2913,40 +2928,54 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, else layer = CustomData_get_active_layer_index(tfdata, CD_MCOL); - if (layer != -1) { - a = attribs->totmcol++; + a = attribs->totmcol++; + if (layer != -1) { attribs->mcol[a].array = tfdata->layers[layer].data; /* odd, store the offset for a different layer type here, but editmode draw code expects it */ attribs->mcol[a].em_offset = tfdata->layers[layer].offset; - attribs->mcol[a].gl_index = gattribs->layer[b].glindex; } + else { + attribs->mcol[a].array = NULL; + attribs->mcol[a].em_offset = -1; + } + + attribs->mcol[a].gl_index = gattribs->layer[b].glindex; } } else if (gattribs->layer[b].type == CD_TANGENT) { /* tangents */ layer = CustomData_get_layer_index(fdata, CD_TANGENT); - if (layer != -1) { - attribs->tottang = 1; + attribs->tottang = 1; + if (layer != -1) { attribs->tang.array = fdata->layers[layer].data; attribs->tang.em_offset = fdata->layers[layer].offset; - attribs->tang.gl_index = gattribs->layer[b].glindex; } + else { + attribs->tang.array = NULL; + attribs->tang.em_offset = -1; + } + + attribs->tang.gl_index = gattribs->layer[b].glindex; } else if (gattribs->layer[b].type == CD_ORCO) { /* original coordinates */ layer = CustomData_get_layer_index(vdata, CD_ORCO); + attribs->totorco = 1; if (layer != -1) { - attribs->totorco = 1; - attribs->orco.array = vdata->layers[layer].data; attribs->orco.em_offset = vdata->layers[layer].offset; - attribs->orco.gl_index = gattribs->layer[b].glindex; - attribs->orco.gl_texco = gattribs->layer[b].gltexco; } + else { + attribs->orco.array = NULL; + attribs->orco.em_offset = -1; + } + + attribs->orco.gl_index = gattribs->layer[b].glindex; + attribs->orco.gl_texco = gattribs->layer[b].gltexco; } } } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 1bc12cffe7b..309eb68ffc4 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1063,37 +1063,57 @@ static void cdDM_drawMappedFacesTex(DerivedMesh *dm, static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int a, int index, int vert, int smoothnormal) { + const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; int b; /* orco texture coordinates */ if (attribs->totorco) { + const float (*array)[3] = attribs->orco.array; + const float *orco = (array) ? array[index] : zero; + if (attribs->orco.gl_texco) - glTexCoord3fv(attribs->orco.array[index]); + glTexCoord3fv(orco); else - glVertexAttrib3fvARB(attribs->orco.gl_index, attribs->orco.array[index]); + glVertexAttrib3fvARB(attribs->orco.gl_index, orco); } /* uv texture coordinates */ for (b = 0; b < attribs->tottface; b++) { - MTFace *tf = &attribs->tface[b].array[a]; + const float *uv; + + if (attribs->tface[b].array) { + MTFace *tf = &attribs->tface[b].array[a]; + uv = tf->uv[vert]; + } + else { + uv = zero; + } if (attribs->tface[b].gl_texco) - glTexCoord2fv(tf->uv[vert]); + glTexCoord2fv(uv); else - glVertexAttrib2fvARB(attribs->tface[b].gl_index, tf->uv[vert]); + glVertexAttrib2fvARB(attribs->tface[b].gl_index, uv); } /* vertex colors */ for (b = 0; b < attribs->totmcol; b++) { - MCol *cp = &attribs->mcol[b].array[a * 4 + vert]; GLubyte col[4]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + + if (attribs->mcol[b].array) { + MCol *cp = &attribs->mcol[b].array[a * 4 + vert]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + } + else { + col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0; + } + glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col); } /* tangent for normal mapping */ if (attribs->tottang) { - float *tang = attribs->tang.array[a * 4 + vert]; + const float (*array)[4] = attribs->tang.array; + const float *tang = (array) ? array[a * 4 + vert] : zero; glVertexAttrib4fvARB(attribs->tang.gl_index, tang); } @@ -1264,25 +1284,29 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, if (do_draw) { DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); - if (attribs.totorco) { + if (attribs.totorco && attribs.orco.array) { datatypes[numdata].index = attribs.orco.gl_index; datatypes[numdata].size = 3; datatypes[numdata].type = GL_FLOAT; numdata++; } for (b = 0; b < attribs.tottface; b++) { - datatypes[numdata].index = attribs.tface[b].gl_index; - datatypes[numdata].size = 2; - datatypes[numdata].type = GL_FLOAT; - numdata++; + if (attribs.tface[b].array) { + datatypes[numdata].index = attribs.tface[b].gl_index; + datatypes[numdata].size = 2; + datatypes[numdata].type = GL_FLOAT; + numdata++; + } } for (b = 0; b < attribs.totmcol; b++) { - datatypes[numdata].index = attribs.mcol[b].gl_index; - datatypes[numdata].size = 4; - datatypes[numdata].type = GL_UNSIGNED_BYTE; - numdata++; + if (attribs.mcol[b].array) { + datatypes[numdata].index = attribs.mcol[b].gl_index; + datatypes[numdata].size = 4; + datatypes[numdata].type = GL_UNSIGNED_BYTE; + numdata++; + } } - if (attribs.tottang) { + if (attribs.tottang && attribs.tang.array) { datatypes[numdata].index = attribs.tang.gl_index; datatypes[numdata].size = 4; datatypes[numdata].type = GL_FLOAT; @@ -1315,34 +1339,38 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, if (do_draw && numdata != 0) { offset = 0; - if (attribs.totorco) { + if (attribs.totorco && attribs.orco.array) { copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v1]); copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v2]); copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v3]); offset += sizeof(float) * 3; } for (b = 0; b < attribs.tottface; b++) { - MTFace *tf = &attribs.tface[b].array[a]; - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]); - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]); + if (attribs.tface[b].array) { + MTFace *tf = &attribs.tface[b].array[a]; + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]); - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]); - offset += sizeof(float) * 2; + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]); + offset += sizeof(float) * 2; + } } for (b = 0; b < attribs.totmcol; b++) { - MCol *cp = &attribs.mcol[b].array[a * 4 + 0]; - GLubyte col[4]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; - copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); - cp = &attribs.mcol[b].array[a * 4 + 1]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; - copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); - cp = &attribs.mcol[b].array[a * 4 + 2]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; - copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); - offset += sizeof(unsigned char) * 4; + if (attribs.mcol[b].array) { + MCol *cp = &attribs.mcol[b].array[a * 4 + 0]; + GLubyte col[4]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 1]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 2]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); + offset += sizeof(unsigned char) * 4; + } } - if (attribs.tottang) { + if (attribs.tottang && attribs.tang.array) { float *tang = attribs.tang.array[a * 4 + 0]; copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); tang = attribs.tang.array[a * 4 + 1]; @@ -1357,33 +1385,37 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, if (mface->v4) { if (do_draw && numdata != 0) { offset = 0; - if (attribs.totorco) { + if (attribs.totorco && attribs.orco.array) { copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v3]); copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v4]); copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v1]); offset += sizeof(float) * 3; } for (b = 0; b < attribs.tottface; b++) { - MTFace *tf = &attribs.tface[b].array[a]; - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[2]); - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[3]); - copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[0]); - offset += sizeof(float) * 2; + if (attribs.tface[b].array) { + MTFace *tf = &attribs.tface[b].array[a]; + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[2]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[3]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[0]); + offset += sizeof(float) * 2; + } } for (b = 0; b < attribs.totmcol; b++) { - MCol *cp = &attribs.mcol[b].array[a * 4 + 2]; - GLubyte col[4]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; - copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); - cp = &attribs.mcol[b].array[a * 4 + 3]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; - copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); - cp = &attribs.mcol[b].array[a * 4 + 0]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; - copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); - offset += sizeof(unsigned char) * 4; + if (attribs.mcol[b].array) { + MCol *cp = &attribs.mcol[b].array[a * 4 + 2]; + GLubyte col[4]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 3]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 0]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); + offset += sizeof(unsigned char) * 4; + } } - if (attribs.tottang) { + if (attribs.tottang && attribs.tang.array) { float *tang = attribs.tang.array[a * 4 + 2]; copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); tang = attribs.tang.array[a * 4 + 3]; diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index caa5bf90584..f71bc83f5d3 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -888,23 +888,47 @@ static void emdm_pass_attrib_vertex_glsl(DMVertexAttribs *attribs, BMLoop *loop, { BMVert *eve = loop->v; int i; + const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; if (attribs->totorco) { - const float *orco = attribs->orco.array[BM_elem_index_get(eve)]; - glVertexAttrib3fvARB(attribs->orco.gl_index, orco); + int index = BM_elem_index_get(eve); + const float *orco = (attribs->orco.array) ? attribs->orco.array[index] : zero; + + if (attribs->orco.gl_texco) + glTexCoord3fv(orco); + else + glVertexAttrib3fvARB(attribs->orco.gl_index, orco); } for (i = 0; i < attribs->tottface; i++) { - const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(loop, attribs->tface[i].em_offset); - glVertexAttrib2fvARB(attribs->tface[i].gl_index, luv->uv); + const float *uv; + + if(attribs->tface[i].em_offset != -1) { + const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(loop, attribs->tface[i].em_offset); + uv = luv->uv; + } + else { + uv = zero; + } + + if (attribs->tface[i].gl_texco) + glTexCoord2fv(uv); + else + glVertexAttrib2fvARB(attribs->tface[i].gl_index, uv); } for (i = 0; i < attribs->totmcol; i++) { - const MLoopCol *cp = BM_ELEM_CD_GET_VOID_P(loop, attribs->mcol[i].em_offset); GLubyte col[4]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + if(attribs->mcol[i].em_offset != -1) { + const MLoopCol *cp = BM_ELEM_CD_GET_VOID_P(loop, attribs->mcol[i].em_offset); + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + } + else { + col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0; + } glVertexAttrib4ubvARB(attribs->mcol[i].gl_index, col); } if (attribs->tottang) { - const float *tang = attribs->tang.array[i * 4 + index_in_face]; + int index = i * 4 + index_in_face; + const float *tang = (attribs->tang.array) ? attribs->tang.array[index] : zero; glVertexAttrib4fvARB(attribs->tang.gl_index, tang); } } @@ -1020,38 +1044,6 @@ static void emDM_drawFacesGLSL(DerivedMesh *dm, dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL); } -/* emdm_pass_attrib_vertex_glsl's note about em_offset use applies here */ -static void emdm_pass_attrib_vertex_mat(DMVertexAttribs *attribs, BMLoop *loop, int index_in_face) -{ - BMVert *eve = loop->v; - int i; - - if (attribs->totorco) { - float *orco = attribs->orco.array[BM_elem_index_get(eve)]; - if (attribs->orco.gl_texco) - glTexCoord3fv(orco); - else - glVertexAttrib3fvARB(attribs->orco.gl_index, orco); - } - for (i = 0; i < attribs->tottface; i++) { - const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(loop, attribs->tface[i].em_offset); - if (attribs->tface[i].gl_texco) - glTexCoord2fv(luv->uv); - else - glVertexAttrib2fvARB(attribs->tface[i].gl_index, luv->uv); - } - for (i = 0; i < attribs->totmcol; i++) { - const MLoopCol *cp = BM_ELEM_CD_GET_VOID_P(loop, attribs->mcol[i].em_offset); - GLubyte col[4]; - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; - glVertexAttrib4ubvARB(attribs->mcol[i].gl_index, col); - } - if (attribs->tottang) { - float *tang = attribs->tang.array[i * 4 + index_in_face]; - glVertexAttrib4fvARB(attribs->tang.gl_index, tang); - } -} - static void emDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *userData, int, void *attribs), bool (*setFace)(void *userData, int index), void *userData) @@ -1105,21 +1097,21 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm, if (vertexCos) glNormal3fv(polyNos[BM_elem_index_get(efa)]); else glNormal3fv(efa->no); - emdm_pass_attrib_vertex_mat(&attribs, ltri[0], 0); + emdm_pass_attrib_vertex_glsl(&attribs, ltri[0], 0); if (vertexCos) glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); else glVertex3fv(ltri[0]->v->co); - emdm_pass_attrib_vertex_mat(&attribs, ltri[1], 1); + emdm_pass_attrib_vertex_glsl(&attribs, ltri[1], 1); if (vertexCos) glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); else glVertex3fv(ltri[1]->v->co); - emdm_pass_attrib_vertex_mat(&attribs, ltri[2], 2); + emdm_pass_attrib_vertex_glsl(&attribs, ltri[2], 2); if (vertexCos) glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); else glVertex3fv(ltri[2]->v->co); } else { - emdm_pass_attrib_vertex_mat(&attribs, ltri[0], 0); + emdm_pass_attrib_vertex_glsl(&attribs, ltri[0], 0); if (vertexCos) { glNormal3fv(vertexNos[BM_elem_index_get(ltri[0]->v)]); glVertex3fv(vertexCos[BM_elem_index_get(ltri[0]->v)]); @@ -1129,7 +1121,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm, glVertex3fv(ltri[0]->v->co); } - emdm_pass_attrib_vertex_mat(&attribs, ltri[1], 1); + emdm_pass_attrib_vertex_glsl(&attribs, ltri[1], 1); if (vertexCos) { glNormal3fv(vertexNos[BM_elem_index_get(ltri[1]->v)]); glVertex3fv(vertexCos[BM_elem_index_get(ltri[1]->v)]); @@ -1139,7 +1131,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm, glVertex3fv(ltri[1]->v->co); } - emdm_pass_attrib_vertex_mat(&attribs, ltri[2], 2); + emdm_pass_attrib_vertex_glsl(&attribs, ltri[2], 2); if (vertexCos) { glNormal3fv(vertexNos[BM_elem_index_get(ltri[2]->v)]); glVertex3fv(vertexCos[BM_elem_index_get(ltri[2]->v)]); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index ac11a012347..176e79aff36 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1817,6 +1817,64 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) } } +static void ccgdm_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, int vert) +{ + const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + int b; + + /* orco texture coordinates */ + if (attribs->totorco) { + const float (*array)[3] = attribs->orco.array; + const float *orco = (array) ? array[index] : zero; + + if (attribs->orco.gl_texco) + glTexCoord3fv(orco); + else + glVertexAttrib3fvARB(attribs->orco.gl_index, orco); + } + + /* uv texture coordinates */ + for (b = 0; b < attribs->tottface; b++) { + const float *uv; + + if (attribs->tface[b].array) { + MTFace *tf = &attribs->tface[b].array[a]; + uv = tf->uv[vert]; + } + else { + uv = zero; + } + + if (attribs->tface[b].gl_texco) + glTexCoord2fv(uv); + else + glVertexAttrib2fvARB(attribs->tface[b].gl_index, uv); + } + + /* vertex colors */ + for (b = 0; b < attribs->totmcol; b++) { + GLubyte col[4]; + + if (attribs->mcol[b].array) { + MCol *cp = &attribs->mcol[b].array[a * 4 + vert]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + } + else { + col[0] = 0; col[1] = 0; col[2] = 0; col[3] = 0; + } + + glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col); + } + + /* tangent for normal mapping */ + if (attribs->tottang) { + const float (*array)[4] = attribs->tang.array; + const float *tang = (array) ? array[a * 4 + vert] : zero; + + glVertexAttrib4fvARB(attribs->tang.gl_index, tang); + } +} + /* Only used by non-editmesh types */ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial, @@ -1833,7 +1891,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int gridFaces = gridSize - 1; int edgeSize = ccgSubSurf_getEdgeSize(ss); DMFlagMat *faceFlags = ccgdm->faceFlags; - int a, b, i, do_draw, numVerts, matnr, new_matnr, totface; + int a, i, do_draw, numVerts, matnr, new_matnr, totface; CCG_key_top_level(&key, ss); ccgdm_pbvh_update(ccgdm); @@ -1842,25 +1900,11 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, matnr = -1; #define PASSATTRIB(dx, dy, vert) { \ - if (attribs.totorco) { \ + if (attribs.totorco) \ index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \ - glVertexAttrib3fvARB(attribs.orco.gl_index, \ - attribs.orco.array[index]); \ - } \ - for (b = 0; b < attribs.tottface; b++) { \ - MTFace *tf = &attribs.tface[b].array[a]; \ - glVertexAttrib2fvARB(attribs.tface[b].gl_index, tf->uv[vert]); \ - } \ - for (b = 0; b < attribs.totmcol; b++) { \ - MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \ - GLubyte col[4]; \ - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, col); \ - } \ - if (attribs.tottang) { \ - float *tang = attribs.tang.array[a * 4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ - } \ + else \ + index = 0; \ + ccgdm_draw_attrib_vertex(&attribs, a, index, vert); \ } (void)0 totface = ccgSubSurf_getNumFaces(ss); @@ -1992,31 +2036,11 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, matnr = -1; #define PASSATTRIB(dx, dy, vert) { \ - if (attribs.totorco) { \ + if (attribs.totorco) \ index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \ - if (attribs.orco.gl_texco) \ - glTexCoord3fv(attribs.orco.array[index]); \ - else \ - glVertexAttrib3fvARB(attribs.orco.gl_index, \ - attribs.orco.array[index]); \ - } \ - for (b = 0; b < attribs.tottface; b++) { \ - MTFace *tf = &attribs.tface[b].array[a]; \ - if (attribs.tface[b].gl_texco) \ - glTexCoord2fv(tf->uv[vert]); \ - else \ - glVertexAttrib2fvARB(attribs.tface[b].gl_index, tf->uv[vert]); \ - } \ - for (b = 0; b < attribs.totmcol; b++) { \ - MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \ - GLubyte col[4]; \ - col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, col); \ - } \ - if (attribs.tottang) { \ - float *tang = attribs.tang.array[a * 4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ - } \ + else \ + index = 0; \ + ccgdm_draw_attrib_vertex(&attribs, a, index, vert); \ } (void)0 totface = ccgSubSurf_getNumFaces(ss); diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index d169fc58260..76fcf70a627 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -982,7 +982,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); - if (glsl || picking || !CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) { + if (glsl || picking) { /* draw glsl or solid */ dm->drawMappedFacesMat(dm, tex_mat_set_material_cb, -- cgit v1.2.3 From eb1b4c3b55e212dbcb7fb2390c90adf204f42959 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 14:10:03 +0000 Subject: Fix #37097: Setting scene frame does not update active camera The issue was caused by uncertainty of current camera when there're no markers to the left of current frame. Now in this case camera from the top-left marker will be used. --- source/blender/blenkernel/intern/scene.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 41e43c00457..23b26d0e629 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -874,18 +874,35 @@ Object *BKE_scene_camera_switch_find(Scene *scene) TimeMarker *m; int cfra = scene->r.cfra; int frame = -(MAXFRAME + 1); + int min_frame = MAXFRAME + 1; Object *camera = NULL; + Object *first_camera; for (m = scene->markers.first; m; m = m->next) { - if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER) == 0 && (m->frame <= cfra) && (m->frame > frame)) { - camera = m->camera; - frame = m->frame; + if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER) == 0) { + if ((m->frame <= cfra) && (m->frame > frame)) { + camera = m->camera; + frame = m->frame; - if (frame == cfra) - break; + if (frame == cfra) + break; + } + if (m->frame < min_frame) { + first_camera = m->camera; + min_frame = m->frame; + } } } + + if (camera == NULL) { + /* If there's no marker to the left of current frame, + * use camera from left-most marker to solve all sort + * of Schrodinger uncertainties. + */ + return first_camera; + } + return camera; } #endif -- cgit v1.2.3 From 1263a0891cc0d7d2602fa2668cc7ffa271624046 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 17 Oct 2013 14:19:03 +0000 Subject: Project Pampa Request: Selecting groups in animation editors selects corresponding bones --- .../blender/editors/animation/anim_channels_edit.c | 36 ++++++++++++++++++++-- source/blender/editors/armature/pose_select.c | 30 ++++++++++++++++++ source/blender/editors/include/ED_armature.h | 1 + 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index e04c51b33d8..a260bb3bd7e 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -58,6 +58,7 @@ #include "UI_view2d.h" #include "ED_anim_api.h" +#include "ED_armature.h" #include "ED_keyframes_edit.h" // XXX move the select modes out of there! #include "ED_screen.h" @@ -2441,6 +2442,30 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in { bActionGroup *agrp = (bActionGroup *)ale->data; + Object *ob = NULL; + bPoseChannel *pchan = NULL; + + + /* Armatures-Specific Feature: + * Since groups are used to collect F-Curves of the same Bone by default + * (via Keying Sets) so that they can be managed better, we try to make + * things here easier for animators by mapping group selection to bone + * selection + */ + if ((ale->id) && (GS(ale->id->name) == ID_OB)) { + ob = (Object *)ale->id; + + if (ob->type == OB_ARMATURE) { + /* Assume for now that any group with corresponding name is what we want + * (i.e. for an armature whose location is animated, things would break + * if the user were to add a bone named "Location"). + * + * TODO: check the first F-Curve or so to be sure... + */ + pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); + } + } + /* select/deselect group */ if (selectmode == SELECT_INVERT) { /* inverse selection status of this group only */ @@ -2452,6 +2477,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in /* deselect all other channels */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + if (pchan) ED_pose_deselectall(ob, 0); /* only select channels in group and group itself */ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) @@ -2461,14 +2487,20 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in else { /* select group by itself */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); + if (pchan) ED_pose_deselectall(ob, 0); + agrp->flag |= AGRP_SELECTED; } /* if group is selected now, make group the 'active' one in the visible list */ - if (agrp->flag & AGRP_SELECTED) + if (agrp->flag & AGRP_SELECTED) { ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); - else + if (pchan) ED_pose_bone_select(ob, pchan, true); + } + else { ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP); + if (pchan) ED_pose_bone_select(ob, pchan, false); + } notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 9449b5a49bf..bbdf94e56cf 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -64,6 +64,36 @@ /* ***************** Pose Select Utilities ********************* */ +/* Utility method for changing the selection status of a bone */ +void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select) +{ + bArmature *arm; + + /* sanity checks */ + // XXX: actually, we can probably still get away with no object - at most we have no updates + if (ELEM4(NULL, ob, ob->pose, pchan, pchan->bone)) + return; + + arm = ob->data; + /* can only change selection state if bone can be modified */ + if (PBONE_SELECTABLE(arm, pchan->bone)) { + /* change selection state */ + if (select) + pchan->bone->flag |= BONE_SELECTED; + else + pchan->bone->flag &= ~BONE_SELECTED; + + // TODO: select and activate corresponding vgroup? + + /* tag necessary depsgraph updates + * (see rna_Bone_select_update() in rna_armature.c for details) + */ + if (arm->flag & ARM_HAS_VIZ_DEPS) { + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + } + } +} + /* called from editview.c, for mode-less pose selection */ /* assumes scene obact and basact is still on old situation */ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 225d8a0e5a3..e7489e1bc72 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -168,6 +168,7 @@ void ED_armature_ebone_selectflag_disable(EditBone *ebone, int flag); void ED_armature_exit_posemode(struct bContext *C, struct Base *base); void ED_armature_enter_posemode(struct bContext *C, struct Base *base); void ED_pose_deselectall(struct Object *ob, int test); +void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select); void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob); struct Object *ED_pose_object_from_context(struct bContext *C); -- cgit v1.2.3 From a0da34871a6eb75cba7fc3ed024f0dae53e0e3ea Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 14:44:23 +0000 Subject: Fix for GCC bing stupid and not casting float*[3] to const float*[3] without a wanring :S --- source/blender/blenkernel/intern/cdderivedmesh.c | 4 ++-- source/blender/blenkernel/intern/subsurf_ccg.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 309eb68ffc4..4846199b9d9 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1068,7 +1068,7 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int /* orco texture coordinates */ if (attribs->totorco) { - const float (*array)[3] = attribs->orco.array; + /*const*/ float (*array)[3] = attribs->orco.array; const float *orco = (array) ? array[index] : zero; if (attribs->orco.gl_texco) @@ -1112,7 +1112,7 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int /* tangent for normal mapping */ if (attribs->tottang) { - const float (*array)[4] = attribs->tang.array; + /*const*/ float (*array)[4] = attribs->tang.array; const float *tang = (array) ? array[a * 4 + vert] : zero; glVertexAttrib4fvARB(attribs->tang.gl_index, tang); } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 176e79aff36..900d92d1637 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1824,7 +1824,7 @@ static void ccgdm_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, /* orco texture coordinates */ if (attribs->totorco) { - const float (*array)[3] = attribs->orco.array; + /*const*/ float (*array)[3] = attribs->orco.array; const float *orco = (array) ? array[index] : zero; if (attribs->orco.gl_texco) @@ -1868,7 +1868,7 @@ static void ccgdm_draw_attrib_vertex(DMVertexAttribs *attribs, int a, int index, /* tangent for normal mapping */ if (attribs->tottang) { - const float (*array)[4] = attribs->tang.array; + /*const*/ float (*array)[4] = attribs->tang.array; const float *tang = (array) ? array[a * 4 + vert] : zero; glVertexAttrib4fvARB(attribs->tang.gl_index, tang); @@ -2028,7 +2028,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, int gridFaces = gridSize - 1; int edgeSize = ccgSubSurf_getEdgeSize(ss); DMFlagMat *faceFlags = ccgdm->faceFlags; - int a, b, i, numVerts, matnr, new_matnr, totface; + int a, i, numVerts, matnr, new_matnr, totface; CCG_key_top_level(&key, ss); ccgdm_pbvh_update(ccgdm); -- cgit v1.2.3 From 56373ea2718260fed421b94c601fdfa18fab11df Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 17 Oct 2013 15:51:12 +0000 Subject: Fix crash in scenes without camera markers, after recent fix for #37097, first_camera variable was used uninitialized. --- source/blender/blenkernel/intern/scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 23b26d0e629..cd8ceea0a97 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -876,7 +876,7 @@ Object *BKE_scene_camera_switch_find(Scene *scene) int frame = -(MAXFRAME + 1); int min_frame = MAXFRAME + 1; Object *camera = NULL; - Object *first_camera; + Object *first_camera = NULL; for (m = scene->markers.first; m; m = m->next) { if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER) == 0) { -- cgit v1.2.3 From 2e8ab664d552a3361f286005025e1f6f7df14a23 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 17 Oct 2013 16:05:57 +0000 Subject: Fix cycles mesh synchronization being too slow with vector blur and duplis. --- intern/cycles/blender/blender_mesh.cpp | 6 ++++++ intern/cycles/blender/blender_object.cpp | 6 ++++++ intern/cycles/blender/blender_sync.h | 1 + 3 files changed, 13 insertions(+) diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index 940a923e5af..f6c7319e210 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -539,6 +539,12 @@ void BlenderSync::sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion) if(!size || !ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) return; + /* ensure we only sync instanced meshes once */ + if(mesh_motion_synced.find(mesh) != mesh_motion_synced.end()) + return; + + mesh_motion_synced.insert(mesh); + /* get derived mesh */ BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, !preview, false); diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 461e897efe1..ba584e172dc 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -405,6 +405,9 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion) mesh_synced.clear(); particle_system_map.pre_sync(); } + else { + mesh_motion_synced.clear(); + } /* object loop */ BL::Scene::objects_iterator b_ob; @@ -492,6 +495,9 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion) scene->particle_system_manager->tag_update(scene); mesh_synced.clear(); } + + if(motion) + mesh_motion_synced.clear(); } void BlenderSync::sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override) diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index f6e19229578..295b1fcee5c 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -108,6 +108,7 @@ private: id_map light_map; id_map particle_system_map; set mesh_synced; + set mesh_motion_synced; void *world_map; bool world_recalc; -- cgit v1.2.3 From a709cb2d55573029a4cd36a74ec8f7cabcb834fa Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 18:29:01 +0000 Subject: Fix #37123: UV editor view does not update when using large faces Update tagging was happening only after full triangle was handled. Now made it so images are updating once in 0.5sec, progress bar will still update only after the whole triangle is done. --- source/blender/editors/object/object_bake.c | 4 ++-- source/blender/render/intern/source/bake.c | 4 ++++ source/blender/render/intern/source/multires_bake.c | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 4a8097f260e..060e48f39bc 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -556,7 +556,7 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op) wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Multires Bake", WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE); WM_jobs_customdata_set(wm_job, bkr, multiresbake_freejob); - WM_jobs_timer(wm_job, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ + WM_jobs_timer(wm_job, 0.5, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ WM_jobs_callbacks(wm_job, multiresbake_startjob, NULL, NULL, NULL); G.is_break = FALSE; @@ -816,7 +816,7 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, const wmEvent wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Texture Bake", WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE); WM_jobs_customdata_set(wm_job, bkr, bake_freejob); - WM_jobs_timer(wm_job, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ + WM_jobs_timer(wm_job, 0.5, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ WM_jobs_callbacks(wm_job, bake_startjob, NULL, bake_update, NULL); G.is_break = FALSE; diff --git a/source/blender/render/intern/source/bake.c b/source/blender/render/intern/source/bake.c index cb6ca0e30ac..c150133b276 100644 --- a/source/blender/render/intern/source/bake.c +++ b/source/blender/render/intern/source/bake.c @@ -322,6 +322,10 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua if (bs->rect_mask) { bs->rect_mask[bs->rectx * y + x] = FILTER_MASK_USED; } + + if (bs->do_update) { + *bs->do_update = true; + } } static void bake_displacement(void *handle, ShadeInput *UNUSED(shi), float dist, int x, int y) diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c index 3259608c18f..3ae075b4936 100644 --- a/source/blender/render/intern/source/multires_bake.c +++ b/source/blender/render/intern/source/multires_bake.c @@ -95,6 +95,7 @@ typedef struct { char *texels; const MResolvePixelData *data; MFlushPixel flush_pixel; + short *do_update; } MBakeRast; typedef struct { @@ -162,7 +163,8 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], } } -static void init_bake_rast(MBakeRast *bake_rast, const ImBuf *ibuf, const MResolvePixelData *data, MFlushPixel flush_pixel) +static void init_bake_rast(MBakeRast *bake_rast, const ImBuf *ibuf, const MResolvePixelData *data, + MFlushPixel flush_pixel, short *do_update) { BakeImBufuserData *userdata = (BakeImBufuserData *) ibuf->userdata; @@ -173,6 +175,7 @@ static void init_bake_rast(MBakeRast *bake_rast, const ImBuf *ibuf, const MResol bake_rast->h = ibuf->y; bake_rast->data = data; bake_rast->flush_pixel = flush_pixel; + bake_rast->do_update = do_update; } static void flush_pixel(const MResolvePixelData *data, const int x, const int y) @@ -240,6 +243,9 @@ static void set_rast_triangle(const MBakeRast *bake_rast, const int x, const int if ((bake_rast->texels[y * w + x]) == 0) { bake_rast->texels[y * w + x] = FILTER_MASK_USED; flush_pixel(bake_rast->data, x, y); + if (bake_rast->do_update) { + *bake_rast->do_update = true; + } } } } @@ -529,7 +535,7 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, int require_ta handle->height_min = FLT_MAX; handle->height_max = -FLT_MAX; - init_bake_rast(&handle->bake_rast, ibuf, &handle->data, flush_pixel); + init_bake_rast(&handle->bake_rast, ibuf, &handle->data, flush_pixel, bkr->do_update); if (tot_thread > 1) BLI_insert_thread(&threads, handle); -- cgit v1.2.3 From cb9439fc2f4514e6296d7c58133f0119e21a10b7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 18:49:09 +0000 Subject: Fix #37048: Default keybindings: text.find_next in Text (Global), should be in Text Generic --- source/blender/editors/space_text/space_text.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index c668c8063a8..bd85551f8b1 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -239,7 +239,11 @@ static void text_keymap(struct wmKeyConfig *keyconf) #ifdef __APPLE__ WM_keymap_add_item(keymap, "TEXT_OT_start_find", FKEY, KM_PRESS, KM_OSKEY, 0); #endif - + WM_keymap_add_item(keymap, "TEXT_OT_jump", JKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_find", GKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_replace", HKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_properties", TKEY, KM_PRESS, KM_CTRL, 0); + keymap = WM_keymap_find(keyconf, "Text", SPACE_TEXT, 0); #ifdef __APPLE__ @@ -265,7 +269,6 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_find_set_selected", EKEY, KM_PRESS, KM_OSKEY, 0); - WM_keymap_add_item(keymap, "TEXT_OT_find", GKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_select_all", AKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_select_line", AKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0); #endif @@ -309,13 +312,6 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "selection", TRUE); } - WM_keymap_add_item(keymap, "TEXT_OT_properties", TKEY, KM_PRESS, KM_CTRL, 0); - - WM_keymap_add_item(keymap, "TEXT_OT_jump", JKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "TEXT_OT_find", GKEY, KM_PRESS, KM_CTRL, 0); - - WM_keymap_add_item(keymap, "TEXT_OT_replace", HKEY, KM_PRESS, KM_CTRL, 0); - kmi = WM_keymap_add_item(keymap, "TEXT_OT_to_3d_object", MKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "split_lines", FALSE); kmi = WM_keymap_add_item(keymap, "TEXT_OT_to_3d_object", MKEY, KM_PRESS, KM_CTRL, 0); -- cgit v1.2.3 From 27a662f670a8f06a554c32c51f3d4b4884f64848 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 17 Oct 2013 19:31:59 +0000 Subject: Missing ParticleSystem->parent pointer check in BKE_object_unlink. --- source/blender/blenkernel/intern/object.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 94744866a17..d277d25294e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -590,6 +590,9 @@ void BKE_object_unlink(Object *ob) } } } + + if (tpsys->parent == ob) + tpsys->parent = NULL; } if (ob->pd) DAG_id_tag_update(&obt->id, OB_RECALC_DATA); -- cgit v1.2.3 From 4230b8f9c4cc0b71bb1d361d16c5dbe82e24ee9c Mon Sep 17 00:00:00 2001 From: Kevin Mackay Date: Thu, 17 Oct 2013 19:57:14 +0000 Subject: Patch [#37115] Surface split and separate operators Added surface support to recent curve split operator, completing quick hack todo Updated nurbs separate operator to make use of new split logic, completing tools todo Added 'Delete segment' option to surfaces and improved surface duplication, used for split/separate --- source/blender/blenkernel/BKE_curve.h | 1 + source/blender/blenkernel/intern/curve.c | 20 + source/blender/editors/curve/editcurve.c | 1139 ++++++++++++++++------------- source/blender/makesdna/DNA_curve_types.h | 2 + 4 files changed, 671 insertions(+), 491 deletions(-) diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 07116979eab..dee27cebf59 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -119,6 +119,7 @@ void BKE_nurbList_flag_set(ListBase *editnurb, short flag); void BKE_nurb_free(struct Nurb *nu); struct Nurb *BKE_nurb_duplicate(struct Nurb *nu); +struct Nurb *BKE_nurb_copy(struct Nurb *src, int pntsu, int pntsv); void BKE_nurb_test2D(struct Nurb *nu); void BKE_nurb_minmax(struct Nurb *nu, float min[3], float max[3]); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index e255732d3fb..ca9f97b754c 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -579,6 +579,26 @@ Nurb *BKE_nurb_duplicate(Nurb *nu) return newnu; } +/* copy the nurb but allow for different number of points (to be copied after this) */ +Nurb *BKE_nurb_copy(Nurb *src, int pntsu, int pntsv) +{ + Nurb *newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "copyNurb"); + memcpy(newnu, src, sizeof(Nurb)); + + if (pntsu == 1) SWAP(int, pntsu, pntsv); + newnu->pntsu = pntsu; + newnu->pntsv = pntsv; + + if (src->bezt) { + newnu->bezt = (BezTriple *)MEM_mallocN(pntsu * pntsv * sizeof(BezTriple), "copyNurb2"); + } + else { + newnu->bp = (BPoint *)MEM_mallocN(pntsu * pntsv * sizeof(BPoint), "copyNurb3"); + } + + return newnu; +} + void BKE_nurbList_duplicate(ListBase *lb1, ListBase *lb2) { Nurb *nu, *nun; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 2dc32f711b4..24065321f8b 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -111,7 +111,7 @@ typedef enum eCurveElem_Types { void selectend_nurb(Object *obedit, enum eEndPoint_Types selfirst, bool doswap, bool selstatus); static void select_adjacent_cp(ListBase *editnurb, short next, const bool cont, const bool selstatus); static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, const short flag, const bool split); -static int curve_delete_selected(Object *obedit, const eCurveElem_Types type, const bool split); +static int curve_delete_segments(Object *obedit, const bool split); ListBase *object_editcurve_get(Object *ob) { @@ -1373,16 +1373,15 @@ static int separate_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Nurb *nu, *nu1; Object *oldob, *newob; Base *oldbase, *newbase; Curve *oldcu, *newcu; - EditNurb *oldedit, *newedit; + EditNurb *newedit; + ListBase newnurb = {NULL, NULL}; oldbase = CTX_data_active_base(C); oldob = oldbase->object; oldcu = oldob->data; - oldedit = oldcu->editnurb; if (oldcu->key) { BKE_report(op->reports, RPT_ERROR, "Cannot separate a curve with vertex keys"); @@ -1390,44 +1389,43 @@ static int separate_exec(bContext *C, wmOperator *op) } WM_cursor_wait(1); - - /* 1. duplicate the object and data */ + + /* 1. duplicate geometry and check for valid selection for separate */ + adduplicateflagNurb(oldob, &newnurb, SELECT, true); + + if (newnurb.first == NULL) { + WM_cursor_wait(0); + BKE_report(op->reports, RPT_ERROR, "Cannot separate current selection"); + return OPERATOR_CANCELLED; + } + + /* 2. duplicate the object and data */ newbase = ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */ DAG_relations_tag_update(bmain); - ED_base_object_select(newbase, BA_DESELECT); newob = newbase->object; - newcu = newob->data = BKE_curve_copy(oldcu); newcu->editnurb = NULL; oldcu->id.us--; /* because new curve is a copy: reduce user count */ - /* 2. put new object in editmode and clear it */ + /* 3. put new object in editmode, clear it and set separated nurbs */ make_editNurb(newob); newedit = newcu->editnurb; BKE_nurbList_free(&newedit->nurbs); BKE_curve_editNurb_keyIndex_free(newedit); newedit->keyindex = NULL; + BLI_movelisttolist(&newedit->nurbs, &newnurb); - /* 3. move over parts from old object */ - for (nu = oldedit->nurbs.first; nu; nu = nu1) { - nu1 = nu->next; - - if (isNurbsel(nu)) { - keyIndex_delNurb(oldedit, nu); - BLI_remlink(&oldedit->nurbs, nu); - BLI_addtail(&newedit->nurbs, nu); - } - } - - /* 4. put old object out of editmode */ + /* 4. put old object out of editmode and delete separated geometry */ load_editNurb(newob); free_editNurb(newob); + curve_delete_segments(oldob, true); DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */ DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */ WM_event_add_notifier(C, NC_GEOM | ND_DATA, oldob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, newob); WM_cursor_wait(0); @@ -1439,7 +1437,7 @@ void CURVE_OT_separate(wmOperatorType *ot) /* identifiers */ ot->name = "Separate"; ot->idname = "CURVE_OT_separate"; - ot->description = "Separate (partly) selected curves or surfaces into a new object"; + ot->description = "Separate selected points from connected unselected points into a new object"; /* api callbacks */ ot->exec = separate_exec; @@ -1460,7 +1458,7 @@ static int curve_split_exec(bContext *C, wmOperator *op) adduplicateflagNurb(obedit, &newnurb, SELECT, true); if (newnurb.first != NULL) { - curve_delete_selected(obedit, CURVE_SEGMENT, true); + curve_delete_segments(obedit, true); BLI_movelisttolist(editnurb, &newnurb); if (ED_curve_updateAnimPaths(obedit->data)) @@ -1486,7 +1484,7 @@ void CURVE_OT_split(wmOperatorType *ot) /* api callbacks */ ot->exec = curve_split_exec; - ot->poll = ED_operator_editcurve; + ot->poll = ED_operator_editsurfcurve; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1539,6 +1537,57 @@ static short isNurbselUV(Nurb *nu, int *u, int *v, int flag) return 0; } +/* return true if U direction is selected and number of selected columns v */ +static bool isNurbselU(Nurb *nu, int *v, int flag) +{ + BPoint *bp; + int a, b, sel; + + *v = 0; + + for (b = 0, bp = nu->bp; b < nu->pntsv; b++) { + sel = 0; + for (a = 0; a < nu->pntsu; a++, bp++) { + if (bp->f1 & flag) sel++; + } + if (sel == nu->pntsu) { + (*v)++; + } + else if (sel >= 1) { + *v = 0; + return 0; + } + } + + return 1; +} + +/* return true if V direction is selected and number of selected rows u */ +static bool isNurbselV(Nurb *nu, int *u, int flag) +{ + BPoint *bp; + int a, b, sel; + + *u = 0; + + for (a = 0; a < nu->pntsu; a++) { + bp = &nu->bp[a]; + sel = 0; + for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) { + if (bp->f1 & flag) sel++; + } + if (sel == nu->pntsv) { + (*u)++; + } + else if (sel >= 1) { + *u = 0; + return 0; + } + } + + return 1; +} + static void rotateflagNurb(ListBase *editnurb, short flag, const float cent[3], float rotmat[3][3]) { /* all verts with (flag & 'flag') rotate */ @@ -1622,7 +1671,7 @@ static int deleteflagNurb(Object *obedit, short flag) ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu, *next; BPoint *bp, *bpn, *newbp; - int a, b, newu, newv, sel; + int a, b, newu, newv; if (obedit->type != OB_SURF) { return OPERATOR_CANCELLED; @@ -1653,62 +1702,36 @@ static int deleteflagNurb(Object *obedit, short flag) BKE_nurb_free(nu); nu = NULL; } else { - /* is nurb in U direction selected */ - newv = nu->pntsv; - bp = nu->bp; - for (b = 0; b < nu->pntsv; b++) { - sel = 0; - for (a = 0; a < nu->pntsu; a++, bp++) { - if (bp->f1 & flag) sel++; - } - if (sel == nu->pntsu) { - newv--; - } - else if (sel >= 1) { - /* don't delete */ - break; - } - } - if (newv != nu->pntsv && b == nu->pntsv) { - /* delete */ - bp = nu->bp; - bpn = newbp = (BPoint *)MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb"); - for (b = 0; b < nu->pntsv; b++) { - if ((bp->f1 & flag) == 0) { - memcpy(bpn, bp, nu->pntsu * sizeof(BPoint)); - keyIndex_updateBP(cu->editnurb, bp, bpn, nu->pntsu); - bpn += nu->pntsu; - } - else { - keyIndex_delBP(cu->editnurb, bp); + if (isNurbselU(nu, &newv, flag)) { + /* U direction selected */ + newv = nu->pntsv - newv; + if (newv != nu->pntsv) { + /* delete */ + bp = nu->bp; + bpn = newbp = (BPoint *)MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb"); + for (b = 0; b < nu->pntsv; b++) { + if ((bp->f1 & flag) == 0) { + memcpy(bpn, bp, nu->pntsu * sizeof(BPoint)); + keyIndex_updateBP(cu->editnurb, bp, bpn, nu->pntsu); + bpn += nu->pntsu; + } + else { + keyIndex_delBP(cu->editnurb, bp); + } + bp += nu->pntsu; } - bp += nu->pntsu; - } - nu->pntsv = newv; - MEM_freeN(nu->bp); - nu->bp = newbp; - BKE_nurb_order_clamp_v(nu); + nu->pntsv = newv; + MEM_freeN(nu->bp); + nu->bp = newbp; + BKE_nurb_order_clamp_v(nu); - BKE_nurb_knot_calc_v(nu); - } - else { - /* is the nurb in V direction selected */ - newu = nu->pntsu; - for (a = 0; a < nu->pntsu; a++) { - bp = &nu->bp[a]; - sel = 0; - for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) { - if (bp->f1 & flag) sel++; - } - if (sel == nu->pntsv) { - newu--; - } - else if (sel >= 1) { - /* don't delete */ - break; - } + BKE_nurb_knot_calc_v(nu); } - if (newu != nu->pntsu && a == nu->pntsu) { + } + else if (isNurbselV(nu, &newu, flag)) { + /* V direction selected */ + newu = nu->pntsu - newu; + if (newu != nu->pntsu) { /* delete */ bp = nu->bp; bpn = newbp = (BPoint *)MEM_mallocN(newu * nu->pntsv * sizeof(BPoint), "deleteNurb"); @@ -1872,21 +1895,18 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, const short flag, const bool split) { ListBase *editnurb = object_editcurve_get(obedit); - Nurb *nu, *newnu, *startnu; + Nurb *nu = editnurb->last, *newnu; BezTriple *bezt, *bezt1; - BPoint *bp, *bp1; + BPoint *bp, *bp1, *bp2, *bp3; Curve *cu = (Curve *)obedit->data; - int a, b, starta, enda, diffa, newu, newv; + int a, b, c, starta, enda, diffa, cyclicu, cyclicv, newu, newv; char *usel; cu->lastsel = NULL; - - nu = editnurb->last; while (nu) { - startnu = NULL; + cyclicu = cyclicv = 0; if (nu->type == CU_BEZIER) { - bezt = nu->bezt; - for (a = 0; a < nu->pntsu; a++) { + for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) { enda = -1; starta = a; while ((bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag)) { @@ -1897,46 +1917,45 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, bezt++; } if (enda >= starta) { - diffa = enda - starta + 1; - - if (startnu != NULL && enda == nu->pntsu - 1) { - /* end point of cyclic spline selected, so merge end points with start points */ - bezt1 = (BezTriple *)MEM_mallocN((startnu->pntsu + diffa) * sizeof(BezTriple), "adduplicateN"); - memcpy(bezt1, &nu->bezt[starta], diffa * sizeof(BezTriple)); - memcpy(&bezt1[diffa], startnu->bezt, startnu->pntsu * sizeof(BezTriple)); - - MEM_freeN(startnu->bezt); - startnu->bezt = bezt1; - startnu->pntsu += diffa; - newnu = startnu; + newu = diffa = enda - starta + 1; /* set newu and diffa, may use both */ + + if (starta == 0 && newu != nu->pntsu && (nu->flagu & CU_NURB_CYCLIC)) { + cyclicu = newu; } else { - newnu = ED_curve_nurbcpy(nu, diffa); + if (enda == nu->pntsu - 1) newu += cyclicu; + + newnu = BKE_nurb_copy(nu, newu, 1); BLI_addtail(newnurb, newnu); set_actNurb(obedit, newnu); - memcpy(newnu->bezt, &nu->bezt[starta], newnu->pntsu * sizeof(BezTriple)); - } + memcpy(newnu->bezt, &nu->bezt[starta], diffa * sizeof(BezTriple)); + if (newu != diffa) { + memcpy(&newnu->bezt[diffa], nu->bezt, cyclicu * sizeof(BezTriple)); + cyclicu = 0; + } - b = newnu->pntsu; - bezt1 = newnu->bezt; - while (b--) { - select_beztriple(bezt1, SELECT, flag, HIDDEN); - bezt1++; - } + if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC; - if (nu->flagu & CU_NURB_CYCLIC) { - if (starta != 0 || enda != nu->pntsu - 1) { - newnu->flagu &= ~CU_NURB_CYCLIC; - if (starta == 0) startnu = newnu; + for (b = 0, bezt1 = newnu->bezt; b < newnu->pntsu; b++, bezt1++) { + select_beztriple(bezt1, SELECT, flag, HIDDEN); } } } - bezt++; + } + + if (cyclicu != 0) { + newnu = BKE_nurb_copy(nu, cyclicu, 1); + BLI_addtail(newnurb, newnu); + memcpy(newnu->bezt, nu->bezt, cyclicu * sizeof(BezTriple)); + newnu->flagu &= ~CU_NURB_CYCLIC; + + for (b = 0, bezt1 = newnu->bezt; b < newnu->pntsu; b++, bezt1++) { + select_beztriple(bezt1, SELECT, flag, HIDDEN); + } } } else if (nu->pntsv == 1) { /* because UV Nurb has a different method for dupli */ - bp = nu->bp; - for (a = 0; a < nu->pntsu; a++) { + for (a = 0, bp = nu->bp; a < nu->pntsu; a++, bp++) { enda = -1; starta = a; while (bp->f1 & flag) { @@ -1947,46 +1966,48 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, bp++; } if (enda >= starta) { - diffa = enda - starta + 1; - - if (startnu != NULL && enda == nu->pntsu - 1) { - /* end point of cyclic spline selected, so merge end points with start points */ - bp1 = (BPoint *)MEM_mallocN((startnu->pntsu + diffa) * sizeof(BPoint), "adduplicateN2"); - memcpy(bp1, &nu->bp[starta], diffa * sizeof(BPoint)); - memcpy(&bp1[diffa], startnu->bp, startnu->pntsu * sizeof(BPoint)); - - MEM_freeN(startnu->bp); - startnu->bp = bp1; - startnu->pntsu += diffa; - newnu = startnu; + newu = diffa = enda - starta + 1; /* set newu and diffa, may use both */ + + if (starta == 0 && newu != nu->pntsu && (nu->flagu & CU_NURB_CYCLIC)) { + cyclicu = newu; } else { - newnu = ED_curve_nurbcpy(nu, diffa); + if (enda == nu->pntsu - 1) newu += cyclicu; + + newnu = BKE_nurb_copy(nu, newu, 1); BLI_addtail(newnurb, newnu); set_actNurb(obedit, newnu); - memcpy(newnu->bp, &nu->bp[starta], newnu->pntsu * sizeof(BPoint)); - } + memcpy(newnu->bp, &nu->bp[starta], diffa * sizeof(BPoint)); + if (newu != diffa) { + memcpy(&newnu->bp[diffa], nu->bp, cyclicu * sizeof(BPoint)); + cyclicu = 0; + } - b = newnu->pntsu; - bp1 = newnu->bp; - while (b--) { - select_bpoint(bp1, SELECT, flag, HIDDEN); - bp1++; - } + if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC; - if (nu->flagu & CU_NURB_CYCLIC) { - if (starta != 0 || enda != nu->pntsu - 1) { - newnu->flagu &= ~CU_NURB_CYCLIC; - if (starta == 0) startnu = newnu; + for (b = 0, bp1 = newnu->bp; b < newnu->pntsu; b++, bp1++) { + select_bpoint(bp1, SELECT, flag, HIDDEN); } } } - bp++; + } + + if (cyclicu != 0) { + newnu = BKE_nurb_copy(nu, cyclicu, 1); + BLI_addtail(newnurb, newnu); + set_actNurb(obedit, newnu); + + memcpy(newnu->bp, nu->bp, cyclicu * sizeof(BPoint)); + newnu->flagu &= ~CU_NURB_CYCLIC; + + for (b = 0, bp1 = newnu->bp; b < newnu->pntsu; b++, bp1++) { + select_bpoint(bp1, SELECT, flag, HIDDEN); + } } } else { - /* a rectangular area in nurb has to be selected */ if (isNurbsel(nu)) { + /* a rectangular area in nurb has to be selected and if splitting must be in U or V direction */ usel = MEM_callocN(nu->pntsu, "adduplicateN3"); bp = nu->bp; for (a = 0; a < nu->pntsv; a++) { @@ -2008,75 +2029,126 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, } } } - if (newu == 0 || newv == 0) { + MEM_freeN(usel); + + if ((newu == 0 || newv == 0) || + (split && !isNurbselU(nu, &newv, SELECT) && !isNurbselV(nu, &newu, SELECT))) { if (G.debug & G_DEBUG) printf("Can't duplicate Nurb\n"); } else { + for (a = 0, bp1 = nu->bp; a < nu->pntsu * nu->pntsv; a++, bp1++) { + newv = newu = 0; + + if ((bp1->f1 & flag) && !(bp1->f1 & SURF_SEEN)) { + /* point selected, now loop over points in U and V directions */ + for (b = a % nu->pntsu, bp2 = bp1; b < nu->pntsu; b++, bp2++) { + if (bp2->f1 & flag) { + newu++; + for (c = a / nu->pntsu, bp3 = bp2; c < nu->pntsv; c++, bp3 += nu->pntsu) { + if (bp3->f1 & flag) { + bp3->f1 |= SURF_SEEN; /* flag as seen so skipped on future iterations */ + if (newu == 1) newv++; + } + else { + break; + } + } + } + else { + break; + } + } + } - if (newu == 1) SWAP(int, newu, newv); + if ((newu + newv) > 2) { + /* ignore single points */ + if (a == 0) { + /* check if need to save cyclic selection and continue if so */ + if (newu == nu->pntsu && (nu->flagv & CU_NURB_CYCLIC)) cyclicv = newv; + if (newv == nu->pntsv && (nu->flagu & CU_NURB_CYCLIC)) cyclicu = newu; + if (cyclicu != 0 || cyclicv != 0) continue; + } - newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN4"); - memcpy(newnu, nu, sizeof(Nurb)); - BLI_addtail(newnurb, newnu); - set_actNurb(obedit, newnu); - newnu->pntsu = newu; - newnu->pntsv = newv; - newnu->bp = (BPoint *)MEM_mallocN(newu * newv * sizeof(BPoint), "adduplicateN5"); - BKE_nurb_order_clamp_u(newnu); - BKE_nurb_order_clamp_v(newnu); - - newnu->knotsu = newnu->knotsv = NULL; - - bp = newnu->bp; - bp1 = nu->bp; - for (a = 0; a < nu->pntsv; a++) { - for (b = 0; b < nu->pntsu; b++, bp1++) { - if (bp1->f1 & flag) { - memcpy(bp, bp1, sizeof(BPoint)); - select_bpoint(bp1, DESELECT, flag, HIDDEN); - bp++; + if (a + newu == nu->pntsu && cyclicu != 0) { + /* cyclic in U direction */ + newnu = BKE_nurb_copy(nu, newu + cyclicu, newv); + for (b = 0; b < newv; b++) { + memcpy(&newnu->bp[b * newnu->pntsu], &nu->bp[b * nu->pntsu + a], newu * sizeof(BPoint)); + memcpy(&newnu->bp[b * newnu->pntsu + newu], &nu->bp[b * nu->pntsu], cyclicu * sizeof(BPoint)); + } + cyclicu = cyclicv = 0; } + else if ((a / nu->pntsu) + newv == nu->pntsv && cyclicv != 0) { + /* cyclic in V direction */ + newnu = BKE_nurb_copy(nu, newu, newv + cyclicv); + memcpy(newnu->bp, &nu->bp[a], newu * newv * sizeof(BPoint)); + memcpy(&newnu->bp[newu * newv], nu->bp, newu * cyclicv * sizeof(BPoint)); + cyclicu = cyclicv = 0; + } + else { + newnu = BKE_nurb_copy(nu, newu, newv); + for (b = 0; b < newv; b++) { + memcpy(&newnu->bp[b * newu], &nu->bp[b * nu->pntsu + a], newu * sizeof(BPoint)); + } + } + set_actNurb(obedit, newnu); + BLI_addtail(newnurb, newnu); + + if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC; + if (newv != nu->pntsv) newnu->flagv &= ~CU_NURB_CYCLIC; } } - if (BKE_nurb_check_valid_u(newnu)) { - if (nu->pntsu == newnu->pntsu && nu->knotsu) { - newnu->knotsu = MEM_dupallocN(nu->knotsu); - } - else { - BKE_nurb_knot_calc_u(newnu); + + if (cyclicu != 0 || cyclicv != 0) { + /* copy start of a cyclic surface, or copying all selected points */ + newu = cyclicu == 0 ? nu->pntsu : cyclicu; + newv = cyclicv == 0 ? nu->pntsv : cyclicv; + + newnu = BKE_nurb_copy(nu, newu, newv); + for (b = 0; b < newv; b++) { + memcpy(&newnu->bp[b * newu], &nu->bp[b * nu->pntsu], newu * sizeof(BPoint)); } + set_actNurb(obedit, newnu); + BLI_addtail(newnurb, newnu); + + if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC; + if (newv != nu->pntsv) newnu->flagv &= ~CU_NURB_CYCLIC; } - if (BKE_nurb_check_valid_v(newnu)) { - if (nu->pntsv == newnu->pntsv && nu->knotsv) { - newnu->knotsv = MEM_dupallocN(nu->knotsv); - } - else { - BKE_nurb_knot_calc_v(newnu); - } + + for (b = 0, bp1 = nu->bp; b < nu->pntsu * nu->pntsv; b++, bp1++) { + bp1->f1 &= ~SURF_SEEN; + if (!split) select_bpoint(bp1, DESELECT, flag, HIDDEN); } } - MEM_freeN(usel); } } - nu = nu->prev; } - - for (nu = newnurb->first; nu; nu = nu->next) { - /* knots done after duplicate as pntsu may change */ - if (nu->pntsv == 1) { - nu->knotsu = NULL; - BKE_nurb_knot_calc_u(nu); - } - if (split) { - if (nu->type == CU_BEZIER) { + for (nu = newnurb->first; nu; nu = nu->next) { + if (nu->type == CU_BEZIER) { + if (split) { /* recalc first and last */ BKE_nurb_handle_calc_simple(nu, &nu->bezt[0]); BKE_nurb_handle_calc_simple(nu, &nu->bezt[nu->pntsu - 1]); } } + else { + /* knots done after duplicate as pntsu may change */ + nu->knotsu = nu->knotsv = NULL; + BKE_nurb_order_clamp_u(nu); + BKE_nurb_knot_calc_u(nu); + + if (obedit->type == OB_SURF) { + for (a = 0, bp = nu->bp; a < nu->pntsu * nu->pntsv; a++, bp++) { + bp->f1 &= ~SURF_SEEN; + } + + BKE_nurb_order_clamp_v(nu); + BKE_nurb_knot_calc_v(nu); + } + } } /* actnu changed */ @@ -5708,7 +5780,7 @@ void CURVE_OT_select_nth(wmOperatorType *ot) /********************** add duplicate operator *********************/ -static int duplicate_exec(bContext *C, wmOperator *UNUSED(op)) +static int duplicate_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); ListBase newnurb = {NULL, NULL}; @@ -5719,6 +5791,10 @@ static int duplicate_exec(bContext *C, wmOperator *UNUSED(op)) BLI_movelisttolist(object_editcurve_get(obedit), &newnurb); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } + else { + BKE_report(op->reports, RPT_ERROR, "Cannot duplicate current selection"); + return OPERATOR_CANCELLED; + } return OPERATOR_FINISHED; } @@ -5727,7 +5803,7 @@ void CURVE_OT_duplicate(wmOperatorType *ot) { /* identifiers */ ot->name = "Duplicate Curve"; - ot->description = "Duplicate selected control points and segments between them"; + ot->description = "Duplicate selected control points"; ot->idname = "CURVE_OT_duplicate"; /* api callbacks */ @@ -5740,178 +5816,294 @@ void CURVE_OT_duplicate(wmOperatorType *ot) /********************** delete operator *********************/ -static int curve_delete_selected(Object *obedit, eCurveElem_Types type, const bool split) +static int curve_delete_vertices(Object *obedit) { Curve *cu = obedit->data; EditNurb *editnurb = cu->editnurb; ListBase *nubase = &editnurb->nurbs; - Nurb *nu, *nu1, *startnu; - BezTriple *bezt, *bezt1, *bezt2; - BPoint *bp, *bp1, *bp2; - int a, b, starta, enda, cut = 0; - int nuindex = 0; - ListBase newnurb = {NULL, NULL}; + Nurb *nu, *next; + BezTriple *bezt, *bezt1; + BPoint *bp, *bp1; + int a, type, nuindex = 0; if (obedit->type == OB_SURF) { - if (type == CURVE_VERTEX) { - return deleteflagNurb(obedit, SELECT); - } - else { - keyIndex_delNurbList(editnurb, nubase); - BKE_nurbList_free(nubase); - - return OPERATOR_FINISHED; - } + return deleteflagNurb(obedit, SELECT); } - if (type == CURVE_VERTEX) { - /* first loop, can we remove entire pieces? */ - Nurb *next; - nu = nubase->first; - while (nu) { - next = nu->next; - if (nu->type == CU_BEZIER) { - bezt = nu->bezt; - a = nu->pntsu; - if (a) { - while (a) { - if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) { - /* pass */ - } - else { - break; - } - a--; - bezt++; + /* first loop, can we remove entire pieces? */ + nu = nubase->first; + while (nu) { + next = nu->next; + if (nu->type == CU_BEZIER) { + bezt = nu->bezt; + a = nu->pntsu; + if (a) { + while (a) { + if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) { + /* pass */ } - if (a == 0) { - if (cu->actnu == nuindex) - cu->actnu = -1; - - BLI_remlink(nubase, nu); - keyIndex_delNurb(editnurb, nu); - BKE_nurb_free(nu); nu = NULL; + else { + break; } + a--; + bezt++; + } + if (a == 0) { + if (cu->actnu == nuindex) + cu->actnu = -1; + + BLI_remlink(nubase, nu); + keyIndex_delNurb(editnurb, nu); + BKE_nurb_free(nu); nu = NULL; } } - else { - bp = nu->bp; - a = nu->pntsu * nu->pntsv; - if (a) { - while (a) { - if (bp->f1 & SELECT) { - /* pass */ - } - else { - break; - } - a--; - bp++; + } + else { + bp = nu->bp; + a = nu->pntsu * nu->pntsv; + if (a) { + while (a) { + if (bp->f1 & SELECT) { + /* pass */ } - if (a == 0) { - if (cu->actnu == nuindex) - cu->actnu = -1; - - BLI_remlink(nubase, nu); - keyIndex_delNurb(editnurb, nu); - BKE_nurb_free(nu); nu = NULL; + else { + break; } + a--; + bp++; + } + if (a == 0) { + if (cu->actnu == nuindex) + cu->actnu = -1; + + BLI_remlink(nubase, nu); + keyIndex_delNurb(editnurb, nu); + BKE_nurb_free(nu); nu = NULL; } } - - /* Never allow the order to exceed the number of points - * - note, this is ok but changes unselected nurbs, disable for now */ + } + + /* Never allow the order to exceed the number of points + * - note, this is ok but changes unselected nurbs, disable for now */ #if 0 - if ((nu != NULL) && (nu->type == CU_NURBS)) { - clamp_nurb_order_u(nu); - } + if ((nu != NULL) && (nu->type == CU_NURBS)) { + clamp_nurb_order_u(nu); + } #endif - nu = next; - nuindex++; + nu = next; + nuindex++; + } + /* 2nd loop, delete small pieces: just for curves */ + nu = nubase->first; + while (nu) { + next = nu->next; + type = 0; + if (nu->type == CU_BEZIER) { + int delta = 0; + bezt = nu->bezt; + for (a = 0; a < nu->pntsu; a++) { + if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) { + memmove(bezt, bezt + 1, (nu->pntsu - a - 1) * sizeof(BezTriple)); + keyIndex_delBezt(editnurb, bezt + delta); + keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu - a - 1); + nu->pntsu--; + a--; + type = 1; + delta++; + } + else { + bezt++; + } + } + if (type) { + bezt1 = (BezTriple *)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb"); + memcpy(bezt1, nu->bezt, (nu->pntsu) * sizeof(BezTriple)); + keyIndex_updateBezt(editnurb, nu->bezt, bezt1, nu->pntsu); + MEM_freeN(nu->bezt); + nu->bezt = bezt1; + BKE_nurb_handles_calc(nu); + } } - /* 2nd loop, delete small pieces: just for curves */ - nu = nubase->first; - while (nu) { - next = nu->next; - type = 0; - if (nu->type == CU_BEZIER) { - int delta = 0; - bezt = nu->bezt; - for (a = 0; a < nu->pntsu; a++) { - if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) { - memmove(bezt, bezt + 1, (nu->pntsu - a - 1) * sizeof(BezTriple)); - keyIndex_delBezt(editnurb, bezt + delta); - keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu - a - 1); - nu->pntsu--; - a--; - type = 1; - delta++; - } - else { - bezt++; - } + else if (nu->pntsv == 1) { + int delta = 0; + bp = nu->bp; + + for (a = 0; a < nu->pntsu; a++) { + if (bp->f1 & SELECT) { + memmove(bp, bp + 1, (nu->pntsu - a - 1) * sizeof(BPoint)); + keyIndex_delBP(editnurb, bp + delta); + keyIndex_updateBP(editnurb, bp + 1, bp, nu->pntsu - a - 1); + nu->pntsu--; + a--; + type = 1; + delta++; } - if (type) { - bezt1 = (BezTriple *)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb"); - memcpy(bezt1, nu->bezt, (nu->pntsu) * sizeof(BezTriple)); - keyIndex_updateBezt(editnurb, nu->bezt, bezt1, nu->pntsu); - MEM_freeN(nu->bezt); - nu->bezt = bezt1; - BKE_nurb_handles_calc(nu); + else { + bp++; } } - else if (nu->pntsv == 1) { - int delta = 0; - bp = nu->bp; + if (type) { + bp1 = (BPoint *)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2"); + memcpy(bp1, nu->bp, (nu->pntsu) * sizeof(BPoint)); + keyIndex_updateBP(editnurb, nu->bp, bp1, nu->pntsu); + MEM_freeN(nu->bp); + nu->bp = bp1; - for (a = 0; a < nu->pntsu; a++) { - if (bp->f1 & SELECT) { - memmove(bp, bp + 1, (nu->pntsu - a - 1) * sizeof(BPoint)); - keyIndex_delBP(editnurb, bp + delta); - keyIndex_updateBP(editnurb, bp + 1, bp, nu->pntsu - a - 1); - nu->pntsu--; - a--; - type = 1; - delta++; + /* Never allow the order to exceed the number of points + * - note, this is ok but changes unselected nurbs, disable for now */ +#if 0 + if (nu->type == CU_NURBS) { + clamp_nurb_order_u(nu); + } +#endif + } + BKE_nurb_order_clamp_u(nu); + BKE_nurb_knot_calc_u(nu); + } + nu = next; + } + + return OPERATOR_FINISHED; +} + +static int curve_delete_segments(Object *obedit, const bool split) +{ + Curve *cu = obedit->data; + EditNurb *editnurb = cu->editnurb; + ListBase *nubase = &editnurb->nurbs, newnurb = {NULL, NULL}; + Nurb *nu, *nu1; + BezTriple *bezt, *bezt1, *bezt2; + BPoint *bp, *bp1, *bp2; + int a, b, starta, enda, cut, cyclicut; + + for (nu = nubase->first; nu; nu = nu->next) { + nu1 = NULL; + starta = enda = cut = -1; + cyclicut = 0; + + if (nu->type == CU_BEZIER) { + for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) { + if (!BEZSELECTED_HIDDENHANDLES(cu, bezt)) { + enda = a; + if (starta == -1) starta = a; + if (a < nu->pntsu - 1) continue; + } + else if (a < nu->pntsu - 1 && !BEZSELECTED_HIDDENHANDLES(cu, bezt + 1)) { + /* if just single selected point then continue */ + continue; + } + + if (starta >= 0) { + /* got selected segment, now check where and copy */ + if (starta <= 1 && a == nu->pntsu - 1) { + /* copying all points in spline */ + if (starta == 1 && enda != a) nu->flagu &= ~CU_NURB_CYCLIC; + + starta = 0; + enda = a; + cut = enda - starta + 1; + nu1 = BKE_nurb_copy(nu, cut, 1); + } + else if (starta == 0) { + /* if start of curve copy next end point */ + enda++; + cut = enda - starta + 1; + bezt1 = &nu->bezt[nu->pntsu - 1]; + bezt2 = &nu->bezt[nu->pntsu - 2]; + + if ((nu->flagu & CU_NURB_CYCLIC) && + BEZSELECTED_HIDDENHANDLES(cu, bezt1) && + BEZSELECTED_HIDDENHANDLES(cu, bezt2)) + { + /* check if need to join start of spline to end */ + nu1 = BKE_nurb_copy(nu, cut + 1, 1); + ED_curve_beztcpy(editnurb, &nu1->bezt[1], nu->bezt, cut); + starta = nu->pntsu - 1; + cut = 1; + } + else { + if (nu->flagu & CU_NURB_CYCLIC) cyclicut = cut; + else nu1 = BKE_nurb_copy(nu, cut, 1); + } + } + else if (enda == nu->pntsu - 1) { + /* if end of curve copy previous start point */ + starta--; + cut = enda - starta + 1; + bezt1 = nu->bezt; + bezt2 = &nu->bezt[1]; + + if ((nu->flagu & CU_NURB_CYCLIC) && + BEZSELECTED_HIDDENHANDLES(cu, bezt1) && + BEZSELECTED_HIDDENHANDLES(cu, bezt2)) + { + /* check if need to join start of spline to end */ + nu1 = BKE_nurb_copy(nu, cut + 1, 1); + ED_curve_beztcpy(editnurb, &nu1->bezt[cut], nu->bezt, 1); + } + else if (cyclicut != 0) { + /* if cyclicut exists it is a cyclic spline, start and end should be connected */ + nu1 = BKE_nurb_copy(nu, cut + cyclicut, 1); + ED_curve_beztcpy(editnurb, &nu1->bezt[cut], nu->bezt, cyclicut); + cyclicut = 0; + } + else { + nu1 = BKE_nurb_copy(nu, cut, 1); + } } else { - bp++; + /* mid spline selection, copy adjacent start and end */ + starta--; + enda++; + cut = enda - starta + 1; + nu1 = BKE_nurb_copy(nu, cut, 1); } - } - if (type) { - bp1 = (BPoint *)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2"); - memcpy(bp1, nu->bp, (nu->pntsu) * sizeof(BPoint)); - keyIndex_updateBP(editnurb, nu->bp, bp1, nu->pntsu); - MEM_freeN(nu->bp); - nu->bp = bp1; - - /* Never allow the order to exceed the number of points - * - note, this is ok but changes unselected nurbs, disable for now */ -#if 0 - if (nu->type == CU_NURBS) { - clamp_nurb_order_u(nu); + + if (nu1 != NULL) { + ED_curve_beztcpy(editnurb, nu1->bezt, &nu->bezt[starta], cut); + BLI_addtail(&newnurb, nu1); + + if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC; + nu1 = NULL; } -#endif + starta = enda = -1; + } + } + + if (!split && cut != -1 && nu->pntsu > 2 && !(nu->flagu & CU_NURB_CYCLIC)) { + /* start and points copied if connecting segment was deleted and not cylic spline */ + bezt1 = nu->bezt; + bezt2 = &nu->bezt[1]; + + if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) && + BEZSELECTED_HIDDENHANDLES(cu, bezt2)) { + nu1 = BKE_nurb_copy(nu, 1, 1); + ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1); + BLI_addtail(&newnurb, nu1); + } + + bezt1 = &nu->bezt[nu->pntsu - 1]; + bezt2 = &nu->bezt[nu->pntsu - 2]; + + if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) && + BEZSELECTED_HIDDENHANDLES(cu, bezt2)) { + nu1 = BKE_nurb_copy(nu, 1, 1); + ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1); + BLI_addtail(&newnurb, nu1); } - BKE_nurb_order_clamp_u(nu); - BKE_nurb_knot_calc_u(nu); } - nu = next; } - } - else if (type == CURVE_SEGMENT) { - for (nu = nubase->first; nu; nu = nu->next) { - startnu = nu1 = NULL; - starta = enda = cut = -1; + else if (nu->pntsv >= 1) { + int u, v; - if (nu->type == CU_BEZIER) { - for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) { - if (!BEZSELECTED_HIDDENHANDLES(cu, bezt)) { + if (isNurbselV(nu, &u, SELECT)) { + for (a = 0, bp = nu->bp; a < nu->pntsu; a++, bp++) { + if (!(bp->f1 & SELECT)) { enda = a; if (starta == -1) starta = a; if (a < nu->pntsu - 1) continue; } - else if (a < nu->pntsu - 1 && !BEZSELECTED_HIDDENHANDLES(cu, bezt + 1)) { + else if (a < nu->pntsu - 1 && !((bp + 1)->f1 & SELECT)) { /* if just single selected point then continue */ continue; } @@ -5925,69 +6117,52 @@ static int curve_delete_selected(Object *obedit, eCurveElem_Types type, const bo starta = 0; enda = a; cut = enda - starta + 1; - - nu1 = ED_curve_nurbcpy(nu, cut); + nu1 = BKE_nurb_copy(nu, cut, nu->pntsv); } else if (starta == 0) { /* if start of curve copy next end point */ enda++; cut = enda - starta + 1; + bp1 = &nu->bp[nu->pntsu - 1]; + bp2 = &nu->bp[nu->pntsu - 2]; - bezt1 = &nu->bezt[nu->pntsu - 1]; - bezt2 = &nu->bezt[nu->pntsu - 2]; - - if ((nu->flagu & CU_NURB_CYCLIC) && - BEZSELECTED_HIDDENHANDLES(cu, bezt1) && - BEZSELECTED_HIDDENHANDLES(cu, bezt2)) - { + if ((nu->flagu & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) { /* check if need to join start of spline to end */ - nu1 = ED_curve_nurbcpy(nu, cut + 1); - ED_curve_beztcpy(editnurb, &nu1->bezt[1], nu->bezt, cut); + nu1 = BKE_nurb_copy(nu, cut + 1, nu->pntsv); + for (b = 0; b < nu->pntsv; b++) { + ED_curve_bpcpy(editnurb, &nu1->bp[b * nu1->pntsu + 1], &nu->bp[b * nu->pntsu], cut); + } starta = nu->pntsu - 1; cut = 1; } else { - nu1 = ED_curve_nurbcpy(nu, cut); - - if (nu->flagu & CU_NURB_CYCLIC) startnu = nu1; + if (nu->flagu & CU_NURB_CYCLIC) cyclicut = cut; + else nu1 = BKE_nurb_copy(nu, cut, nu->pntsv); } } else if (enda == nu->pntsu - 1) { /* if end of curve copy previous start point */ starta--; cut = enda - starta + 1; + bp1 = nu->bp; + bp2 = &nu->bp[1]; - bezt1 = nu->bezt; - bezt2 = &nu->bezt[1]; - - if ((nu->flagu & CU_NURB_CYCLIC) && - BEZSELECTED_HIDDENHANDLES(cu, bezt1) && - BEZSELECTED_HIDDENHANDLES(cu, bezt2)) - { + if ((nu->flagu & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) { /* check if need to join start of spline to end */ - nu1 = ED_curve_nurbcpy(nu, cut + 1); - ED_curve_beztcpy(editnurb, &nu1->bezt[cut], nu->bezt, 1); + nu1 = BKE_nurb_copy(nu, cut + 1, nu->pntsv); + for (b = 0; b < nu->pntsv; b++) { + ED_curve_bpcpy(editnurb, &nu1->bp[b * nu1->pntsu + cut], &nu->bp[b * nu->pntsu], 1); + } } - else if (startnu != NULL) { - /* if startnu exists it is a cyclic spline, start and end should be connected */ - bezt1 = (BezTriple *)MEM_mallocN((cut + startnu->pntsu) * sizeof(BezTriple), "delNurb3"); - ED_curve_beztcpy(editnurb, bezt1, &nu->bezt[starta], cut); - ED_curve_beztcpy(editnurb, &bezt1[cut], nu->bezt, startnu->pntsu); - - MEM_freeN(startnu->bezt); - startnu->bezt = bezt1; - startnu->pntsu += cut; - - if (split) { - for (b = 0; b < startnu->pntsu; b++, bezt1++) { - select_beztriple(bezt1, DESELECT, SELECT, true); - } + else if (cyclicut != 0) { + /* if cyclicut exists it is a cyclic spline, start and end should be connected */ + nu1 = BKE_nurb_copy(nu, cut + cyclicut, nu->pntsv); + for (b = 0; b < nu->pntsv; b++) { + ED_curve_bpcpy(editnurb, &nu1->bp[b * nu1->pntsu + cut], &nu->bp[b * nu->pntsu], cyclicut); } - - BKE_nurb_handles_calc(startnu); } else { - nu1 = ED_curve_nurbcpy(nu, cut); + nu1 = BKE_nurb_copy(nu, cut, nu->pntsv); } } else { @@ -5995,24 +6170,16 @@ static int curve_delete_selected(Object *obedit, eCurveElem_Types type, const bo starta--; enda++; cut = enda - starta + 1; - - nu1 = ED_curve_nurbcpy(nu, cut); + nu1 = BKE_nurb_copy(nu, cut, nu->pntsv); } if (nu1 != NULL) { - ED_curve_beztcpy(editnurb, nu1->bezt, &nu->bezt[starta], cut); - - if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC; - - if (split) { - /* deselect for split operator */ - for (b = 0, bezt1 = nu1->bezt; b < nu1->pntsu; b++, bezt1++) { - select_beztriple(bezt1, DESELECT, SELECT, true); - } + for (b = 0; b < nu->pntsv; b++) { + ED_curve_bpcpy(editnurb, &nu1->bp[b * nu1->pntsu], &nu->bp[b * nu->pntsu + starta], cut); } - BLI_addtail(&newnurb, nu1); - BKE_nurb_handles_calc(nu1); + + if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC; nu1 = NULL; } starta = enda = -1; @@ -6021,102 +6188,91 @@ static int curve_delete_selected(Object *obedit, eCurveElem_Types type, const bo if (!split && cut != -1 && nu->pntsu > 2 && !(nu->flagu & CU_NURB_CYCLIC)) { /* start and points copied if connecting segment was deleted and not cylic spline */ - bezt1 = nu->bezt; - bezt2 = &nu->bezt[1]; - if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) && BEZSELECTED_HIDDENHANDLES(cu, bezt2)) { - nu1 = ED_curve_nurbcpy(nu, 1); - ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1); + bp1 = nu->bp; + bp2 = &nu->bp[1]; + + if ((bp1->f1 & SELECT) && (bp2->f1 & SELECT)) { + nu1 = BKE_nurb_copy(nu, 1, nu->pntsv); + for (b = 0; b < nu->pntsv; b++) { + ED_curve_bpcpy(editnurb, &nu1->bp[b], &nu->bp[b * nu->pntsu], 1); + } BLI_addtail(&newnurb, nu1); } - bezt1 = &nu->bezt[nu->pntsu - 1]; - bezt2 = &nu->bezt[nu->pntsu - 2]; - if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) && BEZSELECTED_HIDDENHANDLES(cu, bezt2)) { - nu1 = ED_curve_nurbcpy(nu, 1); - ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1); + bp1 = &nu->bp[nu->pntsu - 1]; + bp2 = &nu->bp[nu->pntsu - 2]; + + if ((bp1->f1 & SELECT) && (bp2->f1 & SELECT)) { + nu1 = BKE_nurb_copy(nu, 1, nu->pntsv); + for (b = 0; b < nu->pntsv; b++) { + ED_curve_bpcpy(editnurb, &nu1->bp[b], &nu->bp[b * nu->pntsu + nu->pntsu - 1], 1); + } BLI_addtail(&newnurb, nu1); } } } - else if (nu->pntsv == 1) { - for (a = 0, bp = nu->bp; a < nu->pntsu; a++, bp++) { + else if (isNurbselU(nu, &v, SELECT)) { + for (a = 0, bp = nu->bp; a < nu->pntsv; a++, bp += nu->pntsu) { if (!(bp->f1 & SELECT)) { enda = a; if (starta == -1) starta = a; - if (a < nu->pntsu - 1) continue; + if (a < nu->pntsv - 1) continue; } - else if (a < nu->pntsu - 1 && !((bp + 1)->f1 & SELECT)) { + else if (a < nu->pntsv - 1 && !((bp + nu->pntsu)->f1 & SELECT)) { /* if just single selected point then continue */ continue; } if (starta >= 0) { /* got selected segment, now check where and copy */ - if (starta <= 1 && a == nu->pntsu - 1) { + if (starta <= 1 && a == nu->pntsv - 1) { /* copying all points in spline */ - if (starta == 1 && enda != a) nu->flagu &= ~CU_NURB_CYCLIC; + if (starta == 1 && enda != a) nu->flagv &= ~CU_NURB_CYCLIC; starta = 0; enda = a; cut = enda - starta + 1; - - nu1 = ED_curve_nurbcpy(nu, cut); + nu1 = BKE_nurb_copy(nu, nu->pntsu, cut); } else if (starta == 0) { /* if start of curve copy next end point */ enda++; cut = enda - starta + 1; + bp1 = &nu->bp[nu->pntsv * nu->pntsu - nu->pntsu]; + bp2 = &nu->bp[nu->pntsv * nu->pntsu - (nu->pntsu * 2)]; - bp1 = &nu->bp[nu->pntsu - 1]; - bp2 = &nu->bp[nu->pntsu - 2]; - - if ((nu->flagu & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) { + if ((nu->flagv & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) { /* check if need to join start of spline to end */ - nu1 = ED_curve_nurbcpy(nu, cut + 1); - ED_curve_bpcpy(editnurb, &nu1->bp[1], nu->bp, cut); - starta = nu->pntsu - 1; + nu1 = BKE_nurb_copy(nu, nu->pntsu, cut + 1); + ED_curve_bpcpy(editnurb, &nu1->bp[nu->pntsu], nu->bp, cut * nu->pntsu); + starta = nu->pntsv - 1; cut = 1; } else { - nu1 = ED_curve_nurbcpy(nu, cut); - - if (nu->flagu & CU_NURB_CYCLIC) startnu = nu1; + if (nu->flagv & CU_NURB_CYCLIC) cyclicut = cut; + else nu1 = BKE_nurb_copy(nu, nu->pntsu, cut); } } - else if (enda == nu->pntsu - 1) { + else if (enda == nu->pntsv - 1) { /* if end of curve copy previous start point */ starta--; cut = enda - starta + 1; - bp1 = nu->bp; - bp2 = &nu->bp[1]; + bp2 = &nu->bp[nu->pntsu]; - if ((nu->flagu & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) { + if ((nu->flagv & CU_NURB_CYCLIC) && (bp1->f1 & SELECT) && (bp2->f1 & SELECT)) { /* check if need to join start of spline to end */ - nu1 = ED_curve_nurbcpy(nu, cut + 1); - ED_curve_bpcpy(editnurb, &nu1->bp[cut], nu->bp, 1); + nu1 = BKE_nurb_copy(nu, nu->pntsu, cut + 1); + ED_curve_bpcpy(editnurb, &nu1->bp[cut * nu->pntsu], nu->bp, nu->pntsu); } - else if (startnu != NULL) { - /* if startnu exists it is a cyclic spline, start and end should be connected */ - bp1 = (BPoint *)MEM_mallocN((cut + startnu->pntsu) * sizeof(BPoint), "delNurb4"); - ED_curve_bpcpy(editnurb, bp1, &nu->bp[starta], cut); - ED_curve_bpcpy(editnurb, &bp1[cut], nu->bp, startnu->pntsu); - - MEM_freeN(startnu->bp); - startnu->bp = bp1; - startnu->pntsu += cut; - - if (split) { - for (b = 0; b < startnu->pntsu; b++, bp1++) { - select_bpoint(bp1, DESELECT, SELECT, HIDDEN); - } - } - - BKE_nurb_order_clamp_u(startnu); - BKE_nurb_knot_calc_u(startnu); + else if (cyclicut != 0) { + /* if cyclicut exists it is a cyclic spline, start and end should be connected */ + nu1 = BKE_nurb_copy(nu, nu->pntsu, cut + cyclicut); + ED_curve_bpcpy(editnurb, &nu1->bp[cut * nu->pntsu], nu->bp, nu->pntsu * cyclicut); + cyclicut = 0; } else { - nu1 = ED_curve_nurbcpy(nu, cut); + nu1 = BKE_nurb_copy(nu, nu->pntsu, cut); } } else { @@ -6124,62 +6280,84 @@ static int curve_delete_selected(Object *obedit, eCurveElem_Types type, const bo starta--; enda++; cut = enda - starta + 1; - - nu1 = ED_curve_nurbcpy(nu, cut); + nu1 = BKE_nurb_copy(nu, nu->pntsu, cut); } if (nu1 != NULL) { - ED_curve_bpcpy(editnurb, nu1->bp, &nu->bp[starta], cut); - - if (starta != 0 || enda != nu->pntsu - 1) nu1->flagu &= ~CU_NURB_CYCLIC; - - if (split) { - /* deselect for split operator */ - for (b = 0, bp1 = nu1->bp; b < nu1->pntsu; b++, bp1++) { - select_bpoint(bp1, DESELECT, SELECT, HIDDEN); - } - } - + ED_curve_bpcpy(editnurb, nu1->bp, &nu->bp[starta * nu->pntsu], cut * nu->pntsu); BLI_addtail(&newnurb, nu1); - nu1->knotsu = NULL; - BKE_nurb_order_clamp_u(nu1); - BKE_nurb_knot_calc_u(nu1); + + if (starta != 0 || enda != nu->pntsv - 1) nu1->flagv &= ~CU_NURB_CYCLIC; nu1 = NULL; } starta = enda = -1; } } - if (!split && cut != -1 && nu->pntsu > 2 && !(nu->flagu & CU_NURB_CYCLIC)) { + if (!split && cut != -1 && nu->pntsv > 2 && !(nu->flagv & CU_NURB_CYCLIC)) { /* start and points copied if connecting segment was deleted and not cylic spline */ bp1 = nu->bp; - bp2 = &nu->bp[1]; + bp2 = &nu->bp[nu->pntsu]; + if ((bp1->f1 & SELECT) && (bp2->f1 & SELECT)) { - nu1 = ED_curve_nurbcpy(nu, 1); - ED_curve_bpcpy(editnurb, nu1->bp, bp1, 1); + nu1 = BKE_nurb_copy(nu, nu->pntsu, 1); + ED_curve_bpcpy(editnurb, nu1->bp, nu->bp, nu->pntsu); BLI_addtail(&newnurb, nu1); - nu1->knotsu = NULL; } - bp1 = &nu->bp[nu->pntsu - 1]; - bp2 = &nu->bp[nu->pntsu - 2]; + bp1 = &nu->bp[nu->pntsu * nu->pntsv - nu->pntsu]; + bp2 = &nu->bp[nu->pntsu * nu->pntsv - (nu->pntsu * 2)]; + if ((bp1->f1 & SELECT) && (bp2->f1 & SELECT)) { - nu1 = ED_curve_nurbcpy(nu, 1); - ED_curve_bpcpy(editnurb, nu1->bp, bp1, 1); + nu1 = BKE_nurb_copy(nu, nu->pntsu, 1); + ED_curve_bpcpy(editnurb, nu1->bp, &nu->bp[nu->pntsu * nu->pntsv - nu->pntsu], nu->pntsu); BLI_addtail(&newnurb, nu1); - nu1->knotsu = NULL; } } } + else { + /* selection not valid, just copy nurb to new list */ + nu1 = BKE_nurb_copy(nu, nu->pntsu, nu->pntsv); + ED_curve_bpcpy(editnurb, nu1->bp, nu->bp, nu->pntsu * nu->pntsv); + BLI_addtail(&newnurb, nu1); + } } - - BKE_nurbList_free(nubase); - BLI_movelisttolist(nubase, &newnurb); } - else { - BLI_assert(0); + + for (nu = newnurb.first; nu; nu = nu->next) { + if (nu->type == CU_BEZIER) { + if (split) { + /* deselect for split operator */ + for (b = 0, bezt1 = nu->bezt; b < nu->pntsu; b++, bezt1++) { + select_beztriple(bezt1, DESELECT, SELECT, true); + } + } + + BKE_nurb_handles_calc(nu); + } + else { + if (split) { + /* deselect for split operator */ + for (b = 0, bp1 = nu->bp; b < nu->pntsu * nu->pntsv; b++, bp1++) { + select_bpoint(bp1, DESELECT, SELECT, HIDDEN); + } + } + + nu->knotsu = nu->knotsv = NULL; + BKE_nurb_order_clamp_u(nu); + BKE_nurb_knot_calc_u(nu); + + if (nu->pntsv > 1) { + BKE_nurb_order_clamp_v(nu); + BKE_nurb_knot_calc_v(nu); + } + } } + keyIndex_delNurbList(editnurb, nubase); + BKE_nurbList_free(nubase); + BLI_movelisttolist(nubase, &newnurb); + return OPERATOR_FINISHED; } @@ -6187,7 +6365,11 @@ static int curve_delete_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); eCurveElem_Types type = RNA_enum_get(op->ptr, "type"); - int retval = curve_delete_selected(obedit, type, false); + int retval; + + if (type == CURVE_VERTEX) retval = curve_delete_vertices(obedit); + else if (type == CURVE_SEGMENT) retval = curve_delete_segments(obedit, false); + else BLI_assert(0); if (retval == OPERATOR_FINISHED) { if (ED_curve_updateAnimPaths(obedit->data)) WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); @@ -6210,23 +6392,14 @@ static EnumPropertyItem curve_delete_type_items[] = { static EnumPropertyItem *rna_curve_delete_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { - Object *obedit; EnumPropertyItem *item = NULL; int totitem = 0; - if (!C) /* needed for docs and i18n tools */ return curve_delete_type_items; - obedit = CTX_data_edit_object(C); - if (obedit->type == OB_SURF) { - RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_VERTEX); - } - else { - RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_VERTEX); - RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_SEGMENT); - } - + RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_VERTEX); + RNA_enum_items_add_value(&item, &totitem, curve_delete_type_items, CURVE_SEGMENT); RNA_enum_item_end(&item, &totitem); *free = true; @@ -6615,22 +6788,6 @@ void ED_curve_bpcpy(EditNurb *editnurb, BPoint *dst, BPoint *src, int count) keyIndex_updateBP(editnurb, src, dst, count); } -Nurb *ED_curve_nurbcpy(Nurb *src, int count) -{ - Nurb *newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "copyNurb"); - memcpy(newnu, src, sizeof(Nurb)); - newnu->pntsu = count; - - if (src->bezt) { - newnu->bezt = (BezTriple *)MEM_mallocN(count * sizeof(BezTriple), "copyNurb2"); - } - else { - newnu->bp = (BPoint *)MEM_mallocN(count * sizeof(BPoint), "copyNurb3"); - } - - return newnu; -} - int ED_curve_actSelection(Curve *cu, float center[3]) { Nurb *nu = get_lastsel_nurb(cu); diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 2cfbbbd516b..f1a2cd68f28 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -364,6 +364,8 @@ typedef enum eBezTriple_KeyframeType { /* mixed with KEY_LINEAR but define here since only curve supports */ #define KEY_CU_EASE 3 +/* indicates point has been seen during surface duplication */ +#define SURF_SEEN 4 #endif -- cgit v1.2.3 From 2871b0d7df5804e32e9ac4064ab2f29994b69b2d Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 17 Oct 2013 20:18:48 +0000 Subject: Fix #37110, After deletion of large scene, file still huge. Objects were not being freed when unlinked from all scenes, due to user count increments on the ParticleSystem->parent pointers. These were referencing the objects themselves, creating a user count of 1 and preventing free. Object pointers should not usually do user counting, except in some cases like scenes and groups (thanks to Brecht for clarifying this). --- source/blender/blenloader/intern/readfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2cc5aa33ab6..e6804725587 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3806,7 +3806,7 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase for (; pt; pt=pt->next) pt->ob=newlibadr(fd, id->lib, pt->ob); - psys->parent = newlibadr_us(fd, id->lib, psys->parent); + psys->parent = newlibadr(fd, id->lib, psys->parent); psys->target_ob = newlibadr(fd, id->lib, psys->target_ob); if (psys->clmd) { -- cgit v1.2.3 From bae2b9dea308ea50af24cbc47bd67ce6ea823c90 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 17 Oct 2013 21:17:33 +0000 Subject: Pampa Project request: FPS in sequencer editor perhaps ED_scene_draw_fps is actually better to be placed to a better place, but consider this is good for now. --- source/blender/editors/include/ED_view3d.h | 2 ++ source/blender/editors/space_sequencer/space_sequencer.c | 9 ++++++++- source/blender/editors/space_view3d/view3d_draw.c | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 86abf29c308..e504c858efa 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -328,6 +328,8 @@ float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float float ED_scene_grid_scale(struct Scene *scene, const char **grid_unit); float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit); +void ED_scene_draw_fps(struct Scene *scene, struct rcti *rect); + /* view matrix properties utilities */ /* unused */ #if 0 diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 84c6329db53..4a4754e8adc 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -54,6 +54,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "UI_interface.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -534,8 +535,9 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar) ScrArea *sa = CTX_wm_area(C); SpaceSeq *sseq = sa->spacedata.first; Scene *scene = CTX_data_scene(C); + wmWindowManager *wm = CTX_wm_manager(C); int show_split = scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW && sseq->mainb == SEQ_DRAW_IMG_IMBUF; - + /* XXX temp fix for wrong setting in sseq->mainb */ if (sseq->mainb == SEQ_DRAW_SEQUENCE) sseq->mainb = SEQ_DRAW_IMG_IMBUF; @@ -554,6 +556,11 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar) draw_image_seq(C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra, TRUE); } + if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_playing(wm)) { + rcti rect; + ED_region_visible_rect(ar, &rect); + ED_scene_draw_fps(scene, &rect); + } } static void sequencer_preview_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 24edfb413c8..a37d98e416d 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2857,7 +2857,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w /* NOTE: the info that this uses is updated in ED_refresh_viewport_fps(), * which currently gets called during SCREEN_OT_animation_step. */ -static void draw_viewport_fps(Scene *scene, rcti *rect) +void ED_scene_draw_fps(Scene *scene, rcti *rect) { ScreenFrameRateInfo *fpsi = scene->fps_info; float fps; @@ -3454,7 +3454,7 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_playing(wm)) { - draw_viewport_fps(scene, &rect); + ED_scene_draw_fps(scene, &rect); } else if (U.uiflag & USER_SHOW_VIEWPORTNAME) { draw_viewport_name(ar, v3d, &rect); -- cgit v1.2.3 From 9afddac7275843280cf820b665fd5a2d22e83958 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 18 Oct 2013 09:45:21 +0000 Subject: Fix for wrong active render layer after copying hr scene Also fix crash for files which could have been saved with wrong active render layer. --- source/blender/blenkernel/intern/scene.c | 1 + source/blender/editors/render/render_shading.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index cd8ceea0a97..2ad9080325c 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -157,6 +157,7 @@ Scene *BKE_scene_copy(Scene *sce, int type) lb = scen->r.layers; scen->r = sce->r; scen->r.layers = lb; + scen->r.actlay = 0; scen->unit = sce->unit; scen->physics_settings = sce->physics_settings; scen->gm = sce->gm; diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 553a543390f..3ef1f0db647 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -739,6 +739,10 @@ static int freestyle_active_lineset_poll(bContext *C) Scene *scene = CTX_data_scene(C); SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); + if (!srl) { + return FALSE; + } + return BKE_freestyle_lineset_get_active(&srl->freestyleConfig) != NULL; } -- cgit v1.2.3 From 38c16f9bf4b189227c2fa3805e1c570b35291116 Mon Sep 17 00:00:00 2001 From: Irie Shinsuke Date: Fri, 18 Oct 2013 10:43:54 +0000 Subject: Add debug prints to the PSD loader in imbuf. The error message can be obtained from OIIO by geterror(). --- .../blender/imbuf/intern/oiio/openimageio_api.cpp | 40 ++++++++++++++++------ 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index 838343dce35..1ee4ee00500 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -98,11 +98,17 @@ static ImBuf *imb_oiio_load_image(ImageInput *in, int width, int height, int com try { - in->read_image(TypeDesc::UINT8, - (uchar *)ibuf->rect + (height - 1) * scanlinesize, - AutoStride, - -scanlinesize, - AutoStride); + if (!in->read_image(TypeDesc::UINT8, + (uchar *)ibuf->rect + (height - 1) * scanlinesize, + AutoStride, + -scanlinesize, + AutoStride)) { + std::cerr << __func__ << ": ImageInput::read_image() failed:" << std::endl + << in->geterror() << std::endl; + if (ibuf) IMB_freeImBuf(ibuf); + + return NULL; + } } catch (const std::exception &exc) { @@ -128,11 +134,17 @@ static ImBuf *imb_oiio_load_image_float(ImageInput *in, int width, int height, i try { - in->read_image(TypeDesc::FLOAT, - (uchar *)ibuf->rect_float + (height - 1) * scanlinesize, - AutoStride, - -scanlinesize, - AutoStride); + if (!in->read_image(TypeDesc::FLOAT, + (uchar *)ibuf->rect_float + (height - 1) * scanlinesize, + AutoStride, + -scanlinesize, + AutoStride)) { + std::cerr << __func__ << ": ImageInput::read_image() failed:" << std::endl + << in->geterror() << std::endl; + if (ibuf) IMB_freeImBuf(ibuf); + + return NULL; + } } catch (const std::exception &exc) { @@ -191,12 +203,18 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); in = ImageInput::create(filename); - if (!in) return NULL; + if (!in) { + std::cerr << __func__ << ": ImageInput::create() failed:" << std::endl + << OpenImageIO::geterror() << std::endl; + return NULL; + } ImageSpec spec, config; config.attribute("oiio:UnassociatedAlpha", (int) 1); if (!in->open(filename, spec, config)) { + std::cerr << __func__ << ": ImageInput::open() failed:" << std::endl + << in->geterror() << std::endl; delete in; return NULL; } -- cgit v1.2.3 From a15818f1f7d3089d85d72a4196d0240d9f2f81d9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 18 Oct 2013 14:15:08 +0000 Subject: Tweak for action group -> bone select feature Set newly selected bone as "active", so that the transform properties show the correct values for the newly selected bone --- source/blender/editors/armature/pose_select.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index bbdf94e56cf..a53d8050c5d 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -75,13 +75,18 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select) return; arm = ob->data; + /* can only change selection state if bone can be modified */ if (PBONE_SELECTABLE(arm, pchan->bone)) { - /* change selection state */ - if (select) + /* change selection state - activate too if selected */ + if (select) { pchan->bone->flag |= BONE_SELECTED; - else + arm->act_bone = pchan->bone; + } + else { pchan->bone->flag &= ~BONE_SELECTED; + arm->act_bone = NULL; + } // TODO: select and activate corresponding vgroup? @@ -91,6 +96,9 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select) if (arm->flag & ARM_HAS_VIZ_DEPS) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } + + /* send necessary notifiers */ + WM_main_add_notifier(NC_GEOM | ND_DATA, ob); } } -- cgit v1.2.3 From 5a355c2b01a7b9688adcdd92637c9c06c2671b91 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 18 Oct 2013 15:03:18 +0000 Subject: Fix cycles hair segments not giving correct vector speed pass, the motion vector export was not implemented yet for this primitive. --- intern/cycles/blender/blender_curves.cpp | 69 ++++++++++++++++++++++++++------ intern/cycles/blender/blender_mesh.cpp | 6 ++- intern/cycles/blender/blender_sync.h | 2 +- intern/cycles/render/object.cpp | 4 +- 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp index 1cddc25a22b..06089d9eebe 100644 --- a/intern/cycles/blender/blender_curves.cpp +++ b/intern/cycles/blender/blender_curves.cpp @@ -628,6 +628,47 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData) } } +void ExportCurveSegmentsMotion(Scene *scene, Mesh *mesh, ParticleCurveData *CData, int motion) +{ + /* export motion vectors for curve keys */ + AttributeStandard std = (motion == -1)? ATTR_STD_MOTION_PRE: ATTR_STD_MOTION_POST; + Attribute *attr_motion = mesh->curve_attributes.add(std); + float3 *data_motion = attr_motion->data_float3(); + float3 *current_motion = data_motion; + size_t size = mesh->curve_keys.size(); + size_t i = 0; + bool have_motion = false; + + for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) { + if(CData->psys_curvenum[sys] == 0) + continue; + + for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) { + if(CData->curve_keynum[curve] <= 1) + continue; + + for(int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve]; curvekey++) { + if(i < mesh->curve_keys.size()) { + *current_motion = CData->curvekey_co[curvekey]; + + /* unlike mesh coordinates, these tend to be slightly different + * between frames due to particle transforms into/out of object + * space, so we use an epsilon to detect actual changes */ + if(len_squared(*current_motion - mesh->curve_keys[i].co) > 1e-5f*1e-5f) + have_motion = true; + + current_motion++; + } + + i++; + } + } + } + + if(i != size || !have_motion) + mesh->curve_attributes.remove(std); +} + void ExportCurveTriangleUV(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata) { if(uvdata == NULL) @@ -778,18 +819,21 @@ void BlenderSync::sync_curve_settings() } -void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool object_updated) +void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, int motion) { - /* Clear stored curve data */ - mesh->curve_keys.clear(); - mesh->curves.clear(); - mesh->curve_attributes.clear(); + if(!motion) { + /* Clear stored curve data */ + mesh->curve_keys.clear(); + mesh->curves.clear(); + mesh->curve_attributes.clear(); + } /* obtain general settings */ bool use_curves = scene->curve_system_manager->use_curves; if(!(use_curves && b_ob.mode() == b_ob.mode_OBJECT)) { - mesh->compute_bounds(); + if(!motion) + mesh->compute_bounds(); return; } @@ -829,13 +873,15 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool } } else { - ExportCurveSegments(scene, mesh, &CData); + if(motion) + ExportCurveSegmentsMotion(scene, mesh, &CData, motion); + else + ExportCurveSegments(scene, mesh, &CData); } - /* generated coordinates from first key. we should ideally get this from * blender to handle deforming objects */ - { + if(!motion) { if(mesh->need_attribute(scene, ATTR_STD_GENERATED)) { float3 loc, size; mesh_texture_space(b_mesh, loc, size); @@ -861,7 +907,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool } /* create vertex color attributes */ - { + if(!motion) { BL::Mesh::tessface_vertex_colors_iterator l; int vcol_num = 0; @@ -895,7 +941,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool } /* create UV attributes */ - { + if(!motion) { BL::Mesh::tessface_uv_textures_iterator l; int uv_num = 0; @@ -943,6 +989,5 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool mesh->compute_bounds(); } - CCL_NAMESPACE_END diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index f6c7319e210..e42af60c27b 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -488,7 +488,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri } if(render_layer.use_hair) - sync_curves(mesh, b_mesh, b_ob, object_updated); + sync_curves(mesh, b_mesh, b_ob, 0); /* free derived mesh */ b_data.meshes.remove(b_mesh); @@ -562,6 +562,10 @@ void BlenderSync::sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion) if(i != size || memcmp(M, &mesh->verts[0], sizeof(float3)*size) == 0) mesh->attributes.remove(std); + /* hair motion */ + if(render_layer.use_hair) + sync_curves(mesh, b_mesh, b_ob, motion); + /* free derived mesh */ b_data.meshes.remove(b_mesh); } diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 295b1fcee5c..3d2a3ae5aac 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -81,7 +81,7 @@ private: void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree); Mesh *sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tris); - void sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool object_updated); + void sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, int motion); Object *sync_object(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::DupliObject b_dupli_object, Transform& tfm, uint layer_flag, int motion, bool hide_tris); void sync_light(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::Object b_ob, Transform& tfm); void sync_background_light(); diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index 0479dd9af74..6fb96a3290c 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -253,9 +253,9 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene Transform mtfm_pre = ob->motion.pre; Transform mtfm_post = ob->motion.post; - if(!mesh->attributes.find(ATTR_STD_MOTION_PRE)) + if(!(mesh->attributes.find(ATTR_STD_MOTION_PRE) || mesh->curve_attributes.find(ATTR_STD_MOTION_PRE))) mtfm_pre = mtfm_pre * itfm; - if(!mesh->attributes.find(ATTR_STD_MOTION_POST)) + if(!(mesh->attributes.find(ATTR_STD_MOTION_POST) || mesh->curve_attributes.find(ATTR_STD_MOTION_POST))) mtfm_post = mtfm_post * itfm; memcpy(&objects_vector[i*OBJECT_VECTOR_SIZE+0], &mtfm_pre, sizeof(float4)*3); -- cgit v1.2.3 From 598239eb51445d198047cc0bad57fb930aa87928 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 18 Oct 2013 15:30:38 +0000 Subject: Make strict compiler flags happy --- intern/cycles/blender/blender_curves.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp index 06089d9eebe..b780877a158 100644 --- a/intern/cycles/blender/blender_curves.cpp +++ b/intern/cycles/blender/blender_curves.cpp @@ -628,7 +628,7 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData) } } -void ExportCurveSegmentsMotion(Scene *scene, Mesh *mesh, ParticleCurveData *CData, int motion) +static void ExportCurveSegmentsMotion(Scene *scene, Mesh *mesh, ParticleCurveData *CData, int motion) { /* export motion vectors for curve keys */ AttributeStandard std = (motion == -1)? ATTR_STD_MOTION_PRE: ATTR_STD_MOTION_POST; -- cgit v1.2.3 From 596982fe67a4cf284a92db2436251c6fd33420a2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 18 Oct 2013 17:35:20 +0000 Subject: ID blocks can be pasted to text editor now with mouse drag and move --- source/blender/editors/space_text/space_text.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index bd85551f8b1..a0659d5ce62 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -472,13 +472,26 @@ static void text_drop_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "filepath", drag->path); } +static int text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) +{ + if (drag->type == WM_DRAG_ID) + return TRUE; + + return FALSE; +} + +static void text_drop_paste(wmDrag *drag, wmDropBox *drop) +{ + RNA_string_set(drop->ptr, "text", ((ID*)drag->poin)->name + 2); +} + /* this region dropbox definition */ static void text_dropboxes(void) { ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW); WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy); - + WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste); } /* ************* end drop *********** */ -- cgit v1.2.3 From 451607630edd2d1b1ef86bac2f62baa162546078 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 18 Oct 2013 20:11:07 +0000 Subject: Fix #37134: cycles viewport not displaying correct with multi GPU render and graphics card that does not support CUDA OpenGL interop. --- intern/cycles/device/device.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index eb262a907a4..5c771aa1c8b 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -64,11 +64,16 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w glColor3f(1.0f, 1.0f, 1.0f); if(rgba.data_type == TYPE_HALF) { + /* for multi devices, this assumes the ineffecient method that we allocate + * all pixels on the device even though we only render to a subset */ + GLhalf *data_pointer = (GLhalf*)rgba.data_pointer; + data_pointer += 4*y*w; + /* draw half float texture, GLSL shader for display transform assumed to be bound */ GLuint texid; glGenTextures(1, &texid); glBindTexture(GL_TEXTURE_2D, texid); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, w, h, 0, GL_RGBA, GL_HALF_FLOAT, (void*)rgba.data_pointer); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, w, h, 0, GL_RGBA, GL_HALF_FLOAT, data_pointer); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); -- cgit v1.2.3 From fc8b0ed5e572d0e3e0ee68f5e0b2e7060acfa2cf Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 18 Oct 2013 23:38:51 +0000 Subject: Move utility functions from mball to mathutils --- source/blender/blenkernel/intern/mball.c | 16 ---------------- source/blender/blenlib/BLI_math_matrix.h | 2 ++ source/blender/blenlib/BLI_math_vector.h | 2 ++ source/blender/blenlib/intern/math_matrix.c | 6 ++++++ source/blender/blenlib/intern/math_vector_inline.c | 8 ++++++++ 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index a4b59153e2b..83c257dbd56 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1637,22 +1637,6 @@ static void polygonize(PROCESS *process, MetaBall *mb) } } -/* could move to math api */ -BLI_INLINE void copy_v3_fl3(float v[3], float x, float y, float z) -{ - v[0] = x; - v[1] = y; - v[2] = z; -} - -/* TODO(sergey): Perhaps it could be general utility function in mathutils. */ -static bool has_zero_axis_m4(float matrix[4][4]) -{ - return len_squared_v3(matrix[0]) < FLT_EPSILON || - len_squared_v3(matrix[1]) < FLT_EPSILON || - len_squared_v3(matrix[2]) < FLT_EPSILON; -} - static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return totsize */ { Scene *sce_iter = scene; diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index b04af44156f..7db2227dfaf 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -160,6 +160,8 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A[4][4]); void pseudoinverse_m4_m4(float Ainv[4][4], float A[4][4], float epsilon); void pseudoinverse_m3_m3(float Ainv[3][3], float A[3][3], float epsilon); +bool has_zero_axis_m4(float matrix[4][4]); + /****************************** Transformations ******************************/ void scale_m3_fl(float R[3][3], float scale); diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 675ba88fc72..7576fbe2b54 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -82,6 +82,8 @@ MINLINE void copy_v4fl_v4db(float r[4], const double a[4]); MINLINE void copy_v2db_v2fl(double r[2], const float a[2]); MINLINE void copy_v3db_v3fl(double r[3], const float a[3]); MINLINE void copy_v4db_v4fl(double r[4], const float a[4]); +/* 3 float -> vec */ +MINLINE void copy_v3_fl3(float v[3], float x, float y, float z); /********************************* Arithmetic ********************************/ diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index d24200fc0b7..6b96f0515b9 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -2070,3 +2070,9 @@ void pseudoinverse_m3_m3(float Ainv[3][3], float A[3][3], float epsilon) } } +bool has_zero_axis_m4(float matrix[4][4]) +{ + return len_squared_v3(matrix[0]) < FLT_EPSILON || + len_squared_v3(matrix[1]) < FLT_EPSILON || + len_squared_v3(matrix[2]) < FLT_EPSILON; +} diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index ce5d9657c7f..b479b06da3f 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -235,6 +235,14 @@ MINLINE void swap_v4_v4(float a[4], float b[4]) SWAP(float, a[3], b[3]); } +/* 3 float -> vec */ +MINLINE void copy_v3_fl3(float v[3], float x, float y, float z) +{ + v[0] = x; + v[1] = y; + v[2] = z; +} + /********************************* Arithmetic ********************************/ MINLINE void add_v2_fl(float r[2], float f) -- cgit v1.2.3 From 3887d333744e1a0c3b42b8a229af814e0b25d9ec Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 18 Oct 2013 23:41:11 +0000 Subject: Remove paranoid check which was marked as unneeded for a while already --- source/blender/blenkernel/intern/scene.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 2ad9080325c..d4618e28191 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1502,16 +1502,6 @@ void BKE_scene_disable_color_management(Scene *scene) int BKE_scene_check_color_management_enabled(const Scene *scene) { - /* TODO(sergey): shouldn't be needed. but we're currently far to close to the release, - * so better be extra-safe than sorry. - * - * Will remove the check after the release. - */ - if (!scene) { - BLI_assert(!"Shouldn't happen!"); - return TRUE; - } - return strcmp(scene->display_settings.display_device, "None") != 0; } -- cgit v1.2.3 From 4ecfb215e2af8ab824eb634915da2fc8ec54db98 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 18 Oct 2013 23:44:25 +0000 Subject: Fix: ensure cycles mist pass stays in range 0..1, it could have values out of this range due to sampling noise. Side note: I looked into the mist pass because it was apparently not calculating mist correctly on characters with transparent hair. Turns out this is just sampling noise that goes away with more samples. This noise is because the ray will randomly go to the next transparency layer or get reflected, the path tracing integrator will not branch the path and only pick one of the two directions each time. Branched path tracing however will shade all transparent layers for each AA sample, which means this source of noise is eliminated. --- intern/cycles/render/buffers.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index 5fb648cec5f..44a050ca530 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -184,6 +184,12 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int pixels[0] = (f == 0.0f)? 1e10f: f*scale_exposure; } } + else if(type == PASS_MIST) { + for(int i = 0; i < size; i++, in += pass_stride, pixels++) { + float f = *in; + pixels[0] = clamp(f*scale_exposure, 0.0f, 1.0f); + } + } else { for(int i = 0; i < size; i++, in += pass_stride, pixels++) { float f = *in; -- cgit v1.2.3 From e401fef6b7a3e6d5301a7a4e21e66f3fb53f9982 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 19 Oct 2013 13:39:27 +0000 Subject: Fix [#37146] Dopesheet / Graph editor, select columns between markers doesn't appear to work. Init min/max values were just switched... --- source/blender/editors/animation/anim_markers.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 34246427b7e..8a9f4559140 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -211,8 +211,9 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la TimeMarker *fm = markers->first; TimeMarker *lm = markers->last; - min = (float)fm->frame; - max = (float)lm->frame; + /* Store last marker in min, and first marker in max, so that later real value calc actually works! [#37146]. */ + min = (float)lm->frame; + max = (float)fm->frame; } else { *first = 0.0f; -- cgit v1.2.3 From e783611098550856bd1883e44690552fe1f1326e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 19 Oct 2013 13:48:51 +0000 Subject: Arg! Fix another bug in split normal core algorithm (some flat faces were ignored, depending on the order of evaluation)... :/ --- source/blender/blenkernel/intern/mesh_evaluate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index 47b8e053bf7..007a852dee5 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -379,7 +379,8 @@ void BKE_mesh_normals_loop_split(MVert *mverts, const int UNUSED(numVerts), MEdg if ((e2l[0] | e2l[1]) == 0) { /* 'Empty' edge until now, set e2l[0] (and e2l[1] to INDEX_UNSET to tag it as unset). */ e2l[0] = ml_curr_index; - e2l[1] = INDEX_UNSET; + /* We have to check this here too, else we might miss some flat faces!!! */ + e2l[1] = (mp->flag & ME_SMOOTH) ? INDEX_UNSET : INDEX_INVALID; } else if (e2l[1] == INDEX_UNSET) { /* Second loop using this edge, time to test its sharpness. -- cgit v1.2.3 From 4edffbf54fad68f8be051c76343573deb20fce5c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 19 Oct 2013 14:28:32 +0000 Subject: More complete handling of printf formatting in msgid/msgstr checks. (That commit, r60813, should never have been done to 2.69 branch, will revert it there, sorry :/ ). --- release/scripts/modules/bl_i18n_utils/settings.py | 10 ++++++++++ release/scripts/modules/bl_i18n_utils/utils.py | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index e40b067f552..dba5099607c 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -257,6 +257,16 @@ PYGETTEXT_KEYWORDS = (() + for it in ("BLF_I18N_MSGID_MULTI_CTXT",)) ) +# Check printf mismatches between msgid and msgstr. +CHECK_PRINTF_FORMAT = ( + r"(?!<%)(?:%%)*%" # Begining, with handling for crazy things like '%%%%%s' + r"[-+#0]?" # Flags (note: do not add the ' ' (space) flag here, generates too much false positives!) + r"(?:\*|[0-9]+)?" # Width + r"(?:\.(?:\*|[0-9]+))?" # Precision + r"(?:[hljztL]|hh|ll)?" # Length + r"[tldiuoxXfFeEgGaAcspn]" # Specifiers (note we have Blender-specific %t and %l ones too) +) + # Should po parser warn when finding a first letter not capitalized? WARN_MSGID_NOT_CAPITALIZED = True diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index bef7de00126..feefd14fd28 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -446,10 +446,10 @@ class I18nMessages: """ ret = [] default_context = self.settings.DEFAULT_CONTEXT - _format = re.compile("%[.0-9]*[tslfd]").findall + _format = re.compile(self.settings.CHECK_PRINTF_FORMAT).findall done_keys = set() - tmp = {} rem = set() + tmp = {} for key, msg in self.msgs.items(): msgctxt, msgid, msgstr = msg.msgctxt, msg.msgid, msg.msgstr real_key = (msgctxt or default_context, msgid) @@ -464,7 +464,7 @@ class I18nMessages: done_keys.add(key) if '%' in msgid and msgstr and _format(msgid) != _format(msgstr): if not msg.is_fuzzy: - ret.append("Error! msg's format entities are not matched in msgid and msgstr ({} / {})" + ret.append("Error! msg's format entities are not matched in msgid and msgstr ({} / \"{}\")" "".format(real_key, msgstr)) if fix: msg.msgstr = "" -- cgit v1.2.3 From 1c675034c1a5439cc515b273f1b5f233749fb407 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Sat, 19 Oct 2013 16:51:35 +0000 Subject: Compositor: did some inner loop optimizations of the fast gaussian blur. - At Mind - --- .../operations/COM_FastGaussianBlurOperation.cpp | 50 ++++++++++++++-------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 9231261986d..d0c3d1b25ab 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -82,8 +82,8 @@ void FastGaussianBlurOperation::deinitExecution() void *FastGaussianBlurOperation::initializeTileData(rcti *rect) { lockMutex(); - if (!this->m_iirgaus) { - MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect); + if (!this->m_iirgaus) { + MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect); MemoryBuffer *copy = newBuf->duplicate(); updateSize(); @@ -194,25 +194,41 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf"); Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf"); W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf"); - if (xy & 1) { // H + if (xy & 1) { // H + int offset; for (y = 0; y < src_height; ++y) { - const int yx = y * src_width; - for (x = 0; x < src_width; ++x) - X[x] = buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan]; + const int yx = y * src_width; + offset = yx*COM_NUMBER_OF_CHANNELS + chan; + for (x = 0; x < src_width; ++x) { + X[x] = buffer[offset]; + offset += COM_NUMBER_OF_CHANNELS; + } YVV(src_width); - for (x = 0; x < src_width; ++x) - buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan] = Y[x]; - } + offset = yx*COM_NUMBER_OF_CHANNELS + chan; + for (x = 0; x < src_width; ++x) { + buffer[offset] = Y[x]; + offset += COM_NUMBER_OF_CHANNELS; + } + } } - if (xy & 2) { // V - for (x = 0; x < src_width; ++x) { - for (y = 0; y < src_height; ++y) - X[y] = buffer[(x + y * src_width) * COM_NUMBER_OF_CHANNELS + chan]; + if (xy & 2) { // V + int offset; + const int add = src_width * COM_NUMBER_OF_CHANNELS; + + for (x = 0; x < src_width; ++x) { + offset = x * COM_NUMBER_OF_CHANNELS + chan; + for (y = 0; y < src_height; ++y) { + X[y] = buffer[offset]; + offset += add; + } YVV(src_height); - for (y = 0; y < src_height; ++y) - buffer[(x + y * src_width) * COM_NUMBER_OF_CHANNELS + chan] = Y[y]; - } - } + offset = x * COM_NUMBER_OF_CHANNELS + chan; + for (y = 0; y < src_height; ++y) { + buffer[offset] = Y[y]; + offset += add; + } + } + } MEM_freeN(X); MEM_freeN(W); -- cgit v1.2.3 From 0410eff30606473ab106f49cca8a83abf599dacf Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Sat, 19 Oct 2013 17:45:58 +0000 Subject: Applied patch [#34178] tile rendering for fast gaussian blur Thanks to David M (erwin94) only added some comments. https://projects.blender.org/tracker/?func=detail&aid=34178&group_id=9&atid=127 --- source/blender/compositor/nodes/COM_BlurNode.cpp | 1 + .../operations/COM_FastGaussianBlurOperation.cpp | 118 ++++++++++++++++++--- .../operations/COM_FastGaussianBlurOperation.h | 7 +- 3 files changed, 112 insertions(+), 14 deletions(-) diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp index b59a92710bc..a8de2aed526 100644 --- a/source/blender/compositor/nodes/COM_BlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BlurNode.cpp @@ -53,6 +53,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co if (data->filtertype == R_FILTER_FAST_GAUSS) { FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation(); operationfgb->setData(data); + operationfgb->setChunksize(context->getChunksize()); operationfgb->setbNode(editorNode); this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), 1, graph); graph->addOperation(operationfgb); diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index d0c3d1b25ab..aec1e1387c3 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -29,6 +29,7 @@ FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { this->m_iirgaus = NULL; + this->m_chunksize = 256; } void FastGaussianBlurOperation::executePixel(float output[4], int x, int y, void *data) @@ -37,22 +38,56 @@ void FastGaussianBlurOperation::executePixel(float output[4], int x, int y, void newData->read(output, x, y); } +// Calculate the depending area of interest. This depends on the +// size of the blur operation; if the blur is large it is faster +// to just calculate the whole image at once. +// Returns true if the area is just a tile and false if it is +// the whole image. +bool FastGaussianBlurOperation::getDAI(rcti *rect, rcti *output) +{ + // m_data->sizex * m_size should be enough? For some reason there + // seem to be errors in the boundary between tiles. + int sx = this->m_data->sizex * this->m_size * 2; + if (sx < 1) + sx = 1; + int sy = this->m_data->sizey * this->m_size * 2; + if (sy < 1) + sy = 1; + + if (sx >= this->m_chunksize || sy >= this->m_chunksize) { + output->xmin = 0; + output->xmax = this->getWidth(); + output->ymin = 0; + output->ymax = this->getHeight(); + return false; + } + else { + output->xmin = rect->xmin - sx - 1; + output->xmax = rect->xmax + sx + 1; + output->ymin = rect->ymin - sy - 1; + output->ymax = rect->ymax + sy + 1; + return true; + } +} + bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - rcti sizeInput; - sizeInput.xmin = 0; - sizeInput.ymin = 0; - sizeInput.xmax = 5; - sizeInput.ymax = 5; - NodeOperation *operation = this->getInputOperation(1); - if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { - return true; + if (!this->m_sizeavailable) { + rcti sizeInput; + sizeInput.xmin = 0; + sizeInput.ymin = 0; + sizeInput.xmax = 5; + sizeInput.ymax = 5; + NodeOperation *operation = this->getInputOperation(1); + if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { + return true; + } } - else { - if (this->m_iirgaus) { - return false; + { + if (this->m_sizeavailable) { + getDAI(input, &newInput); } else { newInput.xmin = 0; @@ -81,7 +116,7 @@ void FastGaussianBlurOperation::deinitExecution() void *FastGaussianBlurOperation::initializeTileData(rcti *rect) { - lockMutex(); +/* lockMutex(); if (!this->m_iirgaus) { MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect); MemoryBuffer *copy = newBuf->duplicate(); @@ -109,8 +144,67 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect) } unlockMutex(); return this->m_iirgaus; +}*/ + + lockMutex(); + if (this->m_iirgaus) { + // if this->m_iirgaus is set, we don't do tile rendering, so + // we can return the already calculated cache + unlockMutex(); + return this->m_iirgaus; + } + updateSize(); + rcti dai; + bool use_tiles = getDAI(rect, &dai); + if (use_tiles) { + unlockMutex(); + } + + MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL); + rcti *buf_rect = buffer->getRect(); + + dai.xmin = max(dai.xmin, buf_rect->xmin); + dai.xmax = min(dai.xmax, buf_rect->xmax); + dai.ymin = max(dai.ymin, buf_rect->ymin); + dai.ymax = min(dai.ymax, buf_rect->ymax); + + MemoryBuffer *tile = new MemoryBuffer(NULL, &dai); + tile->copyContentFrom(buffer); + + int c; + float sx = this->m_data->sizex * this->m_size / 2.0f; + float sy = this->m_data->sizey * this->m_size / 2.0f; + + if ((sx == sy) && (sx > 0.f)) { + for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) + IIR_gauss(tile, sx, c, 3); + } + else { + if (sx > 0.0f) { + for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) + IIR_gauss(tile, sx, c, 1); + } + if (sy > 0.0f) { + for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) + IIR_gauss(tile, sy, c, 2); + } + } + if (!use_tiles) { + this->m_iirgaus = tile; + unlockMutex(); + } + return tile; } +void FastGaussianBlurOperation::deinitializeTileData(rcti *rect, void *data) +{ + if (!this->m_iirgaus && data) { + MemoryBuffer *tile = (MemoryBuffer *)data; + delete tile; + } +} + + void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsigned int chan, unsigned int xy) { double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3]; diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h index 58bf1d4f596..e12d437b43e 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h @@ -28,16 +28,19 @@ class FastGaussianBlurOperation : public BlurBaseOperation { private: - float m_sx; - float m_sy; MemoryBuffer *m_iirgaus; + int m_chunksize; + public: FastGaussianBlurOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void executePixel(float output[4], int x, int y, void *data); + void setChunksize(int size) { this->m_chunksize = size; } static void IIR_gauss(MemoryBuffer *src, float sigma, unsigned int channel, unsigned int xy); + bool getDAI(rcti *rect, rcti *output); void *initializeTileData(rcti *rect); + void deinitializeTileData(rcti *rect, void *data); void deinitExecution(); void initExecution(); }; -- cgit v1.2.3 From 8f22c120f52fa6c9868eefa6561d06e984a86535 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 19 Oct 2013 21:20:50 +0000 Subject: fix [#37145] "Triangulate Face" crash in specific scene it was asserting if the last edge faces were already all set --- source/blender/bmesh/intern/bmesh_polygon.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 46810f4dc8c..8a3abcb9b5e 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -974,26 +974,25 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, BLI_assert(ok); - if (i == edge_array_len - 1) { - if (FACE_USED_TEST(f_a) == false) { + if (FACE_USED_TEST(f_a) == false) { + FACE_USED_SET(f_a); + + if (nf_i < edge_array_len) { + r_faces_new[nf_i++] = f_a; + } else { f_new = f_a; - } - else if (FACE_USED_TEST(f_b) == false) { - f_new = f_b; - } - else { - BLI_assert(false); + break; } } - else { - if (FACE_USED_TEST(f_a) == false) { - FACE_USED_SET(f_a); - r_faces_new[nf_i++] = f_a; - } - if (FACE_USED_TEST(f_b) == false) { - FACE_USED_SET(f_b); + if (FACE_USED_TEST(f_b) == false) { + FACE_USED_SET(f_b); + + if (nf_i < edge_array_len) { r_faces_new[nf_i++] = f_b; + } else { + f_new = f_b; + break; } } } -- cgit v1.2.3 From 4f6dd555b7254efe9e8aa58481469eca74768c79 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 20 Oct 2013 00:12:54 +0000 Subject: Fix for wrong implementation of mmap in lock-free allocator - Freeing was not using proper block length - Duplicating memory block was not aware of mmaped blocks. --- intern/guardedalloc/intern/mallocn_lockfree_impl.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.c b/intern/guardedalloc/intern/mallocn_lockfree_impl.c index 35caebcc5e8..44f51a34134 100644 --- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c +++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c @@ -61,6 +61,7 @@ static void (*thread_unlock_callback)(void) = NULL; #define MEMHEAD_FROM_PTR(ptr) (((MemHead*) vmemh) - 1) #define PTR_FROM_MEMHEAD(memhead) (memhead + 1) +#define MEMHEAD_IS_MMAP(memhead) ((memhead)->len & (size_t) 1) #ifdef __GNUC__ __attribute__ ((format(printf, 1, 2))) @@ -112,13 +113,13 @@ void MEM_lockfree_freeN(void *vmemh) atomic_sub_u(&totblock, 1); atomic_sub_z(&mem_in_use, len); - if (memh->len & (size_t) 1) { + if (MEMHEAD_IS_MMAP(memh)) { atomic_sub_z(&mmap_in_use, len); #if defined(WIN32) /* our windows mmap implementation is not thread safe */ mem_lock_thread(); #endif - if (munmap(memh, memh->len + sizeof(MemHead))) + if (munmap(memh, len + sizeof(MemHead))) printf("Couldn't unmap memory\n"); #if defined(WIN32) mem_unlock_thread(); @@ -136,8 +137,14 @@ void *MEM_lockfree_dupallocN(const void *vmemh) { void *newp = NULL; if (vmemh) { + MemHead *memh = MEMHEAD_FROM_PTR(vmemh); const size_t prev_size = MEM_allocN_len(vmemh); - newp = MEM_lockfree_mallocN(prev_size, "dupli_malloc"); + if (MEMHEAD_IS_MMAP(memh)) { + newp = MEM_lockfree_mapallocN(prev_size, "dupli_mapalloc"); + } + else { + newp = MEM_lockfree_mallocN(prev_size, "dupli_malloc"); + } memcpy(newp, vmemh, prev_size); } return newp; -- cgit v1.2.3 From 3718c048447a0fd596cafb4e1d619d0c8273e6f4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 20 Oct 2013 01:09:25 +0000 Subject: Fix compositor rendering scenes multiple times in some cases Issue was caused by Blender Internal changing LIB_DOIT flag for scene when it gets updated for new frame. This leads into conflict with flag used for tagging scenes fr render, For now made it so nodes are being tagged instead of scene. Only none node from those who're sharing the scene will be tagged. And rendering scenes for node tree now checks for node flag instead of scene's datablock one. Ideally this tag would be replaced with scenes stored in an array, but then it's not so clear how to check which node to update. --- source/blender/render/intern/source/pipeline.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index fa05f8dd18d..9930a8f7f61 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1600,6 +1600,7 @@ static void tag_scenes_for_render(Render *re) /* check for render-layers nodes using other scenes, we tag them LIB_DOIT */ for (node = re->scene->nodetree->nodes.first; node; node = node->next) { + node->flag &= ~NODE_TEST; if (node->type == CMP_NODE_R_LAYERS) { if (node->id) { if (!MAIN_VERSION_ATLEAST(re->main, 265, 5)) { @@ -1617,8 +1618,12 @@ static void tag_scenes_for_render(Render *re) } } - if (node->id != (ID *)re->scene) - node->id->flag |= LIB_DOIT; + if (node->id != (ID *)re->scene) { + if ((node->id->flag & LIB_DOIT) == 0) { + node->flag |= NODE_TEST; + node->id->flag |= LIB_DOIT; + } + } } } } @@ -1640,12 +1645,12 @@ static void ntree_render_scenes(Render *re) for (node = re->scene->nodetree->nodes.first; node; node = node->next) { if (node->type == CMP_NODE_R_LAYERS) { if (node->id && node->id != (ID *)re->scene) { - if (node->id->flag & LIB_DOIT) { + if (node->flag & NODE_TEST) { Scene *scene = (Scene *)node->id; render_scene(re, scene, cfra); restore_scene = (scene != re->scene); - node->id->flag &= ~LIB_DOIT; + node->flag &= ~NODE_TEST; nodeUpdate(re->scene->nodetree, node); } -- cgit v1.2.3 From 30a2d7fe8572791947f5fe3b94b9735bfab83166 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 20 Oct 2013 10:13:19 +0000 Subject: Fix #37153: Bool union of 2 planes makes Blender 2.69 RC2 hang Fix deadlock in Carve when rescaling to zero scale. basically, scaling to zero scale is not what we want :) Boolean result could still be unpredictable coz plane is not a closed manifold. --- intern/bsp/intern/BOP_CarveInterface.cpp | 63 ++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/intern/bsp/intern/BOP_CarveInterface.cpp b/intern/bsp/intern/BOP_CarveInterface.cpp index bb3a783548c..a96196ee8f5 100644 --- a/intern/bsp/intern/BOP_CarveInterface.cpp +++ b/intern/bsp/intern/BOP_CarveInterface.cpp @@ -711,6 +711,47 @@ static BSP_CSGMesh *Carve_exportMesh(MeshSet<3>* &poly, carve::interpolate::Face return outputMesh; } +static void meshSetMinMax(const MeshSet<3> *mesh, + carve::geom3d::Vector *min, + carve::geom3d::Vector *max) +{ + for (uint i = 0; i < mesh->vertex_storage.size(); ++i) { + min->x = MIN(min->x, mesh->vertex_storage[i].v.x); + min->y = MIN(min->y, mesh->vertex_storage[i].v.y); + min->z = MIN(min->z, mesh->vertex_storage[i].v.z); + max->x = MAX(max->x, mesh->vertex_storage[i].v.x); + max->y = MAX(max->y, mesh->vertex_storage[i].v.y); + max->z = MAX(max->z, mesh->vertex_storage[i].v.z); + } +} + +static void getRescaleMinMax(const MeshSet<3> *left, + const MeshSet<3> *right, + carve::geom3d::Vector *min, + carve::geom3d::Vector *max) +{ + min->x = max->x = left->vertex_storage[0].v.x; + min->y = max->y = left->vertex_storage[0].v.y; + min->z = max->z = left->vertex_storage[0].v.z; + + meshSetMinMax(left, min, max); + meshSetMinMax(right, min, max); + + // Make sure we don't scale object with zer oscale + if ((min->x - max->x) < DBL_EPSILON) { + min->x = -1.0; + max->x = 1.0; + } + if ((min->y - max->y) < DBL_EPSILON) { + min->y = -1.0; + max->y = 1.0; + } + if ((min->z - max->z) < DBL_EPSILON) { + min->z = -1.0; + max->z = 1.0; + } +} + /** * Performs a generic booleam operation, the entry point for external modules. * @param opType Boolean operation type BOP_INTERSECTION, BOP_UNION, BOP_DIFFERENCE @@ -753,29 +794,11 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType, left = Carve_addMesh(obAFaces, obAVertices, oface_num, num_origfaces ); right = Carve_addMesh(obBFaces, obBVertices, oface_num, num_origfaces ); - min.x = max.x = left->vertex_storage[0].v.x; - min.y = max.y = left->vertex_storage[0].v.y; - min.z = max.z = left->vertex_storage[0].v.z; - for (uint i = 1; i < left->vertex_storage.size(); ++i) { - min.x = MIN(min.x,left->vertex_storage[i].v.x); - min.y = MIN(min.y,left->vertex_storage[i].v.y); - min.z = MIN(min.z,left->vertex_storage[i].v.z); - max.x = MAX(max.x,left->vertex_storage[i].v.x); - max.y = MAX(max.y,left->vertex_storage[i].v.y); - max.z = MAX(max.z,left->vertex_storage[i].v.z); - } - for (uint i = 0; i < right->vertex_storage.size(); ++i) { - min.x = MIN(min.x,right->vertex_storage[i].v.x); - min.y = MIN(min.y,right->vertex_storage[i].v.y); - min.z = MIN(min.z,right->vertex_storage[i].v.z); - max.x = MAX(max.x,right->vertex_storage[i].v.x); - max.y = MAX(max.y,right->vertex_storage[i].v.y); - max.z = MAX(max.z,right->vertex_storage[i].v.z); - } + getRescaleMinMax(left, right, &min, &max); carve::rescale::rescale scaler(min.x, min.y, min.z, max.x, max.y, max.z); carve::rescale::fwd fwd_r(scaler); - carve::rescale::rev rev_r(scaler); + carve::rescale::rev rev_r(scaler); left->transform(fwd_r); right->transform(fwd_r); -- cgit v1.2.3 From e9d5e9813c5cce45f14bb25bb82f2e88f5688351 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 20 Oct 2013 12:08:51 +0000 Subject: Code cleanup: added generic function copt_m3_m3d --- source/blender/blenkernel/intern/tracking.c | 21 ++------------------- source/blender/blenlib/BLI_math_matrix.h | 3 +++ source/blender/blenlib/intern/math_matrix.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index c7fea98d7cf..3c2eca1a157 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -3263,23 +3263,6 @@ static int point_markers_correspondences_on_both_image(MovieTrackingPlaneTrack * return correspondence_index; } -/* TODO(sergey): Make it generic function available for everyone. */ -BLI_INLINE void mat3f_from_mat3d(float mat_float[3][3], double mat_double[3][3]) -{ - /* Keep it stupid simple for better data flow in CPU. */ - mat_float[0][0] = mat_double[0][0]; - mat_float[0][1] = mat_double[0][1]; - mat_float[0][2] = mat_double[0][2]; - - mat_float[1][0] = mat_double[1][0]; - mat_float[1][1] = mat_double[1][1]; - mat_float[1][2] = mat_double[1][2]; - - mat_float[2][0] = mat_double[2][0]; - mat_float[2][1] = mat_double[2][1]; - mat_float[2][2] = mat_double[2][2]; -} - /* NOTE: frame number should be in clip space, not scene space */ static void track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_track, int start_frame, int direction, bool retrack) @@ -3341,7 +3324,7 @@ static void track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_trac libmv_homography2DFromCorrespondencesEuc(x1, x2, num_correspondences, H_double); - mat3f_from_mat3d(H, H_double); + copt_m3_m3d(H, H_double); for (i = 0; i < 4; i++) { float vec[3] = {0.0f, 0.0f, 1.0f}, vec2[3]; @@ -3445,7 +3428,7 @@ void BKE_tracking_homography_between_two_quads(/*const*/ float reference_corners libmv_homography2DFromCorrespondencesEuc(x1, x2, 4, H_double); - mat3f_from_mat3d(H, H_double); + copt_m3_m3d(H, H_double); } /*********************** Camera solving *************************/ diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 7db2227dfaf..cb0d95301fb 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -60,6 +60,9 @@ void copy_m4_m4(float R[4][4], float A[4][4]); void copy_m3_m4(float R[3][3], float A[4][4]); void copy_m4_m3(float R[4][4], float A[3][3]); +/* double->float */ +void copt_m3_m3d(float R[3][3], double A[3][3]); + void swap_m3m3(float A[3][3], float B[3][3]); void swap_m4m4(float A[4][4], float B[4][4]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 6b96f0515b9..2cda4425d8e 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -112,6 +112,22 @@ void copy_m4_m3(float m1[4][4], float m2[3][3]) /* no clear */ } +void copt_m3_m3d(float R[3][3], double A[3][3]) +{ + /* Keep it stupid simple for better data flow in CPU. */ + R[0][0] = A[0][0]; + R[0][1] = A[0][1]; + R[0][2] = A[0][2]; + + R[1][0] = A[1][0]; + R[1][1] = A[1][1]; + R[1][2] = A[1][2]; + + R[2][0] = A[2][0]; + R[2][1] = A[2][1]; + R[2][2] = A[2][2]; +} + void swap_m3m3(float m1[3][3], float m2[3][3]) { float t; -- cgit v1.2.3 From ce741bc223940654a13b3d6b723fc42328c3b832 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 20 Oct 2013 13:01:07 +0000 Subject: Code cleanup: de-duplicate implementation of get_texture_value Expect to be no functional changes :) --- source/blender/blenkernel/BKE_texture.h | 3 +++ source/blender/blenkernel/intern/smoke.c | 24 ++----------------- source/blender/blenkernel/intern/texture.c | 27 ++++++++++++++++++++++ source/blender/modifiers/intern/MOD_displace.c | 2 +- source/blender/modifiers/intern/MOD_util.c | 24 ------------------- source/blender/modifiers/intern/MOD_util.h | 1 - source/blender/modifiers/intern/MOD_warp.c | 2 +- source/blender/modifiers/intern/MOD_wave.c | 3 ++- .../blender/modifiers/intern/MOD_weightvg_util.c | 2 +- 9 files changed, 37 insertions(+), 51 deletions(-) diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index 2a00dee2a3f..e9e351f8f37 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -52,6 +52,7 @@ struct ParticleSettings; struct PointDensity; struct Tex; struct TexMapping; +struct TexResult; struct VoxelData; struct World; @@ -129,6 +130,8 @@ struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot); bool BKE_texture_dependsOnTime(const struct Tex *texture); +void BKE_texture_get_value(struct Scene *scene, struct Tex *texture, float *tex_co, struct TexResult *texres, bool use_color_management); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index fb0e22abf2a..a40bfd48c39 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -84,6 +84,7 @@ #include "BKE_pointcache.h" #include "BKE_scene.h" #include "BKE_smoke.h" +#include "BKE_texture.h" #include "RE_shader_ext.h" @@ -1418,27 +1419,6 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke } } -/* TODO(sergey): de-duplicate with get_texture_value from modifier utils */ -/* NOTE: Skips color management, because result is only used for value now, not for color. */ -static void get_texture_value(Tex *texture, float tex_co[3], TexResult *texres) -{ - int result_type; - - /* no node textures for now */ - result_type = multitex_ext_safe(texture, tex_co, texres, NULL, false); - - /* if the texture gave an RGB value, we assume it didn't give a valid - * intensity, since this is in the context of modifiers don't use perceptual color conversion. - * if the texture didn't give an RGB value, copy the intensity across - */ - if (result_type & TEX_RGB) { - texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb); - } - else { - copy_v3_fl(&texres->tr, texres->tin); - } -} - static void sample_derivedmesh(SmokeFlowSettings *sfs, MVert *mvert, MTFace *tface, MFace *mface, float *influence_map, float *velocity_map, int index, int base_res[3], float flow_center[3], BVHTreeFromMesh *treeData, float ray_start[3], float *vert_vel, int has_velocity, int defgrp_index, MDeformVert *dvert, float x, float y, float z) { @@ -1550,7 +1530,7 @@ static void sample_derivedmesh(SmokeFlowSettings *sfs, MVert *mvert, MTFace *tfa tex_co[2] = sfs->texture_offset; } texres.nor = NULL; - get_texture_value(sfs->noise_texture, tex_co, &texres); + BKE_texture_get_value(NULL, sfs->noise_texture, tex_co, &texres, false); sample_str *= texres.tin; } } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 22b0fe7bc24..ccbccac85cf 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -68,6 +68,9 @@ #include "BKE_node.h" #include "BKE_animsys.h" #include "BKE_colortools.h" +#include "BKE_scene.h" + +#include "RE_shader_ext.h" /* ****************** Mapping ******************* */ @@ -1436,3 +1439,27 @@ bool BKE_texture_dependsOnTime(const struct Tex *texture) } /* ------------------------------------------------------------------------- */ + +void BKE_texture_get_value(Scene *scene, Tex *texture, float *tex_co, TexResult *texres, bool use_color_management) +{ + int result_type; + bool do_color_manage = false; + + if (scene && use_color_management) { + do_color_manage = BKE_scene_check_color_management_enabled(scene); + } + + /* no node textures for now */ + result_type = multitex_ext_safe(texture, tex_co, texres, NULL, do_color_manage); + + /* if the texture gave an RGB value, we assume it didn't give a valid + * intensity, since this is in the context of modifiers don't use perceptual color conversion. + * if the texture didn't give an RGB value, copy the intensity across + */ + if (result_type & TEX_RGB) { + texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb); + } + else { + copy_v3_fl(&texres->tr, texres->tin); + } +} diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 25254c7a30e..61f5495bee8 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -219,7 +219,7 @@ static void displaceModifier_do( if (dmd->texture) { texres.nor = NULL; - get_texture_value(dmd->modifier.scene, dmd->texture, tex_co[i], &texres, false); + BKE_texture_get_value(dmd->modifier.scene, dmd->texture, tex_co[i], &texres, false); delta = texres.tin - dmd->midlevel; } else { diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 230931a1a33..e9fabcd1fd0 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -70,30 +70,6 @@ void modifier_init_texture(Scene *scene, Tex *tex) BKE_image_user_frame_calc(&tex->iuser, scene->r.cfra, 0); } -void get_texture_value(Scene *scene, Tex *texture, float *tex_co, TexResult *texres, bool use_color_management) -{ - int result_type; - bool do_color_manage = false; - - if (use_color_management) { - do_color_manage = BKE_scene_check_color_management_enabled(scene); - } - - /* no node textures for now */ - result_type = multitex_ext_safe(texture, tex_co, texres, NULL, do_color_manage); - - /* if the texture gave an RGB value, we assume it didn't give a valid - * intensity, since this is in the context of modifiers don't use perceptual color conversion. - * if the texture didn't give an RGB value, copy the intensity across - */ - if (result_type & TEX_RGB) { - texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb); - } - else { - copy_v3_fl(&texres->tr, texres->tin); - } -} - void get_texture_coords(MappingInfoModifierData *dmd, Object *ob, DerivedMesh *dm, float (*co)[3], float (*texco)[3], diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h index 25632eb5b80..b4dcdc1721a 100644 --- a/source/blender/modifiers/intern/MOD_util.h +++ b/source/blender/modifiers/intern/MOD_util.h @@ -41,7 +41,6 @@ struct Tex; struct TexResult; void modifier_init_texture(struct Scene *scene, struct Tex *texture); -void get_texture_value(struct Scene *scene, struct Tex *texture, float *tex_co, struct TexResult *texres, bool do_color_manage); void get_texture_coords(struct MappingInfoModifierData *dmd, struct Object *ob, struct DerivedMesh *dm, float (*co)[3], float (*texco)[3], int numVerts); void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]); diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 4fac201377a..83b05ae708a 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -282,7 +282,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, if (tex_co) { TexResult texres; texres.nor = NULL; - get_texture_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false); + BKE_texture_get_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false); fac *= texres.tin; } diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 43dc1ba4eb9..168907e293c 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -48,6 +48,7 @@ #include "BKE_library.h" #include "BKE_object.h" #include "BKE_scene.h" +#include "BKE_texture.h" #include "depsgraph_private.h" @@ -306,7 +307,7 @@ static void waveModifier_do(WaveModifierData *md, if (wmd->texture) { TexResult texres; texres.nor = NULL; - get_texture_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false); + BKE_texture_get_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false); amplit *= texres.tin; } diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index e2267addd53..5c3b87bd92c 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -164,7 +164,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne do_color_manage = tex_use_channel != MOD_WVG_MASK_TEX_USE_INT; texres.nor = NULL; - get_texture_value(scene, texture, tex_co[idx], &texres, do_color_manage); + BKE_texture_get_value(scene, texture, tex_co[idx], &texres, do_color_manage); /* Get the good channel value... */ switch (tex_use_channel) { case MOD_WVG_MASK_TEX_USE_INT: -- cgit v1.2.3 From 8587ce85975952957580291f5554cd75a2fdeae3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 20 Oct 2013 14:42:26 +0000 Subject: Splash screen update for final 2.69 release (remove release candidate text). --- release/datafiles/splash.png | Bin 139754 -> 220834 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/release/datafiles/splash.png b/release/datafiles/splash.png index 9551fad2fac..ad0028ee0b4 100644 Binary files a/release/datafiles/splash.png and b/release/datafiles/splash.png differ -- cgit v1.2.3 From f023fcf5354d2a2c95f358d9f5d0cacf7f45d4ec Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 20 Oct 2013 17:53:29 +0000 Subject: Project Pampa request: show curves for node grupps It was not implemented in anim filter yet. it's strictly speaking not so much clear how "selected only" mode is expected to work when having multiple node trees editing at the same time. For now all the animation data from selected group will be displayed. --- source/blender/editors/animation/anim_filter.c | 29 ++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 09b6e7d2206..b7a1614146a 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1503,8 +1503,7 @@ static size_t animdata_filter_mask(ListBase *anim_data, void *UNUSED(data), int } /* NOTE: owner_id is scene, material, or texture block, which is the direct owner of the node tree in question */ -// TODO: how to handle group nodes is still unclear... -static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode) +static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1538,6 +1537,32 @@ static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data, return items; } +static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode) +{ + bNode *node; + size_t items = 0; + int group_filter_mode = filter_mode & ~ADS_FILTER_ONLYSEL; + + items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, owner_id, ntree, filter_mode); + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == NODE_GROUP) { + if (node->id) { + int filterflag = ads->filterflag; + if ((filter_mode & ADS_FILTER_ONLYSEL) && (node->flag & NODE_SELECT) == 0) { + continue; + } + /* TODO(sergey): A bit creepy, but this flag is not used from threads anyway. */ + ads->filterflag &= ~ADS_FILTER_ONLYSEL; + items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, owner_id, (bNodeTree *) node->id, group_filter_mode); + ads->filterflag = filterflag; + } + } + } + + return items; +} + static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) { SceneRenderLayer *srl; -- cgit v1.2.3 From 55201ce48ba5883297bc0ed8db990faf93a20276 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 21 Oct 2013 11:13:39 +0000 Subject: Fix [#37160] Rotate edge direction changed between 2.64 and 2.65 (low priority) Easy to fix, but do not really understand *why* this is needed... --- source/blender/bmesh/intern/bmesh_mods.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 3ffdd0f86a6..eb83f891038 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -849,7 +849,7 @@ void BM_edge_calc_rotate(BMEdge *e, const bool ccw, /* we could swap the verts _or_ the faces, swapping faces * gives more predictable results since that way the next vert * just stitches from face fa / fb */ - if (ccw) { + if (!ccw) { SWAP(BMFace *, fa, fb); } -- cgit v1.2.3 From 5d132e722efeaed52536b411fb6cf86083b7d6e4 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 21 Oct 2013 14:40:14 +0000 Subject: Followup to r60857: code was assuming markers were sorted, which is not guaranted. Also heavily simplified it (previous code was supposed to have optimizations, but ended just looping twice over the markers' list...). Many thanks to Brecht and Sergey for noting the quirk and reviews! :) --- source/blender/editors/animation/anim_markers.c | 56 +++++-------------------- 1 file changed, 10 insertions(+), 46 deletions(-) diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 8a9f4559140..1e8f2bfc038 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -197,59 +197,23 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la { TimeMarker *marker; float min, max; - int selcount = 0; /* sanity check */ //printf("markers = %p - %p, %p\n", markers, markers->first, markers->last); - if (markers == NULL) { - *first = 0.0f; - *last = 0.0f; - return; - } - - if (markers->first && markers->last) { - TimeMarker *fm = markers->first; - TimeMarker *lm = markers->last; - - /* Store last marker in min, and first marker in max, so that later real value calc actually works! [#37146]. */ - min = (float)lm->frame; - max = (float)fm->frame; - } - else { + if (ELEM3(NULL, markers, markers->first, markers->last)) { *first = 0.0f; *last = 0.0f; return; } - - /* count how many markers are usable - see later */ - if (sel) { - for (marker = markers->first; marker; marker = marker->next) { - if (marker->flag & SELECT) - selcount++; - } - } - else - selcount = BLI_countlist(markers); - - /* if only selected are to be considered, only consider the selected ones - * (optimization for not searching list) - */ - if (selcount > 1) { - for (marker = markers->first; marker; marker = marker->next) { - if (sel) { - if (marker->flag & SELECT) { - if (marker->frame < min) - min = (float)marker->frame; - if (marker->frame > max) - max = (float)marker->frame; - } - } - else { - if (marker->frame < min) - min = (float)marker->frame; - if (marker->frame > max) - max = (float)marker->frame; - } + + min = FLT_MAX; + max = -FLT_MAX; + for (marker = markers->first; marker; marker = marker->next) { + if (!sel || (marker->flag & SELECT)) { + if (marker->frame < min) + min = (float)marker->frame; + if (marker->frame > max) + max = (float)marker->frame; } } -- cgit v1.2.3 From efe2b1edf1df06ea25e0d7b7ae1ce9ecab49783c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 21 Oct 2013 15:00:22 +0000 Subject: Jump to Next/Previous Marker operators in the timeline menu, shortcuts are ctrl + shift + left/right arrow key. Patch #37142 by Henrik Aarnio, thanks! --- release/scripts/startup/bl_ui/space_time.py | 5 +++ source/blender/editors/screen/screen_ops.c | 67 +++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py index fb78194d1a4..700d1004718 100644 --- a/release/scripts/startup/bl_ui/space_time.py +++ b/release/scripts/startup/bl_ui/space_time.py @@ -228,6 +228,11 @@ def marker_menu_generic(layout): layout.operator("marker.rename", text="Rename Marker") layout.operator("marker.move", text="Grab/Move Marker") + + layout.separator() + + layout.operator("screen.marker_jump", text="Jump to Next Marker").next = True + layout.operator("screen.marker_jump", text="Jump to Previous Marker").next = False if __name__ == "__main__": # only for live edit. diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index fbdd90312dd..a325183dd78 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2123,6 +2123,65 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot) RNA_def_boolean(ot->srna, "next", TRUE, "Next Keyframe", ""); } +/* ************** jump to marker operator ***************************** */ + +/* function to be called outside UI context, or for redo */ +static int marker_jump_exec(bContext *C, wmOperator *op) +{ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + TimeMarker *marker; + int closest; + short next = RNA_boolean_get(op->ptr, "next"); + bool found = false; + + /* find matching marker in the right direction */ + for (marker = scene->markers.first; marker; marker = marker->next) { + if (next) { + if (marker->frame > CFRA && (!found || closest > marker->frame)) { + closest = marker->frame; + found = true; + } + } else { + if (marker->frame < CFRA && (!found || closest < marker->frame)) { + closest = marker->frame; + found = true; + } + } + } + + /* any success? */ + if (!found) { + BKE_report(op->reports, RPT_INFO, "No more markers to jump to in this direction"); + + return OPERATOR_CANCELLED; + } + else { + CFRA = closest; + + sound_seek_scene(bmain, scene); + + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); + + return OPERATOR_FINISHED; + } +} + +static void SCREEN_OT_marker_jump(wmOperatorType *ot) +{ + ot->name = "Jump to Marker"; + ot->description = "Jump to previous/next marker"; + ot->idname = "SCREEN_OT_marker_jump"; + + ot->exec = marker_jump_exec; + + ot->poll = ED_operator_screenactive_norender; + ot->flag = OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "next", TRUE, "Next Marker", ""); +} + /* ************** switch screen operator ***************************** */ static int screen_set_is_ok(bScreen *screen, bScreen *screen_prev) @@ -3807,6 +3866,7 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_frame_offset); WM_operatortype_append(SCREEN_OT_frame_jump); WM_operatortype_append(SCREEN_OT_keyframe_jump); + WM_operatortype_append(SCREEN_OT_marker_jump); WM_operatortype_append(SCREEN_OT_animation_step); WM_operatortype_append(SCREEN_OT_animation_play); @@ -3984,6 +4044,13 @@ void ED_keymap_screen(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", MEDIAFIRST, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "next", FALSE); + + kmi = WM_keymap_add_item(keymap, "SCREEN_OT_marker_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "next", TRUE); + + kmi = WM_keymap_add_item(keymap, "SCREEN_OT_marker_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "next", FALSE); + /* play (forward and backwards) */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0); -- cgit v1.2.3 From 34cd28d283ed9958a71ac8c7b84ff877c6332b75 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 21 Oct 2013 15:44:09 +0000 Subject: Partial fix for [#37159] Particle Emitter set to not render still appears in 3D view, when display set to rendered only. Emitter also appears in all GL Renders and some F12 renders. Fixed OpenGL part: in draw_object, when object has some particle systems and none of them render the emitter, and display option is set to show only rendered objects, skip this object. Note: Cycles matter I did not investigate, looks like a render-engine issue. --- source/blender/editors/space_view3d/drawobject.c | 443 ++++++++++++----------- 1 file changed, 228 insertions(+), 215 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 3e27346f9fe..65d6a1d0ec2 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6581,6 +6581,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short char dt; short zbufoff = 0; const bool is_obact = (ob == OBACT); + const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0; + bool particle_skip_object = false; /* Draw particles but not their emitter object. */ /* only once set now, will be removed too, should become a global standard */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -6589,16 +6591,31 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short if (ob->restrictflag & OB_RESTRICT_VIEW) { return; } - else if ((ob->restrictflag & OB_RESTRICT_RENDER) && - (v3d->flag2 & V3D_RENDER_OVERRIDE)) + else if ((ob->restrictflag & OB_RESTRICT_RENDER) && render_override) { return; } } - /* XXX particles are not safe for simultaneous threaded render */ - if (G.is_rendering && ob->particlesystem.first) - return; + if (ob->particlesystem.first) { + /* XXX particles are not safe for simultaneous threaded render */ + if (G.is_rendering) { + return; + } + + if (ob->mode == OB_MODE_OBJECT) { + ParticleSystem *psys; + + particle_skip_object = render_override; + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + /* Once we have found a psys which renders its emitter object, we are done. */ + if (psys->part->draw & PART_DRAW_EMITTER) { + particle_skip_object = false; + break; + } + } + } + } /* xray delay? */ if ((dflag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) { @@ -6624,7 +6641,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short view3d_cached_text_draw_begin(); /* draw motion paths (in view space) */ - if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + if (ob->mpath && !render_override) { bAnimVizSettings *avs = &ob->avs; /* setup drawing environment for paths */ @@ -6665,7 +6682,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short /* faceselect exception: also draw solid when (dt == wire), except in editmode */ if (is_obact && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) { - if (ob->type == OB_MESH) { + if (ob->type == OB_MESH) { if (dt < OB_SOLID) { zbufoff = 1; dt = OB_SOLID; @@ -6688,7 +6705,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short /* draw-extra supported for boundbox drawmode too */ if (dt >= OB_BOUNDBOX) { - dtx = ob->dtx; if (ob->mode & OB_MODE_EDIT) { // the only 2 extra drawtypes alowed in editmode @@ -6697,240 +6713,241 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } - /* bad exception, solve this! otherwise outline shows too late */ - if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */ - if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first)) { - BKE_displist_make_curveTypes(scene, ob, 0); + if (!particle_skip_object) { + /* bad exception, solve this! otherwise outline shows too late */ + if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { + /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */ + if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first)) { + BKE_displist_make_curveTypes(scene, ob, 0); + } } - } - - /* draw outline for selected objects, mesh does itself */ - if ((v3d->flag & V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && ob->type != OB_MESH) { - if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) { - if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) { - drawObjectSelect(scene, v3d, ar, base, ob_wire_col); + + /* draw outline for selected objects, mesh does itself */ + if ((v3d->flag & V3D_SELECT_OUTLINE) && !render_override && ob->type != OB_MESH) { + if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) { + if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) { + drawObjectSelect(scene, v3d, ar, base, ob_wire_col); + } } } - } - switch (ob->type) { - case OB_MESH: - empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag); - if (dflag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself - - break; - case OB_FONT: - cu = ob->data; - if (cu->editfont) { - draw_textcurs(rv3d, cu->editfont->textcurs); - - if (cu->flag & CU_FAST) { - cpack(0xFFFFFF); - set_inverted_drawing(1); - drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col); - set_inverted_drawing(0); - } - else { - drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); - } + switch (ob->type) { + case OB_MESH: + empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag); + if (dflag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself - if (cu->linewidth != 0.0f) { - UI_ThemeColor(TH_WIRE_EDIT); - copy_v3_v3(vec1, ob->orig); - copy_v3_v3(vec2, ob->orig); - vec1[0] += cu->linewidth; - vec2[0] += cu->linewidth; - vec1[1] += cu->linedist * cu->fsize; - vec2[1] -= cu->lines * cu->linedist * cu->fsize; - setlinestyle(3); - glBegin(GL_LINE_STRIP); - glVertex2fv(vec1); - glVertex2fv(vec2); - glEnd(); - setlinestyle(0); - } + break; + case OB_FONT: + cu = ob->data; + if (cu->editfont) { + draw_textcurs(rv3d, cu->editfont->textcurs); + + if (cu->flag & CU_FAST) { + cpack(0xFFFFFF); + set_inverted_drawing(1); + drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col); + set_inverted_drawing(0); + } + else { + drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); + } - setlinestyle(3); - for (i = 0; i < cu->totbox; i++) { - if (cu->tb[i].w != 0.0f) { - UI_ThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE); - vec1[0] = (cu->xof * cu->fsize) + cu->tb[i].x; - vec1[1] = (cu->yof * cu->fsize) + cu->tb[i].y + cu->fsize; - vec1[2] = 0.001; + if (cu->linewidth != 0.0f) { + UI_ThemeColor(TH_WIRE_EDIT); + copy_v3_v3(vec1, ob->orig); + copy_v3_v3(vec2, ob->orig); + vec1[0] += cu->linewidth; + vec2[0] += cu->linewidth; + vec1[1] += cu->linedist * cu->fsize; + vec2[1] -= cu->lines * cu->linedist * cu->fsize; + setlinestyle(3); glBegin(GL_LINE_STRIP); - glVertex3fv(vec1); - vec1[0] += cu->tb[i].w; - glVertex3fv(vec1); - vec1[1] -= cu->tb[i].h; - glVertex3fv(vec1); - vec1[0] -= cu->tb[i].w; - glVertex3fv(vec1); - vec1[1] += cu->tb[i].h; - glVertex3fv(vec1); + glVertex2fv(vec1); + glVertex2fv(vec2); glEnd(); + setlinestyle(0); } - } - setlinestyle(0); + setlinestyle(3); + for (i = 0; i < cu->totbox; i++) { + if (cu->tb[i].w != 0.0f) { + UI_ThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE); + vec1[0] = (cu->xof * cu->fsize) + cu->tb[i].x; + vec1[1] = (cu->yof * cu->fsize) + cu->tb[i].y + cu->fsize; + vec1[2] = 0.001; + glBegin(GL_LINE_STRIP); + glVertex3fv(vec1); + vec1[0] += cu->tb[i].w; + glVertex3fv(vec1); + vec1[1] -= cu->tb[i].h; + glVertex3fv(vec1); + vec1[0] -= cu->tb[i].w; + glVertex3fv(vec1); + vec1[1] += cu->tb[i].h; + glVertex3fv(vec1); + glEnd(); + } + } + setlinestyle(0); - if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) { - float selboxw; - cpack(0xffffff); - set_inverted_drawing(1); - for (i = 0; i <= (selend - selstart); i++) { - SelBox *sb = &(cu->selboxes[i]); + if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) { + float selboxw; - if (i < (selend - selstart)) { - if (cu->selboxes[i + 1].y == sb->y) - selboxw = cu->selboxes[i + 1].x - sb->x; - else + cpack(0xffffff); + set_inverted_drawing(1); + for (i = 0; i <= (selend - selstart); i++) { + SelBox *sb = &(cu->selboxes[i]); + + if (i < (selend - selstart)) { + if (cu->selboxes[i + 1].y == sb->y) + selboxw = cu->selboxes[i + 1].x - sb->x; + else + selboxw = sb->w; + } + else { selboxw = sb->w; + } + glBegin(GL_QUADS); + glVertex3f(sb->x, sb->y, 0.001); + glVertex3f(sb->x + selboxw, sb->y, 0.001); + glVertex3f(sb->x + selboxw, sb->y + sb->h, 0.001); + glVertex3f(sb->x, sb->y + sb->h, 0.001); + glEnd(); } - else { - selboxw = sb->w; - } - glBegin(GL_QUADS); - glVertex3f(sb->x, sb->y, 0.001); - glVertex3f(sb->x + selboxw, sb->y, 0.001); - glVertex3f(sb->x + selboxw, sb->y + sb->h, 0.001); - glVertex3f(sb->x, sb->y + sb->h, 0.001); - glEnd(); + set_inverted_drawing(0); } - set_inverted_drawing(0); } - } - else if (dt == OB_BOUNDBOX) { - if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_WIRE) == 0) { - draw_bounding_volume(scene, ob, ob->boundtype); + else if (dt == OB_BOUNDBOX) { + if ((render_override && v3d->drawtype >= OB_WIRE) == 0) { + draw_bounding_volume(scene, ob, ob->boundtype); + } + } + else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) { + empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); } - } - else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) { - empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); - } - break; - case OB_CURVE: - case OB_SURF: - cu = ob->data; + break; + case OB_CURVE: + case OB_SURF: + cu = ob->data; - if (cu->editnurb) { - ListBase *nurbs = BKE_curve_editNurbs_get(cu); - drawnurb(scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col); - } - else if (dt == OB_BOUNDBOX) { - if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) { - draw_bounding_volume(scene, ob, ob->boundtype); + if (cu->editnurb) { + ListBase *nurbs = BKE_curve_editNurbs_get(cu); + drawnurb(scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col); } - } - else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) { - empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); + else if (dt == OB_BOUNDBOX) { + if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) { + draw_bounding_volume(scene, ob, ob->boundtype); + } + } + else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) { + empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); //XXX old animsys if (cu->path) // curve_draw_speed(scene, ob); - } - break; - case OB_MBALL: - { - MetaBall *mb = ob->data; - - if (mb->editelems) - drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); - else if (dt == OB_BOUNDBOX) { - if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) { - draw_bounding_volume(scene, ob, ob->boundtype); } + break; + case OB_MBALL: + { + MetaBall *mb = ob->data; + + if (mb->editelems) + drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); + else if (dt == OB_BOUNDBOX) { + if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) { + draw_bounding_volume(scene, ob, ob->boundtype); + } + } + else + empty_object = drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); + break; } - else - empty_object = drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); - break; - } - case OB_EMPTY: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - if (ob->empty_drawtype == OB_EMPTY_IMAGE) { - draw_empty_image(ob, dflag, ob_wire_col); + case OB_EMPTY: + if (!render_override) { + if (ob->empty_drawtype == OB_EMPTY_IMAGE) { + draw_empty_image(ob, dflag, ob_wire_col); + } + else { + drawaxes(ob->empty_drawsize, ob->empty_drawtype); + } } - else { - drawaxes(ob->empty_drawsize, ob->empty_drawtype); + break; + case OB_LAMP: + if (!render_override) { + drawlamp(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); + if (dtx || (base->flag & SELECT)) glMultMatrixf(ob->obmat); } - } - break; - case OB_LAMP: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - drawlamp(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); - if (dtx || (base->flag & SELECT)) glMultMatrixf(ob->obmat); - } - break; - case OB_CAMERA: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0 || - (rv3d->persp == RV3D_CAMOB && v3d->camera == ob)) /* special exception for active camera */ - { - drawcamera(scene, v3d, rv3d, base, dflag, ob_wire_col); - } - break; - case OB_SPEAKER: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) - drawspeaker(scene, v3d, rv3d, ob, dflag); - break; - case OB_LATTICE: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - /* Do not allow boundbox in edit nor pose mode! */ - if ((dt == OB_BOUNDBOX) && (ob->mode & OB_MODE_EDIT)) - dt = OB_WIRE; - if (dt == OB_BOUNDBOX) { - draw_bounding_volume(scene, ob, ob->boundtype); + break; + case OB_CAMERA: + if (!render_override || + (rv3d->persp == RV3D_CAMOB && v3d->camera == ob)) /* special exception for active camera */ + { + drawcamera(scene, v3d, rv3d, base, dflag, ob_wire_col); } - else { - drawlattice(scene, v3d, ob); + break; + case OB_SPEAKER: + if (!render_override) + drawspeaker(scene, v3d, rv3d, ob, dflag); + break; + case OB_LATTICE: + if (!render_override) { + /* Do not allow boundbox in edit nor pose mode! */ + if ((dt == OB_BOUNDBOX) && (ob->mode & OB_MODE_EDIT)) + dt = OB_WIRE; + if (dt == OB_BOUNDBOX) { + draw_bounding_volume(scene, ob, ob->boundtype); + } + else { + drawlattice(scene, v3d, ob); + } } - } - break; - case OB_ARMATURE: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - /* Do not allow boundbox in edit nor pose mode! */ - if ((dt == OB_BOUNDBOX) && (ob->mode & (OB_MODE_EDIT | OB_MODE_POSE))) - dt = OB_WIRE; - if (dt == OB_BOUNDBOX) { - draw_bounding_volume(scene, ob, ob->boundtype); + break; + case OB_ARMATURE: + if (!render_override) { + /* Do not allow boundbox in edit nor pose mode! */ + if ((dt == OB_BOUNDBOX) && (ob->mode & (OB_MODE_EDIT | OB_MODE_POSE))) + dt = OB_WIRE; + if (dt == OB_BOUNDBOX) { + draw_bounding_volume(scene, ob, ob->boundtype); + } + else { + if (dt > OB_WIRE) + GPU_enable_material(0, NULL); /* we use default material */ + empty_object = draw_armature(scene, v3d, ar, base, dt, dflag, ob_wire_col, false); + if (dt > OB_WIRE) + GPU_disable_material(); + } } - else { - if (dt > OB_WIRE) - GPU_enable_material(0, NULL); /* we use default material */ - empty_object = draw_armature(scene, v3d, ar, base, dt, dflag, ob_wire_col, false); - if (dt > OB_WIRE) - GPU_disable_material(); + break; + default: + if (!render_override) { + drawaxes(1.0, OB_ARROWS); } - } - break; - default: - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - drawaxes(1.0, OB_ARROWS); - } - break; - } - - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - - if (ob->soft /*&& dflag & OB_SBMOTION*/) { - float mrt[3][3], msc[3][3], mtr[3][3]; - SoftBody *sb = NULL; - float tipw = 0.5f, tiph = 0.5f, drawsize = 4.0f; - if ((sb = ob->soft)) { - if (sb->solverflags & SBSO_ESTIMATEIPO) { + break; + } - glLoadMatrixf(rv3d->viewmat); - copy_m3_m3(msc, sb->lscale); - copy_m3_m3(mrt, sb->lrot); - mul_m3_m3m3(mtr, mrt, msc); - ob_draw_RE_motion(sb->lcom, mtr, tipw, tiph, drawsize); - glMultMatrixf(ob->obmat); + if (!render_override) { + if (ob->soft /*&& dflag & OB_SBMOTION*/) { + float mrt[3][3], msc[3][3], mtr[3][3]; + SoftBody *sb = NULL; + float tipw = 0.5f, tiph = 0.5f, drawsize = 4.0f; + if ((sb = ob->soft)) { + if (sb->solverflags & SBSO_ESTIMATEIPO) { + + glLoadMatrixf(rv3d->viewmat); + copy_m3_m3(msc, sb->lscale); + copy_m3_m3(mrt, sb->lrot); + mul_m3_m3m3(mtr, mrt, msc); + ob_draw_RE_motion(sb->lcom, mtr, tipw, tiph, drawsize); + glMultMatrixf(ob->obmat); + } } } - } - if (ob->pd && ob->pd->forcefield) { - draw_forcefield(ob, rv3d, dflag, ob_wire_col); + if (ob->pd && ob->pd->forcefield) { + draw_forcefield(ob, rv3d, dflag, ob_wire_col); + } } } @@ -7093,7 +7110,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } } - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + if (!render_override) { bConstraint *con; for (con = ob->constraints.first; con; con = con->next) { @@ -7145,9 +7162,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } } - if ((dt <= OB_SOLID) && - ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0)) - { + if ((dt <= OB_SOLID) && !render_override) { if (((ob->gameflag & OB_DYNAMIC) && !ELEM(ob->collision_boundtype, OB_BOUND_TRIANGLE_MESH, OB_BOUND_CONVEX_HULL)) || @@ -7181,9 +7196,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short glDisable(GL_DEPTH_TEST); } - if ((base->flag & OB_FROMDUPLI) || - (v3d->flag2 & V3D_RENDER_OVERRIDE)) - { + if ((base->flag & OB_FROMDUPLI) || render_override) { ED_view3d_clear_mats_rv3d(rv3d); return; } @@ -7192,7 +7205,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short if (!is_obact || !(ob->mode & OB_MODE_ALL_PAINT)) { int do_draw_center = -1; /* defines below are zero or positive... */ - if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + if (render_override) { /* don't draw */ } else if ((scene->basact) == base) @@ -7220,7 +7233,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } /* not for sets, duplicators or picking */ - if (dflag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + if (dflag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && !render_override) { ListBase *list; RigidBodyCon *rbc = ob->rigidbody_constraint; -- cgit v1.2.3 From 4b0ff02aebc82e15d83c57c4e7b46c9b2c664672 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Mon, 21 Oct 2013 18:08:20 +0000 Subject: Fix #37169 brush UI not getting updated. A notifier was missing for all unified paint settings properties, made sure to notify that active brush has changed. --- source/blender/makesrna/intern/rna_scene.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 3e42abf376a..476f92b77da 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1443,6 +1443,12 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons } } +static void rna_UnifiedPaintSettings_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +{ + Brush *br = BKE_paint_brush(BKE_paint_get_active(scene)); + WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); +} + static void rna_UnifiedPaintSettings_size_set(PointerRNA *ptr, int value) { UnifiedPaintSettings *ups = ptr->data; @@ -1462,10 +1468,11 @@ static void rna_UnifiedPaintSettings_unprojected_radius_set(PointerRNA *ptr, flo ups->unprojected_radius = value; } -static void rna_UnifiedPaintSettings_radius_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +static void rna_UnifiedPaintSettings_radius_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - /* changing the unified size should invalidate */ + /* changing the unified size should invalidate the overlay but also update the brush */ BKE_paint_invalidate_overlay_all(); + rna_UnifiedPaintSettings_update(bmain, scene, ptr); } static char *rna_UnifiedPaintSettings_path(PointerRNA *UNUSED(ptr)) @@ -2036,6 +2043,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3); RNA_def_property_ui_text(prop, "Strength", "How powerful the effect of the brush is when applied"); + RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update"); prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "weight"); @@ -2043,6 +2051,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3); RNA_def_property_ui_text(prop, "Weight", "Weight to assign in vertex groups"); + RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update"); prop = RNA_def_property(srna, "use_pressure_size", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", UNIFIED_PAINT_BRUSH_SIZE_PRESSURE); -- cgit v1.2.3 From 7c8c49a34a32bdd67e9da27d4b5166f59d45ed70 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Oct 2013 23:35:08 +0000 Subject: style cleanup --- source/blender/blenkernel/intern/editderivedmesh.c | 4 ++-- source/blender/blenlib/intern/BLI_mempool.c | 2 +- source/blender/bmesh/intern/bmesh_polygon.c | 8 +++++--- source/blender/bmesh/intern/bmesh_walkers_impl.c | 2 +- source/blender/bmesh/operators/bmo_fill_grid.c | 4 ++-- .../operations/COM_FastGaussianBlurOperation.cpp | 22 ++++++++++++---------- source/blender/editors/interface/interface.c | 9 +++++++-- source/blender/editors/screen/screen_ops.c | 3 ++- source/blender/makesrna/intern/makesrna.c | 2 +- source/blender/python/intern/bpy_app_ffmpeg.c | 4 ++-- 10 files changed, 35 insertions(+), 25 deletions(-) diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index f71bc83f5d3..6dd0efc9ab4 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -902,7 +902,7 @@ static void emdm_pass_attrib_vertex_glsl(DMVertexAttribs *attribs, BMLoop *loop, for (i = 0; i < attribs->tottface; i++) { const float *uv; - if(attribs->tface[i].em_offset != -1) { + if (attribs->tface[i].em_offset != -1) { const MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(loop, attribs->tface[i].em_offset); uv = luv->uv; } @@ -917,7 +917,7 @@ static void emdm_pass_attrib_vertex_glsl(DMVertexAttribs *attribs, BMLoop *loop, } for (i = 0; i < attribs->totmcol; i++) { GLubyte col[4]; - if(attribs->mcol[i].em_offset != -1) { + if (attribs->mcol[i].em_offset != -1) { const MLoopCol *cp = BM_ELEM_CD_GET_VOID_P(loop, attribs->mcol[i].em_offset); col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; } diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 261e53f0f55..28539d9ca34 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -584,7 +584,7 @@ void BLI_mempool_clear_ex(BLI_mempool *pool, const int totelem_reserve) /* free all after pool->maxchunks */ - for (mpchunk = BLI_findlink(&pool->chunks, (int)maxchunks); mpchunk; mpchunk = mpchunk_next) { + for (mpchunk = BLI_findlink(&pool->chunks, (int)maxchunks); mpchunk; mpchunk = mpchunk_next) { mpchunk_next = mpchunk->next; BLI_remlink(&pool->chunks, mpchunk); mempool_chunk_free(mpchunk, pool->flag); diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 8a3abcb9b5e..12ec3da9b69 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -944,7 +944,7 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, } - if ((!use_beauty) || (!r_faces_new)){ + if ((!use_beauty) || (!r_faces_new)) { /* we can't delete the real face, because some of the callers expect it to remain valid. * so swap data and delete the last created tri */ bmesh_face_swap_data(bm, f, f_new); @@ -979,7 +979,8 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, if (nf_i < edge_array_len) { r_faces_new[nf_i++] = f_a; - } else { + } + else { f_new = f_a; break; } @@ -990,7 +991,8 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, if (nf_i < edge_array_len) { r_faces_new[nf_i++] = f_b; - } else { + } + else { f_new = f_b; break; } diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 238b7b4aaaa..aca2f96dc18 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -37,7 +37,7 @@ #include "intern/bmesh_walkers_private.h" /* pop into stack memory (common operation) */ -#define BMW_state_remove_r(walker, owalk) { \ +#define BMW_state_remove_r(walker, owalk) { \ memcpy(owalk, BMW_current_state(walker), sizeof(*(owalk))); \ BMW_state_remove(walker); \ } (void)0 diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c index a4b1237bc5d..4e302a8ff63 100644 --- a/source/blender/bmesh/operators/bmo_fill_grid.c +++ b/source/blender/bmesh/operators/bmo_fill_grid.c @@ -142,11 +142,11 @@ static void bm_loop_pair_from_verts(BMVert *v_a, BMVert *v_b, static void bm_loop_pair_test_copy(BMLoop *l_pair_a[2], BMLoop *l_pair_b[2]) { /* if the first one is set, we know the second is too */ - if (l_pair_a[0] && l_pair_b[0] == NULL) { + if (l_pair_a[0] && l_pair_b[0] == NULL) { l_pair_b[0] = l_pair_a[1]; l_pair_b[1] = l_pair_a[0]; } - else if (l_pair_b[0] && l_pair_a[0] == NULL) { + else if (l_pair_b[0] && l_pair_a[0] == NULL) { l_pair_a[0] = l_pair_b[1]; l_pair_a[1] = l_pair_b[0]; } diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index aec1e1387c3..fd201fcbc11 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -116,9 +116,10 @@ void FastGaussianBlurOperation::deinitExecution() void *FastGaussianBlurOperation::initializeTileData(rcti *rect) { -/* lockMutex(); - if (!this->m_iirgaus) { - MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect); +#if 0 + lockMutex(); + if (!this->m_iirgaus) { + MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect); MemoryBuffer *copy = newBuf->duplicate(); updateSize(); @@ -144,9 +145,9 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect) } unlockMutex(); return this->m_iirgaus; -}*/ +#else - lockMutex(); + lockMutex(); if (this->m_iirgaus) { // if this->m_iirgaus is set, we don't do tile rendering, so // we can return the already calculated cache @@ -159,7 +160,7 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect) if (use_tiles) { unlockMutex(); } - + MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL); rcti *buf_rect = buffer->getRect(); @@ -181,19 +182,20 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect) } else { if (sx > 0.0f) { - for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) + for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) IIR_gauss(tile, sx, c, 1); - } + } if (sy > 0.0f) { for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) IIR_gauss(tile, sy, c, 2); - } - } + } + } if (!use_tiles) { this->m_iirgaus = tile; unlockMutex(); } return tile; +#endif } void FastGaussianBlurOperation::deinitializeTileData(rcti *rect, void *data) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 9f6d326cd95..16e92f2bc18 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3158,9 +3158,14 @@ uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, in return but; } -/* if _x_ is a power of two (only one bit) return the power, +/** + * if \a _x_ is a power of two (only one bit) return the power, * otherwise return -1. - * (1<frame; found = true; } - } else { + } + else { if (marker->frame < CFRA && (!found || closest < marker->frame)) { closest = marker->frame; found = true; diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 71e4fd4efd5..b4b3fea09c7 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3695,7 +3695,7 @@ static const char *cpp_classes = "" " typename Tcollection_funcs>\n" "class Collection : public Tcollection_funcs {\n" "public:\n" -" Collection(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n" +" Collection(const PointerRNA &p) : Tcollection_funcs(p), ptr(p) {}\n" "\n" " void begin(CollectionIterator& iter)\n" " { iter.begin(ptr); }\n" diff --git a/source/blender/python/intern/bpy_app_ffmpeg.c b/source/blender/python/intern/bpy_app_ffmpeg.c index 61e12c1cea0..2f7577928c5 100644 --- a/source/blender/python/intern/bpy_app_ffmpeg.c +++ b/source/blender/python/intern/bpy_app_ffmpeg.c @@ -89,7 +89,7 @@ static PyObject *make_ffmpeg_info(void) PyStructSequence_SET_ITEM(ffmpeg_info, pos++, obj) #ifdef WITH_FFMPEG -# define FFMPEG_LIB_VERSION(lib) { \ +# define FFMPEG_LIB_VERSION(lib) { \ curversion = lib ## _version(); \ SetObjItem(Py_BuildValue("(iii)", \ curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \ @@ -97,7 +97,7 @@ static PyObject *make_ffmpeg_info(void) curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \ } (void)0 #else -# define FFMPEG_LIB_VERSION(lib) { \ +# define FFMPEG_LIB_VERSION(lib) { \ SetStrItem("Unknown"); \ SetStrItem("Unknown"); \ } (void)0 -- cgit v1.2.3 From cb8d53efcc47f3ce367b1102966f9b21e8d138b9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Oct 2013 23:46:45 +0000 Subject: fix for invalid RNA created for the 3D viewport header (made ID reporting show incorrectly). --- source/blender/editors/space_view3d/view3d_header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 094204f868b..204054b24cd 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -356,7 +356,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) /* masks aren't used for sculpt and particle painting */ PointerRNA meshptr; - RNA_pointer_create(&ob->id, &RNA_Mesh, ob->data, &meshptr); + RNA_pointer_create(ob->data, &RNA_Mesh, ob->data, &meshptr); if (ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT)) { uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } -- cgit v1.2.3 From 383da79d6301fdebcca8681f2d600d569feb8284 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Oct 2013 00:25:15 +0000 Subject: minor changes to templates --- release/scripts/templates_py/operator_mesh_uv.py | 50 ++++++++++++++++++++++ .../scripts/templates_py/operator_modal_timer.py | 10 +++-- release/scripts/templates_py/operator_uv.py | 50 ---------------------- 3 files changed, 56 insertions(+), 54 deletions(-) create mode 100644 release/scripts/templates_py/operator_mesh_uv.py delete mode 100644 release/scripts/templates_py/operator_uv.py diff --git a/release/scripts/templates_py/operator_mesh_uv.py b/release/scripts/templates_py/operator_mesh_uv.py new file mode 100644 index 00000000000..96e624bc30d --- /dev/null +++ b/release/scripts/templates_py/operator_mesh_uv.py @@ -0,0 +1,50 @@ +import bpy +import bmesh + + +def main(context): + obj = context.active_object + me = obj.data + bm = bmesh.from_edit_mesh(me) + + uv_layer = bm.loops.layers.uv.verify() + bm.faces.layers.tex.verify() # currently blender needs both layers. + + # adjust UVs + for f in bm.faces: + for l in f.loops: + luv = l[uv_layer] + if luv.select: + # apply the location of the vertex as a UV + luv.uv = l.vert.co.xy + + bmesh.update_edit_mesh(me) + + +class UvOperator(bpy.types.Operator): + """UV Operator description""" + bl_idname = "uv.simple_operator" + bl_label = "Simple UV Operator" + + @classmethod + def poll(cls, context): + return (context.mode == 'EDIT_MESH') + + def execute(self, context): + main(context) + return {'FINISHED'} + + +def register(): + bpy.utils.register_class(UvOperator) + + +def unregister(): + bpy.utils.unregister_class(UvOperator) + + +if __name__ == "__main__": + register() + + # test call + bpy.ops.uv.simple_operator() diff --git a/release/scripts/templates_py/operator_modal_timer.py b/release/scripts/templates_py/operator_modal_timer.py index 3088d59fbcf..b8211126daf 100644 --- a/release/scripts/templates_py/operator_modal_timer.py +++ b/release/scripts/templates_py/operator_modal_timer.py @@ -9,7 +9,7 @@ class ModalTimerOperator(bpy.types.Operator): _timer = None def modal(self, context, event): - if event.type == 'ESC': + if event.type in {'RIGHTMOUSE', 'ESC'}: return self.cancel(context) if event.type == 'TIMER': @@ -21,12 +21,14 @@ class ModalTimerOperator(bpy.types.Operator): return {'PASS_THROUGH'} def execute(self, context): - self._timer = context.window_manager.event_timer_add(0.1, context.window) - context.window_manager.modal_handler_add(self) + wm = context.window_manager + self._timer = wm.event_timer_add(0.1, context.window) + wm.modal_handler_add(self) return {'RUNNING_MODAL'} def cancel(self, context): - context.window_manager.event_timer_remove(self._timer) + wm = context.window_manager + wm.event_timer_remove(self._timer) return {'CANCELLED'} diff --git a/release/scripts/templates_py/operator_uv.py b/release/scripts/templates_py/operator_uv.py deleted file mode 100644 index 96e624bc30d..00000000000 --- a/release/scripts/templates_py/operator_uv.py +++ /dev/null @@ -1,50 +0,0 @@ -import bpy -import bmesh - - -def main(context): - obj = context.active_object - me = obj.data - bm = bmesh.from_edit_mesh(me) - - uv_layer = bm.loops.layers.uv.verify() - bm.faces.layers.tex.verify() # currently blender needs both layers. - - # adjust UVs - for f in bm.faces: - for l in f.loops: - luv = l[uv_layer] - if luv.select: - # apply the location of the vertex as a UV - luv.uv = l.vert.co.xy - - bmesh.update_edit_mesh(me) - - -class UvOperator(bpy.types.Operator): - """UV Operator description""" - bl_idname = "uv.simple_operator" - bl_label = "Simple UV Operator" - - @classmethod - def poll(cls, context): - return (context.mode == 'EDIT_MESH') - - def execute(self, context): - main(context) - return {'FINISHED'} - - -def register(): - bpy.utils.register_class(UvOperator) - - -def unregister(): - bpy.utils.unregister_class(UvOperator) - - -if __name__ == "__main__": - register() - - # test call - bpy.ops.uv.simple_operator() -- cgit v1.2.3 From 6193963daae293e090779bcec361dfd81c67e32f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Oct 2013 03:03:56 +0000 Subject: style cleanup --- source/blender/blenkernel/intern/shrinkwrap.c | 6 +++--- source/blender/blenkernel/intern/smoke.c | 4 ++-- source/blender/blenlib/intern/math_rotation.c | 2 +- source/blender/makesrna/intern/makesrna.c | 6 +++--- source/blender/render/intern/source/convertblender.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 5c9c564998e..3a6912157fd 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -136,7 +136,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) nearest.index = -1; nearest.dist = FLT_MAX; #ifndef __APPLE__ -#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static) +#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData, calc) schedule(static) #endif for (i = 0; i < calc->numVerts; ++i) { float *co = calc->vertexCos[i]; @@ -331,7 +331,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) { #ifndef __APPLE__ -#pragma omp parallel for private(i,hit) schedule(static) +#pragma omp parallel for private(i, hit) schedule(static) #endif for (i = 0; i < calc->numVerts; ++i) { float *co = calc->vertexCos[i]; @@ -441,7 +441,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) /* Find the nearest vertex */ #ifndef __APPLE__ -#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static) +#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc, treeData) schedule(static) #endif for (i = 0; i < calc->numVerts; ++i) { float *co = calc->vertexCos[i]; diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index a40bfd48c39..b7251a5e795 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1109,7 +1109,7 @@ static void em_freeData(EmissionMap *em) static void em_combineMaps(EmissionMap *output, EmissionMap *em2, int hires_multiplier, int additive, float sample_size) { - int i, x,y,z; + int i, x, y, z; /* copyfill input 1 struct and clear output for new allocation */ EmissionMap em1; @@ -1227,7 +1227,7 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke float solid = sfs->particle_size * 0.5f; float smooth = 0.5f; /* add 0.5 cells of linear falloff to reduce aliasing */ int hires_multiplier = 1; - int i,z; + int i, z; KDTree *tree; sim.scene = scene; diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 2eebe10dd58..41535cf32b6 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1712,7 +1712,7 @@ float fov_to_focallength(float hfov, float sensor) return (sensor / 2.0f) / tanf(hfov * 0.5f); } -/* 'mod_inline(-3,4)= 1', 'fmod(-3,4)= -3' */ +/* 'mod_inline(-3, 4)= 1', 'fmod(-3, 4)= -3' */ static float mod_inline(float a, float b) { return a - (b * floorf(a / b)); diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index b4b3fea09c7..1cb9eb8e9ae 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3446,7 +3446,7 @@ static const char *cpp_classes = "" " inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n" -" inline Array sname::identifier(void) \\\n" +" inline Array sname::identifier(void) \\\n" " { Array ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n" " inline void sname::identifier(int values[size]) \\\n" " { sname##_##identifier##_set(&ptr, values); } \\\n" @@ -3466,7 +3466,7 @@ static const char *cpp_classes = "" " inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n" -" inline Array sname::identifier(void) \\\n" +" inline Array sname::identifier(void) \\\n" " { Array ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n" " inline void sname::identifier(int values[size]) \\\n" " { sname##_##identifier##_set(&ptr, values); } \\\n" @@ -3486,7 +3486,7 @@ static const char *cpp_classes = "" " inline void sname::identifier(float value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n" -" inline Array sname::identifier(void) \\\n" +" inline Array sname::identifier(void) \\\n" " { Array ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n" " inline void sname::identifier(float values[size]) \\\n" " { sname##_##identifier##_set(&ptr, values); } \\\n" diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index b37489d70b3..8e90ddbb42b 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -334,7 +334,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), * cleanup */ /* ------------------------------------------------------------------------- */ -#define UVTOINDEX(u,v) (startvlak + (u) * sizev + (v)) +#define UVTOINDEX(u, v) (startvlak + (u) * sizev + (v)) /* * * NOTE THAT U/V COORDINATES ARE SOMETIMES SWAPPED !! -- cgit v1.2.3 From c80c1c6f5c90b446652cc866484b966bdcbc6b60 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Oct 2013 03:31:21 +0000 Subject: add copy_v4_fl4, replace QUATSET macro. --- source/blender/blenkernel/intern/font.c | 24 ++++++---------------- source/blender/blenlib/BLI_math_vector.h | 3 ++- source/blender/blenlib/intern/math_vector_inline.c | 10 ++++++++- source/blender/editors/space_view3d/view3d_view.c | 14 ++++++------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index f24d84df2e8..f489adc7445 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -315,25 +315,13 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i MEM_freeN(nu2); return; } - nu2->bp = bp; - nu2->bp[0].vec[0] = x1; - nu2->bp[0].vec[1] = y1; - nu2->bp[0].vec[2] = 0; - nu2->bp[0].vec[3] = 1.0f; - nu2->bp[1].vec[0] = x2; - nu2->bp[1].vec[1] = y1; - nu2->bp[1].vec[2] = 0; - nu2->bp[1].vec[3] = 1.0f; - nu2->bp[2].vec[0] = x2; - nu2->bp[2].vec[1] = y2; - nu2->bp[2].vec[2] = 0; - nu2->bp[2].vec[3] = 1.0f; - nu2->bp[3].vec[0] = x1; - nu2->bp[3].vec[1] = y2; - nu2->bp[3].vec[2] = 0; - nu2->bp[3].vec[3] = 1.0f; - + copy_v4_fl4(bp[0].vec, x1, y1, 0.0f, 1.0f); + copy_v4_fl4(bp[1].vec, x2, y1, 0.0f, 1.0f); + copy_v4_fl4(bp[2].vec, x2, y2, 0.0f, 1.0f); + copy_v4_fl4(bp[3].vec, x1, y2, 0.0f, 1.0f); + + nu2->bp = bp; BLI_addtail(&(cu->nurb), nu2); } diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 7576fbe2b54..5a23e879b1a 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -82,8 +82,9 @@ MINLINE void copy_v4fl_v4db(float r[4], const double a[4]); MINLINE void copy_v2db_v2fl(double r[2], const float a[2]); MINLINE void copy_v3db_v3fl(double r[3], const float a[3]); MINLINE void copy_v4db_v4fl(double r[4], const float a[4]); -/* 3 float -> vec */ +/* float args -> vec */ MINLINE void copy_v3_fl3(float v[3], float x, float y, float z); +MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w); /********************************* Arithmetic ********************************/ diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index b479b06da3f..0ce5855b16a 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -235,7 +235,7 @@ MINLINE void swap_v4_v4(float a[4], float b[4]) SWAP(float, a[3], b[3]); } -/* 3 float -> vec */ +/* float args -> vec */ MINLINE void copy_v3_fl3(float v[3], float x, float y, float z) { v[0] = x; @@ -243,6 +243,14 @@ MINLINE void copy_v3_fl3(float v[3], float x, float y, float z) v[2] = z; } +MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w) +{ + v[0] = x; + v[1] = y; + v[2] = z; + v[3] = w; +} + /********************************* Arithmetic ********************************/ MINLINE void add_v2_fl(float r[2], float f) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index b74527159c2..61c6d5c00dd 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -774,33 +774,31 @@ static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob) mat3_to_quat(rv3d->viewquat, tmat); } -#define QUATSET(a, b, c, d, e) { a[0] = b; a[1] = c; a[2] = d; a[3] = e; } (void)0 - bool ED_view3d_lock(RegionView3D *rv3d) { switch (rv3d->view) { case RV3D_VIEW_BOTTOM: - QUATSET(rv3d->viewquat, 0.0, -1.0, 0.0, 0.0); + copy_v4_fl4(rv3d->viewquat, 0.0, -1.0, 0.0, 0.0); break; case RV3D_VIEW_BACK: - QUATSET(rv3d->viewquat, 0.0, 0.0, -M_SQRT1_2, -M_SQRT1_2); + copy_v4_fl4(rv3d->viewquat, 0.0, 0.0, -M_SQRT1_2, -M_SQRT1_2); break; case RV3D_VIEW_LEFT: - QUATSET(rv3d->viewquat, 0.5, -0.5, 0.5, 0.5); + copy_v4_fl4(rv3d->viewquat, 0.5, -0.5, 0.5, 0.5); break; case RV3D_VIEW_TOP: - QUATSET(rv3d->viewquat, 1.0, 0.0, 0.0, 0.0); + copy_v4_fl4(rv3d->viewquat, 1.0, 0.0, 0.0, 0.0); break; case RV3D_VIEW_FRONT: - QUATSET(rv3d->viewquat, M_SQRT1_2, -M_SQRT1_2, 0.0, 0.0); + copy_v4_fl4(rv3d->viewquat, M_SQRT1_2, -M_SQRT1_2, 0.0, 0.0); break; case RV3D_VIEW_RIGHT: - QUATSET(rv3d->viewquat, 0.5, -0.5, -0.5, -0.5); + copy_v4_fl4(rv3d->viewquat, 0.5, -0.5, -0.5, -0.5); break; default: return false; -- cgit v1.2.3 From 24547931908990354da3f9be55377e3a168f1e67 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 22 Oct 2013 06:24:47 +0000 Subject: DopeSheet Group Select => Bone Select Tweak: Don't change selection status of bones if "Only Selected" dopesheet filter is enabled. When this was enabled, it would be too easy to accidentally change the selected bones, causing the keyframes you were just editing to disappear --- .../blender/editors/animation/anim_channels_edit.c | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index a260bb3bd7e..de04a9f2379 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -2450,20 +2450,25 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in * Since groups are used to collect F-Curves of the same Bone by default * (via Keying Sets) so that they can be managed better, we try to make * things here easier for animators by mapping group selection to bone - * selection + * selection. + * + * Only do this if "Only Selected" dopesheet filter is not active, or else it + * becomes too unpredictable/tricky to manage */ - if ((ale->id) && (GS(ale->id->name) == ID_OB)) { - ob = (Object *)ale->id; - - if (ob->type == OB_ARMATURE) { - /* Assume for now that any group with corresponding name is what we want - * (i.e. for an armature whose location is animated, things would break - * if the user were to add a bone named "Location"). - * - * TODO: check the first F-Curve or so to be sure... - */ - pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); - } + if ((ac->ads->filterflag & ADS_FILTER_ONLYSEL)==0) { + if ((ale->id) && (GS(ale->id->name) == ID_OB)) { + ob = (Object *)ale->id; + + if (ob->type == OB_ARMATURE) { + /* Assume for now that any group with corresponding name is what we want + * (i.e. for an armature whose location is animated, things would break + * if the user were to add a bone named "Location"). + * + * TODO: check the first F-Curve or so to be sure... + */ + pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); + } + } } /* select/deselect group */ -- cgit v1.2.3 From 67e262069a048e93fce72cead392c19d74cba812 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 22 Oct 2013 08:21:00 +0000 Subject: Minor UI messages fixes. --- source/blender/editors/animation/keyframing.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 513085e9a64..1028fb30ba4 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1100,7 +1100,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou if (BKE_fcurve_is_protected(fcu)) { BKE_reportf(reports, RPT_WARNING, - "not deleting keyframe for locked F-Curve '%s' for %s '%s'", + "Not deleting keyframe for locked F-Curve '%s' for %s '%s'", fcu->rna_path, BKE_idcode_to_name(GS(id->name)), id->name + 2); continue; } @@ -1570,7 +1570,7 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op) if (BKE_fcurve_is_protected(fcu)) { BKE_reportf(op->reports, RPT_WARNING, - "not deleting keyframe for locked F-Curve '%s', object '%s'", + "Not deleting keyframe for locked F-Curve '%s', object '%s'", fcu->rna_path, id->name + 2); continue; } -- cgit v1.2.3 From d2fe7c38dd30b0cfdfbc25e61a1a699b3112a704 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 22 Oct 2013 09:59:54 +0000 Subject: Adding comments to clarify each set of modifier mappings for animation editors selection ops --- source/blender/editors/space_action/action_ops.c | 9 ++++++--- source/blender/editors/space_graph/graph_ops.c | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 7d238bf7887..88207e2816a 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -112,21 +112,24 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) wmKeyMapItem *kmi; /* action_select.c - selection tools */ - /* click-select */ + /* click-select: keyframe (replace) */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_boolean_set(kmi->ptr, "column", FALSE); + /* click-select: all on same frame (replace) */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_boolean_set(kmi->ptr, "column", TRUE); + /* click-select: keyframe (add) */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "column", FALSE); + /* click-select: all on same frame (replace) */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "column", TRUE); - /* select left/right */ + /* click-select: left/right */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); @@ -163,7 +166,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "ACTION_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ACTION_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - /* select linekd */ + /* select linked */ WM_keymap_add_item(keymap, "ACTION_OT_select_linked", LKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index e2bc88cf0eb..6dc3f7ac3dc 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -279,33 +279,38 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) /* graph_select.c - selection tools */ - /* click-select */ + /* click-select: keyframe (replace) */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_boolean_set(kmi->ptr, "curves", FALSE); RNA_boolean_set(kmi->ptr, "column", FALSE); + /* click-select: all keyframes on same frame (replace) */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_boolean_set(kmi->ptr, "curves", FALSE); RNA_boolean_set(kmi->ptr, "column", TRUE); + /* click-select: keyframe (add) */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "curves", FALSE); RNA_boolean_set(kmi->ptr, "column", FALSE); + /* click-select: all keyframes on same frame (add) */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "curves", FALSE); RNA_boolean_set(kmi->ptr, "column", TRUE); + /* click-select: all keyframes in same curve (replace) */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_boolean_set(kmi->ptr, "curves", TRUE); RNA_boolean_set(kmi->ptr, "column", FALSE); + /* click-select: all keyframes in same curve (add) */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "curves", TRUE); RNA_boolean_set(kmi->ptr, "column", FALSE); - /* select left/right */ + /* click-select left/right */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST); -- cgit v1.2.3 From 4dc9c9639f78c29b4a33fece5bef989cb1281c8b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 22 Oct 2013 11:12:37 +0000 Subject: Ctrl+Alt+SelectMouse now does "Select all keyframes in same channel" in DopeSheet too Previously, it only worked in the Graph Editor, though I thought I had implemented it here too. --- source/blender/editors/space_action/action_ops.c | 16 ++++- .../blender/editors/space_action/action_select.c | 84 +++++++++++++++++++--- source/blender/editors/space_graph/graph_select.c | 3 +- 3 files changed, 92 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 88207e2816a..2ef61fa580a 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -116,18 +116,32 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_boolean_set(kmi->ptr, "column", FALSE); + RNA_boolean_set(kmi->ptr, "channel", FALSE); /* click-select: all on same frame (replace) */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_boolean_set(kmi->ptr, "column", TRUE); + RNA_boolean_set(kmi->ptr, "channel", FALSE); /* click-select: keyframe (add) */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "column", FALSE); - /* click-select: all on same frame (replace) */ + RNA_boolean_set(kmi->ptr, "channel", FALSE); + /* click-select: all on same frame (add) */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "column", TRUE); + RNA_boolean_set(kmi->ptr, "channel", FALSE); + /* click-select: all on same channel (replace) */ + kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "column", FALSE); + RNA_boolean_set(kmi->ptr, "channel", TRUE); + /* click-select: all on same channel (add) */ + kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "column", FALSE); + RNA_boolean_set(kmi->ptr, "channel", TRUE); /* click-select: left/right */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 9d124cf08ee..d3fc8ce1d34 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -930,6 +930,7 @@ void ACTION_OT_select_leftright(wmOperatorType *ot) * - 1) keyframe under mouse - no special modifiers * - 2) all keyframes on the same side of current frame indicator as mouse - ALT modifier * - 3) column select all keyframes in frame under mouse - CTRL modifier + * - 4) all keyframes in channel under mouse - CTRL+ALT modifiers * * In addition to these basic options, the SHIFT modifier can be used to toggle the * selection mode between replacing the selection (without) and inverting the selection (with). @@ -949,24 +950,31 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s ked.f1 = selx; /* select the nominated keyframe on the given frame */ - if (ale->type == ANIMTYPE_GPLAYER) + if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_select_frame(ale->data, selx, select_mode); - else if (ale->type == ANIMTYPE_MASKLAYER) + } + else if (ale->type == ANIMTYPE_MASKLAYER) { ED_mask_select_frame(ale->data, selx, select_mode); + } else { if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK) && (ale->type == ANIMTYPE_SUMMARY) && (ale->datatype == ALE_ALL)) { ListBase anim_data = {NULL, NULL}; int filter; + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + for (ale = anim_data.first; ale; ale = ale->next) { - if (ale->type == ANIMTYPE_GPLAYER) + if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_select_frame(ale->data, selx, select_mode); - else if (ale->type == ANIMTYPE_MASKLAYER) + } + else if (ale->type == ANIMTYPE_MASKLAYER) { ED_mask_select_frame(ale->data, selx, select_mode); + } } + BLI_freelistN(&anim_data); } else { @@ -1023,10 +1031,55 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se BLI_freelistN(&ked.list); BLI_freelistN(&anim_data); } + +/* option 4) select all keyframes in same channel */ +static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, short select_mode) +{ + KeyframeEditFunc select_cb; + + printf("select all in channel - %d\n", select_mode); + + /* get functions for selecting keyframes */ + select_cb = ANIM_editkeyframes_select(select_mode); + + /* select all keyframes in this channel */ + if (ale->type == ANIMTYPE_GPLAYER) { + ED_gpencil_select_frames(ale->data, select_mode); + } + else if (ale->type == ANIMTYPE_MASKLAYER) { + ED_mask_select_frames(ale->data, select_mode); + } + else { + if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK) && + (ale->type == ANIMTYPE_SUMMARY) && (ale->datatype == ALE_ALL)) + { + ListBase anim_data = {NULL, NULL}; + int filter; + + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + + for (ale = anim_data.first; ale; ale = ale->next) { + if (ale->type == ANIMTYPE_GPLAYER) { + ED_gpencil_select_frames(ale->data, select_mode); + } + else if (ale->type == ANIMTYPE_MASKLAYER) { + ED_mask_select_frames(ale->data, select_mode); + } + } + + BLI_freelistN(&anim_data); + } + else { + int res = ANIM_animchannel_keyframes_loop(NULL, ac->ads, ale, NULL, select_cb, NULL); + printf("\tresult = %d\n", res); + } + } +} /* ------------------- */ -static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_mode, short column) +static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_mode, bool column, bool same_channel) { ListBase anim_data = {NULL, NULL}; DLRBT_Tree anim_keys; @@ -1151,6 +1204,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ /* for replacing selection, firstly need to clear existing selection */ if (select_mode == SELECT_REPLACE) { /* reset selection mode for next steps */ + printf("selectmode = replace\n"); select_mode = SELECT_ADD; /* deselect all keyframes */ @@ -1211,6 +1265,10 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ /* select all keyframes in the same frame as the one we hit on the active channel */ actkeys_mselect_column(ac, select_mode, selx); } + else if (same_channel) { + /* select all keyframes in the active channel */ + actkeys_mselect_channel_only(ac, ale, select_mode); + } else { /* select the nominated keyframe on the given frame */ actkeys_mselect_single(ac, ale, select_mode, selx); @@ -1227,7 +1285,8 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent { bAnimContext ac; /* ARegion *ar; */ /* UNUSED */ - short selectmode, column; + short selectmode; + bool column, channel; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1244,9 +1303,10 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent /* column selection */ column = RNA_boolean_get(op->ptr, "column"); + channel = RNA_boolean_get(op->ptr, "channel"); /* select keyframe(s) based upon mouse position*/ - mouse_action_keys(&ac, event->mval, selectmode, column); + mouse_action_keys(&ac, event->mval, selectmode, column, channel); /* set notifier that keyframe selection (and channels too) have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); @@ -1272,10 +1332,16 @@ void ACTION_OT_clickselect(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", + "Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + + prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select", + "Select all keyframes that occur on the same frame as the one under the mouse"); // ALTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select", ""); // ALTKEY + prop = RNA_def_boolean(ot->srna, "channel", 0, "Only Channel", + "Select all the keyframes in the channel under the mouse"); // CTRLKEY + ALTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); } diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index d87bd9a5077..4bb5e1b11d4 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -1365,7 +1365,8 @@ void GRAPH_OT_clickselect(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", + "Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select", -- cgit v1.2.3 From df553892c9d2f034659e328e9286c1cf6a9554d7 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 22 Oct 2013 11:36:48 +0000 Subject: Bugfix: Renaming bones now renames the corresponding F-Curves in actions used by Action Constraints --- source/blender/blenkernel/BKE_animsys.h | 4 ++ source/blender/blenkernel/intern/anim_sys.c | 44 ++++++++++++++++++++++ source/blender/editors/armature/armature_naming.c | 7 ++++ .../blender/editors/space_action/action_select.c | 6 +-- 4 files changed, 56 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index f0f6b5a2319..a0ec6c7757f 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -104,6 +104,10 @@ void BKE_keyingsets_free(struct ListBase *list); /* ************************************* */ /* Path Fixing API */ +/* Fix all the paths for the the given ID + Action */ +void BKE_action_fix_paths_rename(struct ID *owner_id, struct bAction *act, const char *prefix, const char *oldName, + const char *newName, int oldSubscript, int newSubscript, int verify_paths); + /* Fix all the paths for the given ID+AnimData */ void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, struct ID *ref_id, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 74578266c63..d2189468f53 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -711,6 +711,49 @@ static void nlastrips_path_rename_fix(ID *owner_id, const char *prefix, const ch } } +/* Fix all RNA_Paths in the given Action, relative to the given ID block + * + * This is just an external wrapper for the F-Curve fixing function, + * with input validity checks on top of the basic method. + * + * NOTE: it is assumed that the structure we're replacing is <["><"]> + * i.e. pose.bones["Bone"] + */ +void BKE_action_fix_paths_rename(ID *owner_id, bAction *act, const char *prefix, const char *oldName, + const char *newName, int oldSubscript, int newSubscript, int verify_paths) +{ + char *oldN, *newN; + + /* if no action, no need to proceed */ + if (ELEM(NULL, owner_id, act)) + return; + + /* Name sanitation logic - copied from BKE_animdata_fix_paths_rename() */ + if ((oldName != NULL) && (newName != NULL)) { + /* pad the names with [" "] so that only exact matches are made */ + const size_t name_old_len = strlen(oldName); + const size_t name_new_len = strlen(newName); + char *name_old_esc = BLI_array_alloca(name_old_esc, (name_old_len * 2) + 1); + char *name_new_esc = BLI_array_alloca(name_new_esc, (name_new_len * 2) + 1); + + BLI_strescape(name_old_esc, oldName, (name_old_len * 2) + 1); + BLI_strescape(name_new_esc, newName, (name_new_len * 2) + 1); + oldN = BLI_sprintfN("[\"%s\"]", name_old_esc); + newN = BLI_sprintfN("[\"%s\"]", name_new_esc); + } + else { + oldN = BLI_sprintfN("[%d]", oldSubscript); + newN = BLI_sprintfN("[%d]", newSubscript); + } + + /* fix paths in action */ + fcurves_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &act->curves, verify_paths); + + /* free the temp names */ + MEM_freeN(oldN); + MEM_freeN(newN); +} + /* Fix all RNA-Paths in the AnimData block used by the given ID block * NOTE: it is assumed that the structure we're replacing is <["><"]> * i.e. pose.bones["Bone"] @@ -725,6 +768,7 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons if (ELEM(NULL, owner_id, adt)) return; + /* Name sanitation logic - shared with BKE_action_fix_paths_rename() */ if ((oldName != NULL) && (newName != NULL)) { /* pad the names with [" "] so that only exact matches are made */ const size_t name_old_len = strlen(oldName); diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 8745d571a28..2228cb8386e 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -113,6 +113,7 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char * bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(curcon); ListBase targets = {NULL, NULL}; + /* constraint targets */ if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(curcon, &targets); @@ -126,6 +127,12 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char * if (cti->flush_constraint_targets) cti->flush_constraint_targets(curcon, &targets, 0); } + + /* action constraints */ + if (curcon->type == CONSTRAINT_TYPE_ACTION) { + bActionConstraint *actcon = (bActionConstraint *)curcon->data; + BKE_action_fix_paths_rename(&ob->id, actcon->act, "pose.bones", oldname, newname, 0, 0, 1); + } } } diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index d3fc8ce1d34..d62dd88418f 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -1037,8 +1037,6 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s { KeyframeEditFunc select_cb; - printf("select all in channel - %d\n", select_mode); - /* get functions for selecting keyframes */ select_cb = ANIM_editkeyframes_select(select_mode); @@ -1071,8 +1069,7 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s BLI_freelistN(&anim_data); } else { - int res = ANIM_animchannel_keyframes_loop(NULL, ac->ads, ale, NULL, select_cb, NULL); - printf("\tresult = %d\n", res); + ANIM_animchannel_keyframes_loop(NULL, ac->ads, ale, NULL, select_cb, NULL); } } } @@ -1204,7 +1201,6 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ /* for replacing selection, firstly need to clear existing selection */ if (select_mode == SELECT_REPLACE) { /* reset selection mode for next steps */ - printf("selectmode = replace\n"); select_mode = SELECT_ADD; /* deselect all keyframes */ -- cgit v1.2.3 From 8bb39a536b741e1ccf55fb4cef6b5f580393c2b9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 22 Oct 2013 15:19:37 +0000 Subject: Making real need to remove proxies Otherwise some invalid pointers will be left which could be harmless if real object stays local, but crashes when linking them to another files. Was discovered here in the studio during Project Pampa, and the steps to reproduce are: - Create lib.blend, put armature and cube to it. Create a group with them. - Create scene.blend and link group from lib.blend. - Make a proxy from armature. - Make group real. - Add real objects to a group. - Create comp.blend and link group from scene.blend. This step will creah. --- source/blender/blenkernel/intern/object.c | 5 +++++ source/blender/editors/object/object_add.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index d277d25294e..bef0263b2f5 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1302,6 +1302,11 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, int copy_caches) obn->mode = 0; obn->sculpt = NULL; + /* Proxies are not to be copied. */ + obn->proxy_from = NULL; + obn->proxy_group = NULL; + obn->proxy = NULL; + /* increase user numbers */ id_us_plus((ID *)obn->data); id_us_plus((ID *)obn->gpd); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index db68a0eca4d..db75acef267 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1220,9 +1220,11 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, const short use_base_parent, const short use_hierarchy) { + Main *bmain = CTX_data_main(C); ListBase *lb; DupliObject *dob; GHash *dupli_gh = NULL, *parent_gh = NULL; + Object *object; if (!(base->object->transflag & OB_DUPLI)) return; @@ -1237,6 +1239,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, for (dob = lb->first; dob; dob = dob->next) { Base *basen; Object *ob = BKE_object_copy(dob->ob); + /* font duplis can have a totcol without material, we get them from parent * should be implemented better... */ @@ -1330,6 +1333,17 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, } } + /* The same how BKE_object_unlink detects which object proxies to clear. */ + if (base->object->transflag & OB_DUPLIGROUP && base->object->dup_group) { + for (object = bmain->object.first; object; object = object->id.next) { + if (object->proxy_group == base->object) { + object->proxy = NULL; + object->proxy_from = NULL; + DAG_id_tag_update(&object->id, OB_RECALC_OB); + } + } + } + if (dupli_gh) BLI_ghash_free(dupli_gh, NULL, NULL); if (parent_gh) -- cgit v1.2.3 From 8748840564150e62c537c14172528b2d12e43e9c Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Tue, 22 Oct 2013 23:32:41 +0000 Subject: Fix part 1 of #37177 spikes in sculpting. Was a typo from refactor to calculate sculpt plane from forward facing vertices only. The branch of the code that did the calculation would end up with a nice division by a wrong number. --- source/blender/editors/sculpt_paint/sculpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index b41a2d0f4c9..a7a7b6ab84a 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2488,7 +2488,7 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, /* for flatten center */ add_v3_v3(fc, private_fc); - add_v3_v3(fc_flip, private_fc); + add_v3_v3(fc_flip, private_fc_flip); count += private_count; count_flipped += private_count_flip; } -- cgit v1.2.3 From 304a32bf1f1e9a5b69c9ab938e80919c50a601ed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Oct 2013 02:52:27 +0000 Subject: style cleanup --- .../intern/COM_ExecutionSystemHelper.cpp | 4 +- .../operations/COM_FastGaussianBlurOperation.cpp | 62 +++++++++++----------- .../blender/editors/animation/anim_channels_edit.c | 3 +- source/blender/editors/curve/editcurve.c | 9 ++-- .../blender/editors/space_clip/clip_graph_draw.c | 2 +- source/blender/editors/space_file/fsmenu.c | 4 +- source/blender/editors/space_text/space_text.c | 6 +-- source/blender/editors/space_view3d/drawobject.c | 3 +- .../blender/imbuf/intern/oiio/openimageio_api.cpp | 34 +++++++----- source/blender/windowmanager/intern/wm_keymap.c | 3 +- 10 files changed, 69 insertions(+), 61 deletions(-) diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index 3f8c432a004..7def96d426e 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -47,8 +47,8 @@ void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_star const bNodeTree *basetree = system.getContext().getbNodeTree(); /* update viewers in the active edittree as well the base tree (for backdrop) */ - bool is_active_group = (parent_key.value == basetree->active_viewer_key.value - || tree == basetree); + bool is_active_group = ((parent_key.value == basetree->active_viewer_key.value) || + (tree == basetree)); /* add all nodes of the tree to the node list */ bNode *node = (bNode *)tree->nodes.first; diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index fd201fcbc11..caf71040483 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -290,41 +290,41 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf"); Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf"); W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf"); - if (xy & 1) { // H - int offset; + if (xy & 1) { // H + int offset; for (y = 0; y < src_height; ++y) { - const int yx = y * src_width; - offset = yx*COM_NUMBER_OF_CHANNELS + chan; - for (x = 0; x < src_width; ++x) { - X[x] = buffer[offset]; - offset += COM_NUMBER_OF_CHANNELS; - } + const int yx = y * src_width; + offset = yx*COM_NUMBER_OF_CHANNELS + chan; + for (x = 0; x < src_width; ++x) { + X[x] = buffer[offset]; + offset += COM_NUMBER_OF_CHANNELS; + } YVV(src_width); - offset = yx*COM_NUMBER_OF_CHANNELS + chan; - for (x = 0; x < src_width; ++x) { - buffer[offset] = Y[x]; - offset += COM_NUMBER_OF_CHANNELS; - } - } + offset = yx*COM_NUMBER_OF_CHANNELS + chan; + for (x = 0; x < src_width; ++x) { + buffer[offset] = Y[x]; + offset += COM_NUMBER_OF_CHANNELS; + } + } } - if (xy & 2) { // V - int offset; - const int add = src_width * COM_NUMBER_OF_CHANNELS; - - for (x = 0; x < src_width; ++x) { - offset = x * COM_NUMBER_OF_CHANNELS + chan; - for (y = 0; y < src_height; ++y) { - X[y] = buffer[offset]; - offset += add; - } + if (xy & 2) { // V + int offset; + const int add = src_width * COM_NUMBER_OF_CHANNELS; + + for (x = 0; x < src_width; ++x) { + offset = x * COM_NUMBER_OF_CHANNELS + chan; + for (y = 0; y < src_height; ++y) { + X[y] = buffer[offset]; + offset += add; + } YVV(src_height); - offset = x * COM_NUMBER_OF_CHANNELS + chan; - for (y = 0; y < src_height; ++y) { - buffer[offset] = Y[y]; - offset += add; - } - } - } + offset = x * COM_NUMBER_OF_CHANNELS + chan; + for (y = 0; y < src_height; ++y) { + buffer[offset] = Y[y]; + offset += add; + } + } + } MEM_freeN(X); MEM_freeN(W); diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index de04a9f2379..33ca10420ec 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1107,7 +1107,6 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) break; case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME... - default: /* some collection of actions */ if (adt->action) rearrange_action_channels(&ac, adt->action, mode); @@ -2455,7 +2454,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in * Only do this if "Only Selected" dopesheet filter is not active, or else it * becomes too unpredictable/tricky to manage */ - if ((ac->ads->filterflag & ADS_FILTER_ONLYSEL)==0) { + if ((ac->ads->filterflag & ADS_FILTER_ONLYSEL) == 0) { if ((ale->id) && (GS(ale->id->name) == ID_OB)) { ob = (Object *)ale->id; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 24065321f8b..7b03a15a011 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -2032,7 +2032,8 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, MEM_freeN(usel); if ((newu == 0 || newv == 0) || - (split && !isNurbselU(nu, &newv, SELECT) && !isNurbselV(nu, &newu, SELECT))) { + (split && !isNurbselU(nu, &newv, SELECT) && !isNurbselV(nu, &newu, SELECT))) + { if (G.debug & G_DEBUG) printf("Can't duplicate Nurb\n"); } @@ -6076,7 +6077,8 @@ static int curve_delete_segments(Object *obedit, const bool split) bezt2 = &nu->bezt[1]; if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) && - BEZSELECTED_HIDDENHANDLES(cu, bezt2)) { + BEZSELECTED_HIDDENHANDLES(cu, bezt2)) + { nu1 = BKE_nurb_copy(nu, 1, 1); ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1); BLI_addtail(&newnurb, nu1); @@ -6086,7 +6088,8 @@ static int curve_delete_segments(Object *obedit, const bool split) bezt2 = &nu->bezt[nu->pntsu - 2]; if (BEZSELECTED_HIDDENHANDLES(cu, bezt1) && - BEZSELECTED_HIDDENHANDLES(cu, bezt2)) { + BEZSELECTED_HIDDENHANDLES(cu, bezt2)) + { nu1 = BKE_nurb_copy(nu, 1, 1); ED_curve_beztcpy(editnurb, nu1->bezt, bezt1, 1); BLI_addtail(&newnurb, nu1); diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 9beb8edd914..80b844464db 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -186,7 +186,7 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) /* selected knot handles on top of curves */ userdata.sel = TRUE; clip_graph_tracking_values_iterate(sc, - (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) !=0, + (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0, (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, &userdata, tracking_segment_knot_cb, NULL, NULL); } diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 172488f2c57..0227230fb68 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -415,9 +415,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) if (result != kCFURLEnumeratorSuccess) continue; - CFURLGetFileSystemRepresentation(cfURL, false, (UInt8*)defPath, FILE_MAX); + CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX); fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)defPath, FS_INSERT_SORTED); - } + } CFRelease(volEnum); diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index a0659d5ce62..ee64d680319 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -475,14 +475,14 @@ static void text_drop_copy(wmDrag *drag, wmDropBox *drop) static int text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_ID) - return TRUE; + return true; - return FALSE; + return false; } static void text_drop_paste(wmDrag *drag, wmDropBox *drop) { - RNA_string_set(drop->ptr, "text", ((ID*)drag->poin)->name + 2); + RNA_string_set(drop->ptr, "text", ((ID *)drag->poin)->name + 2); } /* this region dropbox definition */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 65d6a1d0ec2..5bfb8180bfc 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6591,8 +6591,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short if (ob->restrictflag & OB_RESTRICT_VIEW) { return; } - else if ((ob->restrictflag & OB_RESTRICT_RENDER) && render_override) - { + else if ((ob->restrictflag & OB_RESTRICT_RENDER) && render_override) { return; } } diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index 1ee4ee00500..fe74b8f7cce 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -99,13 +99,16 @@ static ImBuf *imb_oiio_load_image(ImageInput *in, int width, int height, int com try { if (!in->read_image(TypeDesc::UINT8, - (uchar *)ibuf->rect + (height - 1) * scanlinesize, - AutoStride, - -scanlinesize, - AutoStride)) { + (uchar *)ibuf->rect + (height - 1) * scanlinesize, + AutoStride, + -scanlinesize, + AutoStride)) + { std::cerr << __func__ << ": ImageInput::read_image() failed:" << std::endl - << in->geterror() << std::endl; - if (ibuf) IMB_freeImBuf(ibuf); + << in->geterror() << std::endl; + + if (ibuf) + IMB_freeImBuf(ibuf); return NULL; } @@ -135,13 +138,16 @@ static ImBuf *imb_oiio_load_image_float(ImageInput *in, int width, int height, i try { if (!in->read_image(TypeDesc::FLOAT, - (uchar *)ibuf->rect_float + (height - 1) * scanlinesize, - AutoStride, - -scanlinesize, - AutoStride)) { + (uchar *)ibuf->rect_float + (height - 1) * scanlinesize, + AutoStride, + -scanlinesize, + AutoStride)) + { std::cerr << __func__ << ": ImageInput::read_image() failed:" << std::endl - << in->geterror() << std::endl; - if (ibuf) IMB_freeImBuf(ibuf); + << in->geterror() << std::endl; + + if (ibuf) + IMB_freeImBuf(ibuf); return NULL; } @@ -205,7 +211,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac in = ImageInput::create(filename); if (!in) { std::cerr << __func__ << ": ImageInput::create() failed:" << std::endl - << OpenImageIO::geterror() << std::endl; + << OpenImageIO::geterror() << std::endl; return NULL; } @@ -214,7 +220,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac if (!in->open(filename, spec, config)) { std::cerr << __func__ << ": ImageInput::open() failed:" << std::endl - << in->geterror() << std::endl; + << in->geterror() << std::endl; delete in; return NULL; } diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 06719514483..ed27228f107 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -139,7 +139,8 @@ void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties wm_keymap_item_properties_set(kmi); } -int WM_keymap_map_type_get(wmKeyMapItem *kmi) { +int WM_keymap_map_type_get(wmKeyMapItem *kmi) +{ if (ISTIMER(kmi->type)) { return KMI_TYPE_TIMER; } -- cgit v1.2.3 From 292d1f55fdaebfb7c5fd69496f26ce2e1bc668eb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Oct 2013 03:57:42 +0000 Subject: refactor transform.c - minor changes - use TREDRAW_HARD define - use apply prefix for transform callbacks. - make callbacks static. --- source/blender/editors/include/ED_transform.h | 2 - source/blender/editors/mesh/editmesh_extrude.c | 1 - source/blender/editors/transform/transform.c | 610 ++++++++++++++++--------- source/blender/editors/transform/transform.h | 87 +--- 4 files changed, 397 insertions(+), 303 deletions(-) diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index eff79b6a039..8ad78630dc7 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -130,8 +130,6 @@ void ED_getTransformOrientationMatrix(const struct bContext *C, float orientatio int BIF_countTransformOrientation(const struct bContext *C); -void BIF_TransformSetUndo(const char *str); - /* to be able to add operator properties to other operators */ #define P_MIRROR (1 << 0) diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 3df4ad738ae..d3207d42983 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -377,7 +377,6 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe BKE_object_handle_update(scene, obedit); /* individual faces? */ -// BIF_TransformSetUndo("Extrude"); if (nr == 2) { // initTransform(TFM_SHRINKFATTEN, CTX_NO_PET|CTX_NO_MIRROR); // Transform(); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ea039c15be4..a0db93d53b8 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -108,6 +108,95 @@ static void drawVertSlide(const struct bContext *C, TransInfo *t); static void len_v3_ensure(float v[3], const float length); static void postInputRotation(TransInfo *t, float values[3]); + +/* Transform Callbacks */ +static void initWarp(TransInfo *t); +static int handleEventWarp(TransInfo *t, const struct wmEvent *event); +static void Warp(TransInfo *t, const int mval[2]); + +static void initShear(TransInfo *t); +static int handleEventShear(TransInfo *t, const struct wmEvent *event); +static void applyShear(TransInfo *t, const int mval[2]); + +static void initResize(TransInfo *t); +static void applyResize(TransInfo *t, const int mval[2]); + +static void initSkinResize(TransInfo *t); +static void applySkinResize(TransInfo *t, const int mval[2]); + +static void initTranslation(TransInfo *t); +static void applyTranslation(TransInfo *t, const int mval[2]); + +static void initToSphere(TransInfo *t); +static void applyToSphere(TransInfo *t, const int mval[2]); + +static void initRotation(TransInfo *t); +static void applyRotation(TransInfo *t, const int mval[2]); + +static void initShrinkFatten(TransInfo *t); +static void applyShrinkFatten(TransInfo *t, const int mval[2]); + +static void initTilt(TransInfo *t); +static void applyTilt(TransInfo *t, const int mval[2]); + +static void initCurveShrinkFatten(TransInfo *t); +static void applyCurveShrinkFatten(TransInfo *t, const int mval[2]); + +static void initMaskShrinkFatten(TransInfo *t); +static void applyMaskShrinkFatten(TransInfo *t, const int mval[2]); + +static void initTrackball(TransInfo *t); +static void applyTrackball(TransInfo *t, const int mval[2]); + +static void initPushPull(TransInfo *t); +static void applyPushPull(TransInfo *t, const int mval[2]); + +static void initBevelWeight(TransInfo *t); +static void applyBevelWeight(TransInfo *t, const int mval[2]); + +static void initCrease(TransInfo *t); +static void applyCrease(TransInfo *t, const int mval[2]); + +static void initBoneSize(TransInfo *t); +static void applyBoneSize(TransInfo *t, const int mval[2]); + +static void initBoneEnvelope(TransInfo *t); +static void applyBoneEnvelope(TransInfo *t, const int mval[2]); + +static void initBoneRoll(TransInfo *t); +static void applyBoneRoll(TransInfo *t, const int mval[2]); + +static void initEdgeSlide(TransInfo *t); +static int handleEventEdgeSlide(TransInfo *t, const struct wmEvent *event); +static void applyEdgeSlide(TransInfo *t, const int mval[2]); + +static void initVertSlide(TransInfo *t); +static int handleEventVertSlide(TransInfo *t, const struct wmEvent *event); +static void applyVertSlide(TransInfo *t, const int mval[2]); + +static void initTimeTranslate(TransInfo *t); +static void applyTimeTranslate(TransInfo *t, const int mval[2]); + +static void initTimeSlide(TransInfo *t); +static void applyTimeSlide(TransInfo *t, const int mval[2]); + +static void initTimeScale(TransInfo *t); +static void applyTimeScale(TransInfo *t, const int mval[2]); + +static void initBakeTime(TransInfo *t); +static void applyBakeTime(TransInfo *t, const int mval[2]); + +static void initMirror(TransInfo *t); +static void applyMirror(TransInfo *t, const int mval[2]); + +static void initAlign(TransInfo *t); +static void applyAlign(TransInfo *t, const int mval[2]); + +static void initSeqSlide(TransInfo *t); +static void applySeqSlide(TransInfo *t, const int mval[2]); +/* end transform callbacks */ + + static bool transdata_check_local_center(TransInfo *t) { return ((t->around == V3D_LOCAL) && ( @@ -2197,7 +2286,7 @@ int transformEnd(bContext *C, TransInfo *t) /* ************************** TRANSFORM LOCKS **************************** */ -static void protectedTransBits(short protectflag, float *vec) +static void protectedTransBits(short protectflag, float vec[3]) { if (protectflag & OB_LOCK_LOCX) vec[0] = 0.0f; @@ -2207,7 +2296,7 @@ static void protectedTransBits(short protectflag, float *vec) vec[2] = 0.0f; } -static void protectedSizeBits(short protectflag, float *size) +static void protectedSizeBits(short protectflag, float size[3]) { if (protectflag & OB_LOCK_SCALEX) size[0] = 1.0f; @@ -2217,7 +2306,7 @@ static void protectedSizeBits(short protectflag, float *size) size[2] = 1.0f; } -static void protectedRotateBits(short protectflag, float *eul, float *oldeul) +static void protectedRotateBits(short protectflag, float eul[3], const float oldeul[3]) { if (protectflag & OB_LOCK_ROTX) eul[0] = oldeul[0]; @@ -2272,7 +2361,7 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl } /* this function only does the delta rotation */ -static void protectedQuaternionBits(short protectflag, float *quat, float *oldquat) +static void protectedQuaternionBits(short protectflag, float quat[4], const float oldquat[4]) { /* check that protection flags are set */ if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) @@ -2576,7 +2665,12 @@ static void constraintSizeLim(TransInfo *t, TransData *td) } } -/* ************************** WARP *************************** */ + +/* -------------------------------------------------------------------- */ +/* Transform (Warp) */ + +/** \name Transform Warp + * \{ */ struct WarpCustomData { float warp_sta[3]; @@ -2589,7 +2683,7 @@ struct WarpCustomData { float warp_init_dist; }; -void initWarp(TransInfo *t) +static void initWarp(TransInfo *t) { const float mval_fl[2] = {UNPACK2(t->mval)}; const float *curs; @@ -2641,20 +2735,18 @@ void initWarp(TransInfo *t) t->customData = data; } -int handleEventWarp(TransInfo *t, const wmEvent *event) +static int handleEventWarp(TransInfo *UNUSED(t), const wmEvent *event) { - int status = 0; + int status = TREDRAW_NOTHING; if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) { - (void)t; - - status = 1; + status = TREDRAW_HARD; } return status; } -int Warp(TransInfo *t, const int UNUSED(mval[2])) +static void Warp(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float vec[3]; @@ -2771,21 +2863,25 @@ int Warp(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + + +/* -------------------------------------------------------------------- */ +/* Transform (Shear) */ -/* ************************** SHEAR *************************** */ +/** \name Transform Shear + * \{ */ static void postInputShear(TransInfo *UNUSED(t), float values[3]) { mul_v3_fl(values, 0.05f); } -void initShear(TransInfo *t) +static void initShear(TransInfo *t) { t->mode = TFM_SHEAR; - t->transform = Shear; + t->transform = applyShear; t->handleEvent = handleEventShear; setInputPostFct(&t->mouse, postInputShear); @@ -2802,9 +2898,9 @@ void initShear(TransInfo *t) t->flag |= T_NO_CONSTRAINT; } -int handleEventShear(TransInfo *t, const wmEvent *event) +static int handleEventShear(TransInfo *t, const wmEvent *event) { - int status = 0; + int status = TREDRAW_NOTHING; if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) { // Use customData pointer to signal Shear direction @@ -2817,26 +2913,26 @@ int handleEventShear(TransInfo *t, const wmEvent *event) t->customData = NULL; } - status = 1; + status = TREDRAW_HARD; } else if (event->type == XKEY && event->val == KM_PRESS) { initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE); t->customData = NULL; - status = 1; + status = TREDRAW_HARD; } else if (event->type == YKEY && event->val == KM_PRESS) { initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE); t->customData = (void *)1; - status = 1; + status = TREDRAW_HARD; } return status; } -int Shear(TransInfo *t, const int UNUSED(mval[2])) +static void applyShear(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float vec[3]; @@ -2910,16 +3006,20 @@ int Shear(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + -/* ************************** RESIZE *************************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Resize) */ -void initResize(TransInfo *t) +/** \name Transform Resize + * \{ */ + +static void initResize(TransInfo *t) { t->mode = TFM_RESIZE; - t->transform = Resize; + t->transform = applyResize; initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); @@ -2940,8 +3040,7 @@ void initResize(TransInfo *t) t->num.increment = t->snap[1]; } -/* We assume str is MAX_INFO_LEN long. */ -static void headerResize(TransInfo *t, float vec[3], char *str) +static void headerResize(TransInfo *t, float vec[3], char str[MAX_INFO_LEN]) { char tvec[NUM_STR_REP_LEN * 3]; size_t ofs = 0; @@ -3117,7 +3216,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) constraintTransLim(t, td); } -int Resize(TransInfo *t, const int mval[2]) +static void applyResize(TransInfo *t, const int mval[2]) { TransData *td; float size[3], mat[3][3]; @@ -3192,16 +3291,20 @@ int Resize(TransInfo *t, const int mval[2]) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + -/* ************************** SKIN *************************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Skin) */ -void initSkinResize(TransInfo *t) +/** \name Transform Skin + * \{ */ + +static void initSkinResize(TransInfo *t) { t->mode = TFM_SKIN_RESIZE; - t->transform = SkinResize; + t->transform = applySkinResize; initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); @@ -3222,7 +3325,7 @@ void initSkinResize(TransInfo *t) t->num.increment = t->snap[1]; } -int SkinResize(TransInfo *t, const int UNUSED(mval[2])) +static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) { TransData *td; float size[3], mat[3][3]; @@ -3282,19 +3385,23 @@ int SkinResize(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + + +/* -------------------------------------------------------------------- */ +/* Transform (ToSphere) */ -/* ************************** TOSPHERE *************************** */ +/** \name Transform ToSphere + * \{ */ -void initToSphere(TransInfo *t) +static void initToSphere(TransInfo *t) { TransData *td = t->data; int i; t->mode = TFM_TOSPHERE; - t->transform = ToSphere; + t->transform = applyToSphere; initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO); @@ -3317,7 +3424,7 @@ void initToSphere(TransInfo *t) t->val /= (float)t->total; } -int ToSphere(TransInfo *t, const int UNUSED(mval[2])) +static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) { float vec[3]; float ratio, radius; @@ -3375,12 +3482,15 @@ int ToSphere(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ -/* ************************** ROTATION *************************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Rotation) */ + +/** \name Transform Rotation + * \{ */ static void postInputRotation(TransInfo *t, float values[3]) { @@ -3389,10 +3499,10 @@ static void postInputRotation(TransInfo *t, float values[3]) } } -void initRotation(TransInfo *t) +static void initRotation(TransInfo *t) { t->mode = TFM_ROTATION; - t->transform = Rotation; + t->transform = applyRotation; setInputPostFct(&t->mouse, postInputRotation); initMouseInputMode(t, &t->mouse, INPUT_ANGLE); @@ -3638,7 +3748,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short } } -static void applyRotation(TransInfo *t, float angle, float axis[3]) +static void applyRotationValue(TransInfo *t, float angle, float axis[3]) { TransData *td = t->data; float mat[3][3]; @@ -3666,7 +3776,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) } } -int Rotation(TransInfo *t, const int UNUSED(mval[2])) +static void applyRotation(TransInfo *t, const int UNUSED(mval[2])) { char str[MAX_INFO_LEN]; size_t ofs = 0; @@ -3710,22 +3820,25 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2])) t->values[0] = final; - applyRotation(t, final, t->axis); + applyRotationValue(t, final, t->axis); recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/* Transform (Rotation - Trackball) */ -/* ************************** TRACKBALL *************************** */ +/** \name Transform Rotation - Trackball + * \{ */ -void initTrackball(TransInfo *t) +static void initTrackball(TransInfo *t) { t->mode = TFM_TRACKBALL; - t->transform = Trackball; + t->transform = applyTrackball; initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL); @@ -3740,7 +3853,7 @@ void initTrackball(TransInfo *t) t->flag |= T_NO_CONSTRAINT; } -static void applyTrackball(TransInfo *t, const float axis1[3], const float axis2[3], float angles[2]) +static void applyTrackballValue(TransInfo *t, const float axis1[3], const float axis2[3], float angles[2]) { TransData *td = t->data; float mat[3][3], smat[3][3], totmat[3][3]; @@ -3769,7 +3882,7 @@ static void applyTrackball(TransInfo *t, const float axis1[3], const float axis2 } } -int Trackball(TransInfo *t, const int UNUSED(mval[2])) +static void applyTrackball(TransInfo *t, const int UNUSED(mval[2])) { char str[MAX_INFO_LEN]; size_t ofs = 0; @@ -3817,18 +3930,22 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2])) // TRANSFORM_FIX_ME //copy_m3_m3(t->mat, mat); // used in manipulator - applyTrackball(t, axis1, axis2, phi); + applyTrackballValue(t, axis1, axis2, phi); recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + -/* ************************** TRANSLATION *************************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Translation) */ -void initTranslation(TransInfo *t) +/** \name Transform Translation + * \{ */ + +static void initTranslation(TransInfo *t) { if (t->spacetype == SPACE_ACTION) { /* this space uses time translate */ @@ -3836,7 +3953,7 @@ void initTranslation(TransInfo *t) } t->mode = TFM_TRANSLATION; - t->transform = Translation; + t->transform = applyTranslation; initMouseInputMode(t, &t->mouse, INPUT_VECTOR); @@ -3871,8 +3988,7 @@ void initTranslation(TransInfo *t) t->num.increment = t->snap[1]; } -/* We assume str is MAX_INFO_LEN long. */ -static void headerTranslation(TransInfo *t, float vec[3], char *str) +static void headerTranslation(TransInfo *t, float vec[3], char str[MAX_INFO_LEN]) { size_t ofs = 0; char tvec[NUM_STR_REP_LEN * 3]; @@ -3959,7 +4075,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) } } -static void applyTranslation(TransInfo *t, float vec[3]) +static void applyTranslationValue(TransInfo *t, float vec[3]) { TransData *td = t->data; float tvec[3]; @@ -4026,7 +4142,7 @@ static void applyTranslation(TransInfo *t, float vec[3]) } /* uses t->vec to store actual translation in */ -int Translation(TransInfo *t, const int UNUSED(mval[2])) +static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) { char str[MAX_INFO_LEN]; @@ -4051,11 +4167,11 @@ int Translation(TransInfo *t, const int UNUSED(mval[2])) headerTranslation(t, t->values, str); } - applyTranslation(t, t->values); + applyTranslationValue(t, t->values); /* evil hack - redo translation if clipping needed */ if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 0)) { - applyTranslation(t, t->values); + applyTranslationValue(t, t->values); /* In proportional edit it can happen that */ /* vertices in the radius of the brush end */ @@ -4069,13 +4185,17 @@ int Translation(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + -/* ************************** SHRINK/FATTEN *************************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Shrink-Fatten) */ -void initShrinkFatten(TransInfo *t) +/** \name Transform Shrink-Fatten + * \{ */ + +static void initShrinkFatten(TransInfo *t) { // If not in mesh edit mode, fallback to Resize if (t->obedit == NULL || t->obedit->type != OB_MESH) { @@ -4083,7 +4203,7 @@ void initShrinkFatten(TransInfo *t) } else { t->mode = TFM_SHRINKFATTEN; - t->transform = ShrinkFatten; + t->transform = applyShrinkFatten; initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE); @@ -4100,7 +4220,7 @@ void initShrinkFatten(TransInfo *t) } -int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) +static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { float distance; int i; @@ -4164,16 +4284,20 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + -/* ************************** TILT *************************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Tilt) */ -void initTilt(TransInfo *t) +/** \name Transform Tilt + * \{ */ + +static void initTilt(TransInfo *t) { t->mode = TFM_TILT; - t->transform = Tilt; + t->transform = applyTilt; initMouseInputMode(t, &t->mouse, INPUT_ANGLE); @@ -4189,8 +4313,7 @@ void initTilt(TransInfo *t) } - -int Tilt(TransInfo *t, const int UNUSED(mval[2])) +static void applyTilt(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; int i; @@ -4235,17 +4358,20 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ -/* ******************** Curve Shrink/Fatten *************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Curve Shrink/Fatten) */ -void initCurveShrinkFatten(TransInfo *t) +/** \name Transform Curve Shrink/Fatten + * \{ */ + +static void initCurveShrinkFatten(TransInfo *t) { t->mode = TFM_CURVE_SHRINKFATTEN; - t->transform = CurveShrinkFatten; + t->transform = applyCurveShrinkFatten; initMouseInputMode(t, &t->mouse, INPUT_SPRING); @@ -4263,7 +4389,7 @@ void initCurveShrinkFatten(TransInfo *t) t->flag |= T_NO_CONSTRAINT; } -int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) +static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float ratio; @@ -4305,15 +4431,20 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + + +/* -------------------------------------------------------------------- */ +/* Transform (Mask Shrink/Fatten) */ +/** \name Transform Mask Shrink/Fatten + * \{ */ -void initMaskShrinkFatten(TransInfo *t) +static void initMaskShrinkFatten(TransInfo *t) { t->mode = TFM_MASK_SHRINKFATTEN; - t->transform = MaskShrinkFatten; + t->transform = applyMaskShrinkFatten; initMouseInputMode(t, &t->mouse, INPUT_SPRING); @@ -4331,7 +4462,7 @@ void initMaskShrinkFatten(TransInfo *t) t->flag |= T_NO_CONSTRAINT; } -int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) +static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { TransData *td; float ratio; @@ -4394,16 +4525,20 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ -/* ************************** PUSH/PULL *************************** */ -void initPushPull(TransInfo *t) +/* -------------------------------------------------------------------- */ +/* Transform (Push/Pull) */ + +/** \name Transform Push/Pull + * \{ */ + +static void initPushPull(TransInfo *t) { t->mode = TFM_PUSHPULL; - t->transform = PushPull; + t->transform = applyPushPull; initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE); @@ -4417,7 +4552,7 @@ void initPushPull(TransInfo *t) } -int PushPull(TransInfo *t, const int UNUSED(mval[2])) +static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) { float vec[3], axis[3]; float distance; @@ -4479,16 +4614,20 @@ int PushPull(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ -/* ************************** BEVEL WEIGHT *************************** */ -void initBevelWeight(TransInfo *t) +/* -------------------------------------------------------------------- */ +/* Transform (Bevel Weight) */ + +/** \name Transform Bevel Weight + * \{ */ + +static void initBevelWeight(TransInfo *t) { t->mode = TFM_BWEIGHT; - t->transform = BevelWeight; + t->transform = applyBevelWeight; initMouseInputMode(t, &t->mouse, INPUT_SPRING); @@ -4503,7 +4642,7 @@ void initBevelWeight(TransInfo *t) t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; } -int BevelWeight(TransInfo *t, const int UNUSED(mval[2])) +static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float weight; @@ -4552,16 +4691,20 @@ int BevelWeight(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + -/* ************************** CREASE *************************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Crease) */ -void initCrease(TransInfo *t) +/** \name Transform Crease + * \{ */ + +static void initCrease(TransInfo *t) { t->mode = TFM_CREASE; - t->transform = Crease; + t->transform = applyCrease; initMouseInputMode(t, &t->mouse, INPUT_SPRING); @@ -4576,7 +4719,7 @@ void initCrease(TransInfo *t) t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; } -int Crease(TransInfo *t, const int UNUSED(mval[2])) +static void applyCrease(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float crease; @@ -4628,16 +4771,20 @@ int Crease(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + -/* ******************** EditBone (B-bone) width scaling *************** */ +/* -------------------------------------------------------------------- */ +/* Transform (EditBone (B-bone) width scaling) */ -void initBoneSize(TransInfo *t) +/** \name Transform B-bone width scaling + * \{ */ + +static void initBoneSize(TransInfo *t) { t->mode = TFM_BONESIZE; - t->transform = BoneSize; + t->transform = applyBoneSize; initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); @@ -4652,8 +4799,7 @@ void initBoneSize(TransInfo *t) t->num.increment = t->snap[1]; } -/* We assume str is MAX_INFO_LEN long. */ -static void headerBoneSize(TransInfo *t, float vec[3], char *str) +static void headerBoneSize(TransInfo *t, float vec[3], char str[MAX_INFO_LEN]) { char tvec[NUM_STR_REP_LEN * 3]; if (hasNumInput(&t->num)) { @@ -4699,7 +4845,7 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3]) td->loc[1] = oldy; } -int BoneSize(TransInfo *t, const int mval[2]) +static void applyBoneSize(TransInfo *t, const int mval[2]) { TransData *td = t->data; float size[3], mat[3][3]; @@ -4748,17 +4894,20 @@ int BoneSize(TransInfo *t, const int mval[2]) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ -/* ******************** EditBone envelope *************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Bone Envelope) */ -void initBoneEnvelope(TransInfo *t) +/** \name Transform Bone Envelope + * \{ */ + +static void initBoneEnvelope(TransInfo *t) { t->mode = TFM_BONE_ENVELOPE; - t->transform = BoneEnvelope; + t->transform = applyBoneEnvelope; initMouseInputMode(t, &t->mouse, INPUT_SPRING); @@ -4773,7 +4922,7 @@ void initBoneEnvelope(TransInfo *t) t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; } -int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) +static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float ratio; @@ -4816,11 +4965,16 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + + +/* -------------------------------------------------------------------- */ +/* Transform (Edge Slide) */ + +/** \name Transform Edge Slide + * \{ */ -/* ******************** Edge Slide *************** */ static BMEdge *get_other_edge(BMVert *v, BMEdge *e) { BMIter iter; @@ -5678,12 +5832,12 @@ void freeEdgeSlideVerts(TransInfo *t) recalcData(t); } -void initEdgeSlide(TransInfo *t) +static void initEdgeSlide(TransInfo *t) { EdgeSlideData *sld; t->mode = TFM_EDGE_SLIDE; - t->transform = EdgeSlide; + t->transform = applyEdgeSlide; t->handleEvent = handleEventEdgeSlide; if (!createEdgeSlideVerts(t)) { @@ -5713,7 +5867,7 @@ void initEdgeSlide(TransInfo *t) t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; } -int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event) +static int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event) { if (t->mode == TFM_EDGE_SLIDE) { EdgeSlideData *sld = t->customData; @@ -5898,7 +6052,7 @@ static int doEdgeSlide(TransInfo *t, float perc) return 1; } -int EdgeSlide(TransInfo *t, const int UNUSED(mval[2])) +static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2])) { char str[MAX_INFO_LEN]; float final; @@ -5938,12 +6092,16 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/* Transform (Vert Slide) */ + +/** \name Transform Vert Slide + * \{ */ -/* ******************** Vert Slide *************** */ static void calcVertSlideCustomPoints(struct TransInfo *t) { VertSlideData *sld = t->customData; @@ -6185,7 +6343,7 @@ void initVertSlide(TransInfo *t) VertSlideData *sld; t->mode = TFM_VERT_SLIDE; - t->transform = VertSlide; + t->transform = applyVertSlide; t->handleEvent = handleEventVertSlide; if (!createVertSlideVerts(t)) { @@ -6399,7 +6557,7 @@ static int doVertSlide(TransInfo *t, float perc) return 1; } -int VertSlide(TransInfo *t, const int UNUSED(mval[2])) +void applyVertSlide(TransInfo *t, const int UNUSED(mval[2])) { char str[MAX_INFO_LEN]; size_t ofs = 0; @@ -6443,17 +6601,20 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/* Transform (EditBone Roll) */ -/* ******************** EditBone roll *************** */ +/** \name Transform EditBone Roll + * \{ */ -void initBoneRoll(TransInfo *t) +static void initBoneRoll(TransInfo *t) { t->mode = TFM_BONE_ROLL; - t->transform = BoneRoll; + t->transform = applyBoneRoll; initMouseInputMode(t, &t->mouse, INPUT_ANGLE); @@ -6468,7 +6629,7 @@ void initBoneRoll(TransInfo *t) t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; } -int BoneRoll(TransInfo *t, const int UNUSED(mval[2])) +static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; int i; @@ -6509,15 +6670,19 @@ int BoneRoll(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ -/* ************************** BAKE TIME ******************* */ -void initBakeTime(TransInfo *t) +/* -------------------------------------------------------------------- */ +/* Transform (Bake-Time) */ + +/** \name Transform Bake-Time + * \{ */ + +static void initBakeTime(TransInfo *t) { - t->transform = BakeTime; + t->transform = applyBakeTime; initMouseInputMode(t, &t->mouse, INPUT_NONE); t->idx_max = 0; @@ -6529,7 +6694,7 @@ void initBakeTime(TransInfo *t) t->num.increment = t->snap[1]; } -int BakeTime(TransInfo *t, const int mval[2]) +static void applyBakeTime(TransInfo *t, const int mval[2]) { TransData *td = t->data; float time; @@ -6587,15 +6752,19 @@ int BakeTime(TransInfo *t, const int mval[2]) recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + -/* ************************** MIRROR *************************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Mirror) */ -void initMirror(TransInfo *t) +/** \name Transform Mirror + * \{ */ + +static void initMirror(TransInfo *t) { - t->transform = Mirror; + t->transform = applyMirror; initMouseInputMode(t, &t->mouse, INPUT_NONE); t->flag |= T_NULL_ONE; @@ -6604,7 +6773,7 @@ void initMirror(TransInfo *t) } } -int Mirror(TransInfo *t, const int UNUSED(mval[2])) +static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) { TransData *td; float size[3], mat[3][3]; @@ -6665,22 +6834,26 @@ int Mirror(TransInfo *t, const int UNUSED(mval[2])) else ED_area_headerprint(t->sa, IFACE_("Select a mirror axis (X, Y, Z)")); } - - return 1; } +/** \} */ + -/* ************************** ALIGN *************************** */ +/* -------------------------------------------------------------------- */ +/* Transform (Align) */ -void initAlign(TransInfo *t) +/** \name Transform Align + * \{ */ + +static void initAlign(TransInfo *t) { t->flag |= T_NO_CONSTRAINT; - t->transform = Align; + t->transform = applyAlign; initMouseInputMode(t, &t->mouse, INPUT_NONE); } -int Align(TransInfo *t, const int UNUSED(mval[2])) +static void applyAlign(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float center[3]; @@ -6721,15 +6894,19 @@ int Align(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); ED_area_headerprint(t->sa, IFACE_("Align")); - - return 1; } +/** \} */ + + +/* -------------------------------------------------------------------- */ +/* Transform (Sequencer Slide) */ -/* ************************** SEQ SLIDE *************************** */ +/** \name Transform Sequencer Slide + * \{ */ -void initSeqSlide(TransInfo *t) +static void initSeqSlide(TransInfo *t) { - t->transform = SeqSlide; + t->transform = applySeqSlide; initMouseInputMode(t, &t->mouse, INPUT_VECTOR); @@ -6744,8 +6921,7 @@ void initSeqSlide(TransInfo *t) t->num.increment = t->snap[1]; } -/* We assume str is MAX_INFO_LEN long. */ -static void headerSeqSlide(TransInfo *t, float val[2], char *str) +static void headerSeqSlide(TransInfo *t, float val[2], char str[MAX_INFO_LEN]) { char tvec[NUM_STR_REP_LEN * 3]; size_t ofs = 0; @@ -6769,7 +6945,7 @@ static void headerSeqSlide(TransInfo *t, float val[2], char *str) WM_bool_as_string(t->flag & T_ALT_TRANSFORM)); } -static void applySeqSlide(TransInfo *t, const float val[2]) +static void applySeqSlideValue(TransInfo *t, const float val[2]) { TransData *td = t->data; int i; @@ -6792,7 +6968,7 @@ static void applySeqSlide(TransInfo *t, const float val[2]) } } -int SeqSlide(TransInfo *t, const int UNUSED(mval[2])) +static void applySeqSlide(TransInfo *t, const int UNUSED(mval[2])) { char str[MAX_INFO_LEN]; @@ -6811,19 +6987,23 @@ int SeqSlide(TransInfo *t, const int UNUSED(mval[2])) t->values[1] = floor(t->values[1] + 0.5f); headerSeqSlide(t, t->values, str); - applySeqSlide(t, t->values); + applySeqSlideValue(t, t->values); recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ -/* ************************** ANIM EDITORS - TRANSFORM TOOLS *************************** */ -/* ---------------- Special Helpers for Various Settings ------------- */ +/* -------------------------------------------------------------------- */ +/* Animation Editors - Transform Utils + * + * Special Helpers for Various Settings + */ +/** \name Animation Editor Utils + * \{ */ /* This function returns the snapping 'mode' for Animation Editors only * We cannot use the standard snapping due to NLA-strip scaling complexities. @@ -6975,10 +7155,16 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, td2d->h2[0] = td2d->ih2[0] + *td->val - td->ival; } } +/** \} */ -/* ----------------- Translation ----------------------- */ -void initTimeTranslate(TransInfo *t) +/* -------------------------------------------------------------------- */ +/* Transform (Animation Translation) */ + +/** \name Transform Animation Translation + * \{ */ + +static void initTimeTranslate(TransInfo *t) { /* this tool is only really available in the Action Editor... */ if (!ELEM(t->spacetype, SPACE_ACTION, SPACE_SEQ)) { @@ -6986,7 +7172,7 @@ void initTimeTranslate(TransInfo *t) } t->mode = TFM_TIME_TRANSLATE; - t->transform = TimeTranslate; + t->transform = applyTimeTranslate; initMouseInputMode(t, &t->mouse, INPUT_NONE); @@ -7002,8 +7188,7 @@ void initTimeTranslate(TransInfo *t) t->num.increment = t->snap[1]; } -/* We assume str is MAX_INFO_LEN long. */ -static void headerTimeTranslate(TransInfo *t, char *str) +static void headerTimeTranslate(TransInfo *t, char str[MAX_INFO_LEN]) { char tvec[NUM_STR_REP_LEN * 3]; @@ -7039,7 +7224,7 @@ static void headerTimeTranslate(TransInfo *t, char *str) BLI_snprintf(str, MAX_INFO_LEN, IFACE_("DeltaX: %s"), &tvec[0]); } -static void applyTimeTranslate(TransInfo *t, float UNUSED(sval)) +static void applyTimeTranslateValue(TransInfo *t, float UNUSED(sval)) { TransData *td = t->data; TransData2D *td2d = t->data2d; @@ -7096,7 +7281,7 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval)) } } -int TimeTranslate(TransInfo *t, const int mval[2]) +static void applyTimeTranslate(TransInfo *t, const int mval[2]) { View2D *v2d = (View2D *)t->view; float cval[2], sval[2]; @@ -7115,18 +7300,22 @@ int TimeTranslate(TransInfo *t, const int mval[2]) t->values[0] = t->vec[0]; headerTimeTranslate(t, str); - applyTimeTranslate(t, sval[0]); + applyTimeTranslateValue(t, sval[0]); recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + -/* ----------------- Time Slide ----------------------- */ +/* -------------------------------------------------------------------- */ +/* Transform (Animation Time Slide) */ -void initTimeSlide(TransInfo *t) +/** \name Transform Animation Time Slide + * \{ */ + +static void initTimeSlide(TransInfo *t) { /* this tool is only really available in the Action Editor... */ if (t->spacetype == SPACE_ACTION) { @@ -7141,7 +7330,7 @@ void initTimeSlide(TransInfo *t) t->mode = TFM_TIME_SLIDE; - t->transform = TimeSlide; + t->transform = applyTimeSlide; t->flag |= T_FREE_CUSTOMDATA; initMouseInputMode(t, &t->mouse, INPUT_NONE); @@ -7158,8 +7347,7 @@ void initTimeSlide(TransInfo *t) t->num.increment = t->snap[1]; } -/* We assume str is MAX_INFO_LEN long. */ -static void headerTimeSlide(TransInfo *t, float sval, char *str) +static void headerTimeSlide(TransInfo *t, float sval, char str[MAX_INFO_LEN]) { char tvec[NUM_STR_REP_LEN * 3]; @@ -7181,7 +7369,7 @@ static void headerTimeSlide(TransInfo *t, float sval, char *str) BLI_snprintf(str, MAX_INFO_LEN, IFACE_("TimeSlide: %s"), &tvec[0]); } -static void applyTimeSlide(TransInfo *t, float sval) +static void applyTimeSlideValue(TransInfo *t, float sval) { TransData *td = t->data; int i; @@ -7228,7 +7416,7 @@ static void applyTimeSlide(TransInfo *t, float sval) } } -int TimeSlide(TransInfo *t, const int mval[2]) +static void applyTimeSlide(TransInfo *t, const int mval[2]) { View2D *v2d = (View2D *)t->view; float cval[2], sval[2]; @@ -7250,18 +7438,22 @@ int TimeSlide(TransInfo *t, const int mval[2]) t->values[0] = (maxx - minx) * t->vec[0] / 2.0f + sval[0]; headerTimeSlide(t, sval[0], str); - applyTimeSlide(t, sval[0]); + applyTimeSlideValue(t, sval[0]); recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; } +/** \} */ + -/* ----------------- Scaling ----------------------- */ +/* -------------------------------------------------------------------- */ +/* Transform (Animation Time Scale) */ -void initTimeScale(TransInfo *t) +/** \name Transform Animation Time Scale + * \{ */ + +static void initTimeScale(TransInfo *t) { float center[2]; @@ -7273,7 +7465,7 @@ void initTimeScale(TransInfo *t) } t->mode = TFM_TIME_SCALE; - t->transform = TimeScale; + t->transform = applyTimeScale; /* recalculate center2d to use CFRA and mouse Y, since that's * what is used in time scale */ @@ -7301,8 +7493,7 @@ void initTimeScale(TransInfo *t) t->num.increment = t->snap[1]; } -/* We assume str is MAX_INFO_LEN long. */ -static void headerTimeScale(TransInfo *t, char *str) +static void headerTimeScale(TransInfo *t, char str[MAX_INFO_LEN]) { char tvec[NUM_STR_REP_LEN * 3]; @@ -7314,7 +7505,7 @@ static void headerTimeScale(TransInfo *t, char *str) BLI_snprintf(str, MAX_INFO_LEN, IFACE_("ScaleX: %s"), &tvec[0]); } -static void applyTimeScale(TransInfo *t) +static void applyTimeScaleValue(TransInfo *t) { Scene *scene = t->scene; TransData *td = t->data; @@ -7354,7 +7545,7 @@ static void applyTimeScale(TransInfo *t) } } -int TimeScale(TransInfo *t, const int UNUSED(mval[2])) +static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2])) { char str[MAX_INFO_LEN]; @@ -7364,22 +7555,13 @@ int TimeScale(TransInfo *t, const int UNUSED(mval[2])) t->values[0] = t->vec[0]; headerTimeScale(t, str); - applyTimeScale(t); + applyTimeScaleValue(t); recalcData(t); ED_area_headerprint(t->sa, str); - - return 1; -} - -/* ************************************ */ - -void BIF_TransformSetUndo(const char *UNUSED(str)) -{ - // TRANSFORM_FIX_ME - //Trans.undostr = str; } +/** \} */ /* TODO, move to: transform_queries.c */ diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index b32ba5ad527..7233d22756d 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -284,7 +284,7 @@ typedef struct TransInfo { int options; /* current context/options for transform */ float val; /* init value for some transformations (and rotation angle) */ float fac; /* factor for distance based transform */ - int (*transform)(struct TransInfo *, const int *); + void (*transform)(struct TransInfo *, const int[2]); /* transform function pointer */ int (*handleEvent)(struct TransInfo *, const struct wmEvent *); /* event handler function pointer RETURN 1 if redraw is needed */ @@ -494,91 +494,6 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2]); void applyAspectRatio(TransInfo *t, float *vec); void removeAspectRatio(TransInfo *t, float *vec); -void initWarp(TransInfo *t); -int handleEventWarp(TransInfo *t, const struct wmEvent *event); -int Warp(TransInfo *t, const int mval[2]); - -void initShear(TransInfo *t); -int handleEventShear(TransInfo *t, const struct wmEvent *event); -int Shear(TransInfo *t, const int mval[2]); - -void initResize(TransInfo *t); -int Resize(TransInfo *t, const int mval[2]); - -void initSkinResize(TransInfo *t); -int SkinResize(TransInfo *t, const int mval[2]); - -void initTranslation(TransInfo *t); -int Translation(TransInfo *t, const int mval[2]); - -void initToSphere(TransInfo *t); -int ToSphere(TransInfo *t, const int mval[2]); - -void initRotation(TransInfo *t); -int Rotation(TransInfo *t, const int mval[2]); - -void initShrinkFatten(TransInfo *t); -int ShrinkFatten(TransInfo *t, const int mval[2]); - -void initTilt(TransInfo *t); -int Tilt(TransInfo *t, const int mval[2]); - -void initCurveShrinkFatten(TransInfo *t); -int CurveShrinkFatten(TransInfo *t, const int mval[2]); - -void initMaskShrinkFatten(TransInfo *t); -int MaskShrinkFatten(TransInfo *t, const int mval[2]); - -void initTrackball(TransInfo *t); -int Trackball(TransInfo *t, const int mval[2]); - -void initPushPull(TransInfo *t); -int PushPull(TransInfo *t, const int mval[2]); - -void initBevelWeight(TransInfo *t); -int BevelWeight(TransInfo *t, const int mval[2]); - -void initCrease(TransInfo *t); -int Crease(TransInfo *t, const int mval[2]); - -void initBoneSize(TransInfo *t); -int BoneSize(TransInfo *t, const int mval[2]); - -void initBoneEnvelope(TransInfo *t); -int BoneEnvelope(TransInfo *t, const int mval[2]); - -void initBoneRoll(TransInfo *t); -int BoneRoll(TransInfo *t, const int mval[2]); - -void initEdgeSlide(TransInfo *t); -int handleEventEdgeSlide(TransInfo *t, const struct wmEvent *event); -int EdgeSlide(TransInfo *t, const int mval[2]); - -void initVertSlide(TransInfo *t); -int handleEventVertSlide(TransInfo *t, const struct wmEvent *event); -int VertSlide(TransInfo *t, const int mval[2]); - -void initTimeTranslate(TransInfo *t); -int TimeTranslate(TransInfo *t, const int mval[2]); - -void initTimeSlide(TransInfo *t); -int TimeSlide(TransInfo *t, const int mval[2]); - -void initTimeScale(TransInfo *t); -int TimeScale(TransInfo *t, const int mval[2]); - -void initBakeTime(TransInfo *t); -int BakeTime(TransInfo *t, const int mval[2]); - -void initMirror(TransInfo *t); -int Mirror(TransInfo *t, const int mval[2]); - -void initAlign(TransInfo *t); -int Align(TransInfo *t, const int mval[2]); - -void initSeqSlide(TransInfo *t); -int SeqSlide(TransInfo *t, const int mval[2]); - void drawPropCircle(const struct bContext *C, TransInfo *t); struct wmKeyMap *transform_modal_keymap(struct wmKeyConfig *keyconf); -- cgit v1.2.3 From c3b746fa7e4ddcddbe42f65bf9915db21fd75669 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Oct 2013 05:33:42 +0000 Subject: fix [#37179] All transformation normals drawn when proportional edit, individual origins and normal transform orientation are set thanks to psy-fi for the initial patch. --- source/blender/editors/transform/transform_constraints.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index a73bf86feb1..4580bbefc96 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -792,6 +792,13 @@ static void drawObjectConstraint(TransInfo *t) float co[3]; float (*axismtx)[3]; + if (t->flag & T_PROP_EDIT) { + /* we're sorted, so skip the rest */ + if (td->factor == 0.0f) { + break; + } + } + if (t->flag & T_OBJECT) { copy_v3_v3(co, td->ob->obmat[3]); axismtx = td->axismtx; -- cgit v1.2.3 From 5816aa42bf7bff9c7037b7a2bd629c8f26ed2fed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Oct 2013 06:48:36 +0000 Subject: code cleanup: minor transform refactor redraw flag were mixing up types - int/char/bool, add enum type to use instead. --- source/blender/editors/include/ED_numinput.h | 7 ++- source/blender/editors/transform/transform.c | 62 ++++++++++++---------- source/blender/editors/transform/transform.h | 23 ++++---- .../editors/transform/transform_constraints.c | 6 +-- .../blender/editors/transform/transform_generics.c | 2 +- source/blender/editors/transform/transform_input.c | 4 +- source/blender/editors/transform/transform_snap.c | 16 +++--- source/blender/editors/util/numinput.c | 8 +-- 8 files changed, 68 insertions(+), 60 deletions(-) diff --git a/source/blender/editors/include/ED_numinput.h b/source/blender/editors/include/ED_numinput.h index e7d80d96f89..f46332c9a82 100644 --- a/source/blender/editors/include/ED_numinput.h +++ b/source/blender/editors/include/ED_numinput.h @@ -27,7 +27,6 @@ #ifndef __ED_NUMINPUT_H__ #define __ED_NUMINPUT_H__ - /* * The ctrl value has different meaning: * 0 : No value has been typed @@ -59,11 +58,11 @@ typedef struct NumInput { void initNumInput(NumInput *n); #define NUM_STR_REP_LEN 20 /* str must be NUM_STR_LEN * (idx_max + 1) length. */ void outputNumInput(NumInput *n, char *str); -short hasNumInput(NumInput *n); +bool hasNumInput(const NumInput *n); void applyNumInput(NumInput *n, float *vec); -char handleNumInput(NumInput *n, const struct wmEvent *event); +bool handleNumInput(NumInput *n, const struct wmEvent *event); #define NUM_MODAL_INCREMENT_UP 18 #define NUM_MODAL_INCREMENT_DOWN 19 -#endif +#endif /* __ED_NUMINPUT_H__ */ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index a0db93d53b8..c0fb959d6b5 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -111,11 +111,11 @@ static void postInputRotation(TransInfo *t, float values[3]); /* Transform Callbacks */ static void initWarp(TransInfo *t); -static int handleEventWarp(TransInfo *t, const struct wmEvent *event); +static eRedrawFlag handleEventWarp(TransInfo *t, const struct wmEvent *event); static void Warp(TransInfo *t, const int mval[2]); static void initShear(TransInfo *t); -static int handleEventShear(TransInfo *t, const struct wmEvent *event); +static eRedrawFlag handleEventShear(TransInfo *t, const struct wmEvent *event); static void applyShear(TransInfo *t, const int mval[2]); static void initResize(TransInfo *t); @@ -167,11 +167,11 @@ static void initBoneRoll(TransInfo *t); static void applyBoneRoll(TransInfo *t, const int mval[2]); static void initEdgeSlide(TransInfo *t); -static int handleEventEdgeSlide(TransInfo *t, const struct wmEvent *event); +static eRedrawFlag handleEventEdgeSlide(TransInfo *t, const struct wmEvent *event); static void applyEdgeSlide(TransInfo *t, const int mval[2]); static void initVertSlide(TransInfo *t); -static int handleEventVertSlide(TransInfo *t, const struct wmEvent *event); +static eRedrawFlag handleEventVertSlide(TransInfo *t, const struct wmEvent *event); static void applyVertSlide(TransInfo *t, const int mval[2]); static void initTimeTranslate(TransInfo *t); @@ -1220,8 +1220,10 @@ int transformEvent(TransInfo *t, const wmEvent *event) break; } - // Modal numinput events - t->redraw |= handleNumInput(&(t->num), event); + /* Modal numinput events */ + if (handleNumInput(&(t->num), event)) { + t->redraw |= TREDRAW_HARD; + } } /* else do non-mapped events */ else if (event->val == KM_PRESS) { @@ -1325,7 +1327,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) t->flag ^= T_PROP_CONNECTED; sort_trans_data_dist(t); calculatePropRatio(t); - t->redraw = 1; + t->redraw = TREDRAW_HARD; } else { stopConstraint(t); @@ -1351,7 +1353,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->far); calculatePropRatio(t); } - t->redraw = 1; + t->redraw = TREDRAW_HARD; break; case PAGEUPKEY: case WHEELDOWNMOUSE: @@ -1361,14 +1363,14 @@ int transformEvent(TransInfo *t, const wmEvent *event) else { view_editmove(event->type); } - t->redraw = 1; + t->redraw = TREDRAW_HARD; break; case PADMINUS: if (event->alt && t->flag & T_PROP_EDIT) { t->prop_size *= 0.90909090f; calculatePropRatio(t); } - t->redraw = 1; + t->redraw = TREDRAW_HARD; break; case PAGEDOWNKEY: case WHEELUPMOUSE: @@ -1378,7 +1380,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) else { view_editmove(event->type); } - t->redraw = 1; + t->redraw = TREDRAW_HARD; break; case LEFTALTKEY: case RIGHTALTKEY: @@ -1393,10 +1395,12 @@ int transformEvent(TransInfo *t, const wmEvent *event) break; } - // Numerical input events - t->redraw |= handleNumInput(&(t->num), event); + /* Numerical input events */ + if (handleNumInput(&(t->num), event)) { + t->redraw |= TREDRAW_HARD; + } - // Snapping key events + /* Snapping key events */ t->redraw |= handleSnapping(t, event); } @@ -2735,9 +2739,9 @@ static void initWarp(TransInfo *t) t->customData = data; } -static int handleEventWarp(TransInfo *UNUSED(t), const wmEvent *event) +static eRedrawFlag handleEventWarp(TransInfo *UNUSED(t), const wmEvent *event) { - int status = TREDRAW_NOTHING; + eRedrawFlag status = TREDRAW_NOTHING; if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) { status = TREDRAW_HARD; @@ -2898,9 +2902,9 @@ static void initShear(TransInfo *t) t->flag |= T_NO_CONSTRAINT; } -static int handleEventShear(TransInfo *t, const wmEvent *event) +static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event) { - int status = TREDRAW_NOTHING; + eRedrawFlag status = TREDRAW_NOTHING; if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) { // Use customData pointer to signal Shear direction @@ -5867,7 +5871,7 @@ static void initEdgeSlide(TransInfo *t) t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; } -static int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event) +static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event) { if (t->mode == TFM_EDGE_SLIDE) { EdgeSlideData *sld = t->customData; @@ -5877,7 +5881,7 @@ static int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event case EKEY: if (event->val == KM_PRESS) { sld->is_proportional = !sld->is_proportional; - return 1; + return TREDRAW_HARD; } break; case FKEY: @@ -5886,7 +5890,7 @@ static int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event if (sld->is_proportional == FALSE) { sld->flipped_vtx = !sld->flipped_vtx; } - return 1; + return TREDRAW_HARD; } break; } @@ -5911,7 +5915,7 @@ static int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event } } } - return 0; + return TREDRAW_NOTHING; } static void drawEdgeSlide(const struct bContext *C, TransInfo *t) @@ -6338,7 +6342,7 @@ void freeVertSlideVerts(TransInfo *t) recalcData(t); } -void initVertSlide(TransInfo *t) +static void initVertSlide(TransInfo *t) { VertSlideData *sld; @@ -6373,7 +6377,7 @@ void initVertSlide(TransInfo *t) t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT; } -int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event) +static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event) { if (t->mode == TFM_VERT_SLIDE) { VertSlideData *sld = t->customData; @@ -6386,7 +6390,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event) if (sld->flipped_vtx) { calcVertSlideCustomPoints(t); } - return 1; + return TREDRAW_HARD; } break; case FKEY: @@ -6394,7 +6398,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event) if (event->val == KM_PRESS) { sld->flipped_vtx = !sld->flipped_vtx; calcVertSlideCustomPoints(t); - return 1; + return TREDRAW_HARD; } break; } @@ -6404,7 +6408,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event) if (event->val == KM_PRESS) { t->flag ^= T_ALT_TRANSFORM; calcVertSlideCustomPoints(t); - return 1; + return TREDRAW_HARD; } break; } @@ -6440,7 +6444,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event) } } } - return 0; + return TREDRAW_NOTHING; } static void drawVertSlide(const struct bContext *C, TransInfo *t) @@ -6557,7 +6561,7 @@ static int doVertSlide(TransInfo *t, float perc) return 1; } -void applyVertSlide(TransInfo *t, const int UNUSED(mval[2])) +static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2])) { char str[MAX_INFO_LEN]; size_t ofs = 0; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 7233d22756d..376847937f3 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -62,6 +62,13 @@ struct wmTimer; struct ARegion; struct ReportList; +/* transinfo->redraw */ +typedef enum { + TREDRAW_NOTHING = 0, + TREDRAW_HARD = 1, + TREDRAW_SOFT = 2, +} eRedrawFlag; + typedef struct TransSnapPoint { struct TransSnapPoint *next, *prev; float co[3]; @@ -286,7 +293,7 @@ typedef struct TransInfo { float fac; /* factor for distance based transform */ void (*transform)(struct TransInfo *, const int[2]); /* transform function pointer */ - int (*handleEvent)(struct TransInfo *, const struct wmEvent *); + eRedrawFlag (*handleEvent)(struct TransInfo *, const struct wmEvent *); /* event handler function pointer RETURN 1 if redraw is needed */ int total; /* total number of transformed data */ TransData *data; /* transformed data (array) */ @@ -296,7 +303,7 @@ typedef struct TransInfo { TransSnap tsnap; NumInput num; /* numerical input */ MouseInput mouse; /* mouse input */ - char redraw; /* redraw flag */ + eRedrawFlag redraw; /* redraw flag */ float prop_size; /* proportional circle radius */ char proptext[20]; /* proportional falloff text */ float center[3]; /* center of transformation */ @@ -372,12 +379,6 @@ typedef struct TransInfo { #define TRANS_CONFIRM 2 #define TRANS_CANCEL 3 -/* transinfo->redraw */ -#define TREDRAW_NOTHING 0 -#define TREDRAW_HARD 1 -#define TREDRAW_SOFT 2 - - /* transinfo->flag */ #define T_OBJECT (1 << 0) #define T_EDIT (1 << 1) @@ -575,14 +576,14 @@ void initSnapping(struct TransInfo *t, struct wmOperator *op); void applyProject(TransInfo *t); void applySnapping(TransInfo *t, float *vec); void resetSnapping(TransInfo *t); -bool handleSnapping(TransInfo *t, const struct wmEvent *event); +eRedrawFlag handleSnapping(TransInfo *t, const struct wmEvent *event); void drawSnapping(const struct bContext *C, TransInfo *t); bool usingSnappingNormal(TransInfo *t); bool validSnappingNormal(TransInfo *t); void getSnapPoint(TransInfo *t, float vec[3]); void addSnapPoint(TransInfo *t); -bool updateSelectedSnapPoint(TransInfo *t); +eRedrawFlag updateSelectedSnapPoint(TransInfo *t); void removeSnapPoint(TransInfo *t); /********************** Mouse Input ******************************/ @@ -605,7 +606,7 @@ typedef enum { void initMouseInput(TransInfo *t, MouseInput *mi, const float center[2], const int mval[2]); void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode); -int handleMouseInput(struct TransInfo *t, struct MouseInput *mi, const struct wmEvent *event); +eRedrawFlag handleMouseInput(struct TransInfo *t, struct MouseInput *mi, const struct wmEvent *event); void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3]); void setCustomPoints(TransInfo *t, MouseInput *mi, const int start[2], const int end[2]); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 4580bbefc96..4497723185f 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -569,7 +569,7 @@ void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]) t->con.applyVec = applyAxisConstraintVec; t->con.applySize = applyAxisConstraintSize; t->con.applyRot = applyAxisConstraintRot; - t->redraw = 1; + t->redraw = TREDRAW_HARD; } /* applies individual td->axismtx constraints */ @@ -590,7 +590,7 @@ void setAxisMatrixConstraint(TransInfo *t, int mode, const char text[]) t->con.applyVec = applyObjectConstraintVec; t->con.applySize = applyObjectConstraintSize; t->con.applyRot = applyObjectConstraintRot; - t->redraw = 1; + t->redraw = TREDRAW_HARD; } } @@ -911,7 +911,7 @@ void postSelectConstraint(TransInfo *t) setNearestAxis(t); startConstraint(t); - t->redraw = 1; + t->redraw = TREDRAW_HARD; } static void setNearestAxis2d(TransInfo *t) diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 94f481d8dfc..a8248cc73e1 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1066,7 +1066,7 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even t->flag = 0; - t->redraw = 1; /* redraw first time */ + t->redraw = TREDRAW_HARD; /* redraw first time */ if (event) { copy_v2_v2_int(t->imval, event->mval); diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index ee993129303..39c7b4b5c1c 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -407,9 +407,9 @@ void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float outp } } -int handleMouseInput(TransInfo *t, MouseInput *mi, const wmEvent *event) +eRedrawFlag handleMouseInput(TransInfo *t, MouseInput *mi, const wmEvent *event) { - int redraw = TREDRAW_NOTHING; + eRedrawFlag redraw = TREDRAW_NOTHING; switch (event->type) { case LEFTSHIFTKEY: diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 04bccac2a15..dfb0217dfa8 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -267,16 +267,16 @@ void drawSnapping(const struct bContext *C, TransInfo *t) } } -bool handleSnapping(TransInfo *t, const wmEvent *event) +eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event) { - bool status = false; + eRedrawFlag status = TREDRAW_NOTHING; #if 0 // XXX need a proper selector for all snap mode if (BIF_snappingSupported(t->obedit) && event->type == TABKEY && event->shift) { /* toggle snap and reinit */ t->settings->snap_flag ^= SCE_SNAP; initSnapping(t, NULL); - status = 1; + status = TREDRAW_HARD; } #endif if (event->type == MOUSEMOVE) { @@ -606,9 +606,10 @@ void addSnapPoint(TransInfo *t) } } -bool updateSelectedSnapPoint(TransInfo *t) +eRedrawFlag updateSelectedSnapPoint(TransInfo *t) { - bool status = false; + eRedrawFlag status = TREDRAW_NOTHING; + if (t->tsnap.status & MULTI_POINTS) { TransSnapPoint *p, *closest_p = NULL; float closest_dist = TRANSFORM_SNAP_MAX_PX; @@ -631,7 +632,10 @@ bool updateSelectedSnapPoint(TransInfo *t) } if (closest_p) { - status = (t->tsnap.selectedPoint != closest_p); + if (t->tsnap.selectedPoint != closest_p) { + status = TREDRAW_HARD; + } + t->tsnap.selectedPoint = closest_p; } } diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 3e5f879aa3c..0feaf936172 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -114,16 +114,16 @@ void outputNumInput(NumInput *n, char *str) } } -short hasNumInput(NumInput *n) +bool hasNumInput(const NumInput *n) { short i; for (i = 0; i <= n->idx_max; i++) { if (n->ctrl[i]) - return 1; + return true; } - return 0; + return false; } /** @@ -159,7 +159,7 @@ void applyNumInput(NumInput *n, float *vec) } } -char handleNumInput(NumInput *n, const wmEvent *event) +bool handleNumInput(NumInput *n, const wmEvent *event) { float Val = 0; short idx = n->idx, idx_max = n->idx_max; -- cgit v1.2.3 From 0039b44d102f4d38c3a7750e9607f40b4ab1dee1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Oct 2013 10:35:49 +0000 Subject: fix for negated normal being used when using individual centers & normal orientation in vertex select mode. --- source/blender/editors/transform/transform_conversions.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index f5a12fed076..f7010898fc3 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2098,9 +2098,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx } else if (t->around == V3D_LOCAL) { copy_v3_v3(td->center, td->loc); - - axis_dominant_v3_to_m3(td->axismtx, eve->no); - invert_m3(td->axismtx); + createSpaceNormal(td->axismtx, eve->no); } else { copy_v3_v3(td->center, td->loc); -- cgit v1.2.3 From 89fc09b3be854cb4228b681c8094bf0fbbce6eb5 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 23 Oct 2013 11:30:18 +0000 Subject: Fix for OSL bug reported on IRC by Pablo Vasquez: Clamp option of the math node in OSL produces bad results. Really stupid bug, OSL math node was assigning the clamped 1st input value instead of the clamped result of the actual operation. --- intern/cycles/kernel/shaders/node_math.osl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl index c29891ed574..066e5f8dbe1 100644 --- a/intern/cycles/kernel/shaders/node_math.osl +++ b/intern/cycles/kernel/shaders/node_math.osl @@ -95,6 +95,6 @@ shader node_math( Value = safe_modulo(Value1, Value2); if (Clamp) - Value = clamp(Value1, 0.0, 1.0); + Value = clamp(Value, 0.0, 1.0); } -- cgit v1.2.3 From 268e519b412583da01306c5f9c309fa6327e0e90 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 23 Oct 2013 11:58:00 +0000 Subject: Fix #37175, Viewer node issue for newly toggled render passes. The RenderLayers node would use the "combined" image result for all passes which don't have a valid render result yet. This causes problems when the buffer element size is not actually 4 floats (RGBA) as with the 3 float normal passes. Also the result is rather meaningless then, so just keep the image buffer at NULL for unavailable passes, which will return plain (0,0,0) color. --- source/blender/compositor/operations/COM_RenderLayersProg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp index ea6ad86d92c..a8382dd1746 100644 --- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp @@ -60,7 +60,7 @@ void RenderLayersBaseProg::initExecution() if (rl && rl->rectf) { this->m_inputBuffer = RE_RenderLayerGetPass(rl, this->m_renderpass); - if (this->m_inputBuffer == NULL || this->m_renderpass == SCE_PASS_COMBINED) { + if (this->m_inputBuffer == NULL && this->m_renderpass == SCE_PASS_COMBINED) { this->m_inputBuffer = rl->rectf; } } -- cgit v1.2.3 From 804643793eab79f13da2215a521b56a0dcc264c3 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Thu, 24 Oct 2013 11:41:39 +0000 Subject: Fix for occasional crashes due to numerical instability in Freestyle Perlin noise modifiers with a large 'octaves' value. Problem report by Light BWK through personal communications, thanks a lot! --- source/blender/freestyle/intern/geometry/Noise.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/freestyle/intern/geometry/Noise.cpp b/source/blender/freestyle/intern/geometry/Noise.cpp index b21ded9dd95..8ec56e84f95 100644 --- a/source/blender/freestyle/intern/geometry/Noise.cpp +++ b/source/blender/freestyle/intern/geometry/Noise.cpp @@ -62,10 +62,10 @@ namespace Freestyle { #define SETUP(i, b0, b1, r0, r1) \ { \ (t) = (i) + (N); \ - (b0) = ((int)(t)) & BM; \ - (b1) = ((b0) + 1) & BM; \ - (r0) = (t) - (int)(t); \ + (r0) = modff((t), &(u)); \ (r1) = (r0) - 1.0; \ + (b0) = ((int)(u)) & BM; \ + (b1) = ((b0) + 1) & BM; \ } (void)0 static void normalize2(float v[2]) -- cgit v1.2.3 From 4e96e04643dfa5fbc56e784c2f85e8636f029252 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Thu, 24 Oct 2013 18:46:00 +0000 Subject: OSX/CMake: fix ftemplate condition --- CMakeLists.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbb7c17e64b..c34fc5acb31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1805,13 +1805,9 @@ elseif(APPLE) set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing") endif() - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if(${CMAKE_GENERATOR} MATCHES "Xcode") - if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5) - # Xcode 5 has too low template depth of 128 for libmv - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024") - endif() - endif() + if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5) + # Xcode 5 is always using CLANG, which has too low template depth of 128 for libmv + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024") endif() endif() -- cgit v1.2.3 From 58db4b70f3faa473bd864c9caa43d242570d18be Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Oct 2013 20:17:30 +0000 Subject: make the message for addons failing to parse a little more descriptive (suggested in report [#37196]). --- release/scripts/modules/addon_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 2ac7d4c85aa..2d0c917ffa0 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -128,7 +128,7 @@ def modules_refresh(module_cache=addons_fake_modules): mod.__file__ = mod_path mod.__time__ = os.path.getmtime(mod_path) except: - print("AST error in module %s" % mod_name) + print("AST error parsing bl_info for %s" % mod_name) import traceback traceback.print_exc() raise -- cgit v1.2.3 From 4514eeaa8e335a86de0bda68aa4814c0bafad7eb Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Fri, 25 Oct 2013 02:20:23 +0000 Subject: drawobject: Fix sphere bounds drawing Would draw ellipsoid instead, which is not so useful and wrong when used for rigid body collision shape visualization. svn merge -r59887:59888 ^/branches/soc-2013-rigid_body_sim --- source/blender/editors/space_view3d/drawobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 5bfb8180bfc..06aedb2c36d 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6216,8 +6216,9 @@ static void draw_bb_quadric(BoundBox *bb, char type) glPushMatrix(); if (type == OB_BOUND_SPHERE) { + float scale = MAX3(size[0], size[1], size[2]); glTranslatef(cent[0], cent[1], cent[2]); - glScalef(size[0], size[1], size[2]); + glScalef(scale, scale, scale); gluSphere(qobj, 1.0, 8, 5); } else if (type == OB_BOUND_CYLINDER) { -- cgit v1.2.3 From 472a021aca3c0a6278151f7abee4e0970b026e3f Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Fri, 25 Oct 2013 03:43:20 +0000 Subject: bullet: Update to version 2.82 (bullet revision 2705) Remove patch that has been applied upstream. Fixes several bugs. --- extern/bullet2/CMakeLists.txt | 32 + extern/bullet2/patches/ghost_character.patch | 28 - extern/bullet2/readme.txt | 3 - .../BroadphaseCollision/btDispatcher.h | 5 +- .../BroadphaseCollision/btOverlappingPairCache.cpp | 2 +- .../BroadphaseCollision/btOverlappingPairCache.h | 11 +- .../CollisionDispatch/btCollisionConfiguration.h | 2 - .../CollisionDispatch/btCollisionObject.cpp | 3 +- .../CollisionDispatch/btCollisionObject.h | 37 +- .../CollisionDispatch/btCollisionWorld.cpp | 73 +- .../CollisionDispatch/btCollisionWorld.h | 20 +- .../btCompoundCollisionAlgorithm.cpp | 9 + .../btCompoundCollisionAlgorithm.h | 13 + .../btCompoundCompoundCollisionAlgorithm.cpp | 421 ++++ .../btCompoundCompoundCollisionAlgorithm.h | 90 + .../btConvex2dConvex2dAlgorithm.cpp | 1 - .../btConvexConcaveCollisionAlgorithm.cpp | 18 +- .../CollisionDispatch/btConvexConvexAlgorithm.cpp | 1 - .../btDefaultCollisionConfiguration.cpp | 32 +- .../btDefaultCollisionConfiguration.h | 14 +- .../CollisionDispatch/btHashedSimplePairCache.cpp | 278 +++ .../CollisionDispatch/btHashedSimplePairCache.h | 174 ++ .../CollisionShapes/btCompoundShape.cpp | 4 +- .../CollisionShapes/btConeShape.cpp | 4 + .../BulletCollision/CollisionShapes/btConeShape.h | 53 +- .../CollisionShapes/btConvexShape.cpp | 6 + .../CollisionShapes/btHeightfieldTerrainShape.cpp | 4 +- .../CollisionShapes/btTriangleMesh.cpp | 8 +- .../CollisionShapes/btTriangleMesh.h | 2 +- .../btConvexPenetrationDepthSolver.h | 4 +- .../btDiscreteCollisionDetectorInterface.h | 5 +- .../btGjkEpaPenetrationDepthSolver.cpp | 4 +- .../btGjkEpaPenetrationDepthSolver.h | 2 +- .../NarrowPhaseCollision/btGjkPairDetector.cpp | 29 +- .../NarrowPhaseCollision/btGjkPairDetector.h | 2 +- .../btMinkowskiPenetrationDepthSolver.cpp | 3 +- .../btMinkowskiPenetrationDepthSolver.h | 2 +- .../NarrowPhaseCollision/btRaycastCallback.h | 2 +- .../Character/btCharacterControllerInterface.h | 3 +- .../Character/btKinematicCharacterController.cpp | 167 +- .../Character/btKinematicCharacterController.h | 6 +- .../ConstraintSolver/btConeTwistConstraint.h | 64 +- .../ConstraintSolver/btConstraintSolver.h | 16 +- .../ConstraintSolver/btFixedConstraint.cpp | 129 ++ .../ConstraintSolver/btFixedConstraint.h | 49 + .../ConstraintSolver/btGearConstraint.h | 98 +- .../ConstraintSolver/btGeneric6DofConstraint.h | 44 +- .../btGeneric6DofSpringConstraint.h | 33 +- .../ConstraintSolver/btHingeConstraint.h | 37 +- .../ConstraintSolver/btPoint2PointConstraint.h | 22 +- .../btSequentialImpulseConstraintSolver.cpp | 296 ++- .../btSequentialImpulseConstraintSolver.h | 31 +- .../ConstraintSolver/btSliderConstraint.h | 46 +- .../BulletDynamics/ConstraintSolver/btSolverBody.h | 13 + .../ConstraintSolver/btSolverConstraint.h | 1 + .../ConstraintSolver/btTypedConstraint.cpp | 10 +- .../ConstraintSolver/btTypedConstraint.h | 64 +- .../Dynamics/btDiscreteDynamicsWorld.cpp | 39 +- .../Dynamics/btDiscreteDynamicsWorld.h | 15 +- .../src/BulletDynamics/Dynamics/btDynamicsWorld.h | 3 +- .../src/BulletDynamics/Dynamics/btRigidBody.h | 4 + .../Dynamics/btSimpleDynamicsWorld.cpp | 4 +- .../BulletDynamics/Featherstone/btMultiBody.cpp | 1009 ++++++++++ .../src/BulletDynamics/Featherstone/btMultiBody.h | 466 +++++ .../Featherstone/btMultiBodyConstraint.cpp | 527 +++++ .../Featherstone/btMultiBodyConstraint.h | 166 ++ .../Featherstone/btMultiBodyConstraintSolver.cpp | 795 ++++++++ .../Featherstone/btMultiBodyConstraintSolver.h | 85 + .../Featherstone/btMultiBodyDynamicsWorld.cpp | 578 ++++++ .../Featherstone/btMultiBodyDynamicsWorld.h | 56 + .../btMultiBodyJointLimitConstraint.cpp | 133 ++ .../Featherstone/btMultiBodyJointLimitConstraint.h | 44 + .../Featherstone/btMultiBodyJointMotor.cpp | 89 + .../Featherstone/btMultiBodyJointMotor.h | 47 + .../BulletDynamics/Featherstone/btMultiBodyLink.h | 110 ++ .../Featherstone/btMultiBodyLinkCollider.h | 92 + .../Featherstone/btMultiBodyPoint2Point.cpp | 143 ++ .../Featherstone/btMultiBodyPoint2Point.h | 60 + .../Featherstone/btMultiBodySolverConstraint.h | 82 + .../BulletDynamics/MLCPSolvers/btDantzigLCP.cpp | 2079 ++++++++++++++++++++ .../src/BulletDynamics/MLCPSolvers/btDantzigLCP.h | 77 + .../BulletDynamics/MLCPSolvers/btDantzigSolver.h | 112 ++ .../BulletDynamics/MLCPSolvers/btMLCPSolver.cpp | 626 ++++++ .../src/BulletDynamics/MLCPSolvers/btMLCPSolver.h | 81 + .../MLCPSolvers/btMLCPSolverInterface.h | 33 + .../src/BulletDynamics/MLCPSolvers/btPATHSolver.h | 151 ++ .../MLCPSolvers/btSolveProjectedGaussSeidel.h | 80 + extern/bullet2/src/BulletSoftBody/btSoftBody.cpp | 18 +- extern/bullet2/src/BulletSoftBody/btSoftBody.h | 2 + .../src/BulletSoftBody/btSoftBodyHelpers.cpp | 6 +- extern/bullet2/src/BulletSoftBody/btSparseSDF.h | 17 +- extern/bullet2/src/LinearMath/btIDebugDraw.h | 138 +- extern/bullet2/src/LinearMath/btMatrix3x3.h | 31 +- extern/bullet2/src/LinearMath/btMatrixX.h | 504 +++++ extern/bullet2/src/LinearMath/btQuaternion.h | 42 +- extern/bullet2/src/LinearMath/btScalar.h | 78 +- extern/bullet2/src/LinearMath/btSerializer.cpp | 1583 ++++++++------- extern/bullet2/src/LinearMath/btSerializer.h | 3 +- extern/bullet2/src/LinearMath/btVector3.cpp | 49 +- extern/bullet2/src/LinearMath/btVector3.h | 32 +- extern/bullet2/src/btBulletDynamicsCommon.h | 2 + 101 files changed, 11572 insertions(+), 1249 deletions(-) delete mode 100644 extern/bullet2/patches/ghost_character.patch create mode 100644 extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp create mode 100644 extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h create mode 100644 extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp create mode 100644 extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.h create mode 100644 extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp create mode 100644 extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.h create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.h create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.h create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.h create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyLink.h create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.h create mode 100644 extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodySolverConstraint.h create mode 100644 extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp create mode 100644 extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.h create mode 100644 extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigSolver.h create mode 100644 extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp create mode 100644 extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolver.h create mode 100644 extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h create mode 100644 extern/bullet2/src/BulletDynamics/MLCPSolvers/btPATHSolver.h create mode 100644 extern/bullet2/src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h create mode 100644 extern/bullet2/src/LinearMath/btMatrixX.h diff --git a/extern/bullet2/CMakeLists.txt b/extern/bullet2/CMakeLists.txt index 02ca2cd3755..2b2c18c0685 100644 --- a/extern/bullet2/CMakeLists.txt +++ b/extern/bullet2/CMakeLists.txt @@ -67,6 +67,8 @@ set(SRC src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp src/BulletCollision/CollisionDispatch/btUnionFind.cpp src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp + src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp + src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp src/BulletCollision/CollisionShapes/btBoxShape.cpp src/BulletCollision/CollisionShapes/btBox2dShape.cpp src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp @@ -140,6 +142,7 @@ set(SRC src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp src/BulletDynamics/ConstraintSolver/btGearConstraint.cpp + src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp src/BulletDynamics/Dynamics/btRigidBody.cpp src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp @@ -147,6 +150,15 @@ set(SRC src/BulletDynamics/Vehicle/btRaycastVehicle.cpp src/BulletDynamics/Vehicle/btWheelInfo.cpp src/BulletDynamics/Character/btKinematicCharacterController.cpp + src/BulletDynamics/Featherstone/btMultiBody.cpp + src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp + src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp + src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp + src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp + src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp + src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp + src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp + src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp src/BulletSoftBody/btSoftBody.cpp src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp @@ -204,6 +216,8 @@ set(SRC src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h src/BulletCollision/CollisionDispatch/btUnionFind.h src/BulletCollision/CollisionDispatch/SphereTriangleDetector.h + src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h + src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.h src/BulletCollision/CollisionShapes/btBoxShape.h src/BulletCollision/CollisionShapes/btBox2dShape.h src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h @@ -308,6 +322,7 @@ set(SRC src/BulletDynamics/ConstraintSolver/btTypedConstraint.h src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h src/BulletDynamics/ConstraintSolver/btGearConstraint.h + src/BulletDynamics/ConstraintSolver/btFixedConstraint.h src/BulletDynamics/Dynamics/btActionInterface.h src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h src/BulletDynamics/Dynamics/btDynamicsWorld.h @@ -318,6 +333,22 @@ set(SRC src/BulletDynamics/Vehicle/btWheelInfo.h src/BulletDynamics/Character/btCharacterControllerInterface.h src/BulletDynamics/Character/btKinematicCharacterController.h + src/BulletDynamics/Featherstone/btMultiBody.h + src/BulletDynamics/Featherstone/btMultiBodyConstraint.h + src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h + src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h + src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.h + src/BulletDynamics/Featherstone/btMultiBodyJointMotor.h + src/BulletDynamics/Featherstone/btMultiBodyLink.h + src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h + src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.h + src/BulletDynamics/Featherstone/btMultiBodySolverConstraint.h + src/BulletDynamics/MLCPSolvers/btDantzigLCP.h + src/BulletDynamics/MLCPSolvers/btDantzigSolver.h + src/BulletDynamics/MLCPSolvers/btMLCPSolver.h + src/BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h + src/BulletDynamics/MLCPSolvers/btPATHSolver.h + src/BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h src/BulletSoftBody/btSoftBody.h src/BulletSoftBody/btSoftBodyInternals.h @@ -359,6 +390,7 @@ set(SRC src/LinearMath/btTransformUtil.h src/LinearMath/btVector3.h src/LinearMath/btPolarDecomposition.h + src/LinearMath/btMatrixX.h src/btBulletCollisionCommon.h diff --git a/extern/bullet2/patches/ghost_character.patch b/extern/bullet2/patches/ghost_character.patch deleted file mode 100644 index d4098cb8bc2..00000000000 --- a/extern/bullet2/patches/ghost_character.patch +++ /dev/null @@ -1,28 +0,0 @@ -Index: extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp -=================================================================== ---- extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp (revision 49183) -+++ extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp (working copy) -@@ -77,6 +77,9 @@ - if (convexResult.m_hitCollisionObject == m_me) - return btScalar(1.0); - -+ if (!convexResult.m_hitCollisionObject->hasContactResponse()) -+ return btScalar(1.0); -+ - btVector3 hitNormalWorld; - if (normalInWorldSpace) - { -@@ -173,7 +176,12 @@ - m_manifoldArray.resize(0); - - btBroadphasePair* collisionPair = &m_ghostObject->getOverlappingPairCache()->getOverlappingPairArray()[i]; -- -+ btCollisionObject* obj0 = static_cast(collisionPair->m_pProxy0->m_clientObject); -+ btCollisionObject* obj1 = static_cast(collisionPair->m_pProxy1->m_clientObject); -+ -+ if ((obj0 && !obj0->hasContactResponse()) || (obj1 && !obj1->hasContactResponse())) -+ continue; -+ - if (collisionPair->m_algorithm) - collisionPair->m_algorithm->getAllContactManifolds(m_manifoldArray); - diff --git a/extern/bullet2/readme.txt b/extern/bullet2/readme.txt index dd806d40fac..33430fc8ee3 100644 --- a/extern/bullet2/readme.txt +++ b/extern/bullet2/readme.txt @@ -7,8 +7,5 @@ Erwin Apply patches/ghost_softbody.patch to prevent softbodies being hit by ghost objects. Originally committed in blender svn revision: 43905. -Apply patches/ghost_character.patch to prevent characters from colliding with ghost objects. -Mitchell - Apply patches/convex_hull.patch to add access to the convex hull operation, used in the BMesh convex hull operator. diff --git a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h index 1ebb37797d9..89c307d14ca 100644 --- a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h +++ b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btDispatcher.h @@ -25,7 +25,6 @@ class btOverlappingPairCache; struct btCollisionObjectWrapper; class btPersistentManifold; -class btStackAlloc; class btPoolAllocator; struct btDispatcherInfo @@ -47,8 +46,7 @@ struct btDispatcherInfo m_useEpa(true), m_allowedCcdPenetration(btScalar(0.04)), m_useConvexConservativeDistanceUtil(false), - m_convexConservativeDistanceThreshold(0.0f), - m_stackAllocator(0) + m_convexConservativeDistanceThreshold(0.0f) { } @@ -64,7 +62,6 @@ struct btDispatcherInfo btScalar m_allowedCcdPenetration; bool m_useConvexConservativeDistanceUtil; btScalar m_convexConservativeDistanceThreshold; - btStackAlloc* m_stackAllocator; }; ///The btDispatcher interface class can be used in combination with broadphase to dispatch calculations for overlapping pairs. diff --git a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp index 041bbe05ae2..ae22dadc73a 100644 --- a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp +++ b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp @@ -53,7 +53,7 @@ btHashedOverlappingPairCache::~btHashedOverlappingPairCache() void btHashedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher) { - if (pair.m_algorithm) + if (pair.m_algorithm && dispatcher) { { pair.m_algorithm->~btCollisionAlgorithm(); diff --git a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h index 7a3806c1d28..eee90e473a9 100644 --- a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h +++ b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h @@ -96,6 +96,12 @@ class btHashedOverlappingPairCache : public btOverlappingPairCache btOverlapFilterCallback* m_overlapFilterCallback; bool m_blockedForChanges; +protected: + + btAlignedObjectArray m_hashTable; + btAlignedObjectArray m_next; + btOverlappingPairCallback* m_ghostPairCallback; + public: btHashedOverlappingPairCache(); @@ -265,11 +271,6 @@ private: virtual void sortOverlappingPairs(btDispatcher* dispatcher); -protected: - - btAlignedObjectArray m_hashTable; - btAlignedObjectArray m_next; - btOverlappingPairCallback* m_ghostPairCallback; }; diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h index f63e0923b78..66949849448 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionConfiguration.h @@ -18,7 +18,6 @@ subject to the following restrictions: struct btCollisionAlgorithmCreateFunc; -class btStackAlloc; class btPoolAllocator; ///btCollisionConfiguration allows to configure Bullet collision detection @@ -38,7 +37,6 @@ public: virtual btPoolAllocator* getCollisionAlgorithmPool() = 0; - virtual btStackAlloc* getStackAllocator() = 0; virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1) =0; diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp index cf8ed59a541..d0924100058 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp @@ -38,7 +38,8 @@ btCollisionObject::btCollisionObject() m_hitFraction(btScalar(1.)), m_ccdSweptSphereRadius(btScalar(0.)), m_ccdMotionThreshold(btScalar(0.)), - m_checkCollideWith(false) + m_checkCollideWith(false), + m_updateRevision(0) { m_worldTransform.setIdentity(); } diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h index 2f17967fe0f..89cad168210 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h @@ -92,7 +92,11 @@ protected: int m_internalType; ///users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPointer - void* m_userObjectPointer; + union + { + void* m_userObjectPointer; + int m_userIndex; + }; ///time of impact calculation btScalar m_hitFraction; @@ -106,6 +110,9 @@ protected: /// If some object should have elaborate collision filtering by sub-classes int m_checkCollideWith; + ///internal update revision number. It will be increased when the object changes. This allows some subsystems to perform lazy evaluation. + int m_updateRevision; + virtual bool checkCollideWithOverride(const btCollisionObject* /* co */) const { return true; @@ -135,7 +142,8 @@ public: CO_GHOST_OBJECT=4, CO_SOFT_BODY=8, CO_HF_FLUID=16, - CO_USER_TYPE=32 + CO_USER_TYPE=32, + CO_FEATHERSTONE_LINK=64 }; enum AnisotropicFrictionFlags @@ -202,6 +210,7 @@ public: virtual void setCollisionShape(btCollisionShape* collisionShape) { + m_updateRevision++; m_collisionShape = collisionShape; m_rootCollisionShape = collisionShape; } @@ -257,6 +266,7 @@ public: void setRestitution(btScalar rest) { + m_updateRevision++; m_restitution = rest; } btScalar getRestitution() const @@ -265,6 +275,7 @@ public: } void setFriction(btScalar frict) { + m_updateRevision++; m_friction = frict; } btScalar getFriction() const @@ -274,6 +285,7 @@ public: void setRollingFriction(btScalar frict) { + m_updateRevision++; m_rollingFriction = frict; } btScalar getRollingFriction() const @@ -300,6 +312,7 @@ public: void setWorldTransform(const btTransform& worldTrans) { + m_updateRevision++; m_worldTransform = worldTrans; } @@ -332,16 +345,19 @@ public: void setInterpolationWorldTransform(const btTransform& trans) { + m_updateRevision++; m_interpolationWorldTransform = trans; } void setInterpolationLinearVelocity(const btVector3& linvel) { + m_updateRevision++; m_interpolationLinearVelocity = linvel; } void setInterpolationAngularVelocity(const btVector3& angvel) { + m_updateRevision++; m_interpolationAngularVelocity = angvel; } @@ -431,13 +447,28 @@ public: { return m_userObjectPointer; } - + + int getUserIndex() const + { + return m_userIndex; + } ///users can point to their objects, userPointer is not used by Bullet void setUserPointer(void* userPointer) { m_userObjectPointer = userPointer; } + ///users can point to their objects, userPointer is not used by Bullet + void setUserIndex(int index) + { + m_userIndex = index; + } + + int getUpdateRevisionInternal() const + { + return m_updateRevision; + } + inline bool checkCollideWith(const btCollisionObject* co) const { diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp index 4c09291692d..093c6f9b200 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp @@ -31,11 +31,10 @@ subject to the following restrictions: #include "BulletCollision/BroadphaseCollision/btDbvt.h" #include "LinearMath/btAabbUtil2.h" #include "LinearMath/btQuickprof.h" -#include "LinearMath/btStackAlloc.h" #include "LinearMath/btSerializer.h" #include "BulletCollision/CollisionShapes/btConvexPolyhedron.h" #include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h" - +#include "BulletCollision/Gimpact/btGImpactShape.h" //#define DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION @@ -73,8 +72,6 @@ m_broadphasePairCache(pairCache), m_debugDrawer(0), m_forceUpdateAllAabbs(true) { - m_stackAlloc = collisionConfiguration->getStackAllocator(); - m_dispatchInfo.m_stackAllocator = m_stackAlloc; } @@ -290,13 +287,19 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans,con btConvexShape* convexShape = (btConvexShape*) collisionShape; btVoronoiSimplexSolver simplexSolver; -#define USE_SUBSIMPLEX_CONVEX_CAST 1 -#ifdef USE_SUBSIMPLEX_CONVEX_CAST - btSubsimplexConvexCast convexCaster(castShape,convexShape,&simplexSolver); -#else - //btGjkConvexCast convexCaster(castShape,convexShape,&simplexSolver); + btSubsimplexConvexCast subSimplexConvexCaster(castShape,convexShape,&simplexSolver); + + btGjkConvexCast gjkConvexCaster(castShape,convexShape,&simplexSolver); + //btContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,0); -#endif //#USE_SUBSIMPLEX_CONVEX_CAST + bool condition = true; + btConvexCast* convexCasterPtr = 0; + if (resultCallback.m_flags & btTriangleRaycastCallback::kF_UseSubSimplexConvexCastRaytest) + convexCasterPtr = &subSimplexConvexCaster; + else + convexCasterPtr = &gjkConvexCaster; + + btConvexCast& convexCaster = *convexCasterPtr; if (convexCaster.calcTimeOfImpact(rayFromTrans,rayToTrans,colObjWorldTransform,colObjWorldTransform,castResult)) { @@ -328,34 +331,26 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans,con } else { if (collisionShape->isConcave()) { - // BT_PROFILE("rayTestConcave"); - if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE) - { - ///optimized version for btBvhTriangleMeshShape - btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape; - btTransform worldTocollisionObject = colObjWorldTransform.inverse(); - btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin(); - btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin(); - //ConvexCast::CastResult + //ConvexCast::CastResult struct BridgeTriangleRaycastCallback : public btTriangleRaycastCallback { btCollisionWorld::RayResultCallback* m_resultCallback; const btCollisionObject* m_collisionObject; - btTriangleMeshShape* m_triangleMesh; + const btConcaveShape* m_triangleMesh; btTransform m_colObjWorldTransform; BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to, - btCollisionWorld::RayResultCallback* resultCallback, const btCollisionObject* collisionObject,btTriangleMeshShape* triangleMesh,const btTransform& colObjWorldTransform): - //@BP Mod - btTriangleRaycastCallback(from,to, resultCallback->m_flags), - m_resultCallback(resultCallback), - m_collisionObject(collisionObject), - m_triangleMesh(triangleMesh), - m_colObjWorldTransform(colObjWorldTransform) - { - } + btCollisionWorld::RayResultCallback* resultCallback, const btCollisionObject* collisionObject,const btConcaveShape* triangleMesh,const btTransform& colObjWorldTransform): + //@BP Mod + btTriangleRaycastCallback(from,to, resultCallback->m_flags), + m_resultCallback(resultCallback), + m_collisionObject(collisionObject), + m_triangleMesh(triangleMesh), + m_colObjWorldTransform(colObjWorldTransform) + { + } virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex ) @@ -378,10 +373,28 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans,con }; + btTransform worldTocollisionObject = colObjWorldTransform.inverse(); + btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin(); + btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin(); + + // BT_PROFILE("rayTestConcave"); + if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE) + { + ///optimized version for btBvhTriangleMeshShape + btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape; + BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObjectWrap->getCollisionObject(),triangleMesh,colObjWorldTransform); rcb.m_hitFraction = resultCallback.m_closestHitFraction; triangleMesh->performRaycast(&rcb,rayFromLocal,rayToLocal); - } else + } + else if(collisionShape->getShapeType()==GIMPACT_SHAPE_PROXYTYPE) + { + btGImpactMeshShape* concaveShape = (btGImpactMeshShape*)collisionShape; + + BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObjectWrap->getCollisionObject(),concaveShape, colObjWorldTransform); + rcb.m_hitFraction = resultCallback.m_closestHitFraction; + concaveShape->processAllTrianglesRay(&rcb,rayFromLocal,rayToLocal); + }else { //generic (slower) case btConcaveShape* concaveShape = (btConcaveShape*)collisionShape; diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h index 9412242e8a3..b3fffdecd98 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h @@ -1,6 +1,6 @@ /* Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://bulletphysics.com/Bullet/ +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. @@ -18,13 +18,11 @@ subject to the following restrictions: * @mainpage Bullet Documentation * * @section intro_sec Introduction - * Bullet Collision Detection & Physics SDK - * * Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ). * * The main documentation is Bullet_User_Manual.pdf, included in the source code distribution. * There is the Physics Forum for feedback and general Collision Detection and Physics discussions. - * Please visit http://www.bulletphysics.com + * Please visit http://www.bulletphysics.org * * @section install_sec Installation * @@ -32,7 +30,16 @@ subject to the following restrictions: * You can download the Bullet Physics Library from the Google Code repository: http://code.google.com/p/bullet/downloads/list * * @subsection step2 Step 2: Building - * Bullet main build system for all platforms is cmake, you can download http://www.cmake.org + * Bullet has multiple build systems, including premake, cmake and autotools. Premake and cmake support all platforms. + * Premake is included in the Bullet/build folder for Windows, Mac OSX and Linux. + * Under Windows you can click on Bullet/build/vs2010.bat to create Microsoft Visual Studio projects. + * On Mac OSX and Linux you can open a terminal and generate Makefile, codeblocks or Xcode4 projects: + * cd Bullet/build + * ./premake4_osx gmake or ./premake4_linux gmake or ./premake4_linux64 gmake or (for Mac) ./premake4_osx xcode4 + * cd Bullet/build/gmake + * make + * + * An alternative to premake is cmake. You can download cmake from http://www.cmake.org * cmake can autogenerate projectfiles for Microsoft Visual Studio, Apple Xcode, KDevelop and Unix Makefiles. * The easiest is to run the CMake cmake-gui graphical user interface and choose the options and generate projectfiles. * You can also use cmake in the command-line. Here are some examples for various platforms: @@ -65,7 +72,6 @@ subject to the following restrictions: #ifndef BT_COLLISION_WORLD_H #define BT_COLLISION_WORLD_H -class btStackAlloc; class btCollisionShape; class btConvexShape; class btBroadphaseInterface; @@ -91,8 +97,6 @@ protected: btDispatcherInfo m_dispatchInfo; - btStackAlloc* m_stackAlloc; - btBroadphaseInterface* m_broadphasePairCache; btIDebugDraw* m_debugDrawer; diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp index 39b86a28918..991841ee20b 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp @@ -11,6 +11,7 @@ subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. + */ #include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h" @@ -22,6 +23,8 @@ subject to the following restrictions: #include "btManifoldResult.h" #include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h" +btShapePairCallback gCompoundChildShapePairCallback = 0; + btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped) :btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap), m_isSwapped(isSwapped), @@ -129,6 +132,12 @@ public: childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0); m_otherObjWrap->getCollisionShape()->getAabb(m_otherObjWrap->getWorldTransform(),aabbMin1,aabbMax1); + if (gCompoundChildShapePairCallback) + { + if (!gCompoundChildShapePairCallback(m_otherObjWrap->getCollisionShape(), childShape)) + return; + } + if (TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1)) { diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h index b16fc524672..53675145637 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h @@ -11,6 +11,7 @@ subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. + */ #ifndef BT_COMPOUND_COLLISION_ALGORITHM_H @@ -28,6 +29,10 @@ class btDispatcher; class btDispatcher; class btCollisionObject; +class btCollisionShape; +typedef bool (*btShapePairCallback)(const btCollisionShape* pShape0, const btCollisionShape* pShape1); +extern btShapePairCallback gCompoundChildShapePairCallback; + /// btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes class btCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm { @@ -37,6 +42,7 @@ class btCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm class btPersistentManifold* m_sharedManifold; bool m_ownsManifold; + int m_compoundShapeRevision;//to keep track of changes, so that childAlgorithm array can be updated void removeChildAlgorithms(); @@ -49,6 +55,12 @@ public: virtual ~btCompoundCollisionAlgorithm(); + btCollisionAlgorithm* getChildAlgorithm (int n) const + { + return m_childCollisionAlgorithms[n]; + } + + virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); @@ -63,6 +75,7 @@ public: } } + struct CreateFunc :public btCollisionAlgorithmCreateFunc { virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap) diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp new file mode 100644 index 00000000000..a52dd34fe91 --- /dev/null +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp @@ -0,0 +1,421 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + +*/ + +#include "btCompoundCompoundCollisionAlgorithm.h" +#include "BulletCollision/CollisionDispatch/btCollisionObject.h" +#include "BulletCollision/CollisionShapes/btCompoundShape.h" +#include "BulletCollision/BroadphaseCollision/btDbvt.h" +#include "LinearMath/btIDebugDraw.h" +#include "LinearMath/btAabbUtil2.h" +#include "BulletCollision/CollisionDispatch/btManifoldResult.h" +#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h" + + +btShapePairCallback gCompoundCompoundChildShapePairCallback = 0; + +btCompoundCompoundCollisionAlgorithm::btCompoundCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped) +:btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap), +m_sharedManifold(ci.m_manifold) +{ + m_ownsManifold = false; + + void* ptr = btAlignedAlloc(sizeof(btHashedSimplePairCache),16); + m_childCollisionAlgorithmCache= new(ptr) btHashedSimplePairCache(); + + const btCollisionObjectWrapper* col0ObjWrap = body0Wrap; + btAssert (col0ObjWrap->getCollisionShape()->isCompound()); + + const btCollisionObjectWrapper* col1ObjWrap = body1Wrap; + btAssert (col1ObjWrap->getCollisionShape()->isCompound()); + + const btCompoundShape* compoundShape0 = static_cast(col0ObjWrap->getCollisionShape()); + m_compoundShapeRevision0 = compoundShape0->getUpdateRevision(); + + const btCompoundShape* compoundShape1 = static_cast(col1ObjWrap->getCollisionShape()); + m_compoundShapeRevision1 = compoundShape1->getUpdateRevision(); + + +} + + +btCompoundCompoundCollisionAlgorithm::~btCompoundCompoundCollisionAlgorithm() +{ + removeChildAlgorithms(); + m_childCollisionAlgorithmCache->~btHashedSimplePairCache(); + btAlignedFree(m_childCollisionAlgorithmCache); +} + +void btCompoundCompoundCollisionAlgorithm::getAllContactManifolds(btManifoldArray& manifoldArray) +{ + int i; + btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray(); + for (i=0;igetAllContactManifolds(manifoldArray); + } + } +} + + +void btCompoundCompoundCollisionAlgorithm::removeChildAlgorithms() +{ + btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray(); + + int numChildren = pairs.size(); + int i; + for (i=0;i~btCollisionAlgorithm(); + m_dispatcher->freeCollisionAlgorithm(algo); + } + } + m_childCollisionAlgorithmCache->removeAllPairs(); +} + +struct btCompoundCompoundLeafCallback : btDbvt::ICollide +{ + int m_numOverlapPairs; + + + const btCollisionObjectWrapper* m_compound0ColObjWrap; + const btCollisionObjectWrapper* m_compound1ColObjWrap; + btDispatcher* m_dispatcher; + const btDispatcherInfo& m_dispatchInfo; + btManifoldResult* m_resultOut; + + + class btHashedSimplePairCache* m_childCollisionAlgorithmCache; + + btPersistentManifold* m_sharedManifold; + + btCompoundCompoundLeafCallback (const btCollisionObjectWrapper* compound1ObjWrap, + const btCollisionObjectWrapper* compound0ObjWrap, + btDispatcher* dispatcher, + const btDispatcherInfo& dispatchInfo, + btManifoldResult* resultOut, + btHashedSimplePairCache* childAlgorithmsCache, + btPersistentManifold* sharedManifold) + :m_compound0ColObjWrap(compound1ObjWrap),m_compound1ColObjWrap(compound0ObjWrap),m_dispatcher(dispatcher),m_dispatchInfo(dispatchInfo),m_resultOut(resultOut), + m_childCollisionAlgorithmCache(childAlgorithmsCache), + m_sharedManifold(sharedManifold), + m_numOverlapPairs(0) + { + + } + + + + + void Process(const btDbvtNode* leaf0,const btDbvtNode* leaf1) + { + m_numOverlapPairs++; + + + int childIndex0 = leaf0->dataAsInt; + int childIndex1 = leaf1->dataAsInt; + + + btAssert(childIndex0>=0); + btAssert(childIndex1>=0); + + + const btCompoundShape* compoundShape0 = static_cast(m_compound0ColObjWrap->getCollisionShape()); + btAssert(childIndex0getNumChildShapes()); + + const btCompoundShape* compoundShape1 = static_cast(m_compound1ColObjWrap->getCollisionShape()); + btAssert(childIndex1getNumChildShapes()); + + const btCollisionShape* childShape0 = compoundShape0->getChildShape(childIndex0); + const btCollisionShape* childShape1 = compoundShape1->getChildShape(childIndex1); + + //backup + btTransform orgTrans0 = m_compound0ColObjWrap->getWorldTransform(); + const btTransform& childTrans0 = compoundShape0->getChildTransform(childIndex0); + btTransform newChildWorldTrans0 = orgTrans0*childTrans0 ; + + btTransform orgTrans1 = m_compound1ColObjWrap->getWorldTransform(); + const btTransform& childTrans1 = compoundShape1->getChildTransform(childIndex1); + btTransform newChildWorldTrans1 = orgTrans1*childTrans1 ; + + + //perform an AABB check first + btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1; + childShape0->getAabb(newChildWorldTrans0,aabbMin0,aabbMax0); + childShape1->getAabb(newChildWorldTrans1,aabbMin1,aabbMax1); + + if (gCompoundCompoundChildShapePairCallback) + { + if (!gCompoundCompoundChildShapePairCallback(childShape0,childShape1)) + return; + } + + if (TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1)) + { + btCollisionObjectWrapper compoundWrap0(this->m_compound0ColObjWrap,childShape0, m_compound0ColObjWrap->getCollisionObject(),newChildWorldTrans0,-1,childIndex0); + btCollisionObjectWrapper compoundWrap1(this->m_compound1ColObjWrap,childShape1,m_compound1ColObjWrap->getCollisionObject(),newChildWorldTrans1,-1,childIndex1); + + + btSimplePair* pair = m_childCollisionAlgorithmCache->findPair(childIndex0,childIndex1); + + btCollisionAlgorithm* colAlgo = 0; + + if (pair) + { + colAlgo = (btCollisionAlgorithm*)pair->m_userPointer; + + } else + { + colAlgo = m_dispatcher->findAlgorithm(&compoundWrap0,&compoundWrap1,m_sharedManifold); + pair = m_childCollisionAlgorithmCache->addOverlappingPair(childIndex0,childIndex1); + btAssert(pair); + pair->m_userPointer = colAlgo; + } + + btAssert(colAlgo); + + const btCollisionObjectWrapper* tmpWrap0 = 0; + const btCollisionObjectWrapper* tmpWrap1 = 0; + + tmpWrap0 = m_resultOut->getBody0Wrap(); + tmpWrap1 = m_resultOut->getBody1Wrap(); + + m_resultOut->setBody0Wrap(&compoundWrap0); + m_resultOut->setBody1Wrap(&compoundWrap1); + + m_resultOut->setShapeIdentifiersA(-1,childIndex0); + m_resultOut->setShapeIdentifiersB(-1,childIndex1); + + + colAlgo->processCollision(&compoundWrap0,&compoundWrap1,m_dispatchInfo,m_resultOut); + + m_resultOut->setBody0Wrap(tmpWrap0); + m_resultOut->setBody1Wrap(tmpWrap1); + + + + } + } +}; + + +static DBVT_INLINE bool MyIntersect( const btDbvtAabbMm& a, + const btDbvtAabbMm& b, const btTransform& xform) +{ + btVector3 newmin,newmax; + btTransformAabb(b.Mins(),b.Maxs(),0.f,xform,newmin,newmax); + btDbvtAabbMm newb = btDbvtAabbMm::FromMM(newmin,newmax); + return Intersect(a,newb); +} + + +static inline void MycollideTT( const btDbvtNode* root0, + const btDbvtNode* root1, + const btTransform& xform, + btCompoundCompoundLeafCallback* callback) +{ + + if(root0&&root1) + { + int depth=1; + int treshold=btDbvt::DOUBLE_STACKSIZE-4; + btAlignedObjectArray stkStack; + stkStack.resize(btDbvt::DOUBLE_STACKSIZE); + stkStack[0]=btDbvt::sStkNN(root0,root1); + do { + btDbvt::sStkNN p=stkStack[--depth]; + if(MyIntersect(p.a->volume,p.b->volume,xform)) + { + if(depth>treshold) + { + stkStack.resize(stkStack.size()*2); + treshold=stkStack.size()-4; + } + if(p.a->isinternal()) + { + if(p.b->isinternal()) + { + stkStack[depth++]=btDbvt::sStkNN(p.a->childs[0],p.b->childs[0]); + stkStack[depth++]=btDbvt::sStkNN(p.a->childs[1],p.b->childs[0]); + stkStack[depth++]=btDbvt::sStkNN(p.a->childs[0],p.b->childs[1]); + stkStack[depth++]=btDbvt::sStkNN(p.a->childs[1],p.b->childs[1]); + } + else + { + stkStack[depth++]=btDbvt::sStkNN(p.a->childs[0],p.b); + stkStack[depth++]=btDbvt::sStkNN(p.a->childs[1],p.b); + } + } + else + { + if(p.b->isinternal()) + { + stkStack[depth++]=btDbvt::sStkNN(p.a,p.b->childs[0]); + stkStack[depth++]=btDbvt::sStkNN(p.a,p.b->childs[1]); + } + else + { + callback->Process(p.a,p.b); + } + } + } + } while(depth); + } +} + +void btCompoundCompoundCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) +{ + + const btCollisionObjectWrapper* col0ObjWrap = body0Wrap; + const btCollisionObjectWrapper* col1ObjWrap= body1Wrap; + + btAssert (col0ObjWrap->getCollisionShape()->isCompound()); + btAssert (col1ObjWrap->getCollisionShape()->isCompound()); + const btCompoundShape* compoundShape0 = static_cast(col0ObjWrap->getCollisionShape()); + const btCompoundShape* compoundShape1 = static_cast(col1ObjWrap->getCollisionShape()); + + ///btCompoundShape might have changed: + ////make sure the internal child collision algorithm caches are still valid + if ((compoundShape0->getUpdateRevision() != m_compoundShapeRevision0) || (compoundShape1->getUpdateRevision() != m_compoundShapeRevision1)) + { + ///clear all + removeChildAlgorithms(); + } + + + ///we need to refresh all contact manifolds + ///note that we should actually recursively traverse all children, btCompoundShape can nested more then 1 level deep + ///so we should add a 'refreshManifolds' in the btCollisionAlgorithm + { + int i; + btManifoldArray manifoldArray; + btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray(); + for (i=0;igetAllContactManifolds(manifoldArray); + for (int m=0;mgetNumContacts()) + { + resultOut->setPersistentManifold(manifoldArray[m]); + resultOut->refreshContactPoints(); + resultOut->setPersistentManifold(0); + } + } + manifoldArray.resize(0); + } + } + } + + + const btDbvt* tree0 = compoundShape0->getDynamicAabbTree(); + const btDbvt* tree1 = compoundShape1->getDynamicAabbTree(); + + btCompoundCompoundLeafCallback callback(col0ObjWrap,col1ObjWrap,this->m_dispatcher,dispatchInfo,resultOut,this->m_childCollisionAlgorithmCache,m_sharedManifold); + + + const btTransform xform=col0ObjWrap->getWorldTransform().inverse()*col1ObjWrap->getWorldTransform(); + MycollideTT(tree0->m_root,tree1->m_root,xform,&callback); + + //printf("#compound-compound child/leaf overlap =%d \r",callback.m_numOverlapPairs); + + //remove non-overlapping child pairs + + { + btAssert(m_removePairs.size()==0); + + //iterate over all children, perform an AABB check inside ProcessChildShape + btSimplePairArray& pairs = m_childCollisionAlgorithmCache->getOverlappingPairArray(); + + int i; + btManifoldArray manifoldArray; + + + + + + btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1; + + for (i=0;igetChildShape(pairs[i].m_indexA); + orgTrans0 = col0ObjWrap->getWorldTransform(); + orgInterpolationTrans0 = col0ObjWrap->getWorldTransform(); + const btTransform& childTrans0 = compoundShape0->getChildTransform(pairs[i].m_indexA); + newChildWorldTrans0 = orgTrans0*childTrans0 ; + childShape0->getAabb(newChildWorldTrans0,aabbMin0,aabbMax0); + } + + { + btTransform orgInterpolationTrans1; + const btCollisionShape* childShape1 = 0; + btTransform orgTrans1; + btTransform newChildWorldTrans1; + + childShape1 = compoundShape1->getChildShape(pairs[i].m_indexB); + orgTrans1 = col1ObjWrap->getWorldTransform(); + orgInterpolationTrans1 = col1ObjWrap->getWorldTransform(); + const btTransform& childTrans1 = compoundShape1->getChildTransform(pairs[i].m_indexB); + newChildWorldTrans1 = orgTrans1*childTrans1 ; + childShape1->getAabb(newChildWorldTrans1,aabbMin1,aabbMax1); + } + + + + if (!TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1)) + { + algo->~btCollisionAlgorithm(); + m_dispatcher->freeCollisionAlgorithm(algo); + m_removePairs.push_back(btSimplePair(pairs[i].m_indexA,pairs[i].m_indexB)); + } + } + } + for (int i=0;iremoveOverlappingPair(m_removePairs[i].m_indexA,m_removePairs[i].m_indexB); + } + m_removePairs.clear(); + } + +} + +btScalar btCompoundCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) +{ + btAssert(0); + return 0.f; + +} + + + diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h new file mode 100644 index 00000000000..7e2d7ad7085 --- /dev/null +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h @@ -0,0 +1,90 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + +*/ + +#ifndef BT_COMPOUND_COMPOUND_COLLISION_ALGORITHM_H +#define BT_COMPOUND_COMPOUND_COLLISION_ALGORITHM_H + +#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h" +#include "BulletCollision/BroadphaseCollision/btDispatcher.h" +#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" + +#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" +class btDispatcher; +#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" +#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" +#include "LinearMath/btAlignedObjectArray.h" +#include "BulletCollision/CollisionDispatch/btHashedSimplePairCache.h" +class btDispatcher; +class btCollisionObject; + +class btCollisionShape; +typedef bool (*btShapePairCallback)(const btCollisionShape* pShape0, const btCollisionShape* pShape1); +extern btShapePairCallback gCompoundCompoundChildShapePairCallback; + +/// btCompoundCompoundCollisionAlgorithm supports collision between two btCompoundCollisionShape shapes +class btCompoundCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm +{ + + class btHashedSimplePairCache* m_childCollisionAlgorithmCache; + btSimplePairArray m_removePairs; + + class btPersistentManifold* m_sharedManifold; + bool m_ownsManifold; + + + int m_compoundShapeRevision0;//to keep track of changes, so that childAlgorithm array can be updated + int m_compoundShapeRevision1; + + void removeChildAlgorithms(); + +// void preallocateChildAlgorithms(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap); + +public: + + btCompoundCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,bool isSwapped); + + virtual ~btCompoundCompoundCollisionAlgorithm(); + + + + virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); + + btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); + + virtual void getAllContactManifolds(btManifoldArray& manifoldArray); + + + struct CreateFunc :public btCollisionAlgorithmCreateFunc + { + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap) + { + void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCompoundCollisionAlgorithm)); + return new(mem) btCompoundCompoundCollisionAlgorithm(ci,body0Wrap,body1Wrap,false); + } + }; + + struct SwappedCreateFunc :public btCollisionAlgorithmCreateFunc + { + virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap) + { + void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCompoundCollisionAlgorithm)); + return new(mem) btCompoundCompoundCollisionAlgorithm(ci,body0Wrap,body1Wrap,true); + } + }; + +}; + +#endif //BT_COMPOUND_COMPOUND_COLLISION_ALGORITHM_H diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp index 3e1afede1bf..4ec9ae71386 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp @@ -132,7 +132,6 @@ void btConvex2dConvex2dAlgorithm ::processCollision (const btCollisionObjectWrap input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared; } - input.m_stackAlloc = dispatchInfo.m_stackAllocator; input.m_transformA = body0Wrap->getWorldTransform(); input.m_transformB = body1Wrap->getWorldTransform(); diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp index 18fde771b14..e23f5f7a88d 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp @@ -76,21 +76,27 @@ void btConvexTriangleCallback::clearCache() } - -void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex) +void btConvexTriangleCallback::processTriangle(btVector3* triangle,int +partId, int triangleIndex) { - - //just for debugging purposes - //printf("triangle %d",m_triangleCount++); + if (!TestTriangleAgainstAabb2(triangle, m_aabbMin, m_aabbMax)) + { + return; + } + + //just for debugging purposes + //printf("triangle %d",m_triangleCount++); - //aabb filter is already applied! + const btCollisionObject* ob = const_cast(m_triBodyWrap->getCollisionObject()); btCollisionAlgorithmConstructionInfo ci; ci.m_dispatcher1 = m_dispatcher; //const btCollisionObject* ob = static_cast(m_triBodyWrap->getCollisionObject()); + + #if 0 ///debug drawing of the overlapping triangles diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp index 62f98a846f4..7f2722aa463 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp @@ -373,7 +373,6 @@ void btConvexConvexAlgorithm ::processCollision (const btCollisionObjectWrapper* input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared; } - input.m_stackAlloc = dispatchInfo.m_stackAllocator; input.m_transformA = body0Wrap->getWorldTransform(); input.m_transformB = body1Wrap->getWorldTransform(); diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp index 7faee6faf50..c3cacec4a4f 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp @@ -19,6 +19,8 @@ subject to the following restrictions: #include "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h" #include "BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h" #include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h" +#include "BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.h" + #include "BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h" #include "BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h" #include "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h" @@ -32,7 +34,6 @@ subject to the following restrictions: -#include "LinearMath/btStackAlloc.h" #include "LinearMath/btPoolAllocator.h" @@ -65,6 +66,10 @@ btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefault m_swappedConvexConcaveCreateFunc = new (mem)btConvexConcaveCollisionAlgorithm::SwappedCreateFunc; mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::CreateFunc),16); m_compoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::CreateFunc; + + mem = btAlignedAlloc(sizeof(btCompoundCompoundCollisionAlgorithm::CreateFunc),16); + m_compoundCompoundCreateFunc = new (mem)btCompoundCompoundCollisionAlgorithm::CreateFunc; + mem = btAlignedAlloc(sizeof(btCompoundCollisionAlgorithm::SwappedCreateFunc),16); m_swappedCompoundCreateFunc = new (mem)btCompoundCollisionAlgorithm::SwappedCreateFunc; mem = btAlignedAlloc(sizeof(btEmptyAlgorithm::CreateFunc),16); @@ -106,16 +111,6 @@ btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefault collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2); collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3); - if (constructionInfo.m_stackAlloc) - { - m_ownsStackAllocator = false; - this->m_stackAlloc = constructionInfo.m_stackAlloc; - } else - { - m_ownsStackAllocator = true; - void* mem = btAlignedAlloc(sizeof(btStackAlloc),16); - m_stackAlloc = new(mem)btStackAlloc(constructionInfo.m_defaultStackAllocatorSize); - } if (constructionInfo.m_persistentManifoldPool) { @@ -144,12 +139,6 @@ btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefault btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration() { - if (m_ownsStackAllocator) - { - m_stackAlloc->destroy(); - m_stackAlloc->~btStackAlloc(); - btAlignedFree(m_stackAlloc); - } if (m_ownsCollisionAlgorithmPool) { m_collisionAlgorithmPool->~btPoolAllocator(); @@ -172,6 +161,9 @@ btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration() m_compoundCreateFunc->~btCollisionAlgorithmCreateFunc(); btAlignedFree( m_compoundCreateFunc); + m_compoundCompoundCreateFunc->~btCollisionAlgorithmCreateFunc(); + btAlignedFree(m_compoundCompoundCreateFunc); + m_swappedCompoundCreateFunc->~btCollisionAlgorithmCreateFunc(); btAlignedFree( m_swappedCompoundCreateFunc); @@ -275,6 +267,12 @@ btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration::getCollisionAlg return m_swappedConvexConcaveCreateFunc; } + + if (btBroadphaseProxy::isCompound(proxyType0) && btBroadphaseProxy::isCompound(proxyType1)) + { + return m_compoundCompoundCreateFunc; + } + if (btBroadphaseProxy::isCompound(proxyType0)) { return m_compoundCreateFunc; diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h index 474785bfc7d..2078420e198 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h @@ -22,23 +22,19 @@ class btConvexPenetrationDepthSolver; struct btDefaultCollisionConstructionInfo { - btStackAlloc* m_stackAlloc; btPoolAllocator* m_persistentManifoldPool; btPoolAllocator* m_collisionAlgorithmPool; int m_defaultMaxPersistentManifoldPoolSize; int m_defaultMaxCollisionAlgorithmPoolSize; int m_customCollisionAlgorithmMaxElementSize; - int m_defaultStackAllocatorSize; int m_useEpaPenetrationAlgorithm; btDefaultCollisionConstructionInfo() - :m_stackAlloc(0), - m_persistentManifoldPool(0), + :m_persistentManifoldPool(0), m_collisionAlgorithmPool(0), m_defaultMaxPersistentManifoldPoolSize(4096), m_defaultMaxCollisionAlgorithmPoolSize(4096), m_customCollisionAlgorithmMaxElementSize(0), - m_defaultStackAllocatorSize(0), m_useEpaPenetrationAlgorithm(true) { } @@ -56,8 +52,6 @@ protected: int m_persistentManifoldPoolSize; - btStackAlloc* m_stackAlloc; - bool m_ownsStackAllocator; btPoolAllocator* m_persistentManifoldPool; bool m_ownsPersistentManifoldPool; @@ -75,6 +69,8 @@ protected: btCollisionAlgorithmCreateFunc* m_convexConcaveCreateFunc; btCollisionAlgorithmCreateFunc* m_swappedConvexConcaveCreateFunc; btCollisionAlgorithmCreateFunc* m_compoundCreateFunc; + btCollisionAlgorithmCreateFunc* m_compoundCompoundCreateFunc; + btCollisionAlgorithmCreateFunc* m_swappedCompoundCreateFunc; btCollisionAlgorithmCreateFunc* m_emptyCreateFunc; btCollisionAlgorithmCreateFunc* m_sphereSphereCF; @@ -105,10 +101,6 @@ public: return m_collisionAlgorithmPool; } - virtual btStackAlloc* getStackAllocator() - { - return m_stackAlloc; - } virtual btVoronoiSimplexSolver* getSimplexSolver() { diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp new file mode 100644 index 00000000000..cfcca5654de --- /dev/null +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp @@ -0,0 +1,278 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + + + +#include "btHashedSimplePairCache.h" + + +#include + +int gOverlappingSimplePairs = 0; +int gRemoveSimplePairs =0; +int gAddedSimplePairs =0; +int gFindSimplePairs =0; + + + + +btHashedSimplePairCache::btHashedSimplePairCache(): + m_blockedForChanges(false) +{ + int initialAllocatedSize= 2; + m_overlappingPairArray.reserve(initialAllocatedSize); + growTables(); +} + + + + +btHashedSimplePairCache::~btHashedSimplePairCache() +{ +} + + + + + + +void btHashedSimplePairCache::removeAllPairs() +{ + m_overlappingPairArray.clear(); + m_hashTable.clear(); + m_next.clear(); + + int initialAllocatedSize= 2; + m_overlappingPairArray.reserve(initialAllocatedSize); + growTables(); +} + + + +btSimplePair* btHashedSimplePairCache::findPair(int indexA, int indexB) +{ + gFindSimplePairs++; + + + /*if (indexA > indexB) + btSwap(indexA, indexB);*/ + + int hash = static_cast(getHash(static_cast(indexA), static_cast(indexB)) & (m_overlappingPairArray.capacity()-1)); + + if (hash >= m_hashTable.size()) + { + return NULL; + } + + int index = m_hashTable[hash]; + while (index != BT_SIMPLE_NULL_PAIR && equalsPair(m_overlappingPairArray[index], indexA, indexB) == false) + { + index = m_next[index]; + } + + if (index == BT_SIMPLE_NULL_PAIR) + { + return NULL; + } + + btAssert(index < m_overlappingPairArray.size()); + + return &m_overlappingPairArray[index]; +} + +//#include + +void btHashedSimplePairCache::growTables() +{ + + int newCapacity = m_overlappingPairArray.capacity(); + + if (m_hashTable.size() < newCapacity) + { + //grow hashtable and next table + int curHashtableSize = m_hashTable.size(); + + m_hashTable.resize(newCapacity); + m_next.resize(newCapacity); + + + int i; + + for (i= 0; i < newCapacity; ++i) + { + m_hashTable[i] = BT_SIMPLE_NULL_PAIR; + } + for (i = 0; i < newCapacity; ++i) + { + m_next[i] = BT_SIMPLE_NULL_PAIR; + } + + for(i=0;i(getHash(static_cast(indexA),static_cast(indexB)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask + m_next[i] = m_hashTable[hashValue]; + m_hashTable[hashValue] = i; + } + + + } +} + +btSimplePair* btHashedSimplePairCache::internalAddPair(int indexA, int indexB) +{ + + int hash = static_cast(getHash(static_cast(indexA),static_cast(indexB)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask + + + btSimplePair* pair = internalFindPair(indexA, indexB, hash); + if (pair != NULL) + { + return pair; + } + + int count = m_overlappingPairArray.size(); + int oldCapacity = m_overlappingPairArray.capacity(); + void* mem = &m_overlappingPairArray.expandNonInitializing(); + + int newCapacity = m_overlappingPairArray.capacity(); + + if (oldCapacity < newCapacity) + { + growTables(); + //hash with new capacity + hash = static_cast(getHash(static_cast(indexA),static_cast(indexB)) & (m_overlappingPairArray.capacity()-1)); + } + + pair = new (mem) btSimplePair(indexA,indexB); + + pair->m_userPointer = 0; + + m_next[count] = m_hashTable[hash]; + m_hashTable[hash] = count; + + return pair; +} + + + +void* btHashedSimplePairCache::removeOverlappingPair(int indexA, int indexB) +{ + gRemoveSimplePairs++; + + + /*if (indexA > indexB) + btSwap(indexA, indexB);*/ + + int hash = static_cast(getHash(static_cast(indexA),static_cast(indexB)) & (m_overlappingPairArray.capacity()-1)); + + btSimplePair* pair = internalFindPair(indexA, indexB, hash); + if (pair == NULL) + { + return 0; + } + + + void* userData = pair->m_userPointer; + + + int pairIndex = int(pair - &m_overlappingPairArray[0]); + btAssert(pairIndex < m_overlappingPairArray.size()); + + // Remove the pair from the hash table. + int index = m_hashTable[hash]; + btAssert(index != BT_SIMPLE_NULL_PAIR); + + int previous = BT_SIMPLE_NULL_PAIR; + while (index != pairIndex) + { + previous = index; + index = m_next[index]; + } + + if (previous != BT_SIMPLE_NULL_PAIR) + { + btAssert(m_next[previous] == pairIndex); + m_next[previous] = m_next[pairIndex]; + } + else + { + m_hashTable[hash] = m_next[pairIndex]; + } + + // We now move the last pair into spot of the + // pair being removed. We need to fix the hash + // table indices to support the move. + + int lastPairIndex = m_overlappingPairArray.size() - 1; + + // If the removed pair is the last pair, we are done. + if (lastPairIndex == pairIndex) + { + m_overlappingPairArray.pop_back(); + return userData; + } + + // Remove the last pair from the hash table. + const btSimplePair* last = &m_overlappingPairArray[lastPairIndex]; + /* missing swap here too, Nat. */ + int lastHash = static_cast(getHash(static_cast(last->m_indexA), static_cast(last->m_indexB)) & (m_overlappingPairArray.capacity()-1)); + + index = m_hashTable[lastHash]; + btAssert(index != BT_SIMPLE_NULL_PAIR); + + previous = BT_SIMPLE_NULL_PAIR; + while (index != lastPairIndex) + { + previous = index; + index = m_next[index]; + } + + if (previous != BT_SIMPLE_NULL_PAIR) + { + btAssert(m_next[previous] == lastPairIndex); + m_next[previous] = m_next[lastPairIndex]; + } + else + { + m_hashTable[lastHash] = m_next[lastPairIndex]; + } + + // Copy the last pair into the remove pair's spot. + m_overlappingPairArray[pairIndex] = m_overlappingPairArray[lastPairIndex]; + + // Insert the last pair into the hash table + m_next[pairIndex] = m_hashTable[lastHash]; + m_hashTable[lastHash] = pairIndex; + + m_overlappingPairArray.pop_back(); + + return userData; +} +//#include + + + + + + + + + + diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.h new file mode 100644 index 00000000000..e88ef97e968 --- /dev/null +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.h @@ -0,0 +1,174 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BT_HASHED_SIMPLE_PAIR_CACHE_H +#define BT_HASHED_SIMPLE_PAIR_CACHE_H + + + +#include "LinearMath/btAlignedObjectArray.h" + +const int BT_SIMPLE_NULL_PAIR=0xffffffff; + +struct btSimplePair +{ + btSimplePair(int indexA,int indexB) + :m_indexA(indexA), + m_indexB(indexB), + m_userPointer(0) + { + } + + int m_indexA; + int m_indexB; + union + { + void* m_userPointer; + int m_userValue; + }; +}; + +typedef btAlignedObjectArray btSimplePairArray; + + + +extern int gOverlappingSimplePairs; +extern int gRemoveSimplePairs; +extern int gAddedSimplePairs; +extern int gFindSimplePairs; + + + + +class btHashedSimplePairCache +{ + btSimplePairArray m_overlappingPairArray; + + bool m_blockedForChanges; + + +protected: + + btAlignedObjectArray m_hashTable; + btAlignedObjectArray m_next; + + +public: + btHashedSimplePairCache(); + virtual ~btHashedSimplePairCache(); + + void removeAllPairs(); + + virtual void* removeOverlappingPair(int indexA,int indexB); + + // Add a pair and return the new pair. If the pair already exists, + // no new pair is created and the old one is returned. + virtual btSimplePair* addOverlappingPair(int indexA,int indexB) + { + gAddedSimplePairs++; + + return internalAddPair(indexA,indexB); + } + + + virtual btSimplePair* getOverlappingPairArrayPtr() + { + return &m_overlappingPairArray[0]; + } + + const btSimplePair* getOverlappingPairArrayPtr() const + { + return &m_overlappingPairArray[0]; + } + + btSimplePairArray& getOverlappingPairArray() + { + return m_overlappingPairArray; + } + + const btSimplePairArray& getOverlappingPairArray() const + { + return m_overlappingPairArray; + } + + + btSimplePair* findPair(int indexA,int indexB); + + int GetCount() const { return m_overlappingPairArray.size(); } + + int getNumOverlappingPairs() const + { + return m_overlappingPairArray.size(); + } +private: + + btSimplePair* internalAddPair(int indexA, int indexB); + + void growTables(); + + SIMD_FORCE_INLINE bool equalsPair(const btSimplePair& pair, int indexA, int indexB) + { + return pair.m_indexA == indexA && pair.m_indexB == indexB; + } + + + + SIMD_FORCE_INLINE unsigned int getHash(unsigned int indexA, unsigned int indexB) + { + int key = static_cast(((unsigned int)indexA) | (((unsigned int)indexB) <<16)); + // Thomas Wang's hash + + key += ~(key << 15); + key ^= (key >> 10); + key += (key << 3); + key ^= (key >> 6); + key += ~(key << 11); + key ^= (key >> 16); + return static_cast(key); + } + + + + + + SIMD_FORCE_INLINE btSimplePair* internalFindPair(int proxyIdA , int proxyIdB, int hash) + { + + int index = m_hashTable[hash]; + + while( index != BT_SIMPLE_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyIdA, proxyIdB) == false) + { + index = m_next[index]; + } + + if ( index == BT_SIMPLE_NULL_PAIR ) + { + return NULL; + } + + btAssert(index < m_overlappingPairArray.size()); + + return &m_overlappingPairArray[index]; + } + + +}; + + + + +#endif //BT_HASHED_SIMPLE_PAIR_CACHE_H + + diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp index 12f422f193f..0aa75f2bff3 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCompoundShape.cpp @@ -273,6 +273,8 @@ void btCompoundShape::calculatePrincipalAxisTransform(btScalar* masses, btTransf + + void btCompoundShape::setLocalScaling(const btVector3& scaling) { @@ -283,7 +285,7 @@ void btCompoundShape::setLocalScaling(const btVector3& scaling) // childScale = childScale * (childTrans.getBasis() * scaling); childScale = childScale * scaling / m_localScaling; m_children[i].m_childShape->setLocalScaling(childScale); - childTrans.setOrigin((childTrans.getOrigin())*scaling); + childTrans.setOrigin((childTrans.getOrigin()) * scaling / m_localScaling); updateChildTransform(i, childTrans,false); } diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp index 5e83087b320..2d83c8bfbac 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp @@ -62,6 +62,10 @@ void btConeShape::setConeUpIndex(int upIndex) default: btAssert(0); }; + + m_implicitShapeDimensions[m_coneIndices[0]] = m_radius; + m_implicitShapeDimensions[m_coneIndices[1]] = m_height; + m_implicitShapeDimensions[m_coneIndices[2]] = m_radius; } btVector3 btConeShape::coneLocalSupport(const btVector3& v) const diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h index 5966ae48f11..4a0df0d558b 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h @@ -90,6 +90,13 @@ public: } virtual void setLocalScaling(const btVector3& scaling); + + + virtual int calculateSerializeBufferSize() const; + + ///fills the dataBuffer and returns the struct name (and 0 on failure) + virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; + }; @@ -104,19 +111,61 @@ class btConeShapeX : public btConeShape return btVector3 (1,0,0); } + //debugging + virtual const char* getName()const + { + return "ConeX"; + } + + }; ///btConeShapeZ implements a Cone shape, around the Z axis class btConeShapeZ : public btConeShape { - public: - btConeShapeZ(btScalar radius,btScalar height); +public: + btConeShapeZ(btScalar radius,btScalar height); virtual btVector3 getAnisotropicRollingFrictionDirection() const { return btVector3 (0,0,1); } + //debugging + virtual const char* getName()const + { + return "ConeZ"; + } + + }; + +///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 +struct btConeShapeData +{ + btConvexInternalShapeData m_convexInternalShapeData; + + int m_upIndex; + + char m_padding[4]; +}; + +SIMD_FORCE_INLINE int btConeShape::calculateSerializeBufferSize() const +{ + return sizeof(btConeShapeData); +} + +///fills the dataBuffer and returns the struct name (and 0 on failure) +SIMD_FORCE_INLINE const char* btConeShape::serialize(void* dataBuffer, btSerializer* serializer) const +{ + btConeShapeData* shapeData = (btConeShapeData*) dataBuffer; + + btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData,serializer); + + shapeData->m_upIndex = m_coneIndices[1]; + + return "btConeShapeData"; +} + #endif //BT_CONE_MINKOWSKI_H diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp index 9d40dfdd0dd..fb0d9fdb75a 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp @@ -21,6 +21,7 @@ subject to the following restrictions: #include "btTriangleShape.h" #include "btSphereShape.h" #include "btCylinderShape.h" +#include "btConeShape.h" #include "btCapsuleShape.h" #include "btConvexHullShape.h" #include "btConvexPointCloudShape.h" @@ -336,6 +337,11 @@ btScalar btConvexShape::getMarginNonVirtual () const btCylinderShape* cylShape = (btCylinderShape*)this; return cylShape->getMarginNV(); } + case CONE_SHAPE_PROXYTYPE: + { + btConeShape* conShape = (btConeShape*)this; + return conShape->getMarginNV(); + } case CAPSULE_SHAPE_PROXYTYPE: { btCapsuleShape* capsuleShape = (btCapsuleShape*)this; diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp index 8d4080a63a6..26322791d04 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp @@ -369,7 +369,7 @@ void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback getVertex(x+1,j+1,vertices[2]); callback->processTriangle(vertices,x,j); //second triangle - getVertex(x,j,vertices[0]); + // getVertex(x,j,vertices[0]);//already got this vertex before, thanks to Danny Chapman getVertex(x+1,j+1,vertices[1]); getVertex(x,j+1,vertices[2]); callback->processTriangle(vertices,x,j); @@ -382,7 +382,7 @@ void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback callback->processTriangle(vertices,x,j); //second triangle getVertex(x+1,j,vertices[0]); - getVertex(x,j+1,vertices[1]); + //getVertex(x,j+1,vertices[1]); getVertex(x+1,j+1,vertices[2]); callback->processTriangle(vertices,x,j); } diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp index 51a2f8a0739..5fbed334ec1 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.cpp @@ -111,10 +111,10 @@ int btTriangleMesh::findOrAddVertex(const btVector3& vertex, bool removeDuplicat return i/3; } } - } - m_3componentVertices.push_back((float)vertex.getX()); - m_3componentVertices.push_back((float)vertex.getY()); - m_3componentVertices.push_back((float)vertex.getZ()); + } + m_3componentVertices.push_back(vertex.getX()); + m_3componentVertices.push_back(vertex.getY()); + m_3componentVertices.push_back(vertex.getZ()); m_indexedMeshes[0].m_numVertices++; m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0]; return (m_3componentVertices.size()/3)-1; diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h index 29d1b5cdaa4..0afc2321ff0 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h @@ -27,7 +27,7 @@ subject to the following restrictions: class btTriangleMesh : public btTriangleIndexVertexArray { btAlignedObjectArray m_4componentVertices; - btAlignedObjectArray m_3componentVertices; + btAlignedObjectArray m_3componentVertices; btAlignedObjectArray m_32bitIndices; btAlignedObjectArray m_16bitIndices; diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h index 72eb5aec461..29620abffb9 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h @@ -17,7 +17,6 @@ subject to the following restrictions: #ifndef BT_CONVEX_PENETRATION_DEPTH_H #define BT_CONVEX_PENETRATION_DEPTH_H -class btStackAlloc; class btVector3; #include "btSimplexSolverInterface.h" class btConvexShape; @@ -33,8 +32,7 @@ public: const btConvexShape* convexA,const btConvexShape* convexB, const btTransform& transA,const btTransform& transB, btVector3& v, btVector3& pa, btVector3& pb, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc - ) = 0; + class btIDebugDraw* debugDraw) = 0; }; diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h index f958cc523ef..46ce1ab75e7 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h @@ -19,7 +19,6 @@ subject to the following restrictions: #include "LinearMath/btTransform.h" #include "LinearMath/btVector3.h" -class btStackAlloc; /// This interface is made to be used by an iterative approach to do TimeOfImpact calculations /// This interface allows to query for closest points and penetration depth between two (convex) objects @@ -43,15 +42,13 @@ struct btDiscreteCollisionDetectorInterface struct ClosestPointInput { ClosestPointInput() - :m_maximumDistanceSquared(btScalar(BT_LARGE_FLOAT)), - m_stackAlloc(0) + :m_maximumDistanceSquared(btScalar(BT_LARGE_FLOAT)) { } btTransform m_transformA; btTransform m_transformB; btScalar m_maximumDistanceSquared; - btStackAlloc* m_stackAlloc; }; virtual ~btDiscreteCollisionDetectorInterface() {}; diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp index c6dc3f3a672..572ec36f563 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp @@ -25,7 +25,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim const btConvexShape* pConvexA, const btConvexShape* pConvexB, const btTransform& transformA, const btTransform& transformB, btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB, - class btIDebugDraw* debugDraw, btStackAlloc* stackAlloc ) + class btIDebugDraw* debugDraw) { (void)debugDraw; @@ -34,7 +34,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim // const btScalar radialmargin(btScalar(0.)); - btVector3 guessVector(transformA.getOrigin()-transformB.getOrigin()); + btVector3 guessVector(transformB.getOrigin()-transformA.getOrigin()); btGjkEpaSolver2::sResults results; diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h index a49689a1501..1ed6340af3b 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h @@ -33,7 +33,7 @@ class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver const btConvexShape* pConvexA, const btConvexShape* pConvexB, const btTransform& transformA, const btTransform& transformB, btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc ); + class btIDebugDraw* debugDraw); private : diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp index 8af16b9cf6f..8877579496b 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp @@ -50,7 +50,8 @@ m_marginA(objectA->getMargin()), m_marginB(objectB->getMargin()), m_ignoreMargin(false), m_lastUsedMethod(-1), -m_catchDegeneracies(1) +m_catchDegeneracies(1), +m_fixContactNormalDirection(1) { } btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver) @@ -65,7 +66,8 @@ m_marginA(marginA), m_marginB(marginB), m_ignoreMargin(false), m_lastUsedMethod(-1), -m_catchDegeneracies(1) +m_catchDegeneracies(1), +m_fixContactNormalDirection(1) { } @@ -353,7 +355,7 @@ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& inpu m_minkowskiA,m_minkowskiB, localTransA,localTransB, m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB, - debugDraw,input.m_stackAlloc + debugDraw ); @@ -438,6 +440,27 @@ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& inpu } #endif + if (m_fixContactNormalDirection) + { + ///@workaround for sticky convex collisions + //in some degenerate cases (usually when the use uses very small margins) + //the contact normal is pointing the wrong direction + //so fix it now (until we can deal with all degenerate cases in GJK and EPA) + //contact normals need to point from B to A in all cases, so we can simply check if the contact normal really points from B to A + //We like to use a dot product of the normal against the difference of the centroids, + //once the centroid is available in the API + //until then we use the center of the aabb to approximate the centroid + btVector3 aabbMin,aabbMax; + m_minkowskiA->getAabb(localTransA,aabbMin,aabbMax); + btVector3 posA = (aabbMax+aabbMin)*btScalar(0.5); + + m_minkowskiB->getAabb(localTransB,aabbMin,aabbMax); + btVector3 posB = (aabbMin+aabbMax)*btScalar(0.5); + + btVector3 diff = posA-posB; + if (diff.dot(normalInB) < 0.f) + normalInB *= -1.f; + } m_cachedSeparatingAxis = normalInB; m_cachedSeparatingDistance = distance; diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h index f0043b8b9f2..feeae686213 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h @@ -52,7 +52,7 @@ public: int m_curIter; int m_degenerateSimplex; int m_catchDegeneracies; - + int m_fixContactNormalDirection; btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp index fe31f08d61a..fa45f49037e 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp @@ -26,11 +26,10 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s const btConvexShape* convexA,const btConvexShape* convexB, const btTransform& transA,const btTransform& transB, btVector3& v, btVector3& pa, btVector3& pb, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc + class btIDebugDraw* debugDraw ) { - (void)stackAlloc; (void)v; bool check2d= convexA->isConvex2d() && convexB->isConvex2d(); diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h index 6a8fe52f36f..fd533b4fc33 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h @@ -32,7 +32,7 @@ public: const btConvexShape* convexA,const btConvexShape* convexB, const btTransform& transA,const btTransform& transB, btVector3& v, btVector3& pa, btVector3& pb, - class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc + class btIDebugDraw* debugDraw ); }; diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h index f012889a70e..3999d400503 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h @@ -35,7 +35,7 @@ public: kF_None = 0, kF_FilterBackfaces = 1 << 0, kF_KeepUnflippedNormal = 1 << 1, // Prevents returned face normal getting flipped when a ray hits a back-facing triangle - + kF_UseSubSimplexConvexCastRaytest = 1 << 2, // Uses an approximate but faster ray versus convex intersection algorithm kF_Terminator = 0xFFFFFFFF }; unsigned int m_flags; diff --git a/extern/bullet2/src/BulletDynamics/Character/btCharacterControllerInterface.h b/extern/bullet2/src/BulletDynamics/Character/btCharacterControllerInterface.h index c81813c92be..dffb06dfe94 100644 --- a/extern/bullet2/src/BulletDynamics/Character/btCharacterControllerInterface.h +++ b/extern/bullet2/src/BulletDynamics/Character/btCharacterControllerInterface.h @@ -31,7 +31,7 @@ public: virtual void setWalkDirection(const btVector3& walkDirection) = 0; virtual void setVelocityForTimeInterval(const btVector3& velocity, btScalar timeInterval) = 0; - virtual void reset () = 0; + virtual void reset ( btCollisionWorld* collisionWorld ) = 0; virtual void warp (const btVector3& origin) = 0; virtual void preStep ( btCollisionWorld* collisionWorld) = 0; @@ -40,6 +40,7 @@ public: virtual void jump () = 0; virtual bool onGround () const = 0; + virtual void setUpInterpolate (bool value) = 0; }; #endif //BT_CHARACTER_CONTROLLER_INTERFACE_H diff --git a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp index 9db909a5469..8f1cd20bf45 100644 --- a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp +++ b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp @@ -14,6 +14,7 @@ subject to the following restrictions: */ +#include #include "LinearMath/btIDebugDraw.h" #include "BulletCollision/CollisionDispatch/btGhostObject.h" #include "BulletCollision/CollisionShapes/btMultiSphereShape.h" @@ -79,7 +80,7 @@ public: if (!convexResult.m_hitCollisionObject->hasContactResponse()) return btScalar(1.0); - + btVector3 hitNormalWorld; if (normalInWorldSpace) { @@ -149,7 +150,11 @@ btKinematicCharacterController::btKinematicCharacterController (btPairCachingGho m_jumpSpeed = 10.0; // ? m_wasOnGround = false; m_wasJumping = false; + m_interpolateUp = true; setMaxSlope(btRadians(45.0)); + m_currentStepOffset = 0; + full_drop = false; + bounce_fix = false; } btKinematicCharacterController::~btKinematicCharacterController () @@ -190,9 +195,10 @@ bool btKinematicCharacterController::recoverFromPenetration ( btCollisionWorld* m_manifoldArray.resize(0); btBroadphasePair* collisionPair = &m_ghostObject->getOverlappingPairCache()->getOverlappingPairArray()[i]; + btCollisionObject* obj0 = static_cast(collisionPair->m_pProxy0->m_clientObject); - btCollisionObject* obj1 = static_cast(collisionPair->m_pProxy1->m_clientObject); - + btCollisionObject* obj1 = static_cast(collisionPair->m_pProxy1->m_clientObject); + if ((obj0 && !obj0->hasContactResponse()) || (obj1 && !obj1->hasContactResponse())) continue; @@ -268,7 +274,10 @@ void btKinematicCharacterController::stepUp ( btCollisionWorld* world) { // we moved up only a fraction of the step height m_currentStepOffset = m_stepHeight * callback.m_closestHitFraction; - m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); + if (m_interpolateUp == true) + m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); + else + m_currentPosition = m_targetPosition; } m_verticalVelocity = 0.0; m_verticalOffset = 0.0; @@ -333,7 +342,8 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co { if (m_normalizedDirection.dot(m_touchingNormal) > btScalar(0.0)) { - updateTargetPositionBasedOnCollision (m_touchingNormal); + //interferes with step movement + //updateTargetPositionBasedOnCollision (m_touchingNormal); } } @@ -405,7 +415,8 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld, btScalar dt) { - btTransform start, end; + btTransform start, end, end_double; + bool runonce = false; // phase 3: down /*btScalar additionalDownStep = (m_wasOnGround && !onGround()) ? m_stepHeight : 0.0; @@ -414,44 +425,124 @@ void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld btVector3 gravity_drop = getUpAxisDirections()[m_upAxis] * downVelocity; m_targetPosition -= (step_drop + gravity_drop);*/ + btVector3 orig_position = m_targetPosition; + btScalar downVelocity = (m_verticalVelocity<0.f?-m_verticalVelocity:0.f) * dt; - if(downVelocity > 0.0 && downVelocity < m_stepHeight + + if(downVelocity > 0.0 && downVelocity > m_fallSpeed && (m_wasOnGround || !m_wasJumping)) - { - downVelocity = m_stepHeight; - } + downVelocity = m_fallSpeed; btVector3 step_drop = getUpAxisDirections()[m_upAxis] * (m_currentStepOffset + downVelocity); m_targetPosition -= step_drop; - start.setIdentity (); - end.setIdentity (); + btKinematicClosestNotMeConvexResultCallback callback (m_ghostObject, getUpAxisDirections()[m_upAxis], m_maxSlopeCosine); + callback.m_collisionFilterGroup = getGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup; + callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask; - start.setOrigin (m_currentPosition); - end.setOrigin (m_targetPosition); + btKinematicClosestNotMeConvexResultCallback callback2 (m_ghostObject, getUpAxisDirections()[m_upAxis], m_maxSlopeCosine); + callback2.m_collisionFilterGroup = getGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup; + callback2.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask; - btKinematicClosestNotMeConvexResultCallback callback (m_ghostObject, getUpAxisDirections()[m_upAxis], m_maxSlopeCosine); - callback.m_collisionFilterGroup = getGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup; - callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask; - - if (m_useGhostObjectSweepTest) + while (1) { - m_ghostObject->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration); - } else - { - collisionWorld->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration); + start.setIdentity (); + end.setIdentity (); + + end_double.setIdentity (); + + start.setOrigin (m_currentPosition); + end.setOrigin (m_targetPosition); + + //set double test for 2x the step drop, to check for a large drop vs small drop + end_double.setOrigin (m_targetPosition - step_drop); + + if (m_useGhostObjectSweepTest) + { + m_ghostObject->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration); + + if (!callback.hasHit()) + { + //test a double fall height, to see if the character should interpolate it's fall (full) or not (partial) + m_ghostObject->convexSweepTest (m_convexShape, start, end_double, callback2, collisionWorld->getDispatchInfo().m_allowedCcdPenetration); + } + } else + { + collisionWorld->convexSweepTest (m_convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration); + + if (!callback.hasHit()) + { + //test a double fall height, to see if the character should interpolate it's fall (large) or not (small) + collisionWorld->convexSweepTest (m_convexShape, start, end_double, callback2, collisionWorld->getDispatchInfo().m_allowedCcdPenetration); + } + } + + btScalar downVelocity2 = (m_verticalVelocity<0.f?-m_verticalVelocity:0.f) * dt; + bool has_hit = false; + if (bounce_fix == true) + has_hit = callback.hasHit() || callback2.hasHit(); + else + has_hit = callback2.hasHit(); + + if(downVelocity2 > 0.0 && downVelocity2 < m_stepHeight && has_hit == true && runonce == false + && (m_wasOnGround || !m_wasJumping)) + { + //redo the velocity calculation when falling a small amount, for fast stairs motion + //for larger falls, use the smoother/slower interpolated movement by not touching the target position + + m_targetPosition = orig_position; + downVelocity = m_stepHeight; + + btVector3 step_drop = getUpAxisDirections()[m_upAxis] * (m_currentStepOffset + downVelocity); + m_targetPosition -= step_drop; + runonce = true; + continue; //re-run previous tests + } + break; } - if (callback.hasHit()) + if (callback.hasHit() || runonce == true) { // we dropped a fraction of the height -> hit floor - m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); + + btScalar fraction = (m_currentPosition.getY() - callback.m_hitPointWorld.getY()) / 2; + + //printf("hitpoint: %g - pos %g\n", callback.m_hitPointWorld.getY(), m_currentPosition.getY()); + + if (bounce_fix == true) + { + if (full_drop == true) + m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); + else + //due to errors in the closestHitFraction variable when used with large polygons, calculate the hit fraction manually + m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, fraction); + } + else + m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); + + full_drop = false; + m_verticalVelocity = 0.0; m_verticalOffset = 0.0; m_wasJumping = false; } else { // we dropped the full height + full_drop = true; + + if (bounce_fix == true) + { + downVelocity = (m_verticalVelocity<0.f?-m_verticalVelocity:0.f) * dt; + if (downVelocity > m_fallSpeed && (m_wasOnGround || !m_wasJumping)) + { + m_targetPosition += step_drop; //undo previous target change + downVelocity = m_fallSpeed; + step_drop = getUpAxisDirections()[m_upAxis] * (m_currentStepOffset + downVelocity); + m_targetPosition -= step_drop; + } + } + //printf("full drop - %g, %g\n", m_currentPosition.getY(), m_targetPosition.getY()); + m_currentPosition = m_targetPosition; } } @@ -484,13 +575,24 @@ btScalar timeInterval m_useWalkDirection = false; m_walkDirection = velocity; m_normalizedDirection = getNormalizedVector(m_walkDirection); - m_velocityTimeInterval = timeInterval; + m_velocityTimeInterval += timeInterval; } - - -void btKinematicCharacterController::reset () -{ +void btKinematicCharacterController::reset ( btCollisionWorld* collisionWorld ) +{ + m_verticalVelocity = 0.0; + m_verticalOffset = 0.0; + m_wasOnGround = false; + m_wasJumping = false; + m_walkDirection.setValue(0,0,0); + m_velocityTimeInterval = 0.0; + + //clear pair cache + btHashedOverlappingPairCache *cache = m_ghostObject->getOverlappingPairCache(); + while (cache->getOverlappingPairArray().size() > 0) + { + cache->removeOverlappingPair(cache->getOverlappingPairArray()[0].m_pProxy0, cache->getOverlappingPairArray()[0].m_pProxy1, collisionWorld->getDispatcher()); + } } void btKinematicCharacterController::warp (const btVector3& origin) @@ -661,3 +763,8 @@ btVector3* btKinematicCharacterController::getUpAxisDirections() void btKinematicCharacterController::debugDraw(btIDebugDraw* debugDrawer) { } + +void btKinematicCharacterController::setUpInterpolate(bool value) +{ + m_interpolateUp = value; +} diff --git a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h index 8ec63735cd8..add6f30a687 100644 --- a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h +++ b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h @@ -81,6 +81,9 @@ protected: int m_upAxis; static btVector3* getUpAxisDirections(); + bool m_interpolateUp; + bool full_drop; + bool bounce_fix; btVector3 computeReflectionDirection (const btVector3& direction, const btVector3& normal); btVector3 parallelComponent (const btVector3& direction, const btVector3& normal); @@ -133,7 +136,7 @@ public: virtual void setVelocityForTimeInterval(const btVector3& velocity, btScalar timeInterval); - void reset (); + void reset ( btCollisionWorld* collisionWorld ); void warp (const btVector3& origin); void preStep ( btCollisionWorld* collisionWorld); @@ -161,6 +164,7 @@ public: } bool onGround () const; + void setUpInterpolate (bool value); }; #endif // BT_KINEMATIC_CHARACTER_CONTROLLER_H diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h index 09c048beda8..1735b524dba 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h @@ -40,6 +40,15 @@ and swing 1 and 2 are along the z and y axes respectively. #include "btJacobianEntry.h" #include "btTypedConstraint.h" +#ifdef BT_USE_DOUBLE_PRECISION +#define btConeTwistConstraintData2 btConeTwistConstraintDoubleData +#define btConeTwistConstraintDataName "btConeTwistConstraintDoubleData" +#else +#define btConeTwistConstraintData2 btConeTwistConstraintData +#define btConeTwistConstraintDataName "btConeTwistConstraintData" +#endif //BT_USE_DOUBLE_PRECISION + + class btRigidBody; enum btConeTwistFlags @@ -295,7 +304,30 @@ public: }; -///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 + + +struct btConeTwistConstraintDoubleData +{ + btTypedConstraintDoubleData m_typeConstraintData; + btTransformDoubleData m_rbAFrame; + btTransformDoubleData m_rbBFrame; + + //limits + double m_swingSpan1; + double m_swingSpan2; + double m_twistSpan; + double m_limitSoftness; + double m_biasFactor; + double m_relaxationFactor; + + double m_damping; + + + +}; + +#ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION +///this structure is not used, except for loading pre-2.82 .bullet files struct btConeTwistConstraintData { btTypedConstraintData m_typeConstraintData; @@ -315,12 +347,12 @@ struct btConeTwistConstraintData char m_pad[4]; }; - - +#endif //BT_BACKWARDS_COMPATIBLE_SERIALIZATION +// SIMD_FORCE_INLINE int btConeTwistConstraint::calculateSerializeBufferSize() const { - return sizeof(btConeTwistConstraintData); + return sizeof(btConeTwistConstraintData2); } @@ -328,21 +360,21 @@ SIMD_FORCE_INLINE int btConeTwistConstraint::calculateSerializeBufferSize() cons ///fills the dataBuffer and returns the struct name (and 0 on failure) SIMD_FORCE_INLINE const char* btConeTwistConstraint::serialize(void* dataBuffer, btSerializer* serializer) const { - btConeTwistConstraintData* cone = (btConeTwistConstraintData*) dataBuffer; + btConeTwistConstraintData2* cone = (btConeTwistConstraintData2*) dataBuffer; btTypedConstraint::serialize(&cone->m_typeConstraintData,serializer); - m_rbAFrame.serializeFloat(cone->m_rbAFrame); - m_rbBFrame.serializeFloat(cone->m_rbBFrame); + m_rbAFrame.serialize(cone->m_rbAFrame); + m_rbBFrame.serialize(cone->m_rbBFrame); - cone->m_swingSpan1 = float(m_swingSpan1); - cone->m_swingSpan2 = float(m_swingSpan2); - cone->m_twistSpan = float(m_twistSpan); - cone->m_limitSoftness = float(m_limitSoftness); - cone->m_biasFactor = float(m_biasFactor); - cone->m_relaxationFactor = float(m_relaxationFactor); - cone->m_damping = float(m_damping); - - return "btConeTwistConstraintData"; + cone->m_swingSpan1 = m_swingSpan1; + cone->m_swingSpan2 = m_swingSpan2; + cone->m_twistSpan = m_twistSpan; + cone->m_limitSoftness = m_limitSoftness; + cone->m_biasFactor = m_biasFactor; + cone->m_relaxationFactor = m_relaxationFactor; + cone->m_damping = m_damping; + + return btConeTwistConstraintDataName; } diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h index 6f673102be2..1ba1cd1e839 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h @@ -28,6 +28,14 @@ class btIDebugDraw; class btStackAlloc; class btDispatcher; /// btConstraintSolver provides solver interface + + +enum btConstraintSolverType +{ + BT_SEQUENTIAL_IMPULSE_SOLVER=1, + BT_MLCP_SOLVER=2 +}; + class btConstraintSolver { @@ -38,12 +46,16 @@ public: virtual void prepareSolve (int /* numBodies */, int /* numManifolds */) {;} ///solve a group of constraints - virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints, const btContactSolverInfo& info,class btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher) = 0; + virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints, const btContactSolverInfo& info,class btIDebugDraw* debugDrawer,btDispatcher* dispatcher) = 0; - virtual void allSolved (const btContactSolverInfo& /* info */,class btIDebugDraw* /* debugDrawer */, btStackAlloc* /* stackAlloc */) {;} + virtual void allSolved (const btContactSolverInfo& /* info */,class btIDebugDraw* /* debugDrawer */) {;} ///clear internal cached data and reset random seed virtual void reset() = 0; + + virtual btConstraintSolverType getSolverType() const=0; + + }; diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp new file mode 100644 index 00000000000..f93a3280f35 --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp @@ -0,0 +1,129 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + + +#include "btFixedConstraint.h" +#include "BulletDynamics/Dynamics/btRigidBody.h" +#include "LinearMath/btTransformUtil.h" +#include + + +btFixedConstraint::btFixedConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& frameInA,const btTransform& frameInB) +:btTypedConstraint(FIXED_CONSTRAINT_TYPE,rbA,rbB) +{ + m_pivotInA = frameInA.getOrigin(); + m_pivotInB = frameInB.getOrigin(); + m_relTargetAB = frameInA.getRotation()*frameInB.getRotation().inverse(); + +} + +btFixedConstraint::~btFixedConstraint () +{ +} + + +void btFixedConstraint::getInfo1 (btConstraintInfo1* info) +{ + info->m_numConstraintRows = 6; + info->nub = 6; +} + +void btFixedConstraint::getInfo2 (btConstraintInfo2* info) +{ + //fix the 3 linear degrees of freedom + + + const btVector3& worldPosA = m_rbA.getCenterOfMassTransform().getOrigin(); + const btMatrix3x3& worldOrnA = m_rbA.getCenterOfMassTransform().getBasis(); + const btVector3& worldPosB= m_rbB.getCenterOfMassTransform().getOrigin(); + const btMatrix3x3& worldOrnB = m_rbB.getCenterOfMassTransform().getBasis(); + + + info->m_J1linearAxis[0] = 1; + info->m_J1linearAxis[info->rowskip+1] = 1; + info->m_J1linearAxis[2*info->rowskip+2] = 1; + + btVector3 a1 = worldOrnA*m_pivotInA; + { + btVector3* angular0 = (btVector3*)(info->m_J1angularAxis); + btVector3* angular1 = (btVector3*)(info->m_J1angularAxis+info->rowskip); + btVector3* angular2 = (btVector3*)(info->m_J1angularAxis+2*info->rowskip); + btVector3 a1neg = -a1; + a1neg.getSkewSymmetricMatrix(angular0,angular1,angular2); + } + + if (info->m_J2linearAxis) + { + info->m_J2linearAxis[0] = -1; + info->m_J2linearAxis[info->rowskip+1] = -1; + info->m_J2linearAxis[2*info->rowskip+2] = -1; + } + + btVector3 a2 = worldOrnB*m_pivotInB; + + { + // btVector3 a2n = -a2; + btVector3* angular0 = (btVector3*)(info->m_J2angularAxis); + btVector3* angular1 = (btVector3*)(info->m_J2angularAxis+info->rowskip); + btVector3* angular2 = (btVector3*)(info->m_J2angularAxis+2*info->rowskip); + a2.getSkewSymmetricMatrix(angular0,angular1,angular2); + } + + // set right hand side for the linear dofs + btScalar k = info->fps * info->erp; + + btVector3 linearError = k*(a2+worldPosB-a1-worldPosA); + int j; + for (j=0; j<3; j++) + { + + + + info->m_constraintError[j*info->rowskip] = linearError[j]; + //printf("info->m_constraintError[%d]=%f\n",j,info->m_constraintError[j]); + } + + //fix the 3 angular degrees of freedom + + int start_row = 3; + int s = info->rowskip; + int start_index = start_row * s; + + // 3 rows to make body rotations equal + info->m_J1angularAxis[start_index] = 1; + info->m_J1angularAxis[start_index + s + 1] = 1; + info->m_J1angularAxis[start_index + s*2+2] = 1; + if ( info->m_J2angularAxis) + { + info->m_J2angularAxis[start_index] = -1; + info->m_J2angularAxis[start_index + s+1] = -1; + info->m_J2angularAxis[start_index + s*2+2] = -1; + } + + // set right hand side for the angular dofs + + btVector3 diff; + btScalar angle; + btMatrix3x3 mrelCur = worldOrnA *worldOrnB.inverse(); + btQuaternion qrelCur; + mrelCur.getRotation(qrelCur); + btTransformUtil::calculateDiffAxisAngleQuaternion(m_relTargetAB,qrelCur,diff,angle); + diff*=-angle; + for (j=0; j<3; j++) + { + info->m_constraintError[(3+j)*info->rowskip] = k * diff[j]; + } + +} \ No newline at end of file diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h new file mode 100644 index 00000000000..697e319e2ce --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btFixedConstraint.h @@ -0,0 +1,49 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BT_FIXED_CONSTRAINT_H +#define BT_FIXED_CONSTRAINT_H + +#include "btTypedConstraint.h" + +ATTRIBUTE_ALIGNED16(class) btFixedConstraint : public btTypedConstraint +{ + btVector3 m_pivotInA; + btVector3 m_pivotInB; + btQuaternion m_relTargetAB; + +public: + btFixedConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& frameInA,const btTransform& frameInB); + + virtual ~btFixedConstraint(); + + + virtual void getInfo1 (btConstraintInfo1* info); + + virtual void getInfo2 (btConstraintInfo2* info); + + virtual void setParam(int num, btScalar value, int axis = -1) + { + btAssert(0); + } + virtual btScalar getParam(int num, int axis = -1) const + { + btAssert(0); + return 0.f; + } + +}; + +#endif //BT_FIXED_CONSTRAINT_H diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.h index 60f60094843..f9afcb91211 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGearConstraint.h @@ -19,6 +19,18 @@ subject to the following restrictions: #define BT_GEAR_CONSTRAINT_H #include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" + + +#ifdef BT_USE_DOUBLE_PRECISION +#define btGearConstraintData btGearConstraintDoubleData +#define btGearConstraintDataName "btGearConstraintDoubleData" +#else +#define btGearConstraintData btGearConstraintFloatData +#define btGearConstraintDataName "btGearConstraintFloatData" +#endif //BT_USE_DOUBLE_PRECISION + + + ///The btGeatConstraint will couple the angular velocity for two bodies around given local axis and ratio. ///See Bullet/Demos/ConstraintDemo for an example use. class btGearConstraint : public btTypedConstraint @@ -39,18 +51,102 @@ public: ///internal method used by the constraint solver, don't use them directly virtual void getInfo2 (btConstraintInfo2* info); + void setAxisA(btVector3& axisA) + { + m_axisInA = axisA; + } + void setAxisB(btVector3& axisB) + { + m_axisInB = axisB; + } + void setRatio(btScalar ratio) + { + m_ratio = ratio; + } + const btVector3& getAxisA() const + { + return m_axisInA; + } + const btVector3& getAxisB() const + { + return m_axisInB; + } + btScalar getRatio() const + { + return m_ratio; + } + + virtual void setParam(int num, btScalar value, int axis = -1) { + (void) num; + (void) value; + (void) axis; btAssert(0); - }; + } ///return the local value of parameter virtual btScalar getParam(int num, int axis = -1) const { + (void) num; + (void) axis; btAssert(0); return 0.f; } + virtual int calculateSerializeBufferSize() const; + + ///fills the dataBuffer and returns the struct name (and 0 on failure) + virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; +}; + + + + +///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 +struct btGearConstraintFloatData +{ + btTypedConstraintFloatData m_typeConstraintData; + + btVector3FloatData m_axisInA; + btVector3FloatData m_axisInB; + + float m_ratio; + char m_padding[4]; }; +struct btGearConstraintDoubleData +{ + btTypedConstraintDoubleData m_typeConstraintData; + + btVector3DoubleData m_axisInA; + btVector3DoubleData m_axisInB; + + double m_ratio; +}; + +SIMD_FORCE_INLINE int btGearConstraint::calculateSerializeBufferSize() const +{ + return sizeof(btGearConstraintData); +} + + ///fills the dataBuffer and returns the struct name (and 0 on failure) +SIMD_FORCE_INLINE const char* btGearConstraint::serialize(void* dataBuffer, btSerializer* serializer) const +{ + btGearConstraintData* gear = (btGearConstraintData*)dataBuffer; + btTypedConstraint::serialize(&gear->m_typeConstraintData,serializer); + + m_axisInA.serialize( gear->m_axisInA ); + m_axisInB.serialize( gear->m_axisInB ); + + gear->m_ratio = m_ratio; + + return btGearConstraintDataName; +} + + + + + + #endif //BT_GEAR_CONSTRAINT_H diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h index 0409f95379b..431a524169e 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h @@ -35,6 +35,14 @@ class btRigidBody; +#ifdef BT_USE_DOUBLE_PRECISION +#define btGeneric6DofConstraintData2 btGeneric6DofConstraintDoubleData2 +#define btGeneric6DofConstraintDataName "btGeneric6DofConstraintDoubleData2" +#else +#define btGeneric6DofConstraintData2 btGeneric6DofConstraintData +#define btGeneric6DofConstraintDataName "btGeneric6DofConstraintData" +#endif //BT_USE_DOUBLE_PRECISION + //! Rotation Limit structure for generic joints class btRotationalLimitMotor @@ -561,7 +569,7 @@ public: }; -///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 + struct btGeneric6DofConstraintData { btTypedConstraintData m_typeConstraintData; @@ -578,35 +586,51 @@ struct btGeneric6DofConstraintData int m_useOffsetForConstraintFrame; }; +struct btGeneric6DofConstraintDoubleData2 +{ + btTypedConstraintDoubleData m_typeConstraintData; + btTransformDoubleData m_rbAFrame; // constraint axii. Assumes z is hinge axis. + btTransformDoubleData m_rbBFrame; + + btVector3DoubleData m_linearUpperLimit; + btVector3DoubleData m_linearLowerLimit; + + btVector3DoubleData m_angularUpperLimit; + btVector3DoubleData m_angularLowerLimit; + + int m_useLinearReferenceFrameA; + int m_useOffsetForConstraintFrame; +}; + SIMD_FORCE_INLINE int btGeneric6DofConstraint::calculateSerializeBufferSize() const { - return sizeof(btGeneric6DofConstraintData); + return sizeof(btGeneric6DofConstraintData2); } ///fills the dataBuffer and returns the struct name (and 0 on failure) SIMD_FORCE_INLINE const char* btGeneric6DofConstraint::serialize(void* dataBuffer, btSerializer* serializer) const { - btGeneric6DofConstraintData* dof = (btGeneric6DofConstraintData*)dataBuffer; + btGeneric6DofConstraintData2* dof = (btGeneric6DofConstraintData2*)dataBuffer; btTypedConstraint::serialize(&dof->m_typeConstraintData,serializer); - m_frameInA.serializeFloat(dof->m_rbAFrame); - m_frameInB.serializeFloat(dof->m_rbBFrame); + m_frameInA.serialize(dof->m_rbAFrame); + m_frameInB.serialize(dof->m_rbBFrame); int i; for (i=0;i<3;i++) { - dof->m_angularLowerLimit.m_floats[i] = float(m_angularLimits[i].m_loLimit); - dof->m_angularUpperLimit.m_floats[i] = float(m_angularLimits[i].m_hiLimit); - dof->m_linearLowerLimit.m_floats[i] = float(m_linearLimits.m_lowerLimit[i]); - dof->m_linearUpperLimit.m_floats[i] = float(m_linearLimits.m_upperLimit[i]); + dof->m_angularLowerLimit.m_floats[i] = m_angularLimits[i].m_loLimit; + dof->m_angularUpperLimit.m_floats[i] = m_angularLimits[i].m_hiLimit; + dof->m_linearLowerLimit.m_floats[i] = m_linearLimits.m_lowerLimit[i]; + dof->m_linearUpperLimit.m_floats[i] = m_linearLimits.m_upperLimit[i]; } dof->m_useLinearReferenceFrameA = m_useLinearReferenceFrameA? 1 : 0; dof->m_useOffsetForConstraintFrame = m_useOffsetForConstraintFrame ? 1 : 0; - return "btGeneric6DofConstraintData"; + return btGeneric6DofConstraintDataName; } diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h index 6fabb30369b..1b2e0f62ca8 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h @@ -21,6 +21,15 @@ subject to the following restrictions: #include "btTypedConstraint.h" #include "btGeneric6DofConstraint.h" +#ifdef BT_USE_DOUBLE_PRECISION +#define btGeneric6DofSpringConstraintData2 btGeneric6DofSpringConstraintDoubleData2 +#define btGeneric6DofSpringConstraintDataName "btGeneric6DofSpringConstraintDoubleData2" +#else +#define btGeneric6DofSpringConstraintData2 btGeneric6DofSpringConstraintData +#define btGeneric6DofSpringConstraintDataName "btGeneric6DofSpringConstraintData" +#endif //BT_USE_DOUBLE_PRECISION + + /// Generic 6 DOF constraint that allows to set spring motors to any translational and rotational DOF @@ -65,7 +74,6 @@ public: }; -///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 struct btGeneric6DofSpringConstraintData { btGeneric6DofConstraintData m_6dofData; @@ -76,26 +84,37 @@ struct btGeneric6DofSpringConstraintData float m_springDamping[6]; }; +struct btGeneric6DofSpringConstraintDoubleData2 +{ + btGeneric6DofConstraintDoubleData2 m_6dofData; + + int m_springEnabled[6]; + double m_equilibriumPoint[6]; + double m_springStiffness[6]; + double m_springDamping[6]; +}; + + SIMD_FORCE_INLINE int btGeneric6DofSpringConstraint::calculateSerializeBufferSize() const { - return sizeof(btGeneric6DofSpringConstraintData); + return sizeof(btGeneric6DofSpringConstraintData2); } ///fills the dataBuffer and returns the struct name (and 0 on failure) SIMD_FORCE_INLINE const char* btGeneric6DofSpringConstraint::serialize(void* dataBuffer, btSerializer* serializer) const { - btGeneric6DofSpringConstraintData* dof = (btGeneric6DofSpringConstraintData*)dataBuffer; + btGeneric6DofSpringConstraintData2* dof = (btGeneric6DofSpringConstraintData2*)dataBuffer; btGeneric6DofConstraint::serialize(&dof->m_6dofData,serializer); int i; for (i=0;i<6;i++) { - dof->m_equilibriumPoint[i] = (float)m_equilibriumPoint[i]; - dof->m_springDamping[i] = (float)m_springDamping[i]; + dof->m_equilibriumPoint[i] = m_equilibriumPoint[i]; + dof->m_springDamping[i] = m_springDamping[i]; dof->m_springEnabled[i] = m_springEnabled[i]? 1 : 0; - dof->m_springStiffness[i] = (float)m_springStiffness[i]; + dof->m_springStiffness[i] = m_springStiffness[i]; } - return "btGeneric6DofSpringConstraintData"; + return btGeneric6DofSpringConstraintDataName; } #endif // BT_GENERIC_6DOF_SPRING_CONSTRAINT_H diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h index a7f2cca5500..7c33ac24e05 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h @@ -28,8 +28,8 @@ subject to the following restrictions: class btRigidBody; #ifdef BT_USE_DOUBLE_PRECISION -#define btHingeConstraintData btHingeConstraintDoubleData -#define btHingeConstraintDataName "btHingeConstraintDoubleData" +#define btHingeConstraintData btHingeConstraintDoubleData2 //rename to 2 for backwards compatibility, so we can still load the 'btHingeConstraintDoubleData' version +#define btHingeConstraintDataName "btHingeConstraintDoubleData2" #else #define btHingeConstraintData btHingeConstraintFloatData #define btHingeConstraintDataName "btHingeConstraintFloatData" @@ -302,7 +302,10 @@ public: }; -///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 + +//only for backward compatibility +#ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION +///this structure is not used, except for loading pre-2.82 .bullet files struct btHingeConstraintDoubleData { btTypedConstraintData m_typeConstraintData; @@ -321,7 +324,9 @@ struct btHingeConstraintDoubleData float m_relaxationFactor; }; -///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 +#endif //BT_BACKWARDS_COMPATIBLE_SERIALIZATION + + struct btHingeConstraintFloatData { btTypedConstraintData m_typeConstraintData; @@ -344,6 +349,30 @@ struct btHingeConstraintFloatData +///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 +struct btHingeConstraintDoubleData2 +{ + btTypedConstraintDoubleData m_typeConstraintData; + btTransformDoubleData m_rbAFrame; // constraint axii. Assumes z is hinge axis. + btTransformDoubleData m_rbBFrame; + int m_useReferenceFrameA; + int m_angularOnly; + int m_enableAngularMotor; + double m_motorTargetVelocity; + double m_maxMotorImpulse; + + double m_lowerLimit; + double m_upperLimit; + double m_limitSoftness; + double m_biasFactor; + double m_relaxationFactor; + char m_padding1[4]; + +}; + + + + SIMD_FORCE_INLINE int btHingeConstraint::calculateSerializeBufferSize() const { return sizeof(btHingeConstraintData); diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h index 1e13416dfeb..91218949498 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h @@ -24,10 +24,10 @@ class btRigidBody; #ifdef BT_USE_DOUBLE_PRECISION -#define btPoint2PointConstraintData btPoint2PointConstraintDoubleData -#define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData" +#define btPoint2PointConstraintData2 btPoint2PointConstraintDoubleData2 +#define btPoint2PointConstraintDataName "btPoint2PointConstraintDoubleData2" #else -#define btPoint2PointConstraintData btPoint2PointConstraintFloatData +#define btPoint2PointConstraintData2 btPoint2PointConstraintFloatData #define btPoint2PointConstraintDataName "btPoint2PointConstraintFloatData" #endif //BT_USE_DOUBLE_PRECISION @@ -133,6 +133,17 @@ struct btPoint2PointConstraintFloatData btVector3FloatData m_pivotInB; }; +///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 +struct btPoint2PointConstraintDoubleData2 +{ + btTypedConstraintDoubleData m_typeConstraintData; + btVector3DoubleData m_pivotInA; + btVector3DoubleData m_pivotInB; +}; + +#ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION +///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 +///this structure is not used, except for loading pre-2.82 .bullet files ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 struct btPoint2PointConstraintDoubleData { @@ -140,18 +151,19 @@ struct btPoint2PointConstraintDoubleData btVector3DoubleData m_pivotInA; btVector3DoubleData m_pivotInB; }; +#endif //BT_BACKWARDS_COMPATIBLE_SERIALIZATION SIMD_FORCE_INLINE int btPoint2PointConstraint::calculateSerializeBufferSize() const { - return sizeof(btPoint2PointConstraintData); + return sizeof(btPoint2PointConstraintData2); } ///fills the dataBuffer and returns the struct name (and 0 on failure) SIMD_FORCE_INLINE const char* btPoint2PointConstraint::serialize(void* dataBuffer, btSerializer* serializer) const { - btPoint2PointConstraintData* p2pData = (btPoint2PointConstraintData*)dataBuffer; + btPoint2PointConstraintData2* p2pData = (btPoint2PointConstraintData2*)dataBuffer; btTypedConstraint::serialize(&p2pData->m_typeConstraintData,serializer); m_pivotInA.serialize(p2pData->m_pivotInA); diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp index 5f9437b7add..be93e35434c 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp @@ -152,7 +152,7 @@ void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowGenericSIMD( #endif } -// Project Gauss Seidel or the equivalent Sequential Impulse +// Projected Gauss Seidel or the equivalent Sequential Impulse void btSequentialImpulseConstraintSolver::resolveSingleConstraintRowLowerLimit(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& c) { btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm; @@ -280,7 +280,7 @@ int btSequentialImpulseConstraintSolver::btRandInt2 (int n) -void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject) +void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject, btScalar timeStep) { btRigidBody* rb = collisionObject? btRigidBody::upcast(collisionObject) : 0; @@ -299,6 +299,9 @@ void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBod solverBody->m_linearFactor = rb->getLinearFactor(); solverBody->m_linearVelocity = rb->getLinearVelocity(); solverBody->m_angularVelocity = rb->getAngularVelocity(); + solverBody->m_externalForceImpulse = rb->getTotalForce()*rb->getInvMass()*timeStep; + solverBody->m_externalTorqueImpulse = rb->getTotalTorque()*rb->getInvInertiaTensorWorld()*timeStep ; + } else { solverBody->m_worldTransform.setIdentity(); @@ -308,6 +311,8 @@ void btSequentialImpulseConstraintSolver::initSolverBody(btSolverBody* solverBod solverBody->m_linearFactor.setValue(1,1,1); solverBody->m_linearVelocity.setValue(0,0,0); solverBody->m_angularVelocity.setValue(0,0,0); + solverBody->m_externalForceImpulse.setValue(0,0,0); + solverBody->m_externalTorqueImpulse.setValue(0,0,0); } @@ -326,8 +331,7 @@ btScalar btSequentialImpulseConstraintSolver::restitutionCurve(btScalar rel_vel, -static void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection, int frictionMode); -static void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection, int frictionMode) +void btSequentialImpulseConstraintSolver::applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection, int frictionMode) { @@ -351,8 +355,6 @@ void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstr { - solverConstraint.m_contactNormal1 = normalAxis; - solverConstraint.m_contactNormal2 = -normalAxis; btSolverBody& solverBodyA = m_tmpSolverBodyPool[solverBodyIdA]; btSolverBody& solverBodyB = m_tmpSolverBodyPool[solverBodyIdB]; @@ -368,15 +370,30 @@ void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstr solverConstraint.m_appliedImpulse = 0.f; solverConstraint.m_appliedPushImpulse = 0.f; + if (body0) { + solverConstraint.m_contactNormal1 = normalAxis; btVector3 ftorqueAxis1 = rel_pos1.cross(solverConstraint.m_contactNormal1); solverConstraint.m_relpos1CrossNormal = ftorqueAxis1; - solverConstraint.m_angularComponentA = body0 ? body0->getInvInertiaTensorWorld()*ftorqueAxis1*body0->getAngularFactor() : btVector3(0,0,0); + solverConstraint.m_angularComponentA = body0->getInvInertiaTensorWorld()*ftorqueAxis1*body0->getAngularFactor(); + }else + { + solverConstraint.m_contactNormal1.setZero(); + solverConstraint.m_relpos1CrossNormal.setZero(); + solverConstraint.m_angularComponentA .setZero(); } + + if (body1) { + solverConstraint.m_contactNormal2 = -normalAxis; btVector3 ftorqueAxis1 = rel_pos2.cross(solverConstraint.m_contactNormal2); solverConstraint.m_relpos2CrossNormal = ftorqueAxis1; - solverConstraint.m_angularComponentB = body1 ? body1->getInvInertiaTensorWorld()*ftorqueAxis1*body1->getAngularFactor() : btVector3(0,0,0); + solverConstraint.m_angularComponentB = body1->getInvInertiaTensorWorld()*ftorqueAxis1*body1->getAngularFactor(); + } else + { + solverConstraint.m_contactNormal2.setZero(); + solverConstraint.m_relpos2CrossNormal.setZero(); + solverConstraint.m_angularComponentB.setZero(); } { @@ -401,9 +418,9 @@ void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstr btScalar rel_vel; - btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(body0?solverBodyA.m_linearVelocity:btVector3(0,0,0)) + btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(body0?solverBodyA.m_linearVelocity+solverBodyA.m_externalForceImpulse:btVector3(0,0,0)) + solverConstraint.m_relpos1CrossNormal.dot(body0?solverBodyA.m_angularVelocity:btVector3(0,0,0)); - btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(body1?solverBodyB.m_linearVelocity:btVector3(0,0,0)) + btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(body1?solverBodyB.m_linearVelocity+solverBodyB.m_externalForceImpulse:btVector3(0,0,0)) + solverConstraint.m_relpos2CrossNormal.dot(body1?solverBodyB.m_angularVelocity:btVector3(0,0,0)); rel_vel = vel1Dotn+vel2Dotn; @@ -414,8 +431,8 @@ void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstr btSimdScalar velocityImpulse = velocityError * btSimdScalar(solverConstraint.m_jacDiagABInv); solverConstraint.m_rhs = velocityImpulse; solverConstraint.m_cfm = cfmSlip; - solverConstraint.m_lowerLimit = 0; - solverConstraint.m_upperLimit = 1e10f; + solverConstraint.m_lowerLimit = -solverConstraint.m_friction; + solverConstraint.m_upperLimit = solverConstraint.m_friction; } } @@ -481,9 +498,9 @@ void btSequentialImpulseConstraintSolver::setupRollingFrictionConstraint( btSolv btScalar rel_vel; - btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(body0?solverBodyA.m_linearVelocity:btVector3(0,0,0)) + btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(body0?solverBodyA.m_linearVelocity+solverBodyA.m_externalForceImpulse:btVector3(0,0,0)) + solverConstraint.m_relpos1CrossNormal.dot(body0?solverBodyA.m_angularVelocity:btVector3(0,0,0)); - btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(body1?solverBodyB.m_linearVelocity:btVector3(0,0,0)) + btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(body1?solverBodyB.m_linearVelocity+solverBodyB.m_externalForceImpulse:btVector3(0,0,0)) + solverConstraint.m_relpos2CrossNormal.dot(body1?solverBodyB.m_angularVelocity:btVector3(0,0,0)); rel_vel = vel1Dotn+vel2Dotn; @@ -494,8 +511,8 @@ void btSequentialImpulseConstraintSolver::setupRollingFrictionConstraint( btSolv btSimdScalar velocityImpulse = velocityError * btSimdScalar(solverConstraint.m_jacDiagABInv); solverConstraint.m_rhs = velocityImpulse; solverConstraint.m_cfm = cfmSlip; - solverConstraint.m_lowerLimit = 0; - solverConstraint.m_upperLimit = 1e10f; + solverConstraint.m_lowerLimit = -solverConstraint.m_friction; + solverConstraint.m_upperLimit = solverConstraint.m_friction; } } @@ -517,7 +534,7 @@ btSolverConstraint& btSequentialImpulseConstraintSolver::addRollingFrictionConst } -int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& body) +int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& body,btScalar timeStep) { int solverBodyIdA = -1; @@ -535,11 +552,19 @@ int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& { solverBodyIdA = m_tmpSolverBodyPool.size(); btSolverBody& solverBody = m_tmpSolverBodyPool.expand(); - initSolverBody(&solverBody,&body); + initSolverBody(&solverBody,&body,timeStep); body.setCompanionId(solverBodyIdA); } else { - return 0;//assume first one is a fixed solver body + + if (m_fixedBodyId<0) + { + m_fixedBodyId = m_tmpSolverBodyPool.size(); + btSolverBody& fixedBody = m_tmpSolverBodyPool.expand(); + initSolverBody(&fixedBody,0,timeStep); + } + return m_fixedBodyId; +// return 0;//assume first one is a fixed solver body } } @@ -552,8 +577,8 @@ int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp, const btContactSolverInfo& infoGlobal, - btVector3& vel, btScalar& rel_vel, btScalar& relaxation, - btVector3& rel_pos1, btVector3& rel_pos2) + btScalar& relaxation, + const btVector3& rel_pos1, const btVector3& rel_pos2) { const btVector3& pos1 = cp.getPositionWorldOnA(); @@ -567,8 +592,8 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra // btVector3 rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin(); // btVector3 rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin(); - rel_pos1 = pos1 - bodyA->getWorldTransform().getOrigin(); - rel_pos2 = pos2 - bodyB->getWorldTransform().getOrigin(); + //rel_pos1 = pos1 - bodyA->getWorldTransform().getOrigin(); + //rel_pos2 = pos2 - bodyB->getWorldTransform().getOrigin(); relaxation = 1.f; @@ -601,10 +626,24 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra solverConstraint.m_jacDiagABInv = denom; } - solverConstraint.m_contactNormal1 = cp.m_normalWorldOnB; - solverConstraint.m_contactNormal2 = -cp.m_normalWorldOnB; - solverConstraint.m_relpos1CrossNormal = torqueAxis0; - solverConstraint.m_relpos2CrossNormal = -torqueAxis1; + if (rb0) + { + solverConstraint.m_contactNormal1 = cp.m_normalWorldOnB; + solverConstraint.m_relpos1CrossNormal = torqueAxis0; + } else + { + solverConstraint.m_contactNormal1.setZero(); + solverConstraint.m_relpos1CrossNormal.setZero(); + } + if (rb1) + { + solverConstraint.m_contactNormal2 = -cp.m_normalWorldOnB; + solverConstraint.m_relpos2CrossNormal = -torqueAxis1; + }else + { + solverConstraint.m_contactNormal2.setZero(); + solverConstraint.m_relpos2CrossNormal.setZero(); + } btScalar restitution = 0.f; btScalar penetration = cp.getDistance()+infoGlobal.m_linearSlop; @@ -616,8 +655,8 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra vel2 = rb1? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0); // btVector3 vel2 = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0); - vel = vel1 - vel2; - rel_vel = cp.m_normalWorldOnB.dot(vel); + btVector3 vel = vel1 - vel2; + btScalar rel_vel = cp.m_normalWorldOnB.dot(vel); @@ -648,10 +687,17 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra solverConstraint.m_appliedPushImpulse = 0.f; { - btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(rb0?bodyA->m_linearVelocity:btVector3(0,0,0)) - + solverConstraint.m_relpos1CrossNormal.dot(rb0?bodyA->m_angularVelocity:btVector3(0,0,0)); - btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(rb1?bodyB->m_linearVelocity:btVector3(0,0,0)) - + solverConstraint.m_relpos2CrossNormal.dot(rb1?bodyB->m_angularVelocity:btVector3(0,0,0)); + + btVector3 externalForceImpulseA = bodyA->m_originalBody ? bodyA->m_externalForceImpulse: btVector3(0,0,0); + btVector3 externalTorqueImpulseA = bodyA->m_originalBody ? bodyA->m_externalTorqueImpulse: btVector3(0,0,0); + btVector3 externalForceImpulseB = bodyB->m_originalBody ? bodyB->m_externalForceImpulse: btVector3(0,0,0); + btVector3 externalTorqueImpulseB = bodyB->m_originalBody ?bodyB->m_externalTorqueImpulse : btVector3(0,0,0); + + + btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(bodyA->m_linearVelocity+externalForceImpulseA) + + solverConstraint.m_relpos1CrossNormal.dot(bodyA->m_angularVelocity+externalTorqueImpulseA); + btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(bodyB->m_linearVelocity+externalForceImpulseB) + + solverConstraint.m_relpos2CrossNormal.dot(bodyB->m_angularVelocity+externalTorqueImpulseB); btScalar rel_vel = vel1Dotn+vel2Dotn; btScalar positionalError = 0.f; @@ -680,7 +726,7 @@ void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstra if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold)) { //combine position and velocity into rhs - solverConstraint.m_rhs = penetrationImpulse+velocityImpulse; + solverConstraint.m_rhs = penetrationImpulse+velocityImpulse;//-solverConstraint.m_contactNormal1.dot(bodyA->m_externalForce*bodyA->m_invMass-bodyB->m_externalForce/bodyB->m_invMass)*solverConstraint.m_jacDiagABInv; solverConstraint.m_rhsPenetration = 0.f; } else @@ -754,8 +800,8 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m colObj0 = (btCollisionObject*)manifold->getBody0(); colObj1 = (btCollisionObject*)manifold->getBody1(); - int solverBodyIdA = getOrInitSolverBody(*colObj0); - int solverBodyIdB = getOrInitSolverBody(*colObj1); + int solverBodyIdA = getOrInitSolverBody(*colObj0,infoGlobal.m_timeStep); + int solverBodyIdB = getOrInitSolverBody(*colObj1,infoGlobal.m_timeStep); // btRigidBody* bodyA = btRigidBody::upcast(colObj0); // btRigidBody* bodyB = btRigidBody::upcast(colObj1); @@ -780,19 +826,35 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m btVector3 rel_pos1; btVector3 rel_pos2; btScalar relaxation; - btScalar rel_vel; - btVector3 vel; + int frictionIndex = m_tmpSolverContactConstraintPool.size(); btSolverConstraint& solverConstraint = m_tmpSolverContactConstraintPool.expandNonInitializing(); -// btRigidBody* rb0 = btRigidBody::upcast(colObj0); -// btRigidBody* rb1 = btRigidBody::upcast(colObj1); + btRigidBody* rb0 = btRigidBody::upcast(colObj0); + btRigidBody* rb1 = btRigidBody::upcast(colObj1); solverConstraint.m_solverBodyIdA = solverBodyIdA; solverConstraint.m_solverBodyIdB = solverBodyIdB; solverConstraint.m_originalContactPoint = &cp; - setupContactConstraint(solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal, vel, rel_vel, relaxation, rel_pos1, rel_pos2); + const btVector3& pos1 = cp.getPositionWorldOnA(); + const btVector3& pos2 = cp.getPositionWorldOnB(); + + rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin(); + rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin(); + + btVector3 vel1;// = rb0 ? rb0->getVelocityInLocalPoint(rel_pos1) : btVector3(0,0,0); + btVector3 vel2;// = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0); + + solverBodyA->getVelocityInLocalPointNoDelta(rel_pos1,vel1); + solverBodyB->getVelocityInLocalPointNoDelta(rel_pos2,vel2 ); + + btVector3 vel = vel1 - vel2; + btScalar rel_vel = cp.m_normalWorldOnB.dot(vel); + + setupContactConstraint(solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal, relaxation, rel_pos1, rel_pos2); + + // const btVector3& pos1 = cp.getPositionWorldOnA(); // const btVector3& pos2 = cp.getPositionWorldOnB(); @@ -801,9 +863,11 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m solverConstraint.m_frictionIndex = m_tmpSolverContactFrictionConstraintPool.size(); - btVector3 angVelA,angVelB; - solverBodyA->getAngularVelocity(angVelA); - solverBodyB->getAngularVelocity(angVelB); + btVector3 angVelA(0,0,0),angVelB(0,0,0); + if (rb0) + angVelA = rb0->getAngularVelocity(); + if (rb1) + angVelB = rb1->getAngularVelocity(); btVector3 relAngVel = angVelB-angVelA; if ((cp.m_combinedRollingFriction>0.f) && (rollingFriction>0)) @@ -857,6 +921,10 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON) { cp.m_lateralFrictionDir1 *= 1.f/btSqrt(lat_rel_vel); + applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); + applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); + addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB); @@ -864,17 +932,16 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION); applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION); addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - } - applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); - applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); - addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - } else { btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2); + applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); + applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); + addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) { applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION); @@ -882,9 +949,6 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); } - applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); - applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); - addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS) && (infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION)) { @@ -899,8 +963,8 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation, cp.m_contactMotion2, cp.m_contactCFM2); - setFrictionConstraintImpulse( solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal); } + setFrictionConstraintImpulse( solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal); @@ -909,10 +973,24 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m } } -btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc) +void btSequentialImpulseConstraintSolver::convertContacts(btPersistentManifold** manifoldPtr,int numManifolds, const btContactSolverInfo& infoGlobal) +{ + int i; + btPersistentManifold* manifold = 0; +// btCollisionObject* colObj0=0,*colObj1=0; + + + for (i=0;igetInvMass()) { @@ -1012,9 +1091,8 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol if (body->getFlags()&BT_ENABLE_GYROPSCOPIC_FORCE) { gyroForce = body->computeGyroscopicForce(infoGlobal.m_maxGyroscopicForce); + solverBody.m_externalTorqueImpulse -= gyroForce*body->getInvInertiaTensorWorld()*infoGlobal.m_timeStep; } - solverBody.m_linearVelocity += body->getTotalForce()*body->getInvMass()*infoGlobal.m_timeStep; - solverBody.m_angularVelocity += (body->getTotalTorque()-gyroForce)*body->getInvInertiaTensorWorld()*infoGlobal.m_timeStep; } } @@ -1084,8 +1162,8 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol btRigidBody& rbA = constraint->getRigidBodyA(); btRigidBody& rbB = constraint->getRigidBodyB(); - int solverBodyIdA = getOrInitSolverBody(rbA); - int solverBodyIdB = getOrInitSolverBody(rbB); + int solverBodyIdA = getOrInitSolverBody(rbA,infoGlobal.m_timeStep); + int solverBodyIdB = getOrInitSolverBody(rbB,infoGlobal.m_timeStep); btSolverBody* bodyAPtr = &m_tmpSolverBodyPool[solverBodyIdA]; btSolverBody* bodyBPtr = &m_tmpSolverBodyPool[solverBodyIdB]; @@ -1182,15 +1260,22 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol } - ///fix rhs - ///todo: add force/torque accelerators + { btScalar rel_vel; - btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(rbA.getLinearVelocity()) + solverConstraint.m_relpos1CrossNormal.dot(rbA.getAngularVelocity()); - btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(rbB.getLinearVelocity()) + solverConstraint.m_relpos2CrossNormal.dot(rbB.getAngularVelocity()); + btVector3 externalForceImpulseA = bodyAPtr->m_originalBody ? bodyAPtr->m_externalForceImpulse : btVector3(0,0,0); + btVector3 externalTorqueImpulseA = bodyAPtr->m_originalBody ? bodyAPtr->m_externalTorqueImpulse : btVector3(0,0,0); + + btVector3 externalForceImpulseB = bodyBPtr->m_originalBody ? bodyBPtr->m_externalForceImpulse : btVector3(0,0,0); + btVector3 externalTorqueImpulseB = bodyBPtr->m_originalBody ?bodyBPtr->m_externalTorqueImpulse : btVector3(0,0,0); + + btScalar vel1Dotn = solverConstraint.m_contactNormal1.dot(rbA.getLinearVelocity()+externalForceImpulseA) + + solverConstraint.m_relpos1CrossNormal.dot(rbA.getAngularVelocity()+externalTorqueImpulseA); + + btScalar vel2Dotn = solverConstraint.m_contactNormal2.dot(rbB.getLinearVelocity()+externalForceImpulseB) + + solverConstraint.m_relpos2CrossNormal.dot(rbB.getAngularVelocity()+externalTorqueImpulseB); rel_vel = vel1Dotn+vel2Dotn; - btScalar restitution = 0.f; btScalar positionalError = solverConstraint.m_rhs;//already filled in by getConstraintInfo2 btScalar velocityError = restitution - rel_vel * info2.m_damping; @@ -1199,6 +1284,7 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol solverConstraint.m_rhs = penetrationImpulse+velocityImpulse; solverConstraint.m_appliedImpulse = 0.f; + } } } @@ -1206,18 +1292,8 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol } } - { - int i; - btPersistentManifold* manifold = 0; -// btCollisionObject* colObj0=0,*colObj1=0; - + convertContacts(manifoldPtr,numManifolds,infoGlobal); - for (i=0;iisEnabled()) - { - int bodyAid = getOrInitSolverBody(constraints[j]->getRigidBodyA()); - int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB()); - btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid]; - btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid]; - constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep); - } + if (constraints[j]->isEnabled()) + { + int bodyAid = getOrInitSolverBody(constraints[j]->getRigidBodyA(),infoGlobal.m_timeStep); + int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB(),infoGlobal.m_timeStep); + btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid]; + btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid]; + constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep); + } } ///solve all contact constraints using SIMD, if available @@ -1376,7 +1452,8 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration for (j=0;jisEnabled()) - { - int bodyAid = getOrInitSolverBody(constraints[j]->getRigidBodyA()); - int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB()); - btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid]; - btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid]; - constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep); - } + if (constraints[j]->isEnabled()) + { + int bodyAid = getOrInitSolverBody(constraints[j]->getRigidBodyA(),infoGlobal.m_timeStep); + int bodyBid = getOrInitSolverBody(constraints[j]->getRigidBodyB(),infoGlobal.m_timeStep); + btSolverBody& bodyA = m_tmpSolverBodyPool[bodyAid]; + btSolverBody& bodyB = m_tmpSolverBodyPool[bodyBid]; + constraints[j]->solveConstraintObsolete(bodyA,bodyB,infoGlobal.m_timeStep); + } } ///solve all contact constraints int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); @@ -1492,7 +1570,7 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration } -void btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc) +void btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer) { int iteration; if (infoGlobal.m_splitImpulse) @@ -1532,20 +1610,20 @@ void btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySplitImpulseIte } } -btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc) +btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer) { BT_PROFILE("solveGroupCacheFriendlyIterations"); { ///this is a special step to resolve penetrations (just for contacts) - solveGroupCacheFriendlySplitImpulseIterations(bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer,stackAlloc); + solveGroupCacheFriendlySplitImpulseIterations(bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer); int maxIterations = m_maxOverrideNumSolverIterations > infoGlobal.m_numIterations? m_maxOverrideNumSolverIterations : infoGlobal.m_numIterations; for ( int iteration = 0 ; iteration< maxIterations ; iteration++) //for ( int iteration = maxIterations-1 ; iteration >= 0;iteration--) { - solveSingleIteration(iteration, bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer,stackAlloc); + solveSingleIteration(iteration, bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer); } } @@ -1610,9 +1688,15 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyFinish(btCo m_tmpSolverBodyPool[i].writebackVelocityAndTransform(infoGlobal.m_timeStep, infoGlobal.m_splitImpulseTurnErp); else m_tmpSolverBodyPool[i].writebackVelocity(); + + m_tmpSolverBodyPool[i].m_originalBody->setLinearVelocity( + m_tmpSolverBodyPool[i].m_linearVelocity+ + m_tmpSolverBodyPool[i].m_externalForceImpulse); + + m_tmpSolverBodyPool[i].m_originalBody->setAngularVelocity( + m_tmpSolverBodyPool[i].m_angularVelocity+ + m_tmpSolverBodyPool[i].m_externalTorqueImpulse); - m_tmpSolverBodyPool[i].m_originalBody->setLinearVelocity(m_tmpSolverBodyPool[i].m_linearVelocity); - m_tmpSolverBodyPool[i].m_originalBody->setAngularVelocity(m_tmpSolverBodyPool[i].m_angularVelocity); if (infoGlobal.m_splitImpulse) m_tmpSolverBodyPool[i].m_originalBody->setWorldTransform(m_tmpSolverBodyPool[i].m_worldTransform); @@ -1632,15 +1716,15 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyFinish(btCo /// btSequentialImpulseConstraintSolver Sequentially applies impulses -btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc,btDispatcher* /*dispatcher*/) +btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btDispatcher* /*dispatcher*/) { BT_PROFILE("solveGroup"); //you need to provide at least some bodies - solveGroupCacheFriendlySetup( bodies, numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal,debugDrawer, stackAlloc); + solveGroupCacheFriendlySetup( bodies, numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal,debugDrawer); - solveGroupCacheFriendlyIterations(bodies, numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal,debugDrawer, stackAlloc); + solveGroupCacheFriendlyIterations(bodies, numBodies, manifoldPtr, numManifolds,constraints, numConstraints,infoGlobal,debugDrawer); solveGroupCacheFriendlyFinish(bodies, numBodies, infoGlobal); diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h index 2eea6be0db2..180d2a385d3 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h @@ -18,7 +18,6 @@ subject to the following restrictions: class btIDebugDraw; class btPersistentManifold; -class btStackAlloc; class btDispatcher; class btCollisionObject; #include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" @@ -43,7 +42,7 @@ protected: btAlignedObjectArray m_orderFrictionConstraintPool; btAlignedObjectArray m_tmpConstraintSizesPool; int m_maxOverrideNumSolverIterations; - + int m_fixedBodyId; void setupFrictionConstraint( btSolverConstraint& solverConstraint, const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB, btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2, btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, @@ -57,10 +56,11 @@ protected: btSolverConstraint& addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity=0., btScalar cfmSlip=0.); btSolverConstraint& addRollingFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity=0, btScalar cfmSlip=0.f); - + void setupContactConstraint(btSolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp, - const btContactSolverInfo& infoGlobal, btVector3& vel, btScalar& rel_vel, btScalar& relaxation, - btVector3& rel_pos1, btVector3& rel_pos2); + const btContactSolverInfo& infoGlobal,btScalar& relaxation, const btVector3& rel_pos1, const btVector3& rel_pos2); + + static void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection, int frictionMode); void setFrictionConstraintImpulse( btSolverConstraint& solverConstraint, int solverBodyIdA,int solverBodyIdB, btManifoldPoint& cp, const btContactSolverInfo& infoGlobal); @@ -71,6 +71,8 @@ protected: btScalar restitutionCurve(btScalar rel_vel, btScalar restitution); + virtual void convertContacts(btPersistentManifold** manifoldPtr, int numManifolds, const btContactSolverInfo& infoGlobal); + void convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal); @@ -83,8 +85,8 @@ protected: const btSolverConstraint& contactConstraint); //internal method - int getOrInitSolverBody(btCollisionObject& body); - void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject); + int getOrInitSolverBody(btCollisionObject& body,btScalar timeStep); + void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject, btScalar timeStep); void resolveSingleConstraintRowGeneric(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint); @@ -97,12 +99,12 @@ protected: protected: - virtual void solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); + virtual void solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); virtual btScalar solveGroupCacheFriendlyFinish(btCollisionObject** bodies,int numBodies,const btContactSolverInfo& infoGlobal); - btScalar solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); + virtual btScalar solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); - virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); - virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); + virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); + virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); public: @@ -112,7 +114,7 @@ public: btSequentialImpulseConstraintSolver(); virtual ~btSequentialImpulseConstraintSolver(); - virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher); + virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher); @@ -132,6 +134,11 @@ public: return m_btSeed2; } + + virtual btConstraintSolverType getSolverType() const + { + return BT_SEQUENTIAL_IMPULSE_SOLVER; + } }; diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h index ca8e715bc47..57ebb47d8e7 100755 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h @@ -25,7 +25,13 @@ TODO: #ifndef BT_SLIDER_CONSTRAINT_H #define BT_SLIDER_CONSTRAINT_H - +#ifdef BT_USE_DOUBLE_PRECISION +#define btSliderConstraintData2 btSliderConstraintDoubleData +#define btSliderConstraintDataName "btSliderConstraintDoubleData" +#else +#define btSliderConstraintData2 btSliderConstraintData +#define btSliderConstraintDataName "btSliderConstraintData" +#endif //BT_USE_DOUBLE_PRECISION #include "LinearMath/btVector3.h" #include "btJacobianEntry.h" @@ -283,7 +289,10 @@ public: }; + ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 + + struct btSliderConstraintData { btTypedConstraintData m_typeConstraintData; @@ -302,31 +311,48 @@ struct btSliderConstraintData }; +struct btSliderConstraintDoubleData +{ + btTypedConstraintDoubleData m_typeConstraintData; + btTransformDoubleData m_rbAFrame; // constraint axii. Assumes z is hinge axis. + btTransformDoubleData m_rbBFrame; + + double m_linearUpperLimit; + double m_linearLowerLimit; + + double m_angularUpperLimit; + double m_angularLowerLimit; + + int m_useLinearReferenceFrameA; + int m_useOffsetForConstraintFrame; + +}; + SIMD_FORCE_INLINE int btSliderConstraint::calculateSerializeBufferSize() const { - return sizeof(btSliderConstraintData); + return sizeof(btSliderConstraintData2); } ///fills the dataBuffer and returns the struct name (and 0 on failure) SIMD_FORCE_INLINE const char* btSliderConstraint::serialize(void* dataBuffer, btSerializer* serializer) const { - btSliderConstraintData* sliderData = (btSliderConstraintData*) dataBuffer; + btSliderConstraintData2* sliderData = (btSliderConstraintData2*) dataBuffer; btTypedConstraint::serialize(&sliderData->m_typeConstraintData,serializer); - m_frameInA.serializeFloat(sliderData->m_rbAFrame); - m_frameInB.serializeFloat(sliderData->m_rbBFrame); + m_frameInA.serialize(sliderData->m_rbAFrame); + m_frameInB.serialize(sliderData->m_rbBFrame); - sliderData->m_linearUpperLimit = float(m_upperLinLimit); - sliderData->m_linearLowerLimit = float(m_lowerLinLimit); + sliderData->m_linearUpperLimit = m_upperLinLimit; + sliderData->m_linearLowerLimit = m_lowerLinLimit; - sliderData->m_angularUpperLimit = float(m_upperAngLimit); - sliderData->m_angularLowerLimit = float(m_lowerAngLimit); + sliderData->m_angularUpperLimit = m_upperAngLimit; + sliderData->m_angularLowerLimit = m_lowerAngLimit; sliderData->m_useLinearReferenceFrameA = m_useLinearReferenceFrameA; sliderData->m_useOffsetForConstraintFrame = m_useOffsetForConstraintFrame; - return "btSliderConstraintData"; + return btSliderConstraintDataName; } diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h index ccc45996c8b..27ccefe4169 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h @@ -118,6 +118,8 @@ ATTRIBUTE_ALIGNED16 (struct) btSolverBody btVector3 m_turnVelocity; btVector3 m_linearVelocity; btVector3 m_angularVelocity; + btVector3 m_externalForceImpulse; + btVector3 m_externalTorqueImpulse; btRigidBody* m_originalBody; void setWorldTransform(const btTransform& worldTransform) @@ -130,6 +132,17 @@ ATTRIBUTE_ALIGNED16 (struct) btSolverBody return m_worldTransform; } + + + SIMD_FORCE_INLINE void getVelocityInLocalPointNoDelta(const btVector3& rel_pos, btVector3& velocity ) const + { + if (m_originalBody) + velocity = m_linearVelocity + m_externalForceImpulse + (m_angularVelocity+m_externalTorqueImpulse).cross(rel_pos); + else + velocity.setValue(0,0,0); + } + + SIMD_FORCE_INLINE void getVelocityInLocalPointObsolete(const btVector3& rel_pos, btVector3& velocity ) const { if (m_originalBody) diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h index 2ade61b2f69..5515e6b311c 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h @@ -55,6 +55,7 @@ ATTRIBUTE_ALIGNED16 (struct) btSolverConstraint { void* m_originalContactPoint; btScalar m_unusedPadding4; + int m_numRowsForNonContactConstraint; }; int m_overrideNumSolverIterations; diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp index 465c0746c58..27fdd9d3df8 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp @@ -109,7 +109,7 @@ btScalar btTypedConstraint::getMotorFactor(btScalar pos, btScalar lowLim, btScal ///fills the dataBuffer and returns the struct name (and 0 on failure) const char* btTypedConstraint::serialize(void* dataBuffer, btSerializer* serializer) const { - btTypedConstraintData* tcd = (btTypedConstraintData*) dataBuffer; + btTypedConstraintData2* tcd = (btTypedConstraintData2*) dataBuffer; tcd->m_rbA = (btRigidBodyData*)serializer->getUniquePointer(&m_rbA); tcd->m_rbB = (btRigidBodyData*)serializer->getUniquePointer(&m_rbB); @@ -123,14 +123,14 @@ const char* btTypedConstraint::serialize(void* dataBuffer, btSerializer* seriali tcd->m_objectType = m_objectType; tcd->m_needsFeedback = m_needsFeedback; tcd->m_overrideNumSolverIterations = m_overrideNumSolverIterations; - tcd->m_breakingImpulseThreshold = float(m_breakingImpulseThreshold); + tcd->m_breakingImpulseThreshold = m_breakingImpulseThreshold; tcd->m_isEnabled = m_isEnabled? 1: 0; tcd->m_userConstraintId =m_userConstraintId; tcd->m_userConstraintType =m_userConstraintType; - tcd->m_appliedImpulse = float(m_appliedImpulse); - tcd->m_dbgDrawSize = float(m_dbgDrawSize ); + tcd->m_appliedImpulse = m_appliedImpulse; + tcd->m_dbgDrawSize = m_dbgDrawSize; tcd->m_disableCollisionsBetweenLinkedBodies = false; @@ -142,7 +142,7 @@ const char* btTypedConstraint::serialize(void* dataBuffer, btSerializer* seriali if (m_rbB.getConstraintRef(i) == this) tcd->m_disableCollisionsBetweenLinkedBodies = true; - return "btTypedConstraintData"; + return btTypedConstraintDataName; } btRigidBody& btTypedConstraint::getFixedBody() diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h index 441fa375050..b58f984d0fb 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h @@ -21,6 +21,15 @@ subject to the following restrictions: #include "btSolverConstraint.h" #include "BulletDynamics/Dynamics/btRigidBody.h" +#ifdef BT_USE_DOUBLE_PRECISION +#define btTypedConstraintData2 btTypedConstraintDoubleData +#define btTypedConstraintDataName "btTypedConstraintDoubleData" +#else +#define btTypedConstraintData2 btTypedConstraintFloatData +#define btTypedConstraintDataName "btTypedConstraintFloatData" +#endif //BT_USE_DOUBLE_PRECISION + + class btSerializer; //Don't change any of the existing enum values, so add enum types at the end for serialization compatibility @@ -34,6 +43,7 @@ enum btTypedConstraintType CONTACT_CONSTRAINT_TYPE, D6_SPRING_CONSTRAINT_TYPE, GEAR_CONSTRAINT_TYPE, + FIXED_CONSTRAINT_TYPE, MAX_CONSTRAINT_TYPE }; @@ -356,6 +366,33 @@ SIMD_FORCE_INLINE btScalar btAdjustAngleToLimits(btScalar angleInRadians, btScal } ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 +struct btTypedConstraintFloatData +{ + btRigidBodyFloatData *m_rbA; + btRigidBodyFloatData *m_rbB; + char *m_name; + + int m_objectType; + int m_userConstraintType; + int m_userConstraintId; + int m_needsFeedback; + + float m_appliedImpulse; + float m_dbgDrawSize; + + int m_disableCollisionsBetweenLinkedBodies; + int m_overrideNumSolverIterations; + + float m_breakingImpulseThreshold; + int m_isEnabled; + +}; + +///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 + +#define BT_BACKWARDS_COMPATIBLE_SERIALIZATION +#ifdef BT_BACKWARDS_COMPATIBLE_SERIALIZATION +///this structure is not used, except for loading pre-2.82 .bullet files struct btTypedConstraintData { btRigidBodyData *m_rbA; @@ -377,10 +414,35 @@ struct btTypedConstraintData int m_isEnabled; }; +#endif //BACKWARDS_COMPATIBLE + +struct btTypedConstraintDoubleData +{ + btRigidBodyDoubleData *m_rbA; + btRigidBodyDoubleData *m_rbB; + char *m_name; + + int m_objectType; + int m_userConstraintType; + int m_userConstraintId; + int m_needsFeedback; + + double m_appliedImpulse; + double m_dbgDrawSize; + + int m_disableCollisionsBetweenLinkedBodies; + int m_overrideNumSolverIterations; + + double m_breakingImpulseThreshold; + int m_isEnabled; + char padding[4]; + +}; + SIMD_FORCE_INLINE int btTypedConstraint::calculateSerializeBufferSize() const { - return sizeof(btTypedConstraintData); + return sizeof(btTypedConstraintData2); } diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp index 9ff2d9f1173..fb8a4068e23 100644 --- a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp +++ b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp @@ -87,7 +87,6 @@ struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCal btTypedConstraint** m_sortedConstraints; int m_numConstraints; btIDebugDraw* m_debugDrawer; - btStackAlloc* m_stackAlloc; btDispatcher* m_dispatcher; btAlignedObjectArray m_bodies; @@ -104,7 +103,6 @@ struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCal m_sortedConstraints(NULL), m_numConstraints(0), m_debugDrawer(NULL), - m_stackAlloc(stackAlloc), m_dispatcher(dispatcher) { @@ -135,7 +133,7 @@ struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCal if (islandId<0) { ///we don't split islands, so all constraints/contact manifolds/bodies are passed into the solver regardless the island id - m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,&m_sortedConstraints[0],m_numConstraints,*m_solverInfo,m_debugDrawer,m_stackAlloc,m_dispatcher); + m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,&m_sortedConstraints[0],m_numConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher); } else { //also add all non-contact constraints/joints for this island @@ -163,7 +161,7 @@ struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCal if (m_solverInfo->m_minimumSolverBatchSize<=1) { - m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,startConstraint,numCurConstraints,*m_solverInfo,m_debugDrawer,m_stackAlloc,m_dispatcher); + m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,startConstraint,numCurConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher); } else { @@ -190,7 +188,7 @@ struct InplaceSolverIslandCallback : public btSimulationIslandManager::IslandCal btPersistentManifold** manifold = m_manifolds.size()?&m_manifolds[0]:0; btTypedConstraint** constraints = m_constraints.size()?&m_constraints[0]:0; - m_solver->solveGroup( bodies,m_bodies.size(),manifold, m_manifolds.size(),constraints, m_constraints.size() ,*m_solverInfo,m_debugDrawer,m_stackAlloc,m_dispatcher); + m_solver->solveGroup( bodies,m_bodies.size(),manifold, m_manifolds.size(),constraints, m_constraints.size() ,*m_solverInfo,m_debugDrawer,m_dispatcher); m_bodies.resize(0); m_manifolds.resize(0); m_constraints.resize(0); @@ -210,7 +208,9 @@ m_gravity(0,-10,0), m_localTime(0), m_synchronizeAllMotionStates(false), m_applySpeculativeContactRestitution(false), -m_profileTimings(0) +m_profileTimings(0), +m_fixedTimeStep(0), +m_latencyMotionStateInterpolation(true) { if (!m_constraintSolver) @@ -232,7 +232,7 @@ m_profileTimings(0) { void* mem = btAlignedAlloc(sizeof(InplaceSolverIslandCallback),16); - m_solverIslandCallback = new (mem) InplaceSolverIslandCallback (m_constraintSolver, m_stackAlloc, dispatcher); + m_solverIslandCallback = new (mem) InplaceSolverIslandCallback (m_constraintSolver, 0, dispatcher); } } @@ -359,7 +359,9 @@ void btDiscreteDynamicsWorld::synchronizeSingleMotionState(btRigidBody* body) { btTransform interpolatedTransform; btTransformUtil::integrateTransform(body->getInterpolationWorldTransform(), - body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(),m_localTime*body->getHitFraction(),interpolatedTransform); + body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(), + (m_latencyMotionStateInterpolation && m_fixedTimeStep) ? m_localTime - m_fixedTimeStep : m_localTime*body->getHitFraction(), + interpolatedTransform); body->getMotionState()->setWorldTransform(interpolatedTransform); } } @@ -403,6 +405,7 @@ int btDiscreteDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, if (maxSubSteps) { //fixed timestep with interpolation + m_fixedTimeStep = fixedTimeStep; m_localTime += timeStep; if (m_localTime >= fixedTimeStep) { @@ -413,7 +416,8 @@ int btDiscreteDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, { //variable timestep fixedTimeStep = timeStep; - m_localTime = timeStep; + m_localTime = m_latencyMotionStateInterpolation ? 0 : timeStep; + m_fixedTimeStep = 0; if (btFuzzyZero(timeStep)) { numSimulationSubSteps = 0; @@ -724,7 +728,7 @@ void btDiscreteDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo) m_solverIslandCallback->processConstraints(); - m_constraintSolver->allSolved(solverInfo, m_debugDrawer, m_stackAlloc); + m_constraintSolver->allSolved(solverInfo, m_debugDrawer); } @@ -746,12 +750,7 @@ void btDiscreteDynamicsWorld::calculateSimulationIslands() if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) && ((colObj1) && (!(colObj1)->isStaticOrKinematicObject()))) { - if (colObj0->isActive() || colObj1->isActive()) - { - - getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(), - (colObj1)->getIslandTag()); - } + getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),(colObj1)->getIslandTag()); } } } @@ -770,12 +769,7 @@ void btDiscreteDynamicsWorld::calculateSimulationIslands() if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) && ((colObj1) && (!(colObj1)->isStaticOrKinematicObject()))) { - if (colObj0->isActive() || colObj1->isActive()) - { - - getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(), - (colObj1)->getIslandTag()); - } + getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),(colObj1)->getIslandTag()); } } } @@ -1131,7 +1125,6 @@ void btDiscreteDynamicsWorld::predictUnconstraintMotion(btScalar timeStep) { //don't integrate/update velocities here, it happens in the constraint solver - //damping body->applyDamping(timeStep); body->predictIntegratedTransform(timeStep,body->getInterpolationWorldTransform()); diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h index fa934c49d2b..d8a34b7da3d 100644 --- a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h +++ b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h @@ -53,6 +53,7 @@ protected: //for variable timesteps btScalar m_localTime; + btScalar m_fixedTimeStep; //for variable timesteps bool m_ownsIslandManager; @@ -64,6 +65,8 @@ protected: int m_profileTimings; + bool m_latencyMotionStateInterpolation; + btAlignedObjectArray m_predictiveManifolds; virtual void predictUnconstraintMotion(btScalar timeStep); @@ -74,7 +77,7 @@ protected: virtual void solveConstraints(btContactSolverInfo& solverInfo); - void updateActivationState(btScalar timeStep); + virtual void updateActivationState(btScalar timeStep); void updateActions(btScalar timeStep); @@ -216,6 +219,16 @@ public: ///Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (see Bullet/Demos/SerializeDemo) virtual void serialize(btSerializer* serializer); + ///Interpolate motion state between previous and current transform, instead of current and next transform. + ///This can relieve discontinuities in the rendering, due to penetrations + void setLatencyMotionStateInterpolation(bool latencyInterpolation ) + { + m_latencyMotionStateInterpolation = latencyInterpolation; + } + bool getLatencyMotionStateInterpolation() const + { + return m_latencyMotionStateInterpolation; + } }; #endif //BT_DISCRETE_DYNAMICS_WORLD_H diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h b/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h index 7d5c621f850..35dd1400fe7 100644 --- a/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h +++ b/extern/bullet2/src/BulletDynamics/Dynamics/btDynamicsWorld.h @@ -33,7 +33,8 @@ enum btDynamicsWorldType BT_SIMPLE_DYNAMICS_WORLD=1, BT_DISCRETE_DYNAMICS_WORLD=2, BT_CONTINUOUS_DYNAMICS_WORLD=3, - BT_SOFT_RIGID_DYNAMICS_WORLD=4 + BT_SOFT_RIGID_DYNAMICS_WORLD=4, + BT_GPU_DYNAMICS_WORLD=5 }; ///The btDynamicsWorld is the interface class for several dynamics implementation, basic, discrete, parallel, and continuous etc. diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h b/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h index f0e07f942af..ed90fb44115 100644 --- a/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h +++ b/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h @@ -363,11 +363,13 @@ public: inline void setLinearVelocity(const btVector3& lin_vel) { + m_updateRevision++; m_linearVelocity = lin_vel; } inline void setAngularVelocity(const btVector3& ang_vel) { + m_updateRevision++; m_angularVelocity = ang_vel; } @@ -484,11 +486,13 @@ public: void setAngularFactor(const btVector3& angFac) { + m_updateRevision++; m_angularFactor = angFac; } void setAngularFactor(btScalar angFac) { + m_updateRevision++; m_angularFactor.setValue(angFac,angFac,angFac); } const btVector3& getAngularFactor() const diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp b/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp index 5fc2f3cf8f7..35dd38840f6 100644 --- a/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp +++ b/extern/bullet2/src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp @@ -78,8 +78,8 @@ int btSimpleDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, b btContactSolverInfo infoGlobal; infoGlobal.m_timeStep = timeStep; m_constraintSolver->prepareSolve(0,numManifolds); - m_constraintSolver->solveGroup(&getCollisionObjectArray()[0],getNumCollisionObjects(),manifoldPtr, numManifolds,0,0,infoGlobal,m_debugDrawer, m_stackAlloc,m_dispatcher1); - m_constraintSolver->allSolved(infoGlobal,m_debugDrawer, m_stackAlloc); + m_constraintSolver->solveGroup(&getCollisionObjectArray()[0],getNumCollisionObjects(),manifoldPtr, numManifolds,0,0,infoGlobal,m_debugDrawer, m_dispatcher1); + m_constraintSolver->allSolved(infoGlobal,m_debugDrawer); } ///integrate transforms diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp new file mode 100644 index 00000000000..56a1c55d9ae --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp @@ -0,0 +1,1009 @@ +/* + * PURPOSE: + * Class representing an articulated rigid body. Stores the body's + * current state, allows forces and torques to be set, handles + * timestepping and implements Featherstone's algorithm. + * + * COPYRIGHT: + * Copyright (C) Stephen Thompson, , 2011-2013 + * Portions written By Erwin Coumans: replacing Eigen math library by Bullet LinearMath and a dedicated 6x6 matrix inverse (solveImatrix) + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the use of this software. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it freely, + subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + */ + + +#include "btMultiBody.h" +#include "btMultiBodyLink.h" +#include "btMultiBodyLinkCollider.h" + +// #define INCLUDE_GYRO_TERM + +namespace { + const btScalar SLEEP_EPSILON = btScalar(0.05); // this is a squared velocity (m^2 s^-2) + const btScalar SLEEP_TIMEOUT = btScalar(2); // in seconds +} + + + + +// +// Various spatial helper functions +// + +namespace { + void SpatialTransform(const btMatrix3x3 &rotation_matrix, // rotates vectors in 'from' frame to vectors in 'to' frame + const btVector3 &displacement, // vector from origin of 'from' frame to origin of 'to' frame, in 'to' coordinates + const btVector3 &top_in, // top part of input vector + const btVector3 &bottom_in, // bottom part of input vector + btVector3 &top_out, // top part of output vector + btVector3 &bottom_out) // bottom part of output vector + { + top_out = rotation_matrix * top_in; + bottom_out = -displacement.cross(top_out) + rotation_matrix * bottom_in; + } + + void InverseSpatialTransform(const btMatrix3x3 &rotation_matrix, + const btVector3 &displacement, + const btVector3 &top_in, + const btVector3 &bottom_in, + btVector3 &top_out, + btVector3 &bottom_out) + { + top_out = rotation_matrix.transpose() * top_in; + bottom_out = rotation_matrix.transpose() * (bottom_in + displacement.cross(top_in)); + } + + btScalar SpatialDotProduct(const btVector3 &a_top, + const btVector3 &a_bottom, + const btVector3 &b_top, + const btVector3 &b_bottom) + { + return a_bottom.dot(b_top) + a_top.dot(b_bottom); + } +} + + +// +// Implementation of class btMultiBody +// + +btMultiBody::btMultiBody(int n_links, + btScalar mass, + const btVector3 &inertia, + bool fixed_base_, + bool can_sleep_) + : base_quat(0, 0, 0, 1), + base_mass(mass), + base_inertia(inertia), + + fixed_base(fixed_base_), + awake(true), + can_sleep(can_sleep_), + sleep_timer(0), + m_baseCollider(0), + m_linearDamping(0.04f), + m_angularDamping(0.04f), + m_useGyroTerm(true), + m_maxAppliedImpulse(1000.f), + m_hasSelfCollision(true) +{ + links.resize(n_links); + + vector_buf.resize(2*n_links); + matrix_buf.resize(n_links + 1); + m_real_buf.resize(6 + 2*n_links); + base_pos.setValue(0, 0, 0); + base_force.setValue(0, 0, 0); + base_torque.setValue(0, 0, 0); +} + +btMultiBody::~btMultiBody() +{ +} + +void btMultiBody::setupPrismatic(int i, + btScalar mass, + const btVector3 &inertia, + int parent, + const btQuaternion &rot_parent_to_this, + const btVector3 &joint_axis, + const btVector3 &r_vector_when_q_zero, + bool disableParentCollision) +{ + links[i].mass = mass; + links[i].inertia = inertia; + links[i].parent = parent; + links[i].zero_rot_parent_to_this = rot_parent_to_this; + links[i].axis_top.setValue(0,0,0); + links[i].axis_bottom = joint_axis; + links[i].e_vector = r_vector_when_q_zero; + links[i].is_revolute = false; + links[i].cached_rot_parent_to_this = rot_parent_to_this; + if (disableParentCollision) + links[i].m_flags |=BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION; + + links[i].updateCache(); +} + +void btMultiBody::setupRevolute(int i, + btScalar mass, + const btVector3 &inertia, + int parent, + const btQuaternion &zero_rot_parent_to_this, + const btVector3 &joint_axis, + const btVector3 &parent_axis_position, + const btVector3 &my_axis_position, + bool disableParentCollision) +{ + links[i].mass = mass; + links[i].inertia = inertia; + links[i].parent = parent; + links[i].zero_rot_parent_to_this = zero_rot_parent_to_this; + links[i].axis_top = joint_axis; + links[i].axis_bottom = joint_axis.cross(my_axis_position); + links[i].d_vector = my_axis_position; + links[i].e_vector = parent_axis_position; + links[i].is_revolute = true; + if (disableParentCollision) + links[i].m_flags |=BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION; + links[i].updateCache(); +} + + + + + +int btMultiBody::getParent(int i) const +{ + return links[i].parent; +} + +btScalar btMultiBody::getLinkMass(int i) const +{ + return links[i].mass; +} + +const btVector3 & btMultiBody::getLinkInertia(int i) const +{ + return links[i].inertia; +} + +btScalar btMultiBody::getJointPos(int i) const +{ + return links[i].joint_pos; +} + +btScalar btMultiBody::getJointVel(int i) const +{ + return m_real_buf[6 + i]; +} + +void btMultiBody::setJointPos(int i, btScalar q) +{ + links[i].joint_pos = q; + links[i].updateCache(); +} + +void btMultiBody::setJointVel(int i, btScalar qdot) +{ + m_real_buf[6 + i] = qdot; +} + +const btVector3 & btMultiBody::getRVector(int i) const +{ + return links[i].cached_r_vector; +} + +const btQuaternion & btMultiBody::getParentToLocalRot(int i) const +{ + return links[i].cached_rot_parent_to_this; +} + +btVector3 btMultiBody::localPosToWorld(int i, const btVector3 &local_pos) const +{ + btVector3 result = local_pos; + while (i != -1) { + // 'result' is in frame i. transform it to frame parent(i) + result += getRVector(i); + result = quatRotate(getParentToLocalRot(i).inverse(),result); + i = getParent(i); + } + + // 'result' is now in the base frame. transform it to world frame + result = quatRotate(getWorldToBaseRot().inverse() ,result); + result += getBasePos(); + + return result; +} + +btVector3 btMultiBody::worldPosToLocal(int i, const btVector3 &world_pos) const +{ + if (i == -1) { + // world to base + return quatRotate(getWorldToBaseRot(),(world_pos - getBasePos())); + } else { + // find position in parent frame, then transform to current frame + return quatRotate(getParentToLocalRot(i),worldPosToLocal(getParent(i), world_pos)) - getRVector(i); + } +} + +btVector3 btMultiBody::localDirToWorld(int i, const btVector3 &local_dir) const +{ + btVector3 result = local_dir; + while (i != -1) { + result = quatRotate(getParentToLocalRot(i).inverse() , result); + i = getParent(i); + } + result = quatRotate(getWorldToBaseRot().inverse() , result); + return result; +} + +btVector3 btMultiBody::worldDirToLocal(int i, const btVector3 &world_dir) const +{ + if (i == -1) { + return quatRotate(getWorldToBaseRot(), world_dir); + } else { + return quatRotate(getParentToLocalRot(i) ,worldDirToLocal(getParent(i), world_dir)); + } +} + +void btMultiBody::compTreeLinkVelocities(btVector3 *omega, btVector3 *vel) const +{ + int num_links = getNumLinks(); + // Calculates the velocities of each link (and the base) in its local frame + omega[0] = quatRotate(base_quat ,getBaseOmega()); + vel[0] = quatRotate(base_quat ,getBaseVel()); + + for (int i = 0; i < num_links; ++i) { + const int parent = links[i].parent; + + // transform parent vel into this frame, store in omega[i+1], vel[i+1] + SpatialTransform(btMatrix3x3(links[i].cached_rot_parent_to_this), links[i].cached_r_vector, + omega[parent+1], vel[parent+1], + omega[i+1], vel[i+1]); + + // now add qidot * shat_i + omega[i+1] += getJointVel(i) * links[i].axis_top; + vel[i+1] += getJointVel(i) * links[i].axis_bottom; + } +} + +btScalar btMultiBody::getKineticEnergy() const +{ + int num_links = getNumLinks(); + // TODO: would be better not to allocate memory here + btAlignedObjectArray omega;omega.resize(num_links+1); + btAlignedObjectArray vel;vel.resize(num_links+1); + compTreeLinkVelocities(&omega[0], &vel[0]); + + // we will do the factor of 0.5 at the end + btScalar result = base_mass * vel[0].dot(vel[0]); + result += omega[0].dot(base_inertia * omega[0]); + + for (int i = 0; i < num_links; ++i) { + result += links[i].mass * vel[i+1].dot(vel[i+1]); + result += omega[i+1].dot(links[i].inertia * omega[i+1]); + } + + return 0.5f * result; +} + +btVector3 btMultiBody::getAngularMomentum() const +{ + int num_links = getNumLinks(); + // TODO: would be better not to allocate memory here + btAlignedObjectArray omega;omega.resize(num_links+1); + btAlignedObjectArray vel;vel.resize(num_links+1); + btAlignedObjectArray rot_from_world;rot_from_world.resize(num_links+1); + compTreeLinkVelocities(&omega[0], &vel[0]); + + rot_from_world[0] = base_quat; + btVector3 result = quatRotate(rot_from_world[0].inverse() , (base_inertia * omega[0])); + + for (int i = 0; i < num_links; ++i) { + rot_from_world[i+1] = links[i].cached_rot_parent_to_this * rot_from_world[links[i].parent+1]; + result += (quatRotate(rot_from_world[i+1].inverse() , (links[i].inertia * omega[i+1]))); + } + + return result; +} + + +void btMultiBody::clearForcesAndTorques() +{ + base_force.setValue(0, 0, 0); + base_torque.setValue(0, 0, 0); + + for (int i = 0; i < getNumLinks(); ++i) { + links[i].applied_force.setValue(0, 0, 0); + links[i].applied_torque.setValue(0, 0, 0); + links[i].joint_torque = 0; + } +} + +void btMultiBody::clearVelocities() +{ + for (int i = 0; i < 6 + getNumLinks(); ++i) + { + m_real_buf[i] = 0.f; + } +} +void btMultiBody::addLinkForce(int i, const btVector3 &f) +{ + links[i].applied_force += f; +} + +void btMultiBody::addLinkTorque(int i, const btVector3 &t) +{ + links[i].applied_torque += t; +} + +void btMultiBody::addJointTorque(int i, btScalar Q) +{ + links[i].joint_torque += Q; +} + +const btVector3 & btMultiBody::getLinkForce(int i) const +{ + return links[i].applied_force; +} + +const btVector3 & btMultiBody::getLinkTorque(int i) const +{ + return links[i].applied_torque; +} + +btScalar btMultiBody::getJointTorque(int i) const +{ + return links[i].joint_torque; +} + + +inline btMatrix3x3 vecMulVecTranspose(const btVector3& v0, const btVector3& v1Transposed) +{ + btVector3 row0 = btVector3( + v0.x() * v1Transposed.x(), + v0.x() * v1Transposed.y(), + v0.x() * v1Transposed.z()); + btVector3 row1 = btVector3( + v0.y() * v1Transposed.x(), + v0.y() * v1Transposed.y(), + v0.y() * v1Transposed.z()); + btVector3 row2 = btVector3( + v0.z() * v1Transposed.x(), + v0.z() * v1Transposed.y(), + v0.z() * v1Transposed.z()); + + btMatrix3x3 m(row0[0],row0[1],row0[2], + row1[0],row1[1],row1[2], + row2[0],row2[1],row2[2]); + return m; +} + + +void btMultiBody::stepVelocities(btScalar dt, + btAlignedObjectArray &scratch_r, + btAlignedObjectArray &scratch_v, + btAlignedObjectArray &scratch_m) +{ + // Implement Featherstone's algorithm to calculate joint accelerations (q_double_dot) + // and the base linear & angular accelerations. + + // We apply damping forces in this routine as well as any external forces specified by the + // caller (via addBaseForce etc). + + // output should point to an array of 6 + num_links reals. + // Format is: 3 angular accelerations (in world frame), 3 linear accelerations (in world frame), + // num_links joint acceleration values. + + int num_links = getNumLinks(); + + const btScalar DAMPING_K1_LINEAR = m_linearDamping; + const btScalar DAMPING_K2_LINEAR = m_linearDamping; + + const btScalar DAMPING_K1_ANGULAR = m_angularDamping; + const btScalar DAMPING_K2_ANGULAR= m_angularDamping; + + btVector3 base_vel = getBaseVel(); + btVector3 base_omega = getBaseOmega(); + + // Temporary matrices/vectors -- use scratch space from caller + // so that we don't have to keep reallocating every frame + + scratch_r.resize(2*num_links + 6); + scratch_v.resize(8*num_links + 6); + scratch_m.resize(4*num_links + 4); + + btScalar * r_ptr = &scratch_r[0]; + btScalar * output = &scratch_r[num_links]; // "output" holds the q_double_dot results + btVector3 * v_ptr = &scratch_v[0]; + + // vhat_i (top = angular, bottom = linear part) + btVector3 * vel_top_angular = v_ptr; v_ptr += num_links + 1; + btVector3 * vel_bottom_linear = v_ptr; v_ptr += num_links + 1; + + // zhat_i^A + btVector3 * zero_acc_top_angular = v_ptr; v_ptr += num_links + 1; + btVector3 * zero_acc_bottom_linear = v_ptr; v_ptr += num_links + 1; + + // chat_i (note NOT defined for the base) + btVector3 * coriolis_top_angular = v_ptr; v_ptr += num_links; + btVector3 * coriolis_bottom_linear = v_ptr; v_ptr += num_links; + + // top left, top right and bottom left blocks of Ihat_i^A. + // bottom right block = transpose of top left block and is not stored. + // Note: the top right and bottom left blocks are always symmetric matrices, but we don't make use of this fact currently. + btMatrix3x3 * inertia_top_left = &scratch_m[num_links + 1]; + btMatrix3x3 * inertia_top_right = &scratch_m[2*num_links + 2]; + btMatrix3x3 * inertia_bottom_left = &scratch_m[3*num_links + 3]; + + // Cached 3x3 rotation matrices from parent frame to this frame. + btMatrix3x3 * rot_from_parent = &matrix_buf[0]; + btMatrix3x3 * rot_from_world = &scratch_m[0]; + + // hhat_i, ahat_i + // hhat is NOT stored for the base (but ahat is) + btVector3 * h_top = num_links > 0 ? &vector_buf[0] : 0; + btVector3 * h_bottom = num_links > 0 ? &vector_buf[num_links] : 0; + btVector3 * accel_top = v_ptr; v_ptr += num_links + 1; + btVector3 * accel_bottom = v_ptr; v_ptr += num_links + 1; + + // Y_i, D_i + btScalar * Y = r_ptr; r_ptr += num_links; + btScalar * D = num_links > 0 ? &m_real_buf[6 + num_links] : 0; + + // ptr to the joint accel part of the output + btScalar * joint_accel = output + 6; + + + // Start of the algorithm proper. + + // First 'upward' loop. + // Combines CompTreeLinkVelocities and InitTreeLinks from Mirtich. + + rot_from_parent[0] = btMatrix3x3(base_quat); + + vel_top_angular[0] = rot_from_parent[0] * base_omega; + vel_bottom_linear[0] = rot_from_parent[0] * base_vel; + + if (fixed_base) { + zero_acc_top_angular[0] = zero_acc_bottom_linear[0] = btVector3(0,0,0); + } else { + zero_acc_top_angular[0] = - (rot_from_parent[0] * (base_force + - base_mass*(DAMPING_K1_LINEAR+DAMPING_K2_LINEAR*base_vel.norm())*base_vel)); + + zero_acc_bottom_linear[0] = + - (rot_from_parent[0] * base_torque); + + if (m_useGyroTerm) + zero_acc_bottom_linear[0]+=vel_top_angular[0].cross( base_inertia * vel_top_angular[0] ); + + zero_acc_bottom_linear[0] += base_inertia * vel_top_angular[0] * (DAMPING_K1_ANGULAR + DAMPING_K2_ANGULAR*vel_top_angular[0].norm()); + + } + + + + inertia_top_left[0] = btMatrix3x3(0,0,0,0,0,0,0,0,0);//::Zero(); + + + inertia_top_right[0].setValue(base_mass, 0, 0, + 0, base_mass, 0, + 0, 0, base_mass); + inertia_bottom_left[0].setValue(base_inertia[0], 0, 0, + 0, base_inertia[1], 0, + 0, 0, base_inertia[2]); + + rot_from_world[0] = rot_from_parent[0]; + + for (int i = 0; i < num_links; ++i) { + const int parent = links[i].parent; + rot_from_parent[i+1] = btMatrix3x3(links[i].cached_rot_parent_to_this); + + + rot_from_world[i+1] = rot_from_parent[i+1] * rot_from_world[parent+1]; + + // vhat_i = i_xhat_p(i) * vhat_p(i) + SpatialTransform(rot_from_parent[i+1], links[i].cached_r_vector, + vel_top_angular[parent+1], vel_bottom_linear[parent+1], + vel_top_angular[i+1], vel_bottom_linear[i+1]); + + // we can now calculate chat_i + // remember vhat_i is really vhat_p(i) (but in current frame) at this point + coriolis_bottom_linear[i] = vel_top_angular[i+1].cross(vel_top_angular[i+1].cross(links[i].cached_r_vector)) + + 2 * vel_top_angular[i+1].cross(links[i].axis_bottom) * getJointVel(i); + if (links[i].is_revolute) { + coriolis_top_angular[i] = vel_top_angular[i+1].cross(links[i].axis_top) * getJointVel(i); + coriolis_bottom_linear[i] += (getJointVel(i) * getJointVel(i)) * links[i].axis_top.cross(links[i].axis_bottom); + } else { + coriolis_top_angular[i] = btVector3(0,0,0); + } + + // now set vhat_i to its true value by doing + // vhat_i += qidot * shat_i + vel_top_angular[i+1] += getJointVel(i) * links[i].axis_top; + vel_bottom_linear[i+1] += getJointVel(i) * links[i].axis_bottom; + + // calculate zhat_i^A + zero_acc_top_angular[i+1] = - (rot_from_world[i+1] * (links[i].applied_force)); + zero_acc_top_angular[i+1] += links[i].mass * (DAMPING_K1_LINEAR + DAMPING_K2_LINEAR*vel_bottom_linear[i+1].norm()) * vel_bottom_linear[i+1]; + + zero_acc_bottom_linear[i+1] = + - (rot_from_world[i+1] * links[i].applied_torque); + if (m_useGyroTerm) + { + zero_acc_bottom_linear[i+1] += vel_top_angular[i+1].cross( links[i].inertia * vel_top_angular[i+1] ); + } + + zero_acc_bottom_linear[i+1] += links[i].inertia * vel_top_angular[i+1] * (DAMPING_K1_ANGULAR + DAMPING_K2_ANGULAR*vel_top_angular[i+1].norm()); + + // calculate Ihat_i^A + inertia_top_left[i+1] = btMatrix3x3(0,0,0,0,0,0,0,0,0);//::Zero(); + inertia_top_right[i+1].setValue(links[i].mass, 0, 0, + 0, links[i].mass, 0, + 0, 0, links[i].mass); + inertia_bottom_left[i+1].setValue(links[i].inertia[0], 0, 0, + 0, links[i].inertia[1], 0, + 0, 0, links[i].inertia[2]); + } + + + // 'Downward' loop. + // (part of TreeForwardDynamics in Mirtich.) + for (int i = num_links - 1; i >= 0; --i) { + + h_top[i] = inertia_top_left[i+1] * links[i].axis_top + inertia_top_right[i+1] * links[i].axis_bottom; + h_bottom[i] = inertia_bottom_left[i+1] * links[i].axis_top + inertia_top_left[i+1].transpose() * links[i].axis_bottom; + btScalar val = SpatialDotProduct(links[i].axis_top, links[i].axis_bottom, h_top[i], h_bottom[i]); + D[i] = val; + Y[i] = links[i].joint_torque + - SpatialDotProduct(links[i].axis_top, links[i].axis_bottom, zero_acc_top_angular[i+1], zero_acc_bottom_linear[i+1]) + - SpatialDotProduct(h_top[i], h_bottom[i], coriolis_top_angular[i], coriolis_bottom_linear[i]); + + const int parent = links[i].parent; + + + // Ip += pXi * (Ii - hi hi' / Di) * iXp + const btScalar one_over_di = 1.0f / D[i]; + + + + + const btMatrix3x3 TL = inertia_top_left[i+1] - vecMulVecTranspose(one_over_di * h_top[i] , h_bottom[i]); + const btMatrix3x3 TR = inertia_top_right[i+1] - vecMulVecTranspose(one_over_di * h_top[i] , h_top[i]); + const btMatrix3x3 BL = inertia_bottom_left[i+1]- vecMulVecTranspose(one_over_di * h_bottom[i] , h_bottom[i]); + + + btMatrix3x3 r_cross; + r_cross.setValue( + 0, -links[i].cached_r_vector[2], links[i].cached_r_vector[1], + links[i].cached_r_vector[2], 0, -links[i].cached_r_vector[0], + -links[i].cached_r_vector[1], links[i].cached_r_vector[0], 0); + + inertia_top_left[parent+1] += rot_from_parent[i+1].transpose() * ( TL - TR * r_cross ) * rot_from_parent[i+1]; + inertia_top_right[parent+1] += rot_from_parent[i+1].transpose() * TR * rot_from_parent[i+1]; + inertia_bottom_left[parent+1] += rot_from_parent[i+1].transpose() * + (r_cross * (TL - TR * r_cross) + BL - TL.transpose() * r_cross) * rot_from_parent[i+1]; + + + // Zp += pXi * (Zi + Ii*ci + hi*Yi/Di) + btVector3 in_top, in_bottom, out_top, out_bottom; + const btScalar Y_over_D = Y[i] * one_over_di; + in_top = zero_acc_top_angular[i+1] + + inertia_top_left[i+1] * coriolis_top_angular[i] + + inertia_top_right[i+1] * coriolis_bottom_linear[i] + + Y_over_D * h_top[i]; + in_bottom = zero_acc_bottom_linear[i+1] + + inertia_bottom_left[i+1] * coriolis_top_angular[i] + + inertia_top_left[i+1].transpose() * coriolis_bottom_linear[i] + + Y_over_D * h_bottom[i]; + InverseSpatialTransform(rot_from_parent[i+1], links[i].cached_r_vector, + in_top, in_bottom, out_top, out_bottom); + zero_acc_top_angular[parent+1] += out_top; + zero_acc_bottom_linear[parent+1] += out_bottom; + } + + + // Second 'upward' loop + // (part of TreeForwardDynamics in Mirtich) + + if (fixed_base) + { + accel_top[0] = accel_bottom[0] = btVector3(0,0,0); + } + else + { + if (num_links > 0) + { + //Matrix Imatrix; + //Imatrix.block<3,3>(0,0) = inertia_top_left[0]; + //Imatrix.block<3,3>(3,0) = inertia_bottom_left[0]; + //Imatrix.block<3,3>(0,3) = inertia_top_right[0]; + //Imatrix.block<3,3>(3,3) = inertia_top_left[0].transpose(); + //cached_imatrix_lu.reset(new Eigen::LU >(Imatrix)); // TODO: Avoid memory allocation here? + + cached_inertia_top_left = inertia_top_left[0]; + cached_inertia_top_right = inertia_top_right[0]; + cached_inertia_lower_left = inertia_bottom_left[0]; + cached_inertia_lower_right= inertia_top_left[0].transpose(); + + } + btVector3 rhs_top (zero_acc_top_angular[0][0], zero_acc_top_angular[0][1], zero_acc_top_angular[0][2]); + btVector3 rhs_bot (zero_acc_bottom_linear[0][0], zero_acc_bottom_linear[0][1], zero_acc_bottom_linear[0][2]); + float result[6]; + + solveImatrix(rhs_top, rhs_bot, result); +// printf("result=%f,%f,%f,%f,%f,%f\n",result[0],result[0],result[0],result[0],result[0],result[0]); + for (int i = 0; i < 3; ++i) { + accel_top[0][i] = -result[i]; + accel_bottom[0][i] = -result[i+3]; + } + + } + + // now do the loop over the links + for (int i = 0; i < num_links; ++i) { + const int parent = links[i].parent; + SpatialTransform(rot_from_parent[i+1], links[i].cached_r_vector, + accel_top[parent+1], accel_bottom[parent+1], + accel_top[i+1], accel_bottom[i+1]); + joint_accel[i] = (Y[i] - SpatialDotProduct(h_top[i], h_bottom[i], accel_top[i+1], accel_bottom[i+1])) / D[i]; + accel_top[i+1] += coriolis_top_angular[i] + joint_accel[i] * links[i].axis_top; + accel_bottom[i+1] += coriolis_bottom_linear[i] + joint_accel[i] * links[i].axis_bottom; + } + + // transform base accelerations back to the world frame. + btVector3 omegadot_out = rot_from_parent[0].transpose() * accel_top[0]; + output[0] = omegadot_out[0]; + output[1] = omegadot_out[1]; + output[2] = omegadot_out[2]; + + btVector3 vdot_out = rot_from_parent[0].transpose() * accel_bottom[0]; + output[3] = vdot_out[0]; + output[4] = vdot_out[1]; + output[5] = vdot_out[2]; + // Final step: add the accelerations (times dt) to the velocities. + applyDeltaVee(output, dt); + + +} + + + +void btMultiBody::solveImatrix(const btVector3& rhs_top, const btVector3& rhs_bot, float result[6]) const +{ + int num_links = getNumLinks(); + ///solve I * x = rhs, so the result = invI * rhs + if (num_links == 0) + { + // in the case of 0 links (i.e. a plain rigid body, not a multibody) rhs * invI is easier + result[0] = rhs_bot[0] / base_inertia[0]; + result[1] = rhs_bot[1] / base_inertia[1]; + result[2] = rhs_bot[2] / base_inertia[2]; + result[3] = rhs_top[0] / base_mass; + result[4] = rhs_top[1] / base_mass; + result[5] = rhs_top[2] / base_mass; + } else + { + /// Special routine for calculating the inverse of a spatial inertia matrix + ///the 6x6 matrix is stored as 4 blocks of 3x3 matrices + btMatrix3x3 Binv = cached_inertia_top_right.inverse()*-1.f; + btMatrix3x3 tmp = cached_inertia_lower_right * Binv; + btMatrix3x3 invIupper_right = (tmp * cached_inertia_top_left + cached_inertia_lower_left).inverse(); + tmp = invIupper_right * cached_inertia_lower_right; + btMatrix3x3 invI_upper_left = (tmp * Binv); + btMatrix3x3 invI_lower_right = (invI_upper_left).transpose(); + tmp = cached_inertia_top_left * invI_upper_left; + tmp[0][0]-= 1.0; + tmp[1][1]-= 1.0; + tmp[2][2]-= 1.0; + btMatrix3x3 invI_lower_left = (Binv * tmp); + + //multiply result = invI * rhs + { + btVector3 vtop = invI_upper_left*rhs_top; + btVector3 tmp; + tmp = invIupper_right * rhs_bot; + vtop += tmp; + btVector3 vbot = invI_lower_left*rhs_top; + tmp = invI_lower_right * rhs_bot; + vbot += tmp; + result[0] = vtop[0]; + result[1] = vtop[1]; + result[2] = vtop[2]; + result[3] = vbot[0]; + result[4] = vbot[1]; + result[5] = vbot[2]; + } + + } +} + + +void btMultiBody::calcAccelerationDeltas(const btScalar *force, btScalar *output, + btAlignedObjectArray &scratch_r, btAlignedObjectArray &scratch_v) const +{ + // Temporary matrices/vectors -- use scratch space from caller + // so that we don't have to keep reallocating every frame + int num_links = getNumLinks(); + scratch_r.resize(num_links); + scratch_v.resize(4*num_links + 4); + + btScalar * r_ptr = num_links == 0 ? 0 : &scratch_r[0]; + btVector3 * v_ptr = &scratch_v[0]; + + // zhat_i^A (scratch space) + btVector3 * zero_acc_top_angular = v_ptr; v_ptr += num_links + 1; + btVector3 * zero_acc_bottom_linear = v_ptr; v_ptr += num_links + 1; + + // rot_from_parent (cached from calcAccelerations) + const btMatrix3x3 * rot_from_parent = &matrix_buf[0]; + + // hhat (cached), accel (scratch) + const btVector3 * h_top = num_links > 0 ? &vector_buf[0] : 0; + const btVector3 * h_bottom = num_links > 0 ? &vector_buf[num_links] : 0; + btVector3 * accel_top = v_ptr; v_ptr += num_links + 1; + btVector3 * accel_bottom = v_ptr; v_ptr += num_links + 1; + + // Y_i (scratch), D_i (cached) + btScalar * Y = r_ptr; r_ptr += num_links; + const btScalar * D = num_links > 0 ? &m_real_buf[6 + num_links] : 0; + + btAssert(num_links == 0 || r_ptr - &scratch_r[0] == scratch_r.size()); + btAssert(v_ptr - &scratch_v[0] == scratch_v.size()); + + + + // First 'upward' loop. + // Combines CompTreeLinkVelocities and InitTreeLinks from Mirtich. + + btVector3 input_force(force[3],force[4],force[5]); + btVector3 input_torque(force[0],force[1],force[2]); + + // Fill in zero_acc + // -- set to force/torque on the base, zero otherwise + if (fixed_base) + { + zero_acc_top_angular[0] = zero_acc_bottom_linear[0] = btVector3(0,0,0); + } else + { + zero_acc_top_angular[0] = - (rot_from_parent[0] * input_force); + zero_acc_bottom_linear[0] = - (rot_from_parent[0] * input_torque); + } + for (int i = 0; i < num_links; ++i) + { + zero_acc_top_angular[i+1] = zero_acc_bottom_linear[i+1] = btVector3(0,0,0); + } + + // 'Downward' loop. + for (int i = num_links - 1; i >= 0; --i) + { + + Y[i] = - SpatialDotProduct(links[i].axis_top, links[i].axis_bottom, zero_acc_top_angular[i+1], zero_acc_bottom_linear[i+1]); + Y[i] += force[6 + i]; // add joint torque + + const int parent = links[i].parent; + + // Zp += pXi * (Zi + hi*Yi/Di) + btVector3 in_top, in_bottom, out_top, out_bottom; + const btScalar Y_over_D = Y[i] / D[i]; + in_top = zero_acc_top_angular[i+1] + Y_over_D * h_top[i]; + in_bottom = zero_acc_bottom_linear[i+1] + Y_over_D * h_bottom[i]; + InverseSpatialTransform(rot_from_parent[i+1], links[i].cached_r_vector, + in_top, in_bottom, out_top, out_bottom); + zero_acc_top_angular[parent+1] += out_top; + zero_acc_bottom_linear[parent+1] += out_bottom; + } + + // ptr to the joint accel part of the output + btScalar * joint_accel = output + 6; + + // Second 'upward' loop + if (fixed_base) + { + accel_top[0] = accel_bottom[0] = btVector3(0,0,0); + } else + { + btVector3 rhs_top (zero_acc_top_angular[0][0], zero_acc_top_angular[0][1], zero_acc_top_angular[0][2]); + btVector3 rhs_bot (zero_acc_bottom_linear[0][0], zero_acc_bottom_linear[0][1], zero_acc_bottom_linear[0][2]); + + float result[6]; + solveImatrix(rhs_top,rhs_bot, result); + // printf("result=%f,%f,%f,%f,%f,%f\n",result[0],result[0],result[0],result[0],result[0],result[0]); + + for (int i = 0; i < 3; ++i) { + accel_top[0][i] = -result[i]; + accel_bottom[0][i] = -result[i+3]; + } + + } + + // now do the loop over the links + for (int i = 0; i < num_links; ++i) { + const int parent = links[i].parent; + SpatialTransform(rot_from_parent[i+1], links[i].cached_r_vector, + accel_top[parent+1], accel_bottom[parent+1], + accel_top[i+1], accel_bottom[i+1]); + joint_accel[i] = (Y[i] - SpatialDotProduct(h_top[i], h_bottom[i], accel_top[i+1], accel_bottom[i+1])) / D[i]; + accel_top[i+1] += joint_accel[i] * links[i].axis_top; + accel_bottom[i+1] += joint_accel[i] * links[i].axis_bottom; + } + + // transform base accelerations back to the world frame. + btVector3 omegadot_out; + omegadot_out = rot_from_parent[0].transpose() * accel_top[0]; + output[0] = omegadot_out[0]; + output[1] = omegadot_out[1]; + output[2] = omegadot_out[2]; + + btVector3 vdot_out; + vdot_out = rot_from_parent[0].transpose() * accel_bottom[0]; + + output[3] = vdot_out[0]; + output[4] = vdot_out[1]; + output[5] = vdot_out[2]; +} + +void btMultiBody::stepPositions(btScalar dt) +{ + int num_links = getNumLinks(); + // step position by adding dt * velocity + btVector3 v = getBaseVel(); + base_pos += dt * v; + + // "exponential map" method for the rotation + btVector3 base_omega = getBaseOmega(); + const btScalar omega_norm = base_omega.norm(); + const btScalar omega_times_dt = omega_norm * dt; + const btScalar SMALL_ROTATION_ANGLE = 0.02f; // Theoretically this should be ~ pow(FLT_EPSILON,0.25) which is ~ 0.0156 + if (fabs(omega_times_dt) < SMALL_ROTATION_ANGLE) + { + const btScalar xsq = omega_times_dt * omega_times_dt; // |omega|^2 * dt^2 + const btScalar sin_term = dt * (xsq / 48.0f - 0.5f); // -sin(0.5*dt*|omega|) / |omega| + const btScalar cos_term = 1.0f - xsq / 8.0f; // cos(0.5*dt*|omega|) + base_quat = base_quat * btQuaternion(sin_term * base_omega[0],sin_term * base_omega[1],sin_term * base_omega[2],cos_term); + } else + { + base_quat = base_quat * btQuaternion(base_omega / omega_norm,-omega_times_dt); + } + + // Make sure the quaternion represents a valid rotation. + // (Not strictly necessary, but helps prevent any round-off errors from building up.) + base_quat.normalize(); + + // Finally we can update joint_pos for each of the links + for (int i = 0; i < num_links; ++i) + { + float jointVel = getJointVel(i); + links[i].joint_pos += dt * jointVel; + links[i].updateCache(); + } +} + +void btMultiBody::fillContactJacobian(int link, + const btVector3 &contact_point, + const btVector3 &normal, + btScalar *jac, + btAlignedObjectArray &scratch_r, + btAlignedObjectArray &scratch_v, + btAlignedObjectArray &scratch_m) const +{ + // temporary space + int num_links = getNumLinks(); + scratch_v.resize(2*num_links + 2); + scratch_m.resize(num_links + 1); + + btVector3 * v_ptr = &scratch_v[0]; + btVector3 * p_minus_com = v_ptr; v_ptr += num_links + 1; + btVector3 * n_local = v_ptr; v_ptr += num_links + 1; + btAssert(v_ptr - &scratch_v[0] == scratch_v.size()); + + scratch_r.resize(num_links); + btScalar * results = num_links > 0 ? &scratch_r[0] : 0; + + btMatrix3x3 * rot_from_world = &scratch_m[0]; + + const btVector3 p_minus_com_world = contact_point - base_pos; + + rot_from_world[0] = btMatrix3x3(base_quat); + + p_minus_com[0] = rot_from_world[0] * p_minus_com_world; + n_local[0] = rot_from_world[0] * normal; + + // omega coeffients first. + btVector3 omega_coeffs; + omega_coeffs = p_minus_com_world.cross(normal); + jac[0] = omega_coeffs[0]; + jac[1] = omega_coeffs[1]; + jac[2] = omega_coeffs[2]; + // then v coefficients + jac[3] = normal[0]; + jac[4] = normal[1]; + jac[5] = normal[2]; + + // Set remaining jac values to zero for now. + for (int i = 6; i < 6 + num_links; ++i) { + jac[i] = 0; + } + + // Qdot coefficients, if necessary. + if (num_links > 0 && link > -1) { + + // TODO: speed this up -- don't calculate for links we don't need. + // (Also, we are making 3 separate calls to this function, for the normal & the 2 friction directions, + // which is resulting in repeated work being done...) + + // calculate required normals & positions in the local frames. + for (int i = 0; i < num_links; ++i) { + + // transform to local frame + const int parent = links[i].parent; + const btMatrix3x3 mtx(links[i].cached_rot_parent_to_this); + rot_from_world[i+1] = mtx * rot_from_world[parent+1]; + + n_local[i+1] = mtx * n_local[parent+1]; + p_minus_com[i+1] = mtx * p_minus_com[parent+1] - links[i].cached_r_vector; + + // calculate the jacobian entry + if (links[i].is_revolute) { + results[i] = n_local[i+1].dot( links[i].axis_top.cross(p_minus_com[i+1]) + links[i].axis_bottom ); + } else { + results[i] = n_local[i+1].dot( links[i].axis_bottom ); + } + } + + // Now copy through to output. + while (link != -1) { + jac[6 + link] = results[link]; + link = links[link].parent; + } + } +} + +void btMultiBody::wakeUp() +{ + awake = true; +} + +void btMultiBody::goToSleep() +{ + awake = false; +} + +void btMultiBody::checkMotionAndSleepIfRequired(btScalar timestep) +{ + int num_links = getNumLinks(); + extern bool gDisableDeactivation; + if (!can_sleep || gDisableDeactivation) + { + awake = true; + sleep_timer = 0; + return; + } + + // motion is computed as omega^2 + v^2 + (sum of squares of joint velocities) + btScalar motion = 0; + for (int i = 0; i < 6 + num_links; ++i) { + motion += m_real_buf[i] * m_real_buf[i]; + } + + if (motion < SLEEP_EPSILON) { + sleep_timer += timestep; + if (sleep_timer > SLEEP_TIMEOUT) { + goToSleep(); + } + } else { + sleep_timer = 0; + if (!awake) + wakeUp(); + } +} diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.h new file mode 100644 index 00000000000..7177bebbff5 --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.h @@ -0,0 +1,466 @@ +/* + * PURPOSE: + * Class representing an articulated rigid body. Stores the body's + * current state, allows forces and torques to be set, handles + * timestepping and implements Featherstone's algorithm. + * + * COPYRIGHT: + * Copyright (C) Stephen Thompson, , 2011-2013 + * Portions written By Erwin Coumans: replacing Eigen math library by Bullet LinearMath and a dedicated 6x6 matrix inverse (solveImatrix) + + This software is provided 'as-is', without any express or implied warranty. + In no event will the authors be held liable for any damages arising from the use of this software. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it freely, + subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + */ + + +#ifndef BT_MULTIBODY_H +#define BT_MULTIBODY_H + +#include "LinearMath/btScalar.h" +#include "LinearMath/btVector3.h" +#include "LinearMath/btQuaternion.h" +#include "LinearMath/btMatrix3x3.h" +#include "LinearMath/btAlignedObjectArray.h" + + +#include "btMultiBodyLink.h" +class btMultiBodyLinkCollider; + +class btMultiBody +{ +public: + + + BT_DECLARE_ALIGNED_ALLOCATOR(); + + // + // initialization + // + + btMultiBody(int n_links, // NOT including the base + btScalar mass, // mass of base + const btVector3 &inertia, // inertia of base, in base frame; assumed diagonal + bool fixed_base_, // whether the base is fixed (true) or can move (false) + bool can_sleep_); + + ~btMultiBody(); + + void setupPrismatic(int i, // 0 to num_links-1 + btScalar mass, + const btVector3 &inertia, // in my frame; assumed diagonal + int parent, + const btQuaternion &rot_parent_to_this, // rotate points in parent frame to my frame. + const btVector3 &joint_axis, // in my frame + const btVector3 &r_vector_when_q_zero, // vector from parent COM to my COM, in my frame, when q = 0. + bool disableParentCollision=false + ); + + void setupRevolute(int i, // 0 to num_links-1 + btScalar mass, + const btVector3 &inertia, + int parent, + const btQuaternion &zero_rot_parent_to_this, // rotate points in parent frame to this frame, when q = 0 + const btVector3 &joint_axis, // in my frame + const btVector3 &parent_axis_position, // vector from parent COM to joint axis, in PARENT frame + const btVector3 &my_axis_position, // vector from joint axis to my COM, in MY frame + bool disableParentCollision=false); + + const btMultibodyLink& getLink(int index) const + { + return links[index]; + } + + btMultibodyLink& getLink(int index) + { + return links[index]; + } + + + void setBaseCollider(btMultiBodyLinkCollider* collider)//collider can be NULL to disable collision for the base + { + m_baseCollider = collider; + } + const btMultiBodyLinkCollider* getBaseCollider() const + { + return m_baseCollider; + } + btMultiBodyLinkCollider* getBaseCollider() + { + return m_baseCollider; + } + + // + // get parent + // input: link num from 0 to num_links-1 + // output: link num from 0 to num_links-1, OR -1 to mean the base. + // + int getParent(int link_num) const; + + + // + // get number of links, masses, moments of inertia + // + + int getNumLinks() const { return links.size(); } + btScalar getBaseMass() const { return base_mass; } + const btVector3 & getBaseInertia() const { return base_inertia; } + btScalar getLinkMass(int i) const; + const btVector3 & getLinkInertia(int i) const; + + + // + // change mass (incomplete: can only change base mass and inertia at present) + // + + void setBaseMass(btScalar mass) { base_mass = mass; } + void setBaseInertia(const btVector3 &inertia) { base_inertia = inertia; } + + + // + // get/set pos/vel/rot/omega for the base link + // + + const btVector3 & getBasePos() const { return base_pos; } // in world frame + const btVector3 getBaseVel() const + { + return btVector3(m_real_buf[3],m_real_buf[4],m_real_buf[5]); + } // in world frame + const btQuaternion & getWorldToBaseRot() const + { + return base_quat; + } // rotates world vectors into base frame + btVector3 getBaseOmega() const { return btVector3(m_real_buf[0],m_real_buf[1],m_real_buf[2]); } // in world frame + + void setBasePos(const btVector3 &pos) + { + base_pos = pos; + } + void setBaseVel(const btVector3 &vel) + { + + m_real_buf[3]=vel[0]; m_real_buf[4]=vel[1]; m_real_buf[5]=vel[2]; + } + void setWorldToBaseRot(const btQuaternion &rot) + { + base_quat = rot; + } + void setBaseOmega(const btVector3 &omega) + { + m_real_buf[0]=omega[0]; + m_real_buf[1]=omega[1]; + m_real_buf[2]=omega[2]; + } + + + // + // get/set pos/vel for child links (i = 0 to num_links-1) + // + + btScalar getJointPos(int i) const; + btScalar getJointVel(int i) const; + + void setJointPos(int i, btScalar q); + void setJointVel(int i, btScalar qdot); + + // + // direct access to velocities as a vector of 6 + num_links elements. + // (omega first, then v, then joint velocities.) + // + const btScalar * getVelocityVector() const + { + return &m_real_buf[0]; + } +/* btScalar * getVelocityVector() + { + return &real_buf[0]; + } + */ + + // + // get the frames of reference (positions and orientations) of the child links + // (i = 0 to num_links-1) + // + + const btVector3 & getRVector(int i) const; // vector from COM(parent(i)) to COM(i), in frame i's coords + const btQuaternion & getParentToLocalRot(int i) const; // rotates vectors in frame parent(i) to vectors in frame i. + + + // + // transform vectors in local frame of link i to world frame (or vice versa) + // + btVector3 localPosToWorld(int i, const btVector3 &vec) const; + btVector3 localDirToWorld(int i, const btVector3 &vec) const; + btVector3 worldPosToLocal(int i, const btVector3 &vec) const; + btVector3 worldDirToLocal(int i, const btVector3 &vec) const; + + + // + // calculate kinetic energy and angular momentum + // useful for debugging. + // + + btScalar getKineticEnergy() const; + btVector3 getAngularMomentum() const; + + + // + // set external forces and torques. Note all external forces/torques are given in the WORLD frame. + // + + void clearForcesAndTorques(); + void clearVelocities(); + + void addBaseForce(const btVector3 &f) + { + base_force += f; + } + void addBaseTorque(const btVector3 &t) { base_torque += t; } + void addLinkForce(int i, const btVector3 &f); + void addLinkTorque(int i, const btVector3 &t); + void addJointTorque(int i, btScalar Q); + + const btVector3 & getBaseForce() const { return base_force; } + const btVector3 & getBaseTorque() const { return base_torque; } + const btVector3 & getLinkForce(int i) const; + const btVector3 & getLinkTorque(int i) const; + btScalar getJointTorque(int i) const; + + + // + // dynamics routines. + // + + // timestep the velocities (given the external forces/torques set using addBaseForce etc). + // also sets up caches for calcAccelerationDeltas. + // + // Note: the caller must provide three vectors which are used as + // temporary scratch space. The idea here is to reduce dynamic + // memory allocation: the same scratch vectors can be re-used + // again and again for different Multibodies, instead of each + // btMultiBody allocating (and then deallocating) their own + // individual scratch buffers. This gives a considerable speed + // improvement, at least on Windows (where dynamic memory + // allocation appears to be fairly slow). + // + void stepVelocities(btScalar dt, + btAlignedObjectArray &scratch_r, + btAlignedObjectArray &scratch_v, + btAlignedObjectArray &scratch_m); + + // calcAccelerationDeltas + // input: force vector (in same format as jacobian, i.e.: + // 3 torque values, 3 force values, num_links joint torque values) + // output: 3 omegadot values, 3 vdot values, num_links q_double_dot values + // (existing contents of output array are replaced) + // stepVelocities must have been called first. + void calcAccelerationDeltas(const btScalar *force, btScalar *output, + btAlignedObjectArray &scratch_r, + btAlignedObjectArray &scratch_v) const; + + // apply a delta-vee directly. used in sequential impulses code. + void applyDeltaVee(const btScalar * delta_vee) + { + + for (int i = 0; i < 6 + getNumLinks(); ++i) + { + m_real_buf[i] += delta_vee[i]; + } + + } + void applyDeltaVee(const btScalar * delta_vee, btScalar multiplier) + { + btScalar sum = 0; + for (int i = 0; i < 6 + getNumLinks(); ++i) + { + sum += delta_vee[i]*multiplier*delta_vee[i]*multiplier; + } + btScalar l = btSqrt(sum); + /* + static btScalar maxl = -1e30f; + if (l>maxl) + { + maxl=l; + // printf("maxl=%f\n",maxl); + } + */ + if (l>m_maxAppliedImpulse) + { +// printf("exceeds 100: l=%f\n",maxl); + multiplier *= m_maxAppliedImpulse/l; + } + + for (int i = 0; i < 6 + getNumLinks(); ++i) + { + sum += delta_vee[i]*multiplier*delta_vee[i]*multiplier; + m_real_buf[i] += delta_vee[i] * multiplier; + } + } + + // timestep the positions (given current velocities). + void stepPositions(btScalar dt); + + + // + // contacts + // + + // This routine fills out a contact constraint jacobian for this body. + // the 'normal' supplied must be -n for body1 or +n for body2 of the contact. + // 'normal' & 'contact_point' are both given in world coordinates. + void fillContactJacobian(int link, + const btVector3 &contact_point, + const btVector3 &normal, + btScalar *jac, + btAlignedObjectArray &scratch_r, + btAlignedObjectArray &scratch_v, + btAlignedObjectArray &scratch_m) const; + + + // + // sleeping + // + void setCanSleep(bool canSleep) + { + can_sleep = canSleep; + } + + bool isAwake() const { return awake; } + void wakeUp(); + void goToSleep(); + void checkMotionAndSleepIfRequired(btScalar timestep); + + bool hasFixedBase() const + { + return fixed_base; + } + + int getCompanionId() const + { + return m_companionId; + } + void setCompanionId(int id) + { + //printf("for %p setCompanionId(%d)\n",this, id); + m_companionId = id; + } + + void setNumLinks(int numLinks)//careful: when changing the number of links, make sure to re-initialize or update existing links + { + links.resize(numLinks); + } + + btScalar getLinearDamping() const + { + return m_linearDamping; + } + void setLinearDamping( btScalar damp) + { + m_linearDamping = damp; + } + btScalar getAngularDamping() const + { + return m_angularDamping; + } + + bool getUseGyroTerm() const + { + return m_useGyroTerm; + } + void setUseGyroTerm(bool useGyro) + { + m_useGyroTerm = useGyro; + } + btScalar getMaxAppliedImpulse() const + { + return m_maxAppliedImpulse; + } + void setMaxAppliedImpulse(btScalar maxImp) + { + m_maxAppliedImpulse = maxImp; + } + + void setHasSelfCollision(bool hasSelfCollision) + { + m_hasSelfCollision = hasSelfCollision; + } + bool hasSelfCollision() const + { + return m_hasSelfCollision; + } + +private: + btMultiBody(const btMultiBody &); // not implemented + void operator=(const btMultiBody &); // not implemented + + void compTreeLinkVelocities(btVector3 *omega, btVector3 *vel) const; + + void solveImatrix(const btVector3& rhs_top, const btVector3& rhs_bot, float result[6]) const; + + +private: + + btMultiBodyLinkCollider* m_baseCollider;//can be NULL + + btVector3 base_pos; // position of COM of base (world frame) + btQuaternion base_quat; // rotates world points into base frame + + btScalar base_mass; // mass of the base + btVector3 base_inertia; // inertia of the base (in local frame; diagonal) + + btVector3 base_force; // external force applied to base. World frame. + btVector3 base_torque; // external torque applied to base. World frame. + + btAlignedObjectArray links; // array of links, excluding the base. index from 0 to num_links-1. + btAlignedObjectArray m_colliders; + + // + // real_buf: + // offset size array + // 0 6 + num_links v (base_omega; base_vel; joint_vels) + // 6+num_links num_links D + // + // vector_buf: + // offset size array + // 0 num_links h_top + // num_links num_links h_bottom + // + // matrix_buf: + // offset size array + // 0 num_links+1 rot_from_parent + // + + btAlignedObjectArray m_real_buf; + btAlignedObjectArray vector_buf; + btAlignedObjectArray matrix_buf; + + //std::auto_ptr > > cached_imatrix_lu; + + btMatrix3x3 cached_inertia_top_left; + btMatrix3x3 cached_inertia_top_right; + btMatrix3x3 cached_inertia_lower_left; + btMatrix3x3 cached_inertia_lower_right; + + bool fixed_base; + + // Sleep parameters. + bool awake; + bool can_sleep; + btScalar sleep_timer; + + int m_companionId; + btScalar m_linearDamping; + btScalar m_angularDamping; + bool m_useGyroTerm; + btScalar m_maxAppliedImpulse; + bool m_hasSelfCollision; +}; + +#endif diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp new file mode 100644 index 00000000000..44e04c3a132 --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp @@ -0,0 +1,527 @@ +#include "btMultiBodyConstraint.h" +#include "BulletDynamics/Dynamics/btRigidBody.h" + +btMultiBodyConstraint::btMultiBodyConstraint(btMultiBody* bodyA,btMultiBody* bodyB,int linkA, int linkB, int numRows, bool isUnilateral) + :m_bodyA(bodyA), + m_bodyB(bodyB), + m_linkA(linkA), + m_linkB(linkB), + m_num_rows(numRows), + m_isUnilateral(isUnilateral), + m_maxAppliedImpulse(100) +{ + m_jac_size_A = (6 + bodyA->getNumLinks()); + m_jac_size_both = (m_jac_size_A + (bodyB ? 6 + bodyB->getNumLinks() : 0)); + m_pos_offset = ((1 + m_jac_size_both)*m_num_rows); + m_data.resize((2 + m_jac_size_both) * m_num_rows); +} + +btMultiBodyConstraint::~btMultiBodyConstraint() +{ +} + + + +btScalar btMultiBodyConstraint::fillConstraintRowMultiBodyMultiBody(btMultiBodySolverConstraint& constraintRow, + btMultiBodyJacobianData& data, + btScalar* jacOrgA,btScalar* jacOrgB, + const btContactSolverInfo& infoGlobal, + btScalar desiredVelocity, + btScalar lowerLimit, + btScalar upperLimit) +{ + + + + constraintRow.m_multiBodyA = m_bodyA; + constraintRow.m_multiBodyB = m_bodyB; + + btMultiBody* multiBodyA = constraintRow.m_multiBodyA; + btMultiBody* multiBodyB = constraintRow.m_multiBodyB; + + if (multiBodyA) + { + + const int ndofA = multiBodyA->getNumLinks() + 6; + + constraintRow.m_deltaVelAindex = multiBodyA->getCompanionId(); + + if (constraintRow.m_deltaVelAindex <0) + { + constraintRow.m_deltaVelAindex = data.m_deltaVelocities.size(); + multiBodyA->setCompanionId(constraintRow.m_deltaVelAindex); + data.m_deltaVelocities.resize(data.m_deltaVelocities.size()+ndofA); + } else + { + btAssert(data.m_deltaVelocities.size() >= constraintRow.m_deltaVelAindex+ndofA); + } + + constraintRow.m_jacAindex = data.m_jacobians.size(); + data.m_jacobians.resize(data.m_jacobians.size()+ndofA); + data.m_deltaVelocitiesUnitImpulse.resize(data.m_deltaVelocitiesUnitImpulse.size()+ndofA); + btAssert(data.m_jacobians.size() == data.m_deltaVelocitiesUnitImpulse.size()); + for (int i=0;icalcAccelerationDeltas(&data.m_jacobians[constraintRow.m_jacAindex],delta,data.scratch_r, data.scratch_v); + } + + if (multiBodyB) + { + const int ndofB = multiBodyB->getNumLinks() + 6; + + constraintRow.m_deltaVelBindex = multiBodyB->getCompanionId(); + if (constraintRow.m_deltaVelBindex <0) + { + constraintRow.m_deltaVelBindex = data.m_deltaVelocities.size(); + multiBodyB->setCompanionId(constraintRow.m_deltaVelBindex); + data.m_deltaVelocities.resize(data.m_deltaVelocities.size()+ndofB); + } + + constraintRow.m_jacBindex = data.m_jacobians.size(); + data.m_jacobians.resize(data.m_jacobians.size()+ndofB); + + for (int i=0;icalcAccelerationDeltas(&data.m_jacobians[constraintRow.m_jacBindex],&data.m_deltaVelocitiesUnitImpulse[constraintRow.m_jacBindex],data.scratch_r, data.scratch_v); + } + { + + btVector3 vec; + btScalar denom0 = 0.f; + btScalar denom1 = 0.f; + btScalar* jacB = 0; + btScalar* jacA = 0; + btScalar* lambdaA =0; + btScalar* lambdaB =0; + int ndofA = 0; + if (multiBodyA) + { + ndofA = multiBodyA->getNumLinks() + 6; + jacA = &data.m_jacobians[constraintRow.m_jacAindex]; + lambdaA = &data.m_deltaVelocitiesUnitImpulse[constraintRow.m_jacAindex]; + for (int i = 0; i < ndofA; ++i) + { + btScalar j = jacA[i] ; + btScalar l =lambdaA[i]; + denom0 += j*l; + } + } + if (multiBodyB) + { + const int ndofB = multiBodyB->getNumLinks() + 6; + jacB = &data.m_jacobians[constraintRow.m_jacBindex]; + lambdaB = &data.m_deltaVelocitiesUnitImpulse[constraintRow.m_jacBindex]; + for (int i = 0; i < ndofB; ++i) + { + btScalar j = jacB[i] ; + btScalar l =lambdaB[i]; + denom1 += j*l; + } + + } + + if (multiBodyA && (multiBodyA==multiBodyB)) + { + // ndof1 == ndof2 in this case + for (int i = 0; i < ndofA; ++i) + { + denom1 += jacB[i] * lambdaA[i]; + denom1 += jacA[i] * lambdaB[i]; + } + } + + btScalar d = denom0+denom1; + if (btFabs(d)>SIMD_EPSILON) + { + + constraintRow.m_jacDiagABInv = 1.f/(d); + } else + { + constraintRow.m_jacDiagABInv = 1.f; + } + + } + + + //compute rhs and remaining constraintRow fields + + + + + btScalar rel_vel = 0.f; + int ndofA = 0; + int ndofB = 0; + { + + btVector3 vel1,vel2; + if (multiBodyA) + { + ndofA = multiBodyA->getNumLinks() + 6; + btScalar* jacA = &data.m_jacobians[constraintRow.m_jacAindex]; + for (int i = 0; i < ndofA ; ++i) + rel_vel += multiBodyA->getVelocityVector()[i] * jacA[i]; + } + if (multiBodyB) + { + ndofB = multiBodyB->getNumLinks() + 6; + btScalar* jacB = &data.m_jacobians[constraintRow.m_jacBindex]; + for (int i = 0; i < ndofB ; ++i) + rel_vel += multiBodyB->getVelocityVector()[i] * jacB[i]; + + } + + constraintRow.m_friction = 0.f; + + constraintRow.m_appliedImpulse = 0.f; + constraintRow.m_appliedPushImpulse = 0.f; + + btScalar velocityError = desiredVelocity - rel_vel;// * damping; + + btScalar erp = infoGlobal.m_erp2; + + btScalar velocityImpulse = velocityError *constraintRow.m_jacDiagABInv; + + if (!infoGlobal.m_splitImpulse) + { + //combine position and velocity into rhs + constraintRow.m_rhs = velocityImpulse; + constraintRow.m_rhsPenetration = 0.f; + + } else + { + //split position and velocity into rhs and m_rhsPenetration + constraintRow.m_rhs = velocityImpulse; + constraintRow.m_rhsPenetration = 0.f; + } + + + constraintRow.m_cfm = 0.f; + constraintRow.m_lowerLimit = lowerLimit; + constraintRow.m_upperLimit = upperLimit; + + } + return rel_vel; +} + + +void btMultiBodyConstraint::applyDeltaVee(btMultiBodyJacobianData& data, btScalar* delta_vee, btScalar impulse, int velocityIndex, int ndof) +{ + for (int i = 0; i < ndof; ++i) + data.m_deltaVelocities[velocityIndex+i] += delta_vee[i] * impulse; +} + + +void btMultiBodyConstraint::fillMultiBodyConstraintMixed(btMultiBodySolverConstraint& solverConstraint, + btMultiBodyJacobianData& data, + const btVector3& contactNormalOnB, + const btVector3& posAworld, const btVector3& posBworld, + btScalar position, + const btContactSolverInfo& infoGlobal, + btScalar& relaxation, + bool isFriction, btScalar desiredVelocity, btScalar cfmSlip) +{ + + + btVector3 rel_pos1 = posAworld; + btVector3 rel_pos2 = posBworld; + + solverConstraint.m_multiBodyA = m_bodyA; + solverConstraint.m_multiBodyB = m_bodyB; + solverConstraint.m_linkA = m_linkA; + solverConstraint.m_linkB = m_linkB; + + + btMultiBody* multiBodyA = solverConstraint.m_multiBodyA; + btMultiBody* multiBodyB = solverConstraint.m_multiBodyB; + + const btVector3& pos1 = posAworld; + const btVector3& pos2 = posBworld; + + btSolverBody* bodyA = multiBodyA ? 0 : &data.m_solverBodyPool->at(solverConstraint.m_solverBodyIdA); + btSolverBody* bodyB = multiBodyB ? 0 : &data.m_solverBodyPool->at(solverConstraint.m_solverBodyIdB); + + btRigidBody* rb0 = multiBodyA ? 0 : bodyA->m_originalBody; + btRigidBody* rb1 = multiBodyB ? 0 : bodyB->m_originalBody; + + if (bodyA) + rel_pos1 = pos1 - bodyA->getWorldTransform().getOrigin(); + if (bodyB) + rel_pos2 = pos2 - bodyB->getWorldTransform().getOrigin(); + + relaxation = 1.f; + + if (multiBodyA) + { + const int ndofA = multiBodyA->getNumLinks() + 6; + + solverConstraint.m_deltaVelAindex = multiBodyA->getCompanionId(); + + if (solverConstraint.m_deltaVelAindex <0) + { + solverConstraint.m_deltaVelAindex = data.m_deltaVelocities.size(); + multiBodyA->setCompanionId(solverConstraint.m_deltaVelAindex); + data.m_deltaVelocities.resize(data.m_deltaVelocities.size()+ndofA); + } else + { + btAssert(data.m_deltaVelocities.size() >= solverConstraint.m_deltaVelAindex+ndofA); + } + + solverConstraint.m_jacAindex = data.m_jacobians.size(); + data.m_jacobians.resize(data.m_jacobians.size()+ndofA); + data.m_deltaVelocitiesUnitImpulse.resize(data.m_deltaVelocitiesUnitImpulse.size()+ndofA); + btAssert(data.m_jacobians.size() == data.m_deltaVelocitiesUnitImpulse.size()); + + btScalar* jac1=&data.m_jacobians[solverConstraint.m_jacAindex]; + multiBodyA->fillContactJacobian(solverConstraint.m_linkA, posAworld, contactNormalOnB, jac1, data.scratch_r, data.scratch_v, data.scratch_m); + btScalar* delta = &data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex]; + multiBodyA->calcAccelerationDeltas(&data.m_jacobians[solverConstraint.m_jacAindex],delta,data.scratch_r, data.scratch_v); + } else + { + btVector3 torqueAxis0 = rel_pos1.cross(contactNormalOnB); + solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld()*torqueAxis0*rb0->getAngularFactor() : btVector3(0,0,0); + solverConstraint.m_relpos1CrossNormal = torqueAxis0; + solverConstraint.m_contactNormal1 = contactNormalOnB; + } + + if (multiBodyB) + { + const int ndofB = multiBodyB->getNumLinks() + 6; + + solverConstraint.m_deltaVelBindex = multiBodyB->getCompanionId(); + if (solverConstraint.m_deltaVelBindex <0) + { + solverConstraint.m_deltaVelBindex = data.m_deltaVelocities.size(); + multiBodyB->setCompanionId(solverConstraint.m_deltaVelBindex); + data.m_deltaVelocities.resize(data.m_deltaVelocities.size()+ndofB); + } + + solverConstraint.m_jacBindex = data.m_jacobians.size(); + + data.m_jacobians.resize(data.m_jacobians.size()+ndofB); + data.m_deltaVelocitiesUnitImpulse.resize(data.m_deltaVelocitiesUnitImpulse.size()+ndofB); + btAssert(data.m_jacobians.size() == data.m_deltaVelocitiesUnitImpulse.size()); + + multiBodyB->fillContactJacobian(solverConstraint.m_linkB, posBworld, -contactNormalOnB, &data.m_jacobians[solverConstraint.m_jacBindex], data.scratch_r, data.scratch_v, data.scratch_m); + multiBodyB->calcAccelerationDeltas(&data.m_jacobians[solverConstraint.m_jacBindex],&data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex],data.scratch_r, data.scratch_v); + } else + { + btVector3 torqueAxis1 = rel_pos2.cross(contactNormalOnB); + solverConstraint.m_angularComponentB = rb1 ? rb1->getInvInertiaTensorWorld()*-torqueAxis1*rb1->getAngularFactor() : btVector3(0,0,0); + solverConstraint.m_relpos2CrossNormal = -torqueAxis1; + solverConstraint.m_contactNormal2 = -contactNormalOnB; + } + + { + + btVector3 vec; + btScalar denom0 = 0.f; + btScalar denom1 = 0.f; + btScalar* jacB = 0; + btScalar* jacA = 0; + btScalar* lambdaA =0; + btScalar* lambdaB =0; + int ndofA = 0; + if (multiBodyA) + { + ndofA = multiBodyA->getNumLinks() + 6; + jacA = &data.m_jacobians[solverConstraint.m_jacAindex]; + lambdaA = &data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex]; + for (int i = 0; i < ndofA; ++i) + { + btScalar j = jacA[i] ; + btScalar l =lambdaA[i]; + denom0 += j*l; + } + } else + { + if (rb0) + { + vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1); + denom0 = rb0->getInvMass() + contactNormalOnB.dot(vec); + } + } + if (multiBodyB) + { + const int ndofB = multiBodyB->getNumLinks() + 6; + jacB = &data.m_jacobians[solverConstraint.m_jacBindex]; + lambdaB = &data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex]; + for (int i = 0; i < ndofB; ++i) + { + btScalar j = jacB[i] ; + btScalar l =lambdaB[i]; + denom1 += j*l; + } + + } else + { + if (rb1) + { + vec = ( -solverConstraint.m_angularComponentB).cross(rel_pos2); + denom1 = rb1->getInvMass() + contactNormalOnB.dot(vec); + } + } + + if (multiBodyA && (multiBodyA==multiBodyB)) + { + // ndof1 == ndof2 in this case + for (int i = 0; i < ndofA; ++i) + { + denom1 += jacB[i] * lambdaA[i]; + denom1 += jacA[i] * lambdaB[i]; + } + } + + btScalar d = denom0+denom1; + if (btFabs(d)>SIMD_EPSILON) + { + + solverConstraint.m_jacDiagABInv = relaxation/(d); + } else + { + solverConstraint.m_jacDiagABInv = 1.f; + } + + } + + + //compute rhs and remaining solverConstraint fields + + + + btScalar restitution = 0.f; + btScalar penetration = isFriction? 0 : position+infoGlobal.m_linearSlop; + + btScalar rel_vel = 0.f; + int ndofA = 0; + int ndofB = 0; + { + + btVector3 vel1,vel2; + if (multiBodyA) + { + ndofA = multiBodyA->getNumLinks() + 6; + btScalar* jacA = &data.m_jacobians[solverConstraint.m_jacAindex]; + for (int i = 0; i < ndofA ; ++i) + rel_vel += multiBodyA->getVelocityVector()[i] * jacA[i]; + } else + { + if (rb0) + { + rel_vel += rb0->getVelocityInLocalPoint(rel_pos1).dot(solverConstraint.m_contactNormal1); + } + } + if (multiBodyB) + { + ndofB = multiBodyB->getNumLinks() + 6; + btScalar* jacB = &data.m_jacobians[solverConstraint.m_jacBindex]; + for (int i = 0; i < ndofB ; ++i) + rel_vel += multiBodyB->getVelocityVector()[i] * jacB[i]; + + } else + { + if (rb1) + { + rel_vel += rb1->getVelocityInLocalPoint(rel_pos2).dot(solverConstraint.m_contactNormal2); + } + } + + solverConstraint.m_friction = 0.f;//cp.m_combinedFriction; + + + restitution = restitution * -rel_vel;//restitutionCurve(rel_vel, cp.m_combinedRestitution); + if (restitution <= btScalar(0.)) + { + restitution = 0.f; + }; + } + + + ///warm starting (or zero if disabled) + /* + if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) + { + solverConstraint.m_appliedImpulse = isFriction ? 0 : cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor; + + if (solverConstraint.m_appliedImpulse) + { + if (multiBodyA) + { + btScalar impulse = solverConstraint.m_appliedImpulse; + btScalar* deltaV = &data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex]; + multiBodyA->applyDeltaVee(deltaV,impulse); + applyDeltaVee(data,deltaV,impulse,solverConstraint.m_deltaVelAindex,ndofA); + } else + { + if (rb0) + bodyA->internalApplyImpulse(solverConstraint.m_contactNormal1*bodyA->internalGetInvMass()*rb0->getLinearFactor(),solverConstraint.m_angularComponentA,solverConstraint.m_appliedImpulse); + } + if (multiBodyB) + { + btScalar impulse = solverConstraint.m_appliedImpulse; + btScalar* deltaV = &data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex]; + multiBodyB->applyDeltaVee(deltaV,impulse); + applyDeltaVee(data,deltaV,impulse,solverConstraint.m_deltaVelBindex,ndofB); + } else + { + if (rb1) + bodyB->internalApplyImpulse(-solverConstraint.m_contactNormal2*bodyB->internalGetInvMass()*rb1->getLinearFactor(),-solverConstraint.m_angularComponentB,-(btScalar)solverConstraint.m_appliedImpulse); + } + } + } else + */ + { + solverConstraint.m_appliedImpulse = 0.f; + } + + solverConstraint.m_appliedPushImpulse = 0.f; + + { + + + btScalar positionalError = 0.f; + btScalar velocityError = restitution - rel_vel;// * damping; + + + btScalar erp = infoGlobal.m_erp2; + if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold)) + { + erp = infoGlobal.m_erp; + } + + if (penetration>0) + { + positionalError = 0; + velocityError = -penetration / infoGlobal.m_timeStep; + + } else + { + positionalError = -penetration * erp/infoGlobal.m_timeStep; + } + + btScalar penetrationImpulse = positionalError*solverConstraint.m_jacDiagABInv; + btScalar velocityImpulse = velocityError *solverConstraint.m_jacDiagABInv; + + if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold)) + { + //combine position and velocity into rhs + solverConstraint.m_rhs = penetrationImpulse+velocityImpulse; + solverConstraint.m_rhsPenetration = 0.f; + + } else + { + //split position and velocity into rhs and m_rhsPenetration + solverConstraint.m_rhs = velocityImpulse; + solverConstraint.m_rhsPenetration = penetrationImpulse; + } + + solverConstraint.m_cfm = 0.f; + solverConstraint.m_lowerLimit = -m_maxAppliedImpulse; + solverConstraint.m_upperLimit = m_maxAppliedImpulse; + } + +} diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.h new file mode 100644 index 00000000000..9fa317330b3 --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraint.h @@ -0,0 +1,166 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BT_MULTIBODY_CONSTRAINT_H +#define BT_MULTIBODY_CONSTRAINT_H + +#include "LinearMath/btScalar.h" +#include "LinearMath/btAlignedObjectArray.h" +#include "btMultiBody.h" + +class btMultiBody; +struct btSolverInfo; + +#include "btMultiBodySolverConstraint.h" + +struct btMultiBodyJacobianData +{ + btAlignedObjectArray m_jacobians; + btAlignedObjectArray m_deltaVelocitiesUnitImpulse; + btAlignedObjectArray m_deltaVelocities; + btAlignedObjectArray scratch_r; + btAlignedObjectArray scratch_v; + btAlignedObjectArray scratch_m; + btAlignedObjectArray* m_solverBodyPool; + int m_fixedBodyId; + +}; + + +class btMultiBodyConstraint +{ +protected: + + btMultiBody* m_bodyA; + btMultiBody* m_bodyB; + int m_linkA; + int m_linkB; + + int m_num_rows; + int m_jac_size_A; + int m_jac_size_both; + int m_pos_offset; + + bool m_isUnilateral; + + btScalar m_maxAppliedImpulse; + + + // data block laid out as follows: + // cached impulses. (one per row.) + // jacobians. (interleaved, row1 body1 then row1 body2 then row2 body 1 etc) + // positions. (one per row.) + btAlignedObjectArray m_data; + + void applyDeltaVee(btMultiBodyJacobianData& data, btScalar* delta_vee, btScalar impulse, int velocityIndex, int ndof); + + void fillMultiBodyConstraintMixed(btMultiBodySolverConstraint& solverConstraint, + btMultiBodyJacobianData& data, + const btVector3& contactNormalOnB, + const btVector3& posAworld, const btVector3& posBworld, + btScalar position, + const btContactSolverInfo& infoGlobal, + btScalar& relaxation, + bool isFriction, btScalar desiredVelocity=0, btScalar cfmSlip=0); + + btScalar fillConstraintRowMultiBodyMultiBody(btMultiBodySolverConstraint& constraintRow, + btMultiBodyJacobianData& data, + btScalar* jacOrgA,btScalar* jacOrgB, + const btContactSolverInfo& infoGlobal, + btScalar desiredVelocity, + btScalar lowerLimit, + btScalar upperLimit); + +public: + + btMultiBodyConstraint(btMultiBody* bodyA,btMultiBody* bodyB,int linkA, int linkB, int numRows, bool isUnilateral); + virtual ~btMultiBodyConstraint(); + + + + virtual int getIslandIdA() const =0; + virtual int getIslandIdB() const =0; + + virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows, + btMultiBodyJacobianData& data, + const btContactSolverInfo& infoGlobal)=0; + + int getNumRows() const + { + return m_num_rows; + } + + btMultiBody* getMultiBodyA() + { + return m_bodyA; + } + btMultiBody* getMultiBodyB() + { + return m_bodyB; + } + + // current constraint position + // constraint is pos >= 0 for unilateral, or pos = 0 for bilateral + // NOTE: ignored position for friction rows. + btScalar getPosition(int row) const + { + return m_data[m_pos_offset + row]; + } + + void setPosition(int row, btScalar pos) + { + m_data[m_pos_offset + row] = pos; + } + + + bool isUnilateral() const + { + return m_isUnilateral; + } + + // jacobian blocks. + // each of size 6 + num_links. (jacobian2 is null if no body2.) + // format: 3 'omega' coefficients, 3 'v' coefficients, then the 'qdot' coefficients. + btScalar* jacobianA(int row) + { + return &m_data[m_num_rows + row * m_jac_size_both]; + } + const btScalar* jacobianA(int row) const + { + return &m_data[m_num_rows + (row * m_jac_size_both)]; + } + btScalar* jacobianB(int row) + { + return &m_data[m_num_rows + (row * m_jac_size_both) + m_jac_size_A]; + } + const btScalar* jacobianB(int row) const + { + return &m_data[m_num_rows + (row * m_jac_size_both) + m_jac_size_A]; + } + + btScalar getMaxAppliedImpulse() const + { + return m_maxAppliedImpulse; + } + void setMaxAppliedImpulse(btScalar maxImp) + { + m_maxAppliedImpulse = maxImp; + } + + +}; + +#endif //BT_MULTIBODY_CONSTRAINT_H + diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp new file mode 100644 index 00000000000..577f846225b --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp @@ -0,0 +1,795 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include "btMultiBodyConstraintSolver.h" +#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" +#include "btMultiBodyLinkCollider.h" + +#include "BulletDynamics/ConstraintSolver/btSolverBody.h" +#include "btMultiBodyConstraint.h" +#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" + +#include "LinearMath/btQuickprof.h" + +btScalar btMultiBodyConstraintSolver::solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer) +{ + btScalar val = btSequentialImpulseConstraintSolver::solveSingleIteration(iteration, bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer); + + //solve featherstone non-contact constraints + + //printf("m_multiBodyNonContactConstraints = %d\n",m_multiBodyNonContactConstraints.size()); + for (int j=0;jm_multiBodyFrictionContactConstraints.size();j++) + { + if (iteration < infoGlobal.m_numIterations) + { + btMultiBodySolverConstraint& frictionConstraint = m_multiBodyFrictionContactConstraints[j]; + btScalar totalImpulse = m_multiBodyNormalContactConstraints[frictionConstraint.m_frictionIndex].m_appliedImpulse; + //adjust friction limits here + if (totalImpulse>btScalar(0)) + { + frictionConstraint.m_lowerLimit = -(frictionConstraint.m_friction*totalImpulse); + frictionConstraint.m_upperLimit = frictionConstraint.m_friction*totalImpulse; + resolveSingleConstraintRowGeneric(frictionConstraint); + } + } + } + return val; +} + +btScalar btMultiBodyConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer) +{ + m_multiBodyNonContactConstraints.resize(0); + m_multiBodyNormalContactConstraints.resize(0); + m_multiBodyFrictionContactConstraints.resize(0); + m_data.m_jacobians.resize(0); + m_data.m_deltaVelocitiesUnitImpulse.resize(0); + m_data.m_deltaVelocities.resize(0); + + for (int i=0;im_multiBody->setCompanionId(-1); + } + } + + btScalar val = btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup( bodies,numBodies,manifoldPtr, numManifolds, constraints,numConstraints,infoGlobal,debugDrawer); + + return val; +} + +void btMultiBodyConstraintSolver::applyDeltaVee(btScalar* delta_vee, btScalar impulse, int velocityIndex, int ndof) +{ + for (int i = 0; i < ndof; ++i) + m_data.m_deltaVelocities[velocityIndex+i] += delta_vee[i] * impulse; +} + +void btMultiBodyConstraintSolver::resolveSingleConstraintRowGeneric(const btMultiBodySolverConstraint& c) +{ + + btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm; + btScalar deltaVelADotn=0; + btScalar deltaVelBDotn=0; + btSolverBody* bodyA = 0; + btSolverBody* bodyB = 0; + int ndofA=0; + int ndofB=0; + + if (c.m_multiBodyA) + { + ndofA = c.m_multiBodyA->getNumLinks() + 6; + for (int i = 0; i < ndofA; ++i) + deltaVelADotn += m_data.m_jacobians[c.m_jacAindex+i] * m_data.m_deltaVelocities[c.m_deltaVelAindex+i]; + } else + { + bodyA = &m_tmpSolverBodyPool[c.m_solverBodyIdA]; + deltaVelADotn += c.m_contactNormal1.dot(bodyA->internalGetDeltaLinearVelocity()) + c.m_relpos1CrossNormal.dot(bodyA->internalGetDeltaAngularVelocity()); + } + + if (c.m_multiBodyB) + { + ndofB = c.m_multiBodyB->getNumLinks() + 6; + for (int i = 0; i < ndofB; ++i) + deltaVelBDotn += m_data.m_jacobians[c.m_jacBindex+i] * m_data.m_deltaVelocities[c.m_deltaVelBindex+i]; + } else + { + bodyB = &m_tmpSolverBodyPool[c.m_solverBodyIdB]; + deltaVelBDotn += c.m_contactNormal2.dot(bodyB->internalGetDeltaLinearVelocity()) + c.m_relpos2CrossNormal.dot(bodyB->internalGetDeltaAngularVelocity()); + } + + + deltaImpulse -= deltaVelADotn*c.m_jacDiagABInv;//m_jacDiagABInv = 1./denom + deltaImpulse -= deltaVelBDotn*c.m_jacDiagABInv; + const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse; + + if (sum < c.m_lowerLimit) + { + deltaImpulse = c.m_lowerLimit-c.m_appliedImpulse; + c.m_appliedImpulse = c.m_lowerLimit; + } + else if (sum > c.m_upperLimit) + { + deltaImpulse = c.m_upperLimit-c.m_appliedImpulse; + c.m_appliedImpulse = c.m_upperLimit; + } + else + { + c.m_appliedImpulse = sum; + } + + if (c.m_multiBodyA) + { + applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacAindex],deltaImpulse,c.m_deltaVelAindex,ndofA); + c.m_multiBodyA->applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacAindex],deltaImpulse); + } else + { + bodyA->internalApplyImpulse(c.m_contactNormal1*bodyA->internalGetInvMass(),c.m_angularComponentA,deltaImpulse); + + } + if (c.m_multiBodyB) + { + applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacBindex],deltaImpulse,c.m_deltaVelBindex,ndofB); + c.m_multiBodyB->applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacBindex],deltaImpulse); + } else + { + bodyB->internalApplyImpulse(c.m_contactNormal2*bodyB->internalGetInvMass(),c.m_angularComponentB,deltaImpulse); + } + +} + + +void btMultiBodyConstraintSolver::resolveSingleConstraintRowGenericMultiBody(const btMultiBodySolverConstraint& c) +{ + + btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm; + btScalar deltaVelADotn=0; + btScalar deltaVelBDotn=0; + int ndofA=0; + int ndofB=0; + + if (c.m_multiBodyA) + { + ndofA = c.m_multiBodyA->getNumLinks() + 6; + for (int i = 0; i < ndofA; ++i) + deltaVelADotn += m_data.m_jacobians[c.m_jacAindex+i] * m_data.m_deltaVelocities[c.m_deltaVelAindex+i]; + } + + if (c.m_multiBodyB) + { + ndofB = c.m_multiBodyB->getNumLinks() + 6; + for (int i = 0; i < ndofB; ++i) + deltaVelBDotn += m_data.m_jacobians[c.m_jacBindex+i] * m_data.m_deltaVelocities[c.m_deltaVelBindex+i]; + } + + + deltaImpulse -= deltaVelADotn*c.m_jacDiagABInv;//m_jacDiagABInv = 1./denom + deltaImpulse -= deltaVelBDotn*c.m_jacDiagABInv; + const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse; + + if (sum < c.m_lowerLimit) + { + deltaImpulse = c.m_lowerLimit-c.m_appliedImpulse; + c.m_appliedImpulse = c.m_lowerLimit; + } + else if (sum > c.m_upperLimit) + { + deltaImpulse = c.m_upperLimit-c.m_appliedImpulse; + c.m_appliedImpulse = c.m_upperLimit; + } + else + { + c.m_appliedImpulse = sum; + } + + if (c.m_multiBodyA) + { + applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacAindex],deltaImpulse,c.m_deltaVelAindex,ndofA); + c.m_multiBodyA->applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacAindex],deltaImpulse); + } + if (c.m_multiBodyB) + { + applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacBindex],deltaImpulse,c.m_deltaVelBindex,ndofB); + c.m_multiBodyB->applyDeltaVee(&m_data.m_deltaVelocitiesUnitImpulse[c.m_jacBindex],deltaImpulse); + } +} + + +void btMultiBodyConstraintSolver::setupMultiBodyContactConstraint(btMultiBodySolverConstraint& solverConstraint, + const btVector3& contactNormal, + btManifoldPoint& cp, const btContactSolverInfo& infoGlobal, + btScalar& relaxation, + bool isFriction, btScalar desiredVelocity, btScalar cfmSlip) +{ + + BT_PROFILE("setupMultiBodyContactConstraint"); + btVector3 rel_pos1; + btVector3 rel_pos2; + + btMultiBody* multiBodyA = solverConstraint.m_multiBodyA; + btMultiBody* multiBodyB = solverConstraint.m_multiBodyB; + + const btVector3& pos1 = cp.getPositionWorldOnA(); + const btVector3& pos2 = cp.getPositionWorldOnB(); + + btSolverBody* bodyA = multiBodyA ? 0 : &m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA]; + btSolverBody* bodyB = multiBodyB ? 0 : &m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB]; + + btRigidBody* rb0 = multiBodyA ? 0 : bodyA->m_originalBody; + btRigidBody* rb1 = multiBodyB ? 0 : bodyB->m_originalBody; + + if (bodyA) + rel_pos1 = pos1 - bodyA->getWorldTransform().getOrigin(); + if (bodyB) + rel_pos2 = pos2 - bodyB->getWorldTransform().getOrigin(); + + relaxation = 1.f; + + if (multiBodyA) + { + const int ndofA = multiBodyA->getNumLinks() + 6; + + solverConstraint.m_deltaVelAindex = multiBodyA->getCompanionId(); + + if (solverConstraint.m_deltaVelAindex <0) + { + solverConstraint.m_deltaVelAindex = m_data.m_deltaVelocities.size(); + multiBodyA->setCompanionId(solverConstraint.m_deltaVelAindex); + m_data.m_deltaVelocities.resize(m_data.m_deltaVelocities.size()+ndofA); + } else + { + btAssert(m_data.m_deltaVelocities.size() >= solverConstraint.m_deltaVelAindex+ndofA); + } + + solverConstraint.m_jacAindex = m_data.m_jacobians.size(); + m_data.m_jacobians.resize(m_data.m_jacobians.size()+ndofA); + m_data.m_deltaVelocitiesUnitImpulse.resize(m_data.m_deltaVelocitiesUnitImpulse.size()+ndofA); + btAssert(m_data.m_jacobians.size() == m_data.m_deltaVelocitiesUnitImpulse.size()); + + btScalar* jac1=&m_data.m_jacobians[solverConstraint.m_jacAindex]; + multiBodyA->fillContactJacobian(solverConstraint.m_linkA, cp.getPositionWorldOnA(), contactNormal, jac1, m_data.scratch_r, m_data.scratch_v, m_data.scratch_m); + btScalar* delta = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex]; + multiBodyA->calcAccelerationDeltas(&m_data.m_jacobians[solverConstraint.m_jacAindex],delta,m_data.scratch_r, m_data.scratch_v); + } else + { + btVector3 torqueAxis0 = rel_pos1.cross(contactNormal); + solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld()*torqueAxis0*rb0->getAngularFactor() : btVector3(0,0,0); + solverConstraint.m_relpos1CrossNormal = torqueAxis0; + solverConstraint.m_contactNormal1 = contactNormal; + } + + if (multiBodyB) + { + const int ndofB = multiBodyB->getNumLinks() + 6; + + solverConstraint.m_deltaVelBindex = multiBodyB->getCompanionId(); + if (solverConstraint.m_deltaVelBindex <0) + { + solverConstraint.m_deltaVelBindex = m_data.m_deltaVelocities.size(); + multiBodyB->setCompanionId(solverConstraint.m_deltaVelBindex); + m_data.m_deltaVelocities.resize(m_data.m_deltaVelocities.size()+ndofB); + } + + solverConstraint.m_jacBindex = m_data.m_jacobians.size(); + + m_data.m_jacobians.resize(m_data.m_jacobians.size()+ndofB); + m_data.m_deltaVelocitiesUnitImpulse.resize(m_data.m_deltaVelocitiesUnitImpulse.size()+ndofB); + btAssert(m_data.m_jacobians.size() == m_data.m_deltaVelocitiesUnitImpulse.size()); + + multiBodyB->fillContactJacobian(solverConstraint.m_linkB, cp.getPositionWorldOnB(), -contactNormal, &m_data.m_jacobians[solverConstraint.m_jacBindex], m_data.scratch_r, m_data.scratch_v, m_data.scratch_m); + multiBodyB->calcAccelerationDeltas(&m_data.m_jacobians[solverConstraint.m_jacBindex],&m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex],m_data.scratch_r, m_data.scratch_v); + } else + { + btVector3 torqueAxis1 = rel_pos2.cross(contactNormal); + solverConstraint.m_angularComponentB = rb1 ? rb1->getInvInertiaTensorWorld()*-torqueAxis1*rb1->getAngularFactor() : btVector3(0,0,0); + solverConstraint.m_relpos2CrossNormal = -torqueAxis1; + solverConstraint.m_contactNormal2 = -contactNormal; + } + + { + + btVector3 vec; + btScalar denom0 = 0.f; + btScalar denom1 = 0.f; + btScalar* jacB = 0; + btScalar* jacA = 0; + btScalar* lambdaA =0; + btScalar* lambdaB =0; + int ndofA = 0; + if (multiBodyA) + { + ndofA = multiBodyA->getNumLinks() + 6; + jacA = &m_data.m_jacobians[solverConstraint.m_jacAindex]; + lambdaA = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex]; + for (int i = 0; i < ndofA; ++i) + { + btScalar j = jacA[i] ; + btScalar l =lambdaA[i]; + denom0 += j*l; + } + } else + { + if (rb0) + { + vec = ( solverConstraint.m_angularComponentA).cross(rel_pos1); + denom0 = rb0->getInvMass() + contactNormal.dot(vec); + } + } + if (multiBodyB) + { + const int ndofB = multiBodyB->getNumLinks() + 6; + jacB = &m_data.m_jacobians[solverConstraint.m_jacBindex]; + lambdaB = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex]; + for (int i = 0; i < ndofB; ++i) + { + btScalar j = jacB[i] ; + btScalar l =lambdaB[i]; + denom1 += j*l; + } + + } else + { + if (rb1) + { + vec = ( -solverConstraint.m_angularComponentB).cross(rel_pos2); + denom1 = rb1->getInvMass() + contactNormal.dot(vec); + } + } + + if (multiBodyA && (multiBodyA==multiBodyB)) + { + // ndof1 == ndof2 in this case + for (int i = 0; i < ndofA; ++i) + { + denom1 += jacB[i] * lambdaA[i]; + denom1 += jacA[i] * lambdaB[i]; + } + } + + btScalar d = denom0+denom1; + if (btFabs(d)>SIMD_EPSILON) + { + + solverConstraint.m_jacDiagABInv = relaxation/(d); + } else + { + solverConstraint.m_jacDiagABInv = 1.f; + } + + } + + + //compute rhs and remaining solverConstraint fields + + + + btScalar restitution = 0.f; + btScalar penetration = isFriction? 0 : cp.getDistance()+infoGlobal.m_linearSlop; + + btScalar rel_vel = 0.f; + int ndofA = 0; + int ndofB = 0; + { + + btVector3 vel1,vel2; + if (multiBodyA) + { + ndofA = multiBodyA->getNumLinks() + 6; + btScalar* jacA = &m_data.m_jacobians[solverConstraint.m_jacAindex]; + for (int i = 0; i < ndofA ; ++i) + rel_vel += multiBodyA->getVelocityVector()[i] * jacA[i]; + } else + { + if (rb0) + { + rel_vel += rb0->getVelocityInLocalPoint(rel_pos1).dot(solverConstraint.m_contactNormal1); + } + } + if (multiBodyB) + { + ndofB = multiBodyB->getNumLinks() + 6; + btScalar* jacB = &m_data.m_jacobians[solverConstraint.m_jacBindex]; + for (int i = 0; i < ndofB ; ++i) + rel_vel += multiBodyB->getVelocityVector()[i] * jacB[i]; + + } else + { + if (rb1) + { + rel_vel += rb1->getVelocityInLocalPoint(rel_pos2).dot(solverConstraint.m_contactNormal2); + } + } + + solverConstraint.m_friction = cp.m_combinedFriction; + + + restitution = restitutionCurve(rel_vel, cp.m_combinedRestitution); + if (restitution <= btScalar(0.)) + { + restitution = 0.f; + }; + } + + + ///warm starting (or zero if disabled) + if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) + { + solverConstraint.m_appliedImpulse = isFriction ? 0 : cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor; + + if (solverConstraint.m_appliedImpulse) + { + if (multiBodyA) + { + btScalar impulse = solverConstraint.m_appliedImpulse; + btScalar* deltaV = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacAindex]; + multiBodyA->applyDeltaVee(deltaV,impulse); + applyDeltaVee(deltaV,impulse,solverConstraint.m_deltaVelAindex,ndofA); + } else + { + if (rb0) + bodyA->internalApplyImpulse(solverConstraint.m_contactNormal1*bodyA->internalGetInvMass()*rb0->getLinearFactor(),solverConstraint.m_angularComponentA,solverConstraint.m_appliedImpulse); + } + if (multiBodyB) + { + btScalar impulse = solverConstraint.m_appliedImpulse; + btScalar* deltaV = &m_data.m_deltaVelocitiesUnitImpulse[solverConstraint.m_jacBindex]; + multiBodyB->applyDeltaVee(deltaV,impulse); + applyDeltaVee(deltaV,impulse,solverConstraint.m_deltaVelBindex,ndofB); + } else + { + if (rb1) + bodyB->internalApplyImpulse(-solverConstraint.m_contactNormal2*bodyB->internalGetInvMass()*rb1->getLinearFactor(),-solverConstraint.m_angularComponentB,-(btScalar)solverConstraint.m_appliedImpulse); + } + } + } else + { + solverConstraint.m_appliedImpulse = 0.f; + } + + solverConstraint.m_appliedPushImpulse = 0.f; + + { + + + btScalar positionalError = 0.f; + btScalar velocityError = restitution - rel_vel;// * damping; + + + btScalar erp = infoGlobal.m_erp2; + if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold)) + { + erp = infoGlobal.m_erp; + } + + if (penetration>0) + { + positionalError = 0; + velocityError = -penetration / infoGlobal.m_timeStep; + + } else + { + positionalError = -penetration * erp/infoGlobal.m_timeStep; + } + + btScalar penetrationImpulse = positionalError*solverConstraint.m_jacDiagABInv; + btScalar velocityImpulse = velocityError *solverConstraint.m_jacDiagABInv; + + if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold)) + { + //combine position and velocity into rhs + solverConstraint.m_rhs = penetrationImpulse+velocityImpulse; + solverConstraint.m_rhsPenetration = 0.f; + + } else + { + //split position and velocity into rhs and m_rhsPenetration + solverConstraint.m_rhs = velocityImpulse; + solverConstraint.m_rhsPenetration = penetrationImpulse; + } + + solverConstraint.m_cfm = 0.f; + solverConstraint.m_lowerLimit = 0; + solverConstraint.m_upperLimit = 1e10f; + } + +} + + + + +btMultiBodySolverConstraint& btMultiBodyConstraintSolver::addMultiBodyFrictionConstraint(const btVector3& normalAxis,btPersistentManifold* manifold,int frictionIndex,btManifoldPoint& cp,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, const btContactSolverInfo& infoGlobal, btScalar desiredVelocity, btScalar cfmSlip) +{ + BT_PROFILE("addMultiBodyFrictionConstraint"); + btMultiBodySolverConstraint& solverConstraint = m_multiBodyFrictionContactConstraints.expandNonInitializing(); + solverConstraint.m_frictionIndex = frictionIndex; + bool isFriction = true; + + const btMultiBodyLinkCollider* fcA = btMultiBodyLinkCollider::upcast(manifold->getBody0()); + const btMultiBodyLinkCollider* fcB = btMultiBodyLinkCollider::upcast(manifold->getBody1()); + + btMultiBody* mbA = fcA? fcA->m_multiBody : 0; + btMultiBody* mbB = fcB? fcB->m_multiBody : 0; + + int solverBodyIdA = mbA? -1 : getOrInitSolverBody(*colObj0,infoGlobal.m_timeStep); + int solverBodyIdB = mbB ? -1 : getOrInitSolverBody(*colObj1,infoGlobal.m_timeStep); + + solverConstraint.m_solverBodyIdA = solverBodyIdA; + solverConstraint.m_solverBodyIdB = solverBodyIdB; + solverConstraint.m_multiBodyA = mbA; + if (mbA) + solverConstraint.m_linkA = fcA->m_link; + + solverConstraint.m_multiBodyB = mbB; + if (mbB) + solverConstraint.m_linkB = fcB->m_link; + + solverConstraint.m_originalContactPoint = &cp; + + setupMultiBodyContactConstraint(solverConstraint, normalAxis, cp, infoGlobal,relaxation,isFriction, desiredVelocity, cfmSlip); + return solverConstraint; +} + +void btMultiBodyConstraintSolver::convertMultiBodyContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal) +{ + const btMultiBodyLinkCollider* fcA = btMultiBodyLinkCollider::upcast(manifold->getBody0()); + const btMultiBodyLinkCollider* fcB = btMultiBodyLinkCollider::upcast(manifold->getBody1()); + + btMultiBody* mbA = fcA? fcA->m_multiBody : 0; + btMultiBody* mbB = fcB? fcB->m_multiBody : 0; + + btCollisionObject* colObj0=0,*colObj1=0; + + colObj0 = (btCollisionObject*)manifold->getBody0(); + colObj1 = (btCollisionObject*)manifold->getBody1(); + + int solverBodyIdA = mbA? -1 : getOrInitSolverBody(*colObj0,infoGlobal.m_timeStep); + int solverBodyIdB = mbB ? -1 : getOrInitSolverBody(*colObj1,infoGlobal.m_timeStep); + + btSolverBody* solverBodyA = mbA ? 0 : &m_tmpSolverBodyPool[solverBodyIdA]; + btSolverBody* solverBodyB = mbB ? 0 : &m_tmpSolverBodyPool[solverBodyIdB]; + + + ///avoid collision response between two static objects +// if (!solverBodyA || (solverBodyA->m_invMass.isZero() && (!solverBodyB || solverBodyB->m_invMass.isZero()))) + // return; + + int rollingFriction=1; + + for (int j=0;jgetNumContacts();j++) + { + + btManifoldPoint& cp = manifold->getContactPoint(j); + + if (cp.getDistance() <= manifold->getContactProcessingThreshold()) + { + + btScalar relaxation; + + int frictionIndex = m_multiBodyNormalContactConstraints.size(); + + btMultiBodySolverConstraint& solverConstraint = m_multiBodyNormalContactConstraints.expandNonInitializing(); + + btRigidBody* rb0 = btRigidBody::upcast(colObj0); + btRigidBody* rb1 = btRigidBody::upcast(colObj1); + solverConstraint.m_solverBodyIdA = solverBodyIdA; + solverConstraint.m_solverBodyIdB = solverBodyIdB; + solverConstraint.m_multiBodyA = mbA; + if (mbA) + solverConstraint.m_linkA = fcA->m_link; + + solverConstraint.m_multiBodyB = mbB; + if (mbB) + solverConstraint.m_linkB = fcB->m_link; + + solverConstraint.m_originalContactPoint = &cp; + + bool isFriction = false; + setupMultiBodyContactConstraint(solverConstraint, cp.m_normalWorldOnB,cp, infoGlobal, relaxation, isFriction); + +// const btVector3& pos1 = cp.getPositionWorldOnA(); +// const btVector3& pos2 = cp.getPositionWorldOnB(); + + /////setup the friction constraints +#define ENABLE_FRICTION +#ifdef ENABLE_FRICTION + solverConstraint.m_frictionIndex = frictionIndex; +#if ROLLING_FRICTION + btVector3 angVelA(0,0,0),angVelB(0,0,0); + if (rb0) + angVelA = rb0->getAngularVelocity(); + if (rb1) + angVelB = rb1->getAngularVelocity(); + btVector3 relAngVel = angVelB-angVelA; + + if ((cp.m_combinedRollingFriction>0.f) && (rollingFriction>0)) + { + //only a single rollingFriction per manifold + rollingFriction--; + if (relAngVel.length()>infoGlobal.m_singleAxisRollingFrictionThreshold) + { + relAngVel.normalize(); + applyAnisotropicFriction(colObj0,relAngVel,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION); + applyAnisotropicFriction(colObj1,relAngVel,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION); + if (relAngVel.length()>0.001) + addRollingFrictionConstraint(relAngVel,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + + } else + { + addRollingFrictionConstraint(cp.m_normalWorldOnB,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + btVector3 axis0,axis1; + btPlaneSpace1(cp.m_normalWorldOnB,axis0,axis1); + applyAnisotropicFriction(colObj0,axis0,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION); + applyAnisotropicFriction(colObj1,axis0,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION); + applyAnisotropicFriction(colObj0,axis1,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION); + applyAnisotropicFriction(colObj1,axis1,btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION); + if (axis0.length()>0.001) + addRollingFrictionConstraint(axis0,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + if (axis1.length()>0.001) + addRollingFrictionConstraint(axis1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + + } + } +#endif //ROLLING_FRICTION + + ///Bullet has several options to set the friction directions + ///By default, each contact has only a single friction direction that is recomputed automatically very frame + ///based on the relative linear velocity. + ///If the relative velocity it zero, it will automatically compute a friction direction. + + ///You can also enable two friction directions, using the SOLVER_USE_2_FRICTION_DIRECTIONS. + ///In that case, the second friction direction will be orthogonal to both contact normal and first friction direction. + /// + ///If you choose SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION, then the friction will be independent from the relative projected velocity. + /// + ///The user can manually override the friction directions for certain contacts using a contact callback, + ///and set the cp.m_lateralFrictionInitialized to true + ///In that case, you can set the target relative motion in each friction direction (cp.m_contactMotion1 and cp.m_contactMotion2) + ///this will give a conveyor belt effect + /// + if (!(infoGlobal.m_solverMode & SOLVER_ENABLE_FRICTION_DIRECTION_CACHING) || !cp.m_lateralFrictionInitialized) + {/* + cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel; + btScalar lat_rel_vel = cp.m_lateralFrictionDir1.length2(); + if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON) + { + cp.m_lateralFrictionDir1 *= 1.f/btSqrt(lat_rel_vel); + if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + { + cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB); + cp.m_lateralFrictionDir2.normalize();//?? + applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION); + applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION); + addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + + } + + applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); + applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); + addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + + } else + */ + { + btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2); + + if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + { + applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION); + applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2,btCollisionObject::CF_ANISOTROPIC_FRICTION); + addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir2,manifold,frictionIndex,cp,colObj0,colObj1, relaxation,infoGlobal); + } + + applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); + applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1,btCollisionObject::CF_ANISOTROPIC_FRICTION); + addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir1,manifold,frictionIndex,cp,colObj0,colObj1, relaxation,infoGlobal); + + if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS) && (infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION)) + { + cp.m_lateralFrictionInitialized = true; + } + } + + } else + { + addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir1,manifold,frictionIndex,cp,colObj0,colObj1, relaxation,infoGlobal,cp.m_contactMotion1, cp.m_contactCFM1); + + if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + addMultiBodyFrictionConstraint(cp.m_lateralFrictionDir2,manifold,frictionIndex,cp,colObj0,colObj1, relaxation, infoGlobal,cp.m_contactMotion2, cp.m_contactCFM2); + + //setMultiBodyFrictionConstraintImpulse( solverConstraint, solverBodyIdA, solverBodyIdB, cp, infoGlobal); + //todo: + solverConstraint.m_appliedImpulse = 0.f; + solverConstraint.m_appliedPushImpulse = 0.f; + } + + +#endif //ENABLE_FRICTION + + } + } +} + +void btMultiBodyConstraintSolver::convertContacts(btPersistentManifold** manifoldPtr,int numManifolds, const btContactSolverInfo& infoGlobal) +{ + btPersistentManifold* manifold = 0; + + for (int i=0;igetBody0()); + const btMultiBodyLinkCollider* fcB = btMultiBodyLinkCollider::upcast(manifold->getBody1()); + if (!fcA && !fcB) + { + //the contact doesn't involve any Featherstone btMultiBody, so deal with the regular btRigidBody/btCollisionObject case + convertContact(manifold,infoGlobal); + } else + { + convertMultiBodyContact(manifold,infoGlobal); + } + } + + //also convert the multibody constraints, if any + + + for (int i=0;icreateConstraintRows(m_multiBodyNonContactConstraints,m_data, infoGlobal); + } + +} + + + +btScalar btMultiBodyConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher) +{ + return btSequentialImpulseConstraintSolver::solveGroup(bodies,numBodies,manifold,numManifolds,constraints,numConstraints,info,debugDrawer,dispatcher); +} + + +void btMultiBodyConstraintSolver::solveMultiBodyGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,btMultiBodyConstraint** multiBodyConstraints, int numMultiBodyConstraints, const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher) +{ + //printf("solveMultiBodyGroup start\n"); + m_tmpMultiBodyConstraints = multiBodyConstraints; + m_tmpNumMultiBodyConstraints = numMultiBodyConstraints; + + btSequentialImpulseConstraintSolver::solveGroup(bodies,numBodies,manifold,numManifolds,constraints,numConstraints,info,debugDrawer,dispatcher); + + m_tmpMultiBodyConstraints = 0; + m_tmpNumMultiBodyConstraints = 0; + + +} diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h new file mode 100644 index 00000000000..0f4cd69c029 --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h @@ -0,0 +1,85 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BT_MULTIBODY_CONSTRAINT_SOLVER_H +#define BT_MULTIBODY_CONSTRAINT_SOLVER_H + +#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" +#include "btMultiBodySolverConstraint.h" + + +class btMultiBody; + +#include "btMultiBodyConstraint.h" + + + +ATTRIBUTE_ALIGNED16(class) btMultiBodyConstraintSolver : public btSequentialImpulseConstraintSolver +{ + +protected: + + btMultiBodyConstraintArray m_multiBodyNonContactConstraints; + + btMultiBodyConstraintArray m_multiBodyNormalContactConstraints; + btMultiBodyConstraintArray m_multiBodyFrictionContactConstraints; + + btMultiBodyJacobianData m_data; + + //temp storage for multi body constraints for a specific island/group called by 'solveGroup' + btMultiBodyConstraint** m_tmpMultiBodyConstraints; + int m_tmpNumMultiBodyConstraints; + + void resolveSingleConstraintRowGeneric(const btMultiBodySolverConstraint& c); + void resolveSingleConstraintRowGenericMultiBody(const btMultiBodySolverConstraint& c); + + void convertContacts(btPersistentManifold** manifoldPtr,int numManifolds, const btContactSolverInfo& infoGlobal); + btMultiBodySolverConstraint& addMultiBodyFrictionConstraint(const btVector3& normalAxis,btPersistentManifold* manifold,int frictionIndex,btManifoldPoint& cp,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, const btContactSolverInfo& infoGlobal, btScalar desiredVelocity=0, btScalar cfmSlip=0); + + + void setupMultiBodyJointLimitConstraint(btMultiBodySolverConstraint& constraintRow, + btScalar* jacA,btScalar* jacB, + btScalar penetration,btScalar combinedFrictionCoeff, btScalar combinedRestitutionCoeff, + const btContactSolverInfo& infoGlobal); + + void setupMultiBodyContactConstraint(btMultiBodySolverConstraint& solverConstraint, + const btVector3& contactNormal, + btManifoldPoint& cp, const btContactSolverInfo& infoGlobal, + btScalar& relaxation, + bool isFriction, btScalar desiredVelocity=0, btScalar cfmSlip=0); + + void convertMultiBodyContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal); + virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); +// virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); + + virtual btScalar solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); + void applyDeltaVee(btScalar* deltaV, btScalar impulse, int velocityIndex, int ndof); + +public: + + BT_DECLARE_ALIGNED_ALLOCATOR(); + + ///this method should not be called, it was just used during porting/integration of Featherstone btMultiBody, providing backwards compatibility but no support for btMultiBodyConstraint (only contact constraints) + virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher); + + virtual void solveMultiBodyGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,btMultiBodyConstraint** multiBodyConstraints, int numMultiBodyConstraints, const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher); +}; + + + + + +#endif //BT_MULTIBODY_CONSTRAINT_SOLVER_H + diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp new file mode 100644 index 00000000000..0910f8f6abb --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp @@ -0,0 +1,578 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#include "btMultiBodyDynamicsWorld.h" +#include "btMultiBodyConstraintSolver.h" +#include "btMultiBody.h" +#include "btMultiBodyLinkCollider.h" +#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h" +#include "LinearMath/btQuickprof.h" +#include "btMultiBodyConstraint.h" + + + + +void btMultiBodyDynamicsWorld::addMultiBody(btMultiBody* body, short group, short mask) +{ + m_multiBodies.push_back(body); + +} + +void btMultiBodyDynamicsWorld::removeMultiBody(btMultiBody* body) +{ + m_multiBodies.remove(body); +} + +void btMultiBodyDynamicsWorld::calculateSimulationIslands() +{ + BT_PROFILE("calculateSimulationIslands"); + + getSimulationIslandManager()->updateActivationState(getCollisionWorld(),getCollisionWorld()->getDispatcher()); + + { + //merge islands based on speculative contact manifolds too + for (int i=0;im_predictiveManifolds.size();i++) + { + btPersistentManifold* manifold = m_predictiveManifolds[i]; + + const btCollisionObject* colObj0 = manifold->getBody0(); + const btCollisionObject* colObj1 = manifold->getBody1(); + + if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) && + ((colObj1) && (!(colObj1)->isStaticOrKinematicObject()))) + { + getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),(colObj1)->getIslandTag()); + } + } + } + + { + int i; + int numConstraints = int(m_constraints.size()); + for (i=0;i< numConstraints ; i++ ) + { + btTypedConstraint* constraint = m_constraints[i]; + if (constraint->isEnabled()) + { + const btRigidBody* colObj0 = &constraint->getRigidBodyA(); + const btRigidBody* colObj1 = &constraint->getRigidBodyB(); + + if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) && + ((colObj1) && (!(colObj1)->isStaticOrKinematicObject()))) + { + getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),(colObj1)->getIslandTag()); + } + } + } + } + + //merge islands linked by Featherstone link colliders + for (int i=0;igetBaseCollider(); + + for (int b=0;bgetNumLinks();b++) + { + btMultiBodyLinkCollider* cur = body->getLink(b).m_collider; + + if (((cur) && (!(cur)->isStaticOrKinematicObject())) && + ((prev) && (!(prev)->isStaticOrKinematicObject()))) + { + int tagPrev = prev->getIslandTag(); + int tagCur = cur->getIslandTag(); + getSimulationIslandManager()->getUnionFind().unite(tagPrev, tagCur); + } + if (cur && !cur->isStaticOrKinematicObject()) + prev = cur; + + } + } + } + + //merge islands linked by multibody constraints + { + for (int i=0;im_multiBodyConstraints.size();i++) + { + btMultiBodyConstraint* c = m_multiBodyConstraints[i]; + int tagA = c->getIslandIdA(); + int tagB = c->getIslandIdB(); + if (tagA>=0 && tagB>=0) + getSimulationIslandManager()->getUnionFind().unite(tagA, tagB); + } + } + + //Store the island id in each body + getSimulationIslandManager()->storeIslandActivationState(getCollisionWorld()); + +} + + +void btMultiBodyDynamicsWorld::updateActivationState(btScalar timeStep) +{ + BT_PROFILE("btMultiBodyDynamicsWorld::updateActivationState"); + + + + for ( int i=0;icheckMotionAndSleepIfRequired(timeStep); + if (!body->isAwake()) + { + btMultiBodyLinkCollider* col = body->getBaseCollider(); + if (col && col->getActivationState() == ACTIVE_TAG) + { + col->setActivationState( WANTS_DEACTIVATION); + col->setDeactivationTime(0.f); + } + for (int b=0;bgetNumLinks();b++) + { + btMultiBodyLinkCollider* col = body->getLink(b).m_collider; + if (col && col->getActivationState() == ACTIVE_TAG) + { + col->setActivationState( WANTS_DEACTIVATION); + col->setDeactivationTime(0.f); + } + } + } else + { + btMultiBodyLinkCollider* col = body->getBaseCollider(); + if (col && col->getActivationState() != DISABLE_DEACTIVATION) + col->setActivationState( ACTIVE_TAG ); + + for (int b=0;bgetNumLinks();b++) + { + btMultiBodyLinkCollider* col = body->getLink(b).m_collider; + if (col && col->getActivationState() != DISABLE_DEACTIVATION) + col->setActivationState( ACTIVE_TAG ); + } + } + + } + } + + btDiscreteDynamicsWorld::updateActivationState(timeStep); +} + + +SIMD_FORCE_INLINE int btGetConstraintIslandId2(const btTypedConstraint* lhs) +{ + int islandId; + + const btCollisionObject& rcolObj0 = lhs->getRigidBodyA(); + const btCollisionObject& rcolObj1 = lhs->getRigidBodyB(); + islandId= rcolObj0.getIslandTag()>=0?rcolObj0.getIslandTag():rcolObj1.getIslandTag(); + return islandId; + +} + + +class btSortConstraintOnIslandPredicate2 +{ + public: + + bool operator() ( const btTypedConstraint* lhs, const btTypedConstraint* rhs ) const + { + int rIslandId0,lIslandId0; + rIslandId0 = btGetConstraintIslandId2(rhs); + lIslandId0 = btGetConstraintIslandId2(lhs); + return lIslandId0 < rIslandId0; + } +}; + + + +SIMD_FORCE_INLINE int btGetMultiBodyConstraintIslandId(const btMultiBodyConstraint* lhs) +{ + int islandId; + + int islandTagA = lhs->getIslandIdA(); + int islandTagB = lhs->getIslandIdB(); + islandId= islandTagA>=0?islandTagA:islandTagB; + return islandId; + +} + + +class btSortMultiBodyConstraintOnIslandPredicate +{ + public: + + bool operator() ( const btMultiBodyConstraint* lhs, const btMultiBodyConstraint* rhs ) const + { + int rIslandId0,lIslandId0; + rIslandId0 = btGetMultiBodyConstraintIslandId(rhs); + lIslandId0 = btGetMultiBodyConstraintIslandId(lhs); + return lIslandId0 < rIslandId0; + } +}; + +struct MultiBodyInplaceSolverIslandCallback : public btSimulationIslandManager::IslandCallback +{ + btContactSolverInfo* m_solverInfo; + btMultiBodyConstraintSolver* m_solver; + btMultiBodyConstraint** m_multiBodySortedConstraints; + int m_numMultiBodyConstraints; + + btTypedConstraint** m_sortedConstraints; + int m_numConstraints; + btIDebugDraw* m_debugDrawer; + btDispatcher* m_dispatcher; + + btAlignedObjectArray m_bodies; + btAlignedObjectArray m_manifolds; + btAlignedObjectArray m_constraints; + btAlignedObjectArray m_multiBodyConstraints; + + + MultiBodyInplaceSolverIslandCallback( btMultiBodyConstraintSolver* solver, + btDispatcher* dispatcher) + :m_solverInfo(NULL), + m_solver(solver), + m_multiBodySortedConstraints(NULL), + m_numConstraints(0), + m_debugDrawer(NULL), + m_dispatcher(dispatcher) + { + + } + + MultiBodyInplaceSolverIslandCallback& operator=(MultiBodyInplaceSolverIslandCallback& other) + { + btAssert(0); + (void)other; + return *this; + } + + SIMD_FORCE_INLINE void setup ( btContactSolverInfo* solverInfo, btTypedConstraint** sortedConstraints, int numConstraints, btMultiBodyConstraint** sortedMultiBodyConstraints, int numMultiBodyConstraints, btIDebugDraw* debugDrawer) + { + btAssert(solverInfo); + m_solverInfo = solverInfo; + + m_multiBodySortedConstraints = sortedMultiBodyConstraints; + m_numMultiBodyConstraints = numMultiBodyConstraints; + m_sortedConstraints = sortedConstraints; + m_numConstraints = numConstraints; + + m_debugDrawer = debugDrawer; + m_bodies.resize (0); + m_manifolds.resize (0); + m_constraints.resize (0); + m_multiBodyConstraints.resize(0); + } + + + virtual void processIsland(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifolds,int numManifolds, int islandId) + { + if (islandId<0) + { + ///we don't split islands, so all constraints/contact manifolds/bodies are passed into the solver regardless the island id + m_solver->solveMultiBodyGroup( bodies,numBodies,manifolds, numManifolds,m_sortedConstraints, m_numConstraints, &m_multiBodySortedConstraints[0],m_numConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher); + } else + { + //also add all non-contact constraints/joints for this island + btTypedConstraint** startConstraint = 0; + btMultiBodyConstraint** startMultiBodyConstraint = 0; + + int numCurConstraints = 0; + int numCurMultiBodyConstraints = 0; + + int i; + + //find the first constraint for this island + + for (i=0;im_minimumSolverBatchSize<=1) + { + m_solver->solveGroup( bodies,numBodies,manifolds, numManifolds,startConstraint,numCurConstraints,*m_solverInfo,m_debugDrawer,m_dispatcher); + } else + { + + for (i=0;im_solverInfo->m_minimumSolverBatchSize) + { + processConstraints(); + } else + { + //printf("deferred\n"); + } + } + } + } + void processConstraints() + { + + btCollisionObject** bodies = m_bodies.size()? &m_bodies[0]:0; + btPersistentManifold** manifold = m_manifolds.size()?&m_manifolds[0]:0; + btTypedConstraint** constraints = m_constraints.size()?&m_constraints[0]:0; + btMultiBodyConstraint** multiBodyConstraints = m_multiBodyConstraints.size() ? &m_multiBodyConstraints[0] : 0; + + m_solver->solveMultiBodyGroup( bodies,m_bodies.size(),manifold, m_manifolds.size(),constraints, m_constraints.size() ,multiBodyConstraints, m_multiBodyConstraints.size(), *m_solverInfo,m_debugDrawer,m_dispatcher); + m_bodies.resize(0); + m_manifolds.resize(0); + m_constraints.resize(0); + m_multiBodyConstraints.resize(0); + } + +}; + + + +btMultiBodyDynamicsWorld::btMultiBodyDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btMultiBodyConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration) + :btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration), + m_multiBodyConstraintSolver(constraintSolver) +{ + //split impulse is not yet supported for Featherstone hierarchies + getSolverInfo().m_splitImpulse = false; + getSolverInfo().m_solverMode |=SOLVER_USE_2_FRICTION_DIRECTIONS; + m_solverMultiBodyIslandCallback = new MultiBodyInplaceSolverIslandCallback(constraintSolver,dispatcher); +} + +btMultiBodyDynamicsWorld::~btMultiBodyDynamicsWorld () +{ + delete m_solverMultiBodyIslandCallback; +} + + + + +void btMultiBodyDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo) +{ + + btAlignedObjectArray scratch_r; + btAlignedObjectArray scratch_v; + btAlignedObjectArray scratch_m; + + + BT_PROFILE("solveConstraints"); + + m_sortedConstraints.resize( m_constraints.size()); + int i; + for (i=0;isetup(&solverInfo,constraintsPtr,m_sortedConstraints.size(),sortedMultiBodyConstraints,m_sortedMultiBodyConstraints.size(), getDebugDrawer()); + m_constraintSolver->prepareSolve(getCollisionWorld()->getNumCollisionObjects(), getCollisionWorld()->getDispatcher()->getNumManifolds()); + + /// solve all the constraints for this island + m_islandManager->buildAndProcessIslands(getCollisionWorld()->getDispatcher(),getCollisionWorld(),m_solverMultiBodyIslandCallback); + + + { + BT_PROFILE("btMultiBody addForce and stepVelocities"); + for (int i=0;im_multiBodies.size();i++) + { + btMultiBody* bod = m_multiBodies[i]; + + bool isSleeping = false; + + if (bod->getBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING) + { + isSleeping = true; + } + for (int b=0;bgetNumLinks();b++) + { + if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState()==ISLAND_SLEEPING) + isSleeping = true; + } + + if (!isSleeping) + { + scratch_r.resize(bod->getNumLinks()+1); + scratch_v.resize(bod->getNumLinks()+1); + scratch_m.resize(bod->getNumLinks()+1); + + bod->clearForcesAndTorques(); + bod->addBaseForce(m_gravity * bod->getBaseMass()); + + for (int j = 0; j < bod->getNumLinks(); ++j) + { + bod->addLinkForce(j, m_gravity * bod->getLinkMass(j)); + } + + bod->stepVelocities(solverInfo.m_timeStep, scratch_r, scratch_v, scratch_m); + } + } + } + + m_solverMultiBodyIslandCallback->processConstraints(); + + m_constraintSolver->allSolved(solverInfo, m_debugDrawer); + +} + +void btMultiBodyDynamicsWorld::integrateTransforms(btScalar timeStep) +{ + btDiscreteDynamicsWorld::integrateTransforms(timeStep); + + { + BT_PROFILE("btMultiBody stepPositions"); + //integrate and update the Featherstone hierarchies + btAlignedObjectArray world_to_local; + btAlignedObjectArray local_origin; + + for (int b=0;bgetBaseCollider() && bod->getBaseCollider()->getActivationState() == ISLAND_SLEEPING) + { + isSleeping = true; + } + for (int b=0;bgetNumLinks();b++) + { + if (bod->getLink(b).m_collider && bod->getLink(b).m_collider->getActivationState()==ISLAND_SLEEPING) + isSleeping = true; + } + + + if (!isSleeping) + { + int nLinks = bod->getNumLinks(); + + ///base + num links + world_to_local.resize(nLinks+1); + local_origin.resize(nLinks+1); + + bod->stepPositions(timeStep); + + + + world_to_local[0] = bod->getWorldToBaseRot(); + local_origin[0] = bod->getBasePos(); + + if (bod->getBaseCollider()) + { + btVector3 posr = local_origin[0]; + float pos[4]={posr.x(),posr.y(),posr.z(),1}; + float quat[4]={-world_to_local[0].x(),-world_to_local[0].y(),-world_to_local[0].z(),world_to_local[0].w()}; + btTransform tr; + tr.setIdentity(); + tr.setOrigin(posr); + tr.setRotation(btQuaternion(quat[0],quat[1],quat[2],quat[3])); + + bod->getBaseCollider()->setWorldTransform(tr); + + } + + for (int k=0;kgetNumLinks();k++) + { + const int parent = bod->getParent(k); + world_to_local[k+1] = bod->getParentToLocalRot(k) * world_to_local[parent+1]; + local_origin[k+1] = local_origin[parent+1] + (quatRotate(world_to_local[k+1].inverse() , bod->getRVector(k))); + } + + + for (int m=0;mgetNumLinks();m++) + { + btMultiBodyLinkCollider* col = bod->getLink(m).m_collider; + if (col) + { + int link = col->m_link; + btAssert(link == m); + + int index = link+1; + + btVector3 posr = local_origin[index]; + float pos[4]={posr.x(),posr.y(),posr.z(),1}; + float quat[4]={-world_to_local[index].x(),-world_to_local[index].y(),-world_to_local[index].z(),world_to_local[index].w()}; + btTransform tr; + tr.setIdentity(); + tr.setOrigin(posr); + tr.setRotation(btQuaternion(quat[0],quat[1],quat[2],quat[3])); + + col->setWorldTransform(tr); + } + } + } else + { + bod->clearVelocities(); + } + } + } +} + + + +void btMultiBodyDynamicsWorld::addMultiBodyConstraint( btMultiBodyConstraint* constraint) +{ + m_multiBodyConstraints.push_back(constraint); +} + +void btMultiBodyDynamicsWorld::removeMultiBodyConstraint( btMultiBodyConstraint* constraint) +{ + m_multiBodyConstraints.remove(constraint); +} diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h new file mode 100644 index 00000000000..ad57a346dcc --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h @@ -0,0 +1,56 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BT_MULTIBODY_DYNAMICS_WORLD_H +#define BT_MULTIBODY_DYNAMICS_WORLD_H + +#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h" + + +class btMultiBody; +class btMultiBodyConstraint; +class btMultiBodyConstraintSolver; +struct MultiBodyInplaceSolverIslandCallback; + +///The btMultiBodyDynamicsWorld adds Featherstone multi body dynamics to Bullet +///This implementation is still preliminary/experimental. +class btMultiBodyDynamicsWorld : public btDiscreteDynamicsWorld +{ +protected: + btAlignedObjectArray m_multiBodies; + btAlignedObjectArray m_multiBodyConstraints; + btAlignedObjectArray m_sortedMultiBodyConstraints; + btMultiBodyConstraintSolver* m_multiBodyConstraintSolver; + MultiBodyInplaceSolverIslandCallback* m_solverMultiBodyIslandCallback; + + virtual void calculateSimulationIslands(); + virtual void updateActivationState(btScalar timeStep); + virtual void solveConstraints(btContactSolverInfo& solverInfo); + virtual void integrateTransforms(btScalar timeStep); +public: + + btMultiBodyDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btMultiBodyConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration); + + virtual ~btMultiBodyDynamicsWorld (); + + virtual void addMultiBody(btMultiBody* body, short group= btBroadphaseProxy::DefaultFilter, short mask=btBroadphaseProxy::AllFilter); + + virtual void removeMultiBody(btMultiBody* body); + + virtual void addMultiBodyConstraint( btMultiBodyConstraint* constraint); + + virtual void removeMultiBodyConstraint( btMultiBodyConstraint* constraint); +}; +#endif //BT_MULTIBODY_DYNAMICS_WORLD_H diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp new file mode 100644 index 00000000000..ea309e8857d --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp @@ -0,0 +1,133 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +///This file was written by Erwin Coumans + +#include "btMultiBodyJointLimitConstraint.h" +#include "btMultiBody.h" +#include "btMultiBodyLinkCollider.h" +#include "BulletCollision/CollisionDispatch/btCollisionObject.h" + + +btMultiBodyJointLimitConstraint::btMultiBodyJointLimitConstraint(btMultiBody* body, int link, btScalar lower, btScalar upper) + :btMultiBodyConstraint(body,body,link,link,2,true), + m_lowerBound(lower), + m_upperBound(upper) +{ + // the data.m_jacobians never change, so may as well + // initialize them here + + // note: we rely on the fact that data.m_jacobians are + // always initialized to zero by the Constraint ctor + + // row 0: the lower bound + jacobianA(0)[6 + link] = 1; + + // row 1: the upper bound + jacobianB(1)[6 + link] = -1; +} +btMultiBodyJointLimitConstraint::~btMultiBodyJointLimitConstraint() +{ +} + +int btMultiBodyJointLimitConstraint::getIslandIdA() const +{ + btMultiBodyLinkCollider* col = m_bodyA->getBaseCollider(); + if (col) + return col->getIslandTag(); + for (int i=0;igetNumLinks();i++) + { + if (m_bodyA->getLink(i).m_collider) + return m_bodyA->getLink(i).m_collider->getIslandTag(); + } + return -1; +} + +int btMultiBodyJointLimitConstraint::getIslandIdB() const +{ + btMultiBodyLinkCollider* col = m_bodyB->getBaseCollider(); + if (col) + return col->getIslandTag(); + + for (int i=0;igetNumLinks();i++) + { + col = m_bodyB->getLink(i).m_collider; + if (col) + return col->getIslandTag(); + } + return -1; +} + + +void btMultiBodyJointLimitConstraint::createConstraintRows(btMultiBodyConstraintArray& constraintRows, + btMultiBodyJacobianData& data, + const btContactSolverInfo& infoGlobal) +{ + // only positions need to be updated -- data.m_jacobians and force + // directions were set in the ctor and never change. + + // row 0: the lower bound + setPosition(0, m_bodyA->getJointPos(m_linkA) - m_lowerBound); + + // row 1: the upper bound + setPosition(1, m_upperBound - m_bodyA->getJointPos(m_linkA)); + + for (int row=0;row infoGlobal.m_splitImpulsePenetrationThreshold)) + { + erp = infoGlobal.m_erp; + } + if (penetration>0) + { + positionalError = 0; + velocityError = -penetration / infoGlobal.m_timeStep; + } else + { + positionalError = -penetration * erp/infoGlobal.m_timeStep; + } + + btScalar penetrationImpulse = positionalError*constraintRow.m_jacDiagABInv; + btScalar velocityImpulse = velocityError *constraintRow.m_jacDiagABInv; + if (!infoGlobal.m_splitImpulse || (penetration > infoGlobal.m_splitImpulsePenetrationThreshold)) + { + //combine position and velocity into rhs + constraintRow.m_rhs = penetrationImpulse+velocityImpulse; + constraintRow.m_rhsPenetration = 0.f; + + } else + { + //split position and velocity into rhs and m_rhsPenetration + constraintRow.m_rhs = velocityImpulse; + constraintRow.m_rhsPenetration = penetrationImpulse; + } + } + } + +} + + + + diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.h new file mode 100644 index 00000000000..0c7fc170822 --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.h @@ -0,0 +1,44 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BT_MULTIBODY_JOINT_LIMIT_CONSTRAINT_H +#define BT_MULTIBODY_JOINT_LIMIT_CONSTRAINT_H + +#include "btMultiBodyConstraint.h" +struct btSolverInfo; + +class btMultiBodyJointLimitConstraint : public btMultiBodyConstraint +{ +protected: + + btScalar m_lowerBound; + btScalar m_upperBound; +public: + + btMultiBodyJointLimitConstraint(btMultiBody* body, int link, btScalar lower, btScalar upper); + virtual ~btMultiBodyJointLimitConstraint(); + + virtual int getIslandIdA() const; + virtual int getIslandIdB() const; + + virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows, + btMultiBodyJacobianData& data, + const btContactSolverInfo& infoGlobal); + + +}; + +#endif //BT_MULTIBODY_JOINT_LIMIT_CONSTRAINT_H + diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp new file mode 100644 index 00000000000..ab5a430231b --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp @@ -0,0 +1,89 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +///This file was written by Erwin Coumans + +#include "btMultiBodyJointMotor.h" +#include "btMultiBody.h" +#include "btMultiBodyLinkCollider.h" +#include "BulletCollision/CollisionDispatch/btCollisionObject.h" + + +btMultiBodyJointMotor::btMultiBodyJointMotor(btMultiBody* body, int link, btScalar desiredVelocity, btScalar maxMotorImpulse) + :btMultiBodyConstraint(body,body,link,link,1,true), + m_desiredVelocity(desiredVelocity) +{ + m_maxAppliedImpulse = maxMotorImpulse; + // the data.m_jacobians never change, so may as well + // initialize them here + + // note: we rely on the fact that data.m_jacobians are + // always initialized to zero by the Constraint ctor + + // row 0: the lower bound + jacobianA(0)[6 + link] = 1; +} +btMultiBodyJointMotor::~btMultiBodyJointMotor() +{ +} + +int btMultiBodyJointMotor::getIslandIdA() const +{ + btMultiBodyLinkCollider* col = m_bodyA->getBaseCollider(); + if (col) + return col->getIslandTag(); + for (int i=0;igetNumLinks();i++) + { + if (m_bodyA->getLink(i).m_collider) + return m_bodyA->getLink(i).m_collider->getIslandTag(); + } + return -1; +} + +int btMultiBodyJointMotor::getIslandIdB() const +{ + btMultiBodyLinkCollider* col = m_bodyB->getBaseCollider(); + if (col) + return col->getIslandTag(); + + for (int i=0;igetNumLinks();i++) + { + col = m_bodyB->getLink(i).m_collider; + if (col) + return col->getIslandTag(); + } + return -1; +} + + +void btMultiBodyJointMotor::createConstraintRows(btMultiBodyConstraintArray& constraintRows, + btMultiBodyJacobianData& data, + const btContactSolverInfo& infoGlobal) +{ + // only positions need to be updated -- data.m_jacobians and force + // directions were set in the ctor and never change. + + + + for (int row=0;row=0 || (multiBody && !multiBody->hasFixedBase())) + { + m_collisionFlags &= (~btCollisionObject::CF_STATIC_OBJECT); + } + // else + //{ + // m_collisionFlags |= (btCollisionObject::CF_STATIC_OBJECT); + //} + + m_internalType = CO_FEATHERSTONE_LINK; + } + static btMultiBodyLinkCollider* upcast(btCollisionObject* colObj) + { + if (colObj->getInternalType()&btCollisionObject::CO_FEATHERSTONE_LINK) + return (btMultiBodyLinkCollider*)colObj; + return 0; + } + static const btMultiBodyLinkCollider* upcast(const btCollisionObject* colObj) + { + if (colObj->getInternalType()&btCollisionObject::CO_FEATHERSTONE_LINK) + return (btMultiBodyLinkCollider*)colObj; + return 0; + } + + virtual bool checkCollideWithOverride(const btCollisionObject* co) const + { + const btMultiBodyLinkCollider* other = btMultiBodyLinkCollider::upcast(co); + if (!other) + return true; + if (other->m_multiBody != this->m_multiBody) + return true; + if (!m_multiBody->hasSelfCollision()) + return false; + + //check if 'link' has collision disabled + if (m_link>=0) + { + const btMultibodyLink& link = m_multiBody->getLink(this->m_link); + if ((link.m_flags&BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION) && link.parent == other->m_link) + return false; + } + + if (other->m_link>=0) + { + const btMultibodyLink& otherLink = other->m_multiBody->getLink(other->m_link); + if ((otherLink.m_flags& BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION) && otherLink.parent == this->m_link) + return false; + } + return true; + } +}; + +#endif //BT_FEATHERSTONE_LINK_COLLIDER_H + diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp new file mode 100644 index 00000000000..f6690049156 --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp @@ -0,0 +1,143 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +///This file was written by Erwin Coumans + +#include "btMultiBodyPoint2Point.h" +#include "btMultiBodyLinkCollider.h" +#include "BulletDynamics/Dynamics/btRigidBody.h" + +btMultiBodyPoint2Point::btMultiBodyPoint2Point(btMultiBody* body, int link, btRigidBody* bodyB, const btVector3& pivotInA, const btVector3& pivotInB) + :btMultiBodyConstraint(body,0,link,-1,3,false), + m_rigidBodyA(0), + m_rigidBodyB(bodyB), + m_pivotInA(pivotInA), + m_pivotInB(pivotInB) +{ +} + +btMultiBodyPoint2Point::btMultiBodyPoint2Point(btMultiBody* bodyA, int linkA, btMultiBody* bodyB, int linkB, const btVector3& pivotInA, const btVector3& pivotInB) + :btMultiBodyConstraint(bodyA,bodyB,linkA,linkB,3,false), + m_rigidBodyA(0), + m_rigidBodyB(0), + m_pivotInA(pivotInA), + m_pivotInB(pivotInB) +{ +} + + +btMultiBodyPoint2Point::~btMultiBodyPoint2Point() +{ +} + + +int btMultiBodyPoint2Point::getIslandIdA() const +{ + if (m_rigidBodyA) + return m_rigidBodyA->getIslandTag(); + + if (m_bodyA) + { + btMultiBodyLinkCollider* col = m_bodyA->getBaseCollider(); + if (col) + return col->getIslandTag(); + for (int i=0;igetNumLinks();i++) + { + if (m_bodyA->getLink(i).m_collider) + return m_bodyA->getLink(i).m_collider->getIslandTag(); + } + } + return -1; +} + +int btMultiBodyPoint2Point::getIslandIdB() const +{ + if (m_rigidBodyB) + return m_rigidBodyB->getIslandTag(); + if (m_bodyB) + { + btMultiBodyLinkCollider* col = m_bodyB->getBaseCollider(); + if (col) + return col->getIslandTag(); + + for (int i=0;igetNumLinks();i++) + { + col = m_bodyB->getLink(i).m_collider; + if (col) + return col->getIslandTag(); + } + } + return -1; +} + + + +void btMultiBodyPoint2Point::createConstraintRows(btMultiBodyConstraintArray& constraintRows, + btMultiBodyJacobianData& data, + const btContactSolverInfo& infoGlobal) +{ + +// int i=1; + for (int i=0;i<3;i++) + { + + btMultiBodySolverConstraint& constraintRow = constraintRows.expandNonInitializing(); + + constraintRow.m_solverBodyIdA = data.m_fixedBodyId; + constraintRow.m_solverBodyIdB = data.m_fixedBodyId; + + + btVector3 contactNormalOnB(0,0,0); + contactNormalOnB[i] = -1; + + btScalar penetration = 0; + + // Convert local points back to world + btVector3 pivotAworld = m_pivotInA; + if (m_rigidBodyA) + { + + constraintRow.m_solverBodyIdA = m_rigidBodyA->getCompanionId(); + pivotAworld = m_rigidBodyA->getCenterOfMassTransform()*m_pivotInA; + } else + { + if (m_bodyA) + pivotAworld = m_bodyA->localPosToWorld(m_linkA, m_pivotInA); + } + btVector3 pivotBworld = m_pivotInB; + if (m_rigidBodyB) + { + constraintRow.m_solverBodyIdB = m_rigidBodyB->getCompanionId(); + pivotBworld = m_rigidBodyB->getCenterOfMassTransform()*m_pivotInB; + } else + { + if (m_bodyB) + pivotBworld = m_bodyB->localPosToWorld(m_linkB, m_pivotInB); + + } + btScalar position = (pivotAworld-pivotBworld).dot(contactNormalOnB); + btScalar relaxation = 1.f; + fillMultiBodyConstraintMixed(constraintRow, data, + contactNormalOnB, + pivotAworld, pivotBworld, + position, + infoGlobal, + relaxation, + false); + constraintRow.m_lowerLimit = -m_maxAppliedImpulse; + constraintRow.m_upperLimit = m_maxAppliedImpulse; + + } +} diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.h new file mode 100644 index 00000000000..26ca12b406d --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.h @@ -0,0 +1,60 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +///This file was written by Erwin Coumans + +#ifndef BT_MULTIBODY_POINT2POINT_H +#define BT_MULTIBODY_POINT2POINT_H + +#include "btMultiBodyConstraint.h" + +class btMultiBodyPoint2Point : public btMultiBodyConstraint +{ +protected: + + btRigidBody* m_rigidBodyA; + btRigidBody* m_rigidBodyB; + btVector3 m_pivotInA; + btVector3 m_pivotInB; + + +public: + + btMultiBodyPoint2Point(btMultiBody* body, int link, btRigidBody* bodyB, const btVector3& pivotInA, const btVector3& pivotInB); + btMultiBodyPoint2Point(btMultiBody* bodyA, int linkA, btMultiBody* bodyB, int linkB, const btVector3& pivotInA, const btVector3& pivotInB); + + virtual ~btMultiBodyPoint2Point(); + + virtual int getIslandIdA() const; + virtual int getIslandIdB() const; + + virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows, + btMultiBodyJacobianData& data, + const btContactSolverInfo& infoGlobal); + + const btVector3& getPivotInB() const + { + return m_pivotInB; + } + + void setPivotInB(const btVector3& pivotInB) + { + m_pivotInB = pivotInB; + } + + +}; + +#endif //BT_MULTIBODY_POINT2POINT_H diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodySolverConstraint.h b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodySolverConstraint.h new file mode 100644 index 00000000000..cf06dfb9ebf --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodySolverConstraint.h @@ -0,0 +1,82 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BT_MULTIBODY_SOLVER_CONSTRAINT_H +#define BT_MULTIBODY_SOLVER_CONSTRAINT_H + +#include "LinearMath/btVector3.h" +#include "LinearMath/btAlignedObjectArray.h" + +class btMultiBody; +#include "BulletDynamics/ConstraintSolver/btSolverBody.h" +#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" + +///1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and friction constraints. +ATTRIBUTE_ALIGNED16 (struct) btMultiBodySolverConstraint +{ + BT_DECLARE_ALIGNED_ALLOCATOR(); + + + int m_deltaVelAindex;//more generic version of m_relpos1CrossNormal/m_contactNormal1 + btVector3 m_relpos1CrossNormal; + btVector3 m_contactNormal1; + int m_jacAindex; + + int m_deltaVelBindex; + btVector3 m_relpos2CrossNormal; + btVector3 m_contactNormal2; //usually m_contactNormal2 == -m_contactNormal1, but not always + int m_jacBindex; + + btVector3 m_angularComponentA; + btVector3 m_angularComponentB; + + mutable btSimdScalar m_appliedPushImpulse; + mutable btSimdScalar m_appliedImpulse; + + btScalar m_friction; + btScalar m_jacDiagABInv; + btScalar m_rhs; + btScalar m_cfm; + + btScalar m_lowerLimit; + btScalar m_upperLimit; + btScalar m_rhsPenetration; + union + { + void* m_originalContactPoint; + btScalar m_unusedPadding4; + }; + + int m_overrideNumSolverIterations; + int m_frictionIndex; + + int m_solverBodyIdA; + btMultiBody* m_multiBodyA; + int m_linkA; + + int m_solverBodyIdB; + btMultiBody* m_multiBodyB; + int m_linkB; + + enum btSolverConstraintType + { + BT_SOLVER_CONTACT_1D = 0, + BT_SOLVER_FRICTION_1D + }; +}; + +typedef btAlignedObjectArray btMultiBodyConstraintArray; + +#endif //BT_MULTIBODY_SOLVER_CONSTRAINT_H diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp new file mode 100644 index 00000000000..3bf7b5c1311 --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp @@ -0,0 +1,2079 @@ +/************************************************************************* +* * +* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * +* All rights reserved. Email: russ@q12.org Web: www.q12.org * +* * +* This library is free software; you can redistribute it and/or * +* modify it under the terms of EITHER: * +* (1) The GNU Lesser General Public License as published by the Free * +* Software Foundation; either version 2.1 of the License, or (at * +* your option) any later version. The text of the GNU Lesser * +* General Public License is included with this library in the * +* file LICENSE.TXT. * +* (2) The BSD-style license that is included with this library in * +* the file LICENSE-BSD.TXT. * +* * +* This library 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 files * +* LICENSE.TXT and LICENSE-BSD.TXT for more details. * +* * +*************************************************************************/ + +/* + + +THE ALGORITHM +------------- + +solve A*x = b+w, with x and w subject to certain LCP conditions. +each x(i),w(i) must lie on one of the three line segments in the following +diagram. each line segment corresponds to one index set : + + w(i) + /|\ | : + | | : + | |i in N : + w>0 | |state[i]=0 : + | | : + | | : i in C + w=0 + +-----------------------+ + | : | + | : | + w<0 | : |i in N + | : |state[i]=1 + | : | + | : | + +-------|-----------|-----------|----------> x(i) + lo 0 hi + +the Dantzig algorithm proceeds as follows: + for i=1:n + * if (x(i),w(i)) is not on the line, push x(i) and w(i) positive or + negative towards the line. as this is done, the other (x(j),w(j)) + for j= 0. this makes the algorithm a bit +simpler, because the starting point for x(i),w(i) is always on the dotted +line x=0 and x will only ever increase in one direction, so it can only hit +two out of the three line segments. + + +NOTES +----- + +this is an implementation of "lcp_dantzig2_ldlt.m" and "lcp_dantzig_lohi.m". +the implementation is split into an LCP problem object (btLCP) and an LCP +driver function. most optimization occurs in the btLCP object. + +a naive implementation of the algorithm requires either a lot of data motion +or a lot of permutation-array lookup, because we are constantly re-ordering +rows and columns. to avoid this and make a more optimized algorithm, a +non-trivial data structure is used to represent the matrix A (this is +implemented in the fast version of the btLCP object). + +during execution of this algorithm, some indexes in A are clamped (set C), +some are non-clamped (set N), and some are "don't care" (where x=0). +A,x,b,w (and other problem vectors) are permuted such that the clamped +indexes are first, the unclamped indexes are next, and the don't-care +indexes are last. this permutation is recorded in the array `p'. +initially p = 0..n-1, and as the rows and columns of A,x,b,w are swapped, +the corresponding elements of p are swapped. + +because the C and N elements are grouped together in the rows of A, we can do +lots of work with a fast dot product function. if A,x,etc were not permuted +and we only had a permutation array, then those dot products would be much +slower as we would have a permutation array lookup in some inner loops. + +A is accessed through an array of row pointers, so that element (i,j) of the +permuted matrix is A[i][j]. this makes row swapping fast. for column swapping +we still have to actually move the data. + +during execution of this algorithm we maintain an L*D*L' factorization of +the clamped submatrix of A (call it `AC') which is the top left nC*nC +submatrix of A. there are two ways we could arrange the rows/columns in AC. + +(1) AC is always permuted such that L*D*L' = AC. this causes a problem +when a row/column is removed from C, because then all the rows/columns of A +between the deleted index and the end of C need to be rotated downward. +this results in a lot of data motion and slows things down. +(2) L*D*L' is actually a factorization of a *permutation* of AC (which is +itself a permutation of the underlying A). this is what we do - the +permutation is recorded in the vector C. call this permutation A[C,C]. +when a row/column is removed from C, all we have to do is swap two +rows/columns and manipulate C. + +*/ + + +#include "btDantzigLCP.h" + +#include //memcpy + +bool s_error = false; + +//*************************************************************************** +// code generation parameters + + +#define btLCP_FAST // use fast btLCP object + +// option 1 : matrix row pointers (less data copying) +#define BTROWPTRS +#define BTATYPE btScalar ** +#define BTAROW(i) (m_A[i]) + +// option 2 : no matrix row pointers (slightly faster inner loops) +//#define NOROWPTRS +//#define BTATYPE btScalar * +//#define BTAROW(i) (m_A+(i)*m_nskip) + +#define BTNUB_OPTIMIZATIONS + + + +/* solve L*X=B, with B containing 1 right hand sides. + * L is an n*n lower triangular matrix with ones on the diagonal. + * L is stored by rows and its leading dimension is lskip. + * B is an n*1 matrix that contains the right hand sides. + * B is stored by columns and its leading dimension is also lskip. + * B is overwritten with X. + * this processes blocks of 2*2. + * if this is in the factorizer source file, n must be a multiple of 2. + */ + +static void btSolveL1_1 (const btScalar *L, btScalar *B, int n, int lskip1) +{ + /* declare variables - Z matrix, p and q vectors, etc */ + btScalar Z11,m11,Z21,m21,p1,q1,p2,*ex; + const btScalar *ell; + int i,j; + /* compute all 2 x 1 blocks of X */ + for (i=0; i < n; i+=2) { + /* compute all 2 x 1 block of X, from rows i..i+2-1 */ + /* set the Z matrix to 0 */ + Z11=0; + Z21=0; + ell = L + i*lskip1; + ex = B; + /* the inner loop that computes outer products and adds them to Z */ + for (j=i-2; j >= 0; j -= 2) { + /* compute outer product and add it to the Z matrix */ + p1=ell[0]; + q1=ex[0]; + m11 = p1 * q1; + p2=ell[lskip1]; + m21 = p2 * q1; + Z11 += m11; + Z21 += m21; + /* compute outer product and add it to the Z matrix */ + p1=ell[1]; + q1=ex[1]; + m11 = p1 * q1; + p2=ell[1+lskip1]; + m21 = p2 * q1; + /* advance pointers */ + ell += 2; + ex += 2; + Z11 += m11; + Z21 += m21; + /* end of inner loop */ + } + /* compute left-over iterations */ + j += 2; + for (; j > 0; j--) { + /* compute outer product and add it to the Z matrix */ + p1=ell[0]; + q1=ex[0]; + m11 = p1 * q1; + p2=ell[lskip1]; + m21 = p2 * q1; + /* advance pointers */ + ell += 1; + ex += 1; + Z11 += m11; + Z21 += m21; + } + /* finish computing the X(i) block */ + Z11 = ex[0] - Z11; + ex[0] = Z11; + p1 = ell[lskip1]; + Z21 = ex[1] - Z21 - p1*Z11; + ex[1] = Z21; + /* end of outer loop */ + } +} + +/* solve L*X=B, with B containing 2 right hand sides. + * L is an n*n lower triangular matrix with ones on the diagonal. + * L is stored by rows and its leading dimension is lskip. + * B is an n*2 matrix that contains the right hand sides. + * B is stored by columns and its leading dimension is also lskip. + * B is overwritten with X. + * this processes blocks of 2*2. + * if this is in the factorizer source file, n must be a multiple of 2. + */ + +static void btSolveL1_2 (const btScalar *L, btScalar *B, int n, int lskip1) +{ + /* declare variables - Z matrix, p and q vectors, etc */ + btScalar Z11,m11,Z12,m12,Z21,m21,Z22,m22,p1,q1,p2,q2,*ex; + const btScalar *ell; + int i,j; + /* compute all 2 x 2 blocks of X */ + for (i=0; i < n; i+=2) { + /* compute all 2 x 2 block of X, from rows i..i+2-1 */ + /* set the Z matrix to 0 */ + Z11=0; + Z12=0; + Z21=0; + Z22=0; + ell = L + i*lskip1; + ex = B; + /* the inner loop that computes outer products and adds them to Z */ + for (j=i-2; j >= 0; j -= 2) { + /* compute outer product and add it to the Z matrix */ + p1=ell[0]; + q1=ex[0]; + m11 = p1 * q1; + q2=ex[lskip1]; + m12 = p1 * q2; + p2=ell[lskip1]; + m21 = p2 * q1; + m22 = p2 * q2; + Z11 += m11; + Z12 += m12; + Z21 += m21; + Z22 += m22; + /* compute outer product and add it to the Z matrix */ + p1=ell[1]; + q1=ex[1]; + m11 = p1 * q1; + q2=ex[1+lskip1]; + m12 = p1 * q2; + p2=ell[1+lskip1]; + m21 = p2 * q1; + m22 = p2 * q2; + /* advance pointers */ + ell += 2; + ex += 2; + Z11 += m11; + Z12 += m12; + Z21 += m21; + Z22 += m22; + /* end of inner loop */ + } + /* compute left-over iterations */ + j += 2; + for (; j > 0; j--) { + /* compute outer product and add it to the Z matrix */ + p1=ell[0]; + q1=ex[0]; + m11 = p1 * q1; + q2=ex[lskip1]; + m12 = p1 * q2; + p2=ell[lskip1]; + m21 = p2 * q1; + m22 = p2 * q2; + /* advance pointers */ + ell += 1; + ex += 1; + Z11 += m11; + Z12 += m12; + Z21 += m21; + Z22 += m22; + } + /* finish computing the X(i) block */ + Z11 = ex[0] - Z11; + ex[0] = Z11; + Z12 = ex[lskip1] - Z12; + ex[lskip1] = Z12; + p1 = ell[lskip1]; + Z21 = ex[1] - Z21 - p1*Z11; + ex[1] = Z21; + Z22 = ex[1+lskip1] - Z22 - p1*Z12; + ex[1+lskip1] = Z22; + /* end of outer loop */ + } +} + + +void btFactorLDLT (btScalar *A, btScalar *d, int n, int nskip1) +{ + int i,j; + btScalar sum,*ell,*dee,dd,p1,p2,q1,q2,Z11,m11,Z21,m21,Z22,m22; + if (n < 1) return; + + for (i=0; i<=n-2; i += 2) { + /* solve L*(D*l)=a, l is scaled elements in 2 x i block at A(i,0) */ + btSolveL1_2 (A,A+i*nskip1,i,nskip1); + /* scale the elements in a 2 x i block at A(i,0), and also */ + /* compute Z = the outer product matrix that we'll need. */ + Z11 = 0; + Z21 = 0; + Z22 = 0; + ell = A+i*nskip1; + dee = d; + for (j=i-6; j >= 0; j -= 6) { + p1 = ell[0]; + p2 = ell[nskip1]; + dd = dee[0]; + q1 = p1*dd; + q2 = p2*dd; + ell[0] = q1; + ell[nskip1] = q2; + m11 = p1*q1; + m21 = p2*q1; + m22 = p2*q2; + Z11 += m11; + Z21 += m21; + Z22 += m22; + p1 = ell[1]; + p2 = ell[1+nskip1]; + dd = dee[1]; + q1 = p1*dd; + q2 = p2*dd; + ell[1] = q1; + ell[1+nskip1] = q2; + m11 = p1*q1; + m21 = p2*q1; + m22 = p2*q2; + Z11 += m11; + Z21 += m21; + Z22 += m22; + p1 = ell[2]; + p2 = ell[2+nskip1]; + dd = dee[2]; + q1 = p1*dd; + q2 = p2*dd; + ell[2] = q1; + ell[2+nskip1] = q2; + m11 = p1*q1; + m21 = p2*q1; + m22 = p2*q2; + Z11 += m11; + Z21 += m21; + Z22 += m22; + p1 = ell[3]; + p2 = ell[3+nskip1]; + dd = dee[3]; + q1 = p1*dd; + q2 = p2*dd; + ell[3] = q1; + ell[3+nskip1] = q2; + m11 = p1*q1; + m21 = p2*q1; + m22 = p2*q2; + Z11 += m11; + Z21 += m21; + Z22 += m22; + p1 = ell[4]; + p2 = ell[4+nskip1]; + dd = dee[4]; + q1 = p1*dd; + q2 = p2*dd; + ell[4] = q1; + ell[4+nskip1] = q2; + m11 = p1*q1; + m21 = p2*q1; + m22 = p2*q2; + Z11 += m11; + Z21 += m21; + Z22 += m22; + p1 = ell[5]; + p2 = ell[5+nskip1]; + dd = dee[5]; + q1 = p1*dd; + q2 = p2*dd; + ell[5] = q1; + ell[5+nskip1] = q2; + m11 = p1*q1; + m21 = p2*q1; + m22 = p2*q2; + Z11 += m11; + Z21 += m21; + Z22 += m22; + ell += 6; + dee += 6; + } + /* compute left-over iterations */ + j += 6; + for (; j > 0; j--) { + p1 = ell[0]; + p2 = ell[nskip1]; + dd = dee[0]; + q1 = p1*dd; + q2 = p2*dd; + ell[0] = q1; + ell[nskip1] = q2; + m11 = p1*q1; + m21 = p2*q1; + m22 = p2*q2; + Z11 += m11; + Z21 += m21; + Z22 += m22; + ell++; + dee++; + } + /* solve for diagonal 2 x 2 block at A(i,i) */ + Z11 = ell[0] - Z11; + Z21 = ell[nskip1] - Z21; + Z22 = ell[1+nskip1] - Z22; + dee = d + i; + /* factorize 2 x 2 block Z,dee */ + /* factorize row 1 */ + dee[0] = btRecip(Z11); + /* factorize row 2 */ + sum = 0; + q1 = Z21; + q2 = q1 * dee[0]; + Z21 = q2; + sum += q1*q2; + dee[1] = btRecip(Z22 - sum); + /* done factorizing 2 x 2 block */ + ell[nskip1] = Z21; + } + /* compute the (less than 2) rows at the bottom */ + switch (n-i) { + case 0: + break; + + case 1: + btSolveL1_1 (A,A+i*nskip1,i,nskip1); + /* scale the elements in a 1 x i block at A(i,0), and also */ + /* compute Z = the outer product matrix that we'll need. */ + Z11 = 0; + ell = A+i*nskip1; + dee = d; + for (j=i-6; j >= 0; j -= 6) { + p1 = ell[0]; + dd = dee[0]; + q1 = p1*dd; + ell[0] = q1; + m11 = p1*q1; + Z11 += m11; + p1 = ell[1]; + dd = dee[1]; + q1 = p1*dd; + ell[1] = q1; + m11 = p1*q1; + Z11 += m11; + p1 = ell[2]; + dd = dee[2]; + q1 = p1*dd; + ell[2] = q1; + m11 = p1*q1; + Z11 += m11; + p1 = ell[3]; + dd = dee[3]; + q1 = p1*dd; + ell[3] = q1; + m11 = p1*q1; + Z11 += m11; + p1 = ell[4]; + dd = dee[4]; + q1 = p1*dd; + ell[4] = q1; + m11 = p1*q1; + Z11 += m11; + p1 = ell[5]; + dd = dee[5]; + q1 = p1*dd; + ell[5] = q1; + m11 = p1*q1; + Z11 += m11; + ell += 6; + dee += 6; + } + /* compute left-over iterations */ + j += 6; + for (; j > 0; j--) { + p1 = ell[0]; + dd = dee[0]; + q1 = p1*dd; + ell[0] = q1; + m11 = p1*q1; + Z11 += m11; + ell++; + dee++; + } + /* solve for diagonal 1 x 1 block at A(i,i) */ + Z11 = ell[0] - Z11; + dee = d + i; + /* factorize 1 x 1 block Z,dee */ + /* factorize row 1 */ + dee[0] = btRecip(Z11); + /* done factorizing 1 x 1 block */ + break; + + //default: *((char*)0)=0; /* this should never happen! */ + } +} + +/* solve L*X=B, with B containing 1 right hand sides. + * L is an n*n lower triangular matrix with ones on the diagonal. + * L is stored by rows and its leading dimension is lskip. + * B is an n*1 matrix that contains the right hand sides. + * B is stored by columns and its leading dimension is also lskip. + * B is overwritten with X. + * this processes blocks of 4*4. + * if this is in the factorizer source file, n must be a multiple of 4. + */ + +void btSolveL1 (const btScalar *L, btScalar *B, int n, int lskip1) +{ + /* declare variables - Z matrix, p and q vectors, etc */ + btScalar Z11,Z21,Z31,Z41,p1,q1,p2,p3,p4,*ex; + const btScalar *ell; + int lskip2,lskip3,i,j; + /* compute lskip values */ + lskip2 = 2*lskip1; + lskip3 = 3*lskip1; + /* compute all 4 x 1 blocks of X */ + for (i=0; i <= n-4; i+=4) { + /* compute all 4 x 1 block of X, from rows i..i+4-1 */ + /* set the Z matrix to 0 */ + Z11=0; + Z21=0; + Z31=0; + Z41=0; + ell = L + i*lskip1; + ex = B; + /* the inner loop that computes outer products and adds them to Z */ + for (j=i-12; j >= 0; j -= 12) { + /* load p and q values */ + p1=ell[0]; + q1=ex[0]; + p2=ell[lskip1]; + p3=ell[lskip2]; + p4=ell[lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[1]; + q1=ex[1]; + p2=ell[1+lskip1]; + p3=ell[1+lskip2]; + p4=ell[1+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[2]; + q1=ex[2]; + p2=ell[2+lskip1]; + p3=ell[2+lskip2]; + p4=ell[2+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[3]; + q1=ex[3]; + p2=ell[3+lskip1]; + p3=ell[3+lskip2]; + p4=ell[3+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[4]; + q1=ex[4]; + p2=ell[4+lskip1]; + p3=ell[4+lskip2]; + p4=ell[4+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[5]; + q1=ex[5]; + p2=ell[5+lskip1]; + p3=ell[5+lskip2]; + p4=ell[5+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[6]; + q1=ex[6]; + p2=ell[6+lskip1]; + p3=ell[6+lskip2]; + p4=ell[6+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[7]; + q1=ex[7]; + p2=ell[7+lskip1]; + p3=ell[7+lskip2]; + p4=ell[7+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[8]; + q1=ex[8]; + p2=ell[8+lskip1]; + p3=ell[8+lskip2]; + p4=ell[8+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[9]; + q1=ex[9]; + p2=ell[9+lskip1]; + p3=ell[9+lskip2]; + p4=ell[9+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[10]; + q1=ex[10]; + p2=ell[10+lskip1]; + p3=ell[10+lskip2]; + p4=ell[10+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* load p and q values */ + p1=ell[11]; + q1=ex[11]; + p2=ell[11+lskip1]; + p3=ell[11+lskip2]; + p4=ell[11+lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* advance pointers */ + ell += 12; + ex += 12; + /* end of inner loop */ + } + /* compute left-over iterations */ + j += 12; + for (; j > 0; j--) { + /* load p and q values */ + p1=ell[0]; + q1=ex[0]; + p2=ell[lskip1]; + p3=ell[lskip2]; + p4=ell[lskip3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + Z21 += p2 * q1; + Z31 += p3 * q1; + Z41 += p4 * q1; + /* advance pointers */ + ell += 1; + ex += 1; + } + /* finish computing the X(i) block */ + Z11 = ex[0] - Z11; + ex[0] = Z11; + p1 = ell[lskip1]; + Z21 = ex[1] - Z21 - p1*Z11; + ex[1] = Z21; + p1 = ell[lskip2]; + p2 = ell[1+lskip2]; + Z31 = ex[2] - Z31 - p1*Z11 - p2*Z21; + ex[2] = Z31; + p1 = ell[lskip3]; + p2 = ell[1+lskip3]; + p3 = ell[2+lskip3]; + Z41 = ex[3] - Z41 - p1*Z11 - p2*Z21 - p3*Z31; + ex[3] = Z41; + /* end of outer loop */ + } + /* compute rows at end that are not a multiple of block size */ + for (; i < n; i++) { + /* compute all 1 x 1 block of X, from rows i..i+1-1 */ + /* set the Z matrix to 0 */ + Z11=0; + ell = L + i*lskip1; + ex = B; + /* the inner loop that computes outer products and adds them to Z */ + for (j=i-12; j >= 0; j -= 12) { + /* load p and q values */ + p1=ell[0]; + q1=ex[0]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[1]; + q1=ex[1]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[2]; + q1=ex[2]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[3]; + q1=ex[3]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[4]; + q1=ex[4]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[5]; + q1=ex[5]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[6]; + q1=ex[6]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[7]; + q1=ex[7]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[8]; + q1=ex[8]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[9]; + q1=ex[9]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[10]; + q1=ex[10]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* load p and q values */ + p1=ell[11]; + q1=ex[11]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* advance pointers */ + ell += 12; + ex += 12; + /* end of inner loop */ + } + /* compute left-over iterations */ + j += 12; + for (; j > 0; j--) { + /* load p and q values */ + p1=ell[0]; + q1=ex[0]; + /* compute outer product and add it to the Z matrix */ + Z11 += p1 * q1; + /* advance pointers */ + ell += 1; + ex += 1; + } + /* finish computing the X(i) block */ + Z11 = ex[0] - Z11; + ex[0] = Z11; + } +} + +/* solve L^T * x=b, with b containing 1 right hand side. + * L is an n*n lower triangular matrix with ones on the diagonal. + * L is stored by rows and its leading dimension is lskip. + * b is an n*1 matrix that contains the right hand side. + * b is overwritten with x. + * this processes blocks of 4. + */ + +void btSolveL1T (const btScalar *L, btScalar *B, int n, int lskip1) +{ + /* declare variables - Z matrix, p and q vectors, etc */ + btScalar Z11,m11,Z21,m21,Z31,m31,Z41,m41,p1,q1,p2,p3,p4,*ex; + const btScalar *ell; + int lskip2,lskip3,i,j; + /* special handling for L and B because we're solving L1 *transpose* */ + L = L + (n-1)*(lskip1+1); + B = B + n-1; + lskip1 = -lskip1; + /* compute lskip values */ + lskip2 = 2*lskip1; + lskip3 = 3*lskip1; + /* compute all 4 x 1 blocks of X */ + for (i=0; i <= n-4; i+=4) { + /* compute all 4 x 1 block of X, from rows i..i+4-1 */ + /* set the Z matrix to 0 */ + Z11=0; + Z21=0; + Z31=0; + Z41=0; + ell = L - i; + ex = B; + /* the inner loop that computes outer products and adds them to Z */ + for (j=i-4; j >= 0; j -= 4) { + /* load p and q values */ + p1=ell[0]; + q1=ex[0]; + p2=ell[-1]; + p3=ell[-2]; + p4=ell[-3]; + /* compute outer product and add it to the Z matrix */ + m11 = p1 * q1; + m21 = p2 * q1; + m31 = p3 * q1; + m41 = p4 * q1; + ell += lskip1; + Z11 += m11; + Z21 += m21; + Z31 += m31; + Z41 += m41; + /* load p and q values */ + p1=ell[0]; + q1=ex[-1]; + p2=ell[-1]; + p3=ell[-2]; + p4=ell[-3]; + /* compute outer product and add it to the Z matrix */ + m11 = p1 * q1; + m21 = p2 * q1; + m31 = p3 * q1; + m41 = p4 * q1; + ell += lskip1; + Z11 += m11; + Z21 += m21; + Z31 += m31; + Z41 += m41; + /* load p and q values */ + p1=ell[0]; + q1=ex[-2]; + p2=ell[-1]; + p3=ell[-2]; + p4=ell[-3]; + /* compute outer product and add it to the Z matrix */ + m11 = p1 * q1; + m21 = p2 * q1; + m31 = p3 * q1; + m41 = p4 * q1; + ell += lskip1; + Z11 += m11; + Z21 += m21; + Z31 += m31; + Z41 += m41; + /* load p and q values */ + p1=ell[0]; + q1=ex[-3]; + p2=ell[-1]; + p3=ell[-2]; + p4=ell[-3]; + /* compute outer product and add it to the Z matrix */ + m11 = p1 * q1; + m21 = p2 * q1; + m31 = p3 * q1; + m41 = p4 * q1; + ell += lskip1; + ex -= 4; + Z11 += m11; + Z21 += m21; + Z31 += m31; + Z41 += m41; + /* end of inner loop */ + } + /* compute left-over iterations */ + j += 4; + for (; j > 0; j--) { + /* load p and q values */ + p1=ell[0]; + q1=ex[0]; + p2=ell[-1]; + p3=ell[-2]; + p4=ell[-3]; + /* compute outer product and add it to the Z matrix */ + m11 = p1 * q1; + m21 = p2 * q1; + m31 = p3 * q1; + m41 = p4 * q1; + ell += lskip1; + ex -= 1; + Z11 += m11; + Z21 += m21; + Z31 += m31; + Z41 += m41; + } + /* finish computing the X(i) block */ + Z11 = ex[0] - Z11; + ex[0] = Z11; + p1 = ell[-1]; + Z21 = ex[-1] - Z21 - p1*Z11; + ex[-1] = Z21; + p1 = ell[-2]; + p2 = ell[-2+lskip1]; + Z31 = ex[-2] - Z31 - p1*Z11 - p2*Z21; + ex[-2] = Z31; + p1 = ell[-3]; + p2 = ell[-3+lskip1]; + p3 = ell[-3+lskip2]; + Z41 = ex[-3] - Z41 - p1*Z11 - p2*Z21 - p3*Z31; + ex[-3] = Z41; + /* end of outer loop */ + } + /* compute rows at end that are not a multiple of block size */ + for (; i < n; i++) { + /* compute all 1 x 1 block of X, from rows i..i+1-1 */ + /* set the Z matrix to 0 */ + Z11=0; + ell = L - i; + ex = B; + /* the inner loop that computes outer products and adds them to Z */ + for (j=i-4; j >= 0; j -= 4) { + /* load p and q values */ + p1=ell[0]; + q1=ex[0]; + /* compute outer product and add it to the Z matrix */ + m11 = p1 * q1; + ell += lskip1; + Z11 += m11; + /* load p and q values */ + p1=ell[0]; + q1=ex[-1]; + /* compute outer product and add it to the Z matrix */ + m11 = p1 * q1; + ell += lskip1; + Z11 += m11; + /* load p and q values */ + p1=ell[0]; + q1=ex[-2]; + /* compute outer product and add it to the Z matrix */ + m11 = p1 * q1; + ell += lskip1; + Z11 += m11; + /* load p and q values */ + p1=ell[0]; + q1=ex[-3]; + /* compute outer product and add it to the Z matrix */ + m11 = p1 * q1; + ell += lskip1; + ex -= 4; + Z11 += m11; + /* end of inner loop */ + } + /* compute left-over iterations */ + j += 4; + for (; j > 0; j--) { + /* load p and q values */ + p1=ell[0]; + q1=ex[0]; + /* compute outer product and add it to the Z matrix */ + m11 = p1 * q1; + ell += lskip1; + ex -= 1; + Z11 += m11; + } + /* finish computing the X(i) block */ + Z11 = ex[0] - Z11; + ex[0] = Z11; + } +} + + + +void btVectorScale (btScalar *a, const btScalar *d, int n) +{ + btAssert (a && d && n >= 0); + for (int i=0; i 0 && nskip >= n); + btSolveL1 (L,b,n,nskip); + btVectorScale (b,d,n); + btSolveL1T (L,b,n,nskip); +} + + + +//*************************************************************************** + +// swap row/column i1 with i2 in the n*n matrix A. the leading dimension of +// A is nskip. this only references and swaps the lower triangle. +// if `do_fast_row_swaps' is nonzero and row pointers are being used, then +// rows will be swapped by exchanging row pointers. otherwise the data will +// be copied. + +static void btSwapRowsAndCols (BTATYPE A, int n, int i1, int i2, int nskip, + int do_fast_row_swaps) +{ + btAssert (A && n > 0 && i1 >= 0 && i2 >= 0 && i1 < n && i2 < n && + nskip >= n && i1 < i2); + +# ifdef BTROWPTRS + btScalar *A_i1 = A[i1]; + btScalar *A_i2 = A[i2]; + for (int i=i1+1; i0 && i1 >=0 && i2 >= 0 && i1 < n && i2 < n && nskip >= n && i1 <= i2); + if (i1==i2) return; + + btSwapRowsAndCols (A,n,i1,i2,nskip,do_fast_row_swaps); + + tmpr = x[i1]; + x[i1] = x[i2]; + x[i2] = tmpr; + + tmpr = b[i1]; + b[i1] = b[i2]; + b[i2] = tmpr; + + tmpr = w[i1]; + w[i1] = w[i2]; + w[i2] = tmpr; + + tmpr = lo[i1]; + lo[i1] = lo[i2]; + lo[i2] = tmpr; + + tmpr = hi[i1]; + hi[i1] = hi[i2]; + hi[i2] = tmpr; + + tmpi = p[i1]; + p[i1] = p[i2]; + p[i2] = tmpi; + + tmpb = state[i1]; + state[i1] = state[i2]; + state[i2] = tmpb; + + if (findex) { + tmpi = findex[i1]; + findex[i1] = findex[i2]; + findex[i2] = tmpi; + } +} + + + + +//*************************************************************************** +// btLCP manipulator object. this represents an n*n LCP problem. +// +// two index sets C and N are kept. each set holds a subset of +// the variable indexes 0..n-1. an index can only be in one set. +// initially both sets are empty. +// +// the index set C is special: solutions to A(C,C)\A(C,i) can be generated. + +//*************************************************************************** +// fast implementation of btLCP. see the above definition of btLCP for +// interface comments. +// +// `p' records the permutation of A,x,b,w,etc. p is initially 1:n and is +// permuted as the other vectors/matrices are permuted. +// +// A,x,b,w,lo,hi,state,findex,p,c are permuted such that sets C,N have +// contiguous indexes. the don't-care indexes follow N. +// +// an L*D*L' factorization is maintained of A(C,C), and whenever indexes are +// added or removed from the set C the factorization is updated. +// thus L*D*L'=A[C,C], i.e. a permuted top left nC*nC submatrix of A. +// the leading dimension of the matrix L is always `nskip'. +// +// at the start there may be other indexes that are unbounded but are not +// included in `nub'. btLCP will permute the matrix so that absolutely all +// unbounded vectors are at the start. thus there may be some initial +// permutation. +// +// the algorithms here assume certain patterns, particularly with respect to +// index transfer. + +#ifdef btLCP_FAST + +struct btLCP +{ + const int m_n; + const int m_nskip; + int m_nub; + int m_nC, m_nN; // size of each index set + BTATYPE const m_A; // A rows + btScalar *const m_x, * const m_b, *const m_w, *const m_lo,* const m_hi; // permuted LCP problem data + btScalar *const m_L, *const m_d; // L*D*L' factorization of set C + btScalar *const m_Dell, *const m_ell, *const m_tmp; + bool *const m_state; + int *const m_findex, *const m_p, *const m_C; + + btLCP (int _n, int _nskip, int _nub, btScalar *_Adata, btScalar *_x, btScalar *_b, btScalar *_w, + btScalar *_lo, btScalar *_hi, btScalar *_L, btScalar *_d, + btScalar *_Dell, btScalar *_ell, btScalar *_tmp, + bool *_state, int *_findex, int *_p, int *_C, btScalar **Arows); + int getNub() const { return m_nub; } + void transfer_i_to_C (int i); + void transfer_i_to_N (int i) { m_nN++; } // because we can assume C and N span 1:i-1 + void transfer_i_from_N_to_C (int i); + void transfer_i_from_C_to_N (int i, btAlignedObjectArray& scratch); + int numC() const { return m_nC; } + int numN() const { return m_nN; } + int indexC (int i) const { return i; } + int indexN (int i) const { return i+m_nC; } + btScalar Aii (int i) const { return BTAROW(i)[i]; } + btScalar AiC_times_qC (int i, btScalar *q) const { return btLargeDot (BTAROW(i), q, m_nC); } + btScalar AiN_times_qN (int i, btScalar *q) const { return btLargeDot (BTAROW(i)+m_nC, q+m_nC, m_nN); } + void pN_equals_ANC_times_qC (btScalar *p, btScalar *q); + void pN_plusequals_ANi (btScalar *p, int i, int sign=1); + void pC_plusequals_s_times_qC (btScalar *p, btScalar s, btScalar *q); + void pN_plusequals_s_times_qN (btScalar *p, btScalar s, btScalar *q); + void solve1 (btScalar *a, int i, int dir=1, int only_transfer=0); + void unpermute(); +}; + + +btLCP::btLCP (int _n, int _nskip, int _nub, btScalar *_Adata, btScalar *_x, btScalar *_b, btScalar *_w, + btScalar *_lo, btScalar *_hi, btScalar *_L, btScalar *_d, + btScalar *_Dell, btScalar *_ell, btScalar *_tmp, + bool *_state, int *_findex, int *_p, int *_C, btScalar **Arows): + m_n(_n), m_nskip(_nskip), m_nub(_nub), m_nC(0), m_nN(0), +# ifdef BTROWPTRS + m_A(Arows), +#else + m_A(_Adata), +#endif + m_x(_x), m_b(_b), m_w(_w), m_lo(_lo), m_hi(_hi), + m_L(_L), m_d(_d), m_Dell(_Dell), m_ell(_ell), m_tmp(_tmp), + m_state(_state), m_findex(_findex), m_p(_p), m_C(_C) +{ + { + btSetZero (m_x,m_n); + } + + { +# ifdef BTROWPTRS + // make matrix row pointers + btScalar *aptr = _Adata; + BTATYPE A = m_A; + const int n = m_n, nskip = m_nskip; + for (int k=0; k nub + { + const int n = m_n; + const int nub = m_nub; + if (nub < n) { + for (int k=0; k<100; k++) { + int i1,i2; + do { + i1 = dRandInt(n-nub)+nub; + i2 = dRandInt(n-nub)+nub; + } + while (i1 > i2); + //printf ("--> %d %d\n",i1,i2); + btSwapProblem (m_A,m_x,m_b,m_w,m_lo,m_hi,m_p,m_state,m_findex,n,i1,i2,m_nskip,0); + } + } + */ + + // permute the problem so that *all* the unbounded variables are at the + // start, i.e. look for unbounded variables not included in `nub'. we can + // potentially push up `nub' this way and get a bigger initial factorization. + // note that when we swap rows/cols here we must not just swap row pointers, + // as the initial factorization relies on the data being all in one chunk. + // variables that have findex >= 0 are *not* considered to be unbounded even + // if lo=-inf and hi=inf - this is because these limits may change during the + // solution process. + + { + int *findex = m_findex; + btScalar *lo = m_lo, *hi = m_hi; + const int n = m_n; + for (int k = m_nub; k= 0) continue; + if (lo[k]==-BT_INFINITY && hi[k]==BT_INFINITY) { + btSwapProblem (m_A,m_x,m_b,m_w,lo,hi,m_p,m_state,findex,n,m_nub,k,m_nskip,0); + m_nub++; + } + } + } + + // if there are unbounded variables at the start, factorize A up to that + // point and solve for x. this puts all indexes 0..nub-1 into C. + if (m_nub > 0) { + const int nub = m_nub; + { + btScalar *Lrow = m_L; + const int nskip = m_nskip; + for (int j=0; j nub such that all findex variables are at the end + if (m_findex) { + const int nub = m_nub; + int *findex = m_findex; + int num_at_end = 0; + for (int k=m_n-1; k >= nub; k--) { + if (findex[k] >= 0) { + btSwapProblem (m_A,m_x,m_b,m_w,m_lo,m_hi,m_p,m_state,findex,m_n,k,m_n-1-num_at_end,m_nskip,1); + num_at_end++; + } + } + } + + // print info about indexes + /* + { + const int n = m_n; + const int nub = m_nub; + for (int k=0; k 0) { + // ell,Dell were computed by solve1(). note, ell = D \ L1solve (L,A(i,C)) + { + const int nC = m_nC; + btScalar *const Ltgt = m_L + nC*m_nskip, *ell = m_ell; + for (int j=0; j 0) { + { + btScalar *const aptr = BTAROW(i); + btScalar *Dell = m_Dell; + const int *C = m_C; +# ifdef BTNUB_OPTIMIZATIONS + // if nub>0, initial part of aptr unpermuted + const int nub = m_nub; + int j=0; + for ( ; j 0 && nskip >= n && r >= 0 && r < n); + if (r >= n-1) return; + if (r > 0) { + { + const size_t move_size = (n-r-1)*sizeof(btScalar); + btScalar *Adst = A + r; + for (int i=0; i& scratch) +{ + btAssert (L && d && a && n > 0 && nskip >= n); + + if (n < 2) return; + scratch.resize(2*nskip); + btScalar *W1 = &scratch[0]; + + btScalar *W2 = W1 + nskip; + + W1[0] = btScalar(0.0); + W2[0] = btScalar(0.0); + for (int j=1; j j) ? _BTGETA(i,j) : _BTGETA(j,i)) + +inline size_t btEstimateLDLTAddTLTmpbufSize(int nskip) +{ + return nskip * 2 * sizeof(btScalar); +} + + +void btLDLTRemove (btScalar **A, const int *p, btScalar *L, btScalar *d, + int n1, int n2, int r, int nskip, btAlignedObjectArray& scratch) +{ + btAssert(A && p && L && d && n1 > 0 && n2 > 0 && r >= 0 && r < n2 && + n1 >= n2 && nskip >= n1); + #ifdef BT_DEBUG + for (int i=0; i= 0 && p[i] < n1); + #endif + + if (r==n2-1) { + return; // deleting last row/col is easy + } + else { + size_t LDLTAddTL_size = btEstimateLDLTAddTLTmpbufSize(nskip); + btAssert(LDLTAddTL_size % sizeof(btScalar) == 0); + scratch.resize(nskip * 2+n2); + btScalar *tmp = &scratch[0]; + if (r==0) { + btScalar *a = (btScalar *)((char *)tmp + LDLTAddTL_size); + const int p_0 = p[0]; + for (int i=0; i& scratch) +{ + { + int *C = m_C; + // remove a row/column from the factorization, and adjust the + // indexes (black magic!) + int last_idx = -1; + const int nC = m_nC; + int j = 0; + for ( ; j 0) { + const int nN = m_nN; + for (int j=0; j 0) { + { + btScalar *Dell = m_Dell; + int *C = m_C; + btScalar *aptr = BTAROW(i); +# ifdef BTNUB_OPTIMIZATIONS + // if nub>0, initial part of aptr[] is guaranteed unpermuted + const int nub = m_nub; + int j=0; + for ( ; j 0) { + int *C = m_C; + btScalar *tmp = m_tmp; + const int nC = m_nC; + for (int j=0; j0 && A && x && b && lo && hi && nub >= 0 && nub <= n); + btAssert(outer_w); + +#ifdef BT_DEBUG + { + // check restrictions on lo and hi + for (int k=0; k= 0); + } +# endif + + + // if all the variables are unbounded then we can just factor, solve, + // and return + if (nub >= n) + { + + + int nskip = (n); + btFactorLDLT (A, outer_w, n, nskip); + btSolveLDLT (A, outer_w, b, n, nskip); + memcpy (x, b, n*sizeof(btScalar)); + + return !s_error; + } + + const int nskip = (n); + scratchMem.L.resize(n*nskip); + + scratchMem.d.resize(n); + + btScalar *w = outer_w; + scratchMem.delta_w.resize(n); + scratchMem.delta_x.resize(n); + scratchMem.Dell.resize(n); + scratchMem.ell.resize(n); + scratchMem.Arows.resize(n); + scratchMem.p.resize(n); + scratchMem.C.resize(n); + + // for i in N, state[i] is 0 if x(i)==lo(i) or 1 if x(i)==hi(i) + scratchMem.state.resize(n); + + + // create LCP object. note that tmp is set to delta_w to save space, this + // optimization relies on knowledge of how tmp is used, so be careful! + btLCP lcp(n,nskip,nub,A,x,b,w,lo,hi,&scratchMem.L[0],&scratchMem.d[0],&scratchMem.Dell[0],&scratchMem.ell[0],&scratchMem.delta_w[0],&scratchMem.state[0],findex,&scratchMem.p[0],&scratchMem.C[0],&scratchMem.Arows[0]); + int adj_nub = lcp.getNub(); + + // loop over all indexes adj_nub..n-1. for index i, if x(i),w(i) satisfy the + // LCP conditions then i is added to the appropriate index set. otherwise + // x(i),w(i) is driven either +ve or -ve to force it to the valid region. + // as we drive x(i), x(C) is also adjusted to keep w(C) at zero. + // while driving x(i) we maintain the LCP conditions on the other variables + // 0..i-1. we do this by watching out for other x(i),w(i) values going + // outside the valid region, and then switching them between index sets + // when that happens. + + bool hit_first_friction_index = false; + for (int i=adj_nub; i= 0) { + // un-permute x into delta_w, which is not being used at the moment + for (int j=0; j= 0) { + lcp.transfer_i_to_N (i); + scratchMem.state[i] = false; + } + else if (hi[i]==0 && w[i] <= 0) { + lcp.transfer_i_to_N (i); + scratchMem.state[i] = true; + } + else if (w[i]==0) { + // this is a degenerate case. by the time we get to this test we know + // that lo != 0, which means that lo < 0 as lo is not allowed to be +ve, + // and similarly that hi > 0. this means that the line segment + // corresponding to set C is at least finite in extent, and we are on it. + // NOTE: we must call lcp.solve1() before lcp.transfer_i_to_C() + lcp.solve1 (&scratchMem.delta_x[0],i,0,1); + + lcp.transfer_i_to_C (i); + } + else { + // we must push x(i) and w(i) + for (;;) { + int dir; + btScalar dirf; + // find direction to push on x(i) + if (w[i] <= 0) { + dir = 1; + dirf = btScalar(1.0); + } + else { + dir = -1; + dirf = btScalar(-1.0); + } + + // compute: delta_x(C) = -dir*A(C,C)\A(C,i) + lcp.solve1 (&scratchMem.delta_x[0],i,dir); + + // note that delta_x[i] = dirf, but we wont bother to set it + + // compute: delta_w = A*delta_x ... note we only care about + // delta_w(N) and delta_w(i), the rest is ignored + lcp.pN_equals_ANC_times_qC (&scratchMem.delta_w[0],&scratchMem.delta_x[0]); + lcp.pN_plusequals_ANi (&scratchMem.delta_w[0],i,dir); + scratchMem.delta_w[i] = lcp.AiC_times_qC (i,&scratchMem.delta_x[0]) + lcp.Aii(i)*dirf; + + // find largest step we can take (size=s), either to drive x(i),w(i) + // to the valid LCP region or to drive an already-valid variable + // outside the valid region. + + int cmd = 1; // index switching command + int si = 0; // si = index to switch if cmd>3 + btScalar s = -w[i]/scratchMem.delta_w[i]; + if (dir > 0) { + if (hi[i] < BT_INFINITY) { + btScalar s2 = (hi[i]-x[i])*dirf; // was (hi[i]-x[i])/dirf // step to x(i)=hi(i) + if (s2 < s) { + s = s2; + cmd = 3; + } + } + } + else { + if (lo[i] > -BT_INFINITY) { + btScalar s2 = (lo[i]-x[i])*dirf; // was (lo[i]-x[i])/dirf // step to x(i)=lo(i) + if (s2 < s) { + s = s2; + cmd = 2; + } + } + } + + { + const int numN = lcp.numN(); + for (int k=0; k < numN; ++k) { + const int indexN_k = lcp.indexN(k); + if (!scratchMem.state[indexN_k] ? scratchMem.delta_w[indexN_k] < 0 : scratchMem.delta_w[indexN_k] > 0) { + // don't bother checking if lo=hi=0 + if (lo[indexN_k] == 0 && hi[indexN_k] == 0) continue; + btScalar s2 = -w[indexN_k] / scratchMem.delta_w[indexN_k]; + if (s2 < s) { + s = s2; + cmd = 4; + si = indexN_k; + } + } + } + } + + { + const int numC = lcp.numC(); + for (int k=adj_nub; k < numC; ++k) { + const int indexC_k = lcp.indexC(k); + if (scratchMem.delta_x[indexC_k] < 0 && lo[indexC_k] > -BT_INFINITY) { + btScalar s2 = (lo[indexC_k]-x[indexC_k]) / scratchMem.delta_x[indexC_k]; + if (s2 < s) { + s = s2; + cmd = 5; + si = indexC_k; + } + } + if (scratchMem.delta_x[indexC_k] > 0 && hi[indexC_k] < BT_INFINITY) { + btScalar s2 = (hi[indexC_k]-x[indexC_k]) / scratchMem.delta_x[indexC_k]; + if (s2 < s) { + s = s2; + cmd = 6; + si = indexC_k; + } + } + } + } + + //static char* cmdstring[8] = {0,"->C","->NL","->NH","N->C", + // "C->NL","C->NH"}; + //printf ("cmd=%d (%s), si=%d\n",cmd,cmdstring[cmd],(cmd>3) ? si : i); + + // if s <= 0 then we've got a problem. if we just keep going then + // we're going to get stuck in an infinite loop. instead, just cross + // our fingers and exit with the current solution. + if (s <= btScalar(0.0)) + { +// printf("LCP internal error, s <= 0 (s=%.4e)",(double)s); + if (i < n) { + btSetZero (x+i,n-i); + btSetZero (w+i,n-i); + } + s_error = true; + break; + } + + // apply x = x + s * delta_x + lcp.pC_plusequals_s_times_qC (x, s, &scratchMem.delta_x[0]); + x[i] += s * dirf; + + // apply w = w + s * delta_w + lcp.pN_plusequals_s_times_qN (w, s, &scratchMem.delta_w[0]); + w[i] += s * scratchMem.delta_w[i]; + +// void *tmpbuf; + // switch indexes between sets if necessary + switch (cmd) { + case 1: // done + w[i] = 0; + lcp.transfer_i_to_C (i); + break; + case 2: // done + x[i] = lo[i]; + scratchMem.state[i] = false; + lcp.transfer_i_to_N (i); + break; + case 3: // done + x[i] = hi[i]; + scratchMem.state[i] = true; + lcp.transfer_i_to_N (i); + break; + case 4: // keep going + w[si] = 0; + lcp.transfer_i_from_N_to_C (si); + break; + case 5: // keep going + x[si] = lo[si]; + scratchMem.state[si] = false; + lcp.transfer_i_from_C_to_N (si, scratchMem.m_scratch); + break; + case 6: // keep going + x[si] = hi[si]; + scratchMem.state[si] = true; + lcp.transfer_i_from_C_to_N (si, scratchMem.m_scratch); + break; + } + + if (cmd <= 3) break; + } // for (;;) + } // else + + if (s_error) + { + break; + } + } // for (int i=adj_nub; i= 0 + (2) x = hi, w <= 0 + (3) lo < x < hi, w = 0 +A is a matrix of dimension n*n, everything else is a vector of size n*1. +lo and hi can be +/- dInfinity as needed. the first `nub' variables are +unbounded, i.e. hi and lo are assumed to be +/- dInfinity. + +we restrict lo(i) <= 0 and hi(i) >= 0. + +the original data (A,b) may be modified by this function. + +if the `findex' (friction index) parameter is nonzero, it points to an array +of index values. in this case constraints that have findex[i] >= 0 are +special. all non-special constraints are solved for, then the lo and hi values +for the special constraints are set: + hi[i] = abs( hi[i] * x[findex[i]] ) + lo[i] = -hi[i] +and the solution continues. this mechanism allows a friction approximation +to be implemented. the first `nub' variables are assumed to have findex < 0. + +*/ + + +#ifndef _BT_LCP_H_ +#define _BT_LCP_H_ + +#include +#include +#include + + +#include "LinearMath/btScalar.h" +#include "LinearMath/btAlignedObjectArray.h" + +struct btDantzigScratchMemory +{ + btAlignedObjectArray m_scratch; + btAlignedObjectArray L; + btAlignedObjectArray d; + btAlignedObjectArray delta_w; + btAlignedObjectArray delta_x; + btAlignedObjectArray Dell; + btAlignedObjectArray ell; + btAlignedObjectArray Arows; + btAlignedObjectArray p; + btAlignedObjectArray C; + btAlignedObjectArray state; +}; + +//return false if solving failed +bool btSolveDantzigLCP (int n, btScalar *A, btScalar *x, btScalar *b, btScalar *w, + int nub, btScalar *lo, btScalar *hi, int *findex,btDantzigScratchMemory& scratch); + + + +#endif //_BT_LCP_H_ diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigSolver.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigSolver.h new file mode 100644 index 00000000000..2a2f2d3d32d --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btDantzigSolver.h @@ -0,0 +1,112 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ +///original version written by Erwin Coumans, October 2013 + +#ifndef BT_DANTZIG_SOLVER_H +#define BT_DANTZIG_SOLVER_H + +#include "btMLCPSolverInterface.h" +#include "btDantzigLCP.h" + + +class btDantzigSolver : public btMLCPSolverInterface +{ +protected: + + btScalar m_acceptableUpperLimitSolution; + + btAlignedObjectArray m_tempBuffer; + + btAlignedObjectArray m_A; + btAlignedObjectArray m_b; + btAlignedObjectArray m_x; + btAlignedObjectArray m_lo; + btAlignedObjectArray m_hi; + btAlignedObjectArray m_dependencies; + btDantzigScratchMemory m_scratchMemory; +public: + + btDantzigSolver() + :m_acceptableUpperLimitSolution(btScalar(1000)) + { + } + + virtual bool solveMLCP(const btMatrixXu & A, const btVectorXu & b, btVectorXu& x, const btVectorXu & lo,const btVectorXu & hi,const btAlignedObjectArray& limitDependency, int numIterations, bool useSparsity = true) + { + bool result = true; + int n = b.rows(); + if (n) + { + int nub = 0; + btAlignedObjectArray ww; + ww.resize(n); + + + const btScalar* Aptr = A.getBufferPointer(); + m_A.resize(n*n); + for (int i=0;i= m_acceptableUpperLimitSolution) + { + return false; + } + + if (x[i] <= -m_acceptableUpperLimitSolution) + { + return false; + } + } + + for (int i=0;i limitDependenciesCopy = m_limitDependencies; +// printf("solve first LCP\n"); + result = m_solver->solveMLCP(m_A, m_b, m_x, m_lo,m_hi, m_limitDependencies,infoGlobal.m_numIterations ); + if (result) + result = m_solver->solveMLCP(Acopy, m_bSplit, m_xSplit, m_lo,m_hi, limitDependenciesCopy,infoGlobal.m_numIterations ); + + } else + { + result = m_solver->solveMLCP(m_A, m_b, m_x, m_lo,m_hi, m_limitDependencies,infoGlobal.m_numIterations ); + } + return result; +} + +struct btJointNode +{ + int jointIndex; // pointer to enclosing dxJoint object + int otherBodyIndex; // *other* body this joint is connected to + int nextJointNodeIndex;//-1 for null + int constraintRowIndex; +}; + + + +void btMLCPSolver::createMLCPFast(const btContactSolverInfo& infoGlobal) +{ + int numContactRows = interleaveContactAndFriction ? 3 : 1; + + int numConstraintRows = m_allConstraintArray.size(); + int n = numConstraintRows; + { + BT_PROFILE("init b (rhs)"); + m_b.resize(numConstraintRows); + m_bSplit.resize(numConstraintRows); + //m_b.setZero(); + for (int i=0;i=0) + { + m_lo[i] = -BT_INFINITY; + m_hi[i] = BT_INFINITY; + } else + { + m_lo[i] = m_allConstraintArray[i].m_lowerLimit; + m_hi[i] = m_allConstraintArray[i].m_upperLimit; + } + } + } + + // + int m=m_allConstraintArray.size(); + + int numBodies = m_tmpSolverBodyPool.size(); + btAlignedObjectArray bodyJointNodeArray; + { + BT_PROFILE("bodyJointNodeArray.resize"); + bodyJointNodeArray.resize(numBodies,-1); + } + btAlignedObjectArray jointNodeArray; + { + BT_PROFILE("jointNodeArray.reserve"); + jointNodeArray.reserve(2*m_allConstraintArray.size()); + } + + static btMatrixXu J3; + { + BT_PROFILE("J3.resize"); + J3.resize(2*m,8); + } + static btMatrixXu JinvM3; + { + BT_PROFILE("JinvM3.resize/setZero"); + + JinvM3.resize(2*m,8); + JinvM3.setZero(); + J3.setZero(); + } + int cur=0; + int rowOffset = 0; + static btAlignedObjectArray ofs; + { + BT_PROFILE("ofs resize"); + ofs.resize(0); + ofs.resizeNoInitialize(m_allConstraintArray.size()); + } + { + BT_PROFILE("Compute J and JinvM"); + int c=0; + + int numRows = 0; + + for (int i=0;igetInvMass(); + btVector3 relPosCrossNormalInvInertia = m_allConstraintArray[i+row].m_relpos1CrossNormal * orgBodyA->getInvInertiaTensorWorld(); + + for (int r=0;r<3;r++) + { + J3.setElem(cur,r,m_allConstraintArray[i+row].m_contactNormal1[r]); + J3.setElem(cur,r+4,m_allConstraintArray[i+row].m_relpos1CrossNormal[r]); + JinvM3.setElem(cur,r,normalInvMass[r]); + JinvM3.setElem(cur,r+4,relPosCrossNormalInvInertia[r]); + } + J3.setElem(cur,3,0); + JinvM3.setElem(cur,3,0); + J3.setElem(cur,7,0); + JinvM3.setElem(cur,7,0); + } + } else + { + cur += numRows; + } + if (orgBodyB) + { + + { + int slotB=-1; + //find free jointNode slot for sbA + slotB =jointNodeArray.size(); + jointNodeArray.expand();//NonInitializing(); + int prevSlot = bodyJointNodeArray[sbB]; + bodyJointNodeArray[sbB] = slotB; + jointNodeArray[slotB].nextJointNodeIndex = prevSlot; + jointNodeArray[slotB].jointIndex = c; + jointNodeArray[slotB].otherBodyIndex = orgBodyA ? sbA : -1; + jointNodeArray[slotB].constraintRowIndex = i; + } + + for (int row=0;rowgetInvMass(); + btVector3 relPosInvInertiaB = m_allConstraintArray[i+row].m_relpos2CrossNormal * orgBodyB->getInvInertiaTensorWorld(); + + for (int r=0;r<3;r++) + { + J3.setElem(cur,r,m_allConstraintArray[i+row].m_contactNormal2[r]); + J3.setElem(cur,r+4,m_allConstraintArray[i+row].m_relpos2CrossNormal[r]); + JinvM3.setElem(cur,r,normalInvMassB[r]); + JinvM3.setElem(cur,r+4,relPosInvInertiaB[r]); + } + J3.setElem(cur,3,0); + JinvM3.setElem(cur,3,0); + J3.setElem(cur,7,0); + JinvM3.setElem(cur,7,0); + } + } + else + { + cur += numRows; + } + rowOffset+=numRows; + + } + + } + + + //compute JinvM = J*invM. + const btScalar* JinvM = JinvM3.getBufferPointer(); + + const btScalar* Jptr = J3.getBufferPointer(); + { + BT_PROFILE("m_A.resize"); + m_A.resize(n,n); + } + + { + BT_PROFILE("m_A.setZero"); + m_A.setZero(); + } + int c=0; + { + int numRows = 0; + BT_PROFILE("Compute A"); + for (int i=0;i=0) + { + int j0 = jointNodeArray[startJointNodeA].jointIndex; + int cr0 = jointNodeArray[startJointNodeA].constraintRowIndex; + if (j0=0) + { + int j1 = jointNodeArray[startJointNodeB].jointIndex; + int cj1 = jointNodeArray[startJointNodeB].constraintRowIndex; + + if (j1m_tmpSolverBodyPool.size(); + int numConstraintRows = m_allConstraintArray.size(); + + m_b.resize(numConstraintRows); + if (infoGlobal.m_splitImpulse) + m_bSplit.resize(numConstraintRows); + + for (int i=0;igetInvInertiaTensorWorld()[r][c] : 0); + } + + static btMatrixXu J; + J.resize(numConstraintRows,6*numBodies); + J.setZero(); + + m_lo.resize(numConstraintRows); + m_hi.resize(numConstraintRows); + + for (int i=0;i m_limitDependencies; + btConstraintArray m_allConstraintArray; + btMLCPSolverInterface* m_solver; + int m_fallback; + + virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); + virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer); + virtual void createMLCP(const btContactSolverInfo& infoGlobal); + virtual void createMLCPFast(const btContactSolverInfo& infoGlobal); + + //return true is it solves the problem successfully + virtual bool solveMLCP(const btContactSolverInfo& infoGlobal); + +public: + + btMLCPSolver( btMLCPSolverInterface* solver); + virtual ~btMLCPSolver(); + + void setMLCPSolver(btMLCPSolverInterface* solver) + { + m_solver = solver; + } + + int getNumFallbacks() const + { + return m_fallback; + } + void setNumFallbacks(int num) + { + m_fallback = num; + } + + virtual btConstraintSolverType getSolverType() const + { + return BT_MLCP_SOLVER; + } + +}; + + +#endif //BT_MLCP_SOLVER_H diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h new file mode 100644 index 00000000000..25bb3f6d327 --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btMLCPSolverInterface.h @@ -0,0 +1,33 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ +///original version written by Erwin Coumans, October 2013 + +#ifndef BT_MLCP_SOLVER_INTERFACE_H +#define BT_MLCP_SOLVER_INTERFACE_H + +#include "LinearMath/btMatrixX.h" + +class btMLCPSolverInterface +{ +public: + virtual ~btMLCPSolverInterface() + { + } + + //return true is it solves the problem successfully + virtual bool solveMLCP(const btMatrixXu & A, const btVectorXu & b, btVectorXu& x, const btVectorXu & lo,const btVectorXu & hi,const btAlignedObjectArray& limitDependency, int numIterations, bool useSparsity = true)=0; +}; + +#endif //BT_MLCP_SOLVER_INTERFACE_H diff --git a/extern/bullet2/src/BulletDynamics/MLCPSolvers/btPATHSolver.h b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btPATHSolver.h new file mode 100644 index 00000000000..9ec31a6d4e4 --- /dev/null +++ b/extern/bullet2/src/BulletDynamics/MLCPSolvers/btPATHSolver.h @@ -0,0 +1,151 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ +///original version written by Erwin Coumans, October 2013 + + +#ifndef BT_PATH_SOLVER_H +#define BT_PATH_SOLVER_H + +//#define BT_USE_PATH +#ifdef BT_USE_PATH + +extern "C" { +#include "PATH/SimpleLCP.h" +#include "PATH/License.h" +#include "PATH/Error_Interface.h" +}; + void __stdcall MyError(Void *data, Char *msg) +{ + printf("Path Error: %s\n",msg); +} + void __stdcall MyWarning(Void *data, Char *msg) +{ + printf("Path Warning: %s\n",msg); +} + +Error_Interface e; + + + +#include "btMLCPSolverInterface.h" +#include "Dantzig/lcp.h" + +class btPathSolver : public btMLCPSolverInterface +{ +public: + + btPathSolver() + { + License_SetString("2069810742&Courtesy_License&&&USR&2013&14_12_2011&1000&PATH&GEN&31_12_2013&0_0_0&0&0_0"); + e.error_data = 0; + e.warning = MyWarning; + e.error = MyError; + Error_SetInterface(&e); + } + + + virtual bool solveMLCP(const btMatrixXu & A, const btVectorXu & b, btVectorXu& x, const btVectorXu & lo,const btVectorXu & hi,const btAlignedObjectArray& limitDependency, int numIterations, bool useSparsity = true) + { + MCP_Termination status; + + + int numVariables = b.rows(); + if (0==numVariables) + return true; + + /* - variables - the number of variables in the problem + - m_nnz - the number of nonzeros in the M matrix + - m_i - a vector of size m_nnz containing the row indices for M + - m_j - a vector of size m_nnz containing the column indices for M + - m_ij - a vector of size m_nnz containing the data for M + - q - a vector of size variables + - lb - a vector of size variables containing the lower bounds on x + - ub - a vector of size variables containing the upper bounds on x + */ + btAlignedObjectArray values; + btAlignedObjectArray rowIndices; + btAlignedObjectArray colIndices; + + for (int i=0;i zResult; + zResult.resize(numVariables); + btAlignedObjectArray rhs; + btAlignedObjectArray upperBounds; + btAlignedObjectArray lowerBounds; + for (int i=0;i& limitDependency, int numIterations, bool useSparsity = true) + { + //A is a m-n matrix, m rows, n columns + btAssert(A.rows() == b.rows()); + + int i, j, numRows = A.rows(); + + float delta; + + for (int k = 0; k =0) + { + s = x[limitDependency[i]]; + if (s<0) + s=1; + } + + if (x[i]hi[i]*s) + x[i]=hi[i]*s; + } + } + return true; + } + +}; + +#endif //BT_SOLVE_PROJECTED_GAUSS_SEIDEL_H diff --git a/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp b/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp index e8c8fdb6402..9429d56e05a 100644 --- a/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp +++ b/extern/bullet2/src/BulletSoftBody/btSoftBody.cpp @@ -1767,7 +1767,23 @@ void btSoftBody::predictMotion(btScalar dt) { Node& n=m_nodes[i]; n.m_q = n.m_x; - n.m_v += n.m_f*n.m_im*m_sst.sdt; + btVector3 deltaV = n.m_f*n.m_im*m_sst.sdt; + { + btScalar maxDisplacement = m_worldInfo->m_maxDisplacement; + btScalar clampDeltaV = maxDisplacement/m_sst.sdt; + for (int c=0;c<3;c++) + { + if (deltaV[c]>clampDeltaV) + { + deltaV[c] = clampDeltaV; + } + if (deltaV[c]<-clampDeltaV) + { + deltaV[c]=-clampDeltaV; + } + } + } + n.m_v += deltaV; n.m_x += n.m_v*m_sst.sdt; n.m_f = btVector3(0,0,0); } diff --git a/extern/bullet2/src/BulletSoftBody/btSoftBody.h b/extern/bullet2/src/BulletSoftBody/btSoftBody.h index 2116c34f06d..ee1a3d95228 100644 --- a/extern/bullet2/src/BulletSoftBody/btSoftBody.h +++ b/extern/bullet2/src/BulletSoftBody/btSoftBody.h @@ -45,6 +45,7 @@ struct btSoftBodyWorldInfo btScalar air_density; btScalar water_density; btScalar water_offset; + btScalar m_maxDisplacement; btVector3 water_normal; btBroadphaseInterface* m_broadphase; btDispatcher* m_dispatcher; @@ -55,6 +56,7 @@ struct btSoftBodyWorldInfo :air_density((btScalar)1.2), water_density(0), water_offset(0), + m_maxDisplacement(1000.f),//avoid soft body from 'exploding' so use some upper threshold of maximum motion that a node can travel per frame water_normal(0,0,0), m_broadphase(0), m_dispatcher(0), diff --git a/extern/bullet2/src/BulletSoftBody/btSoftBodyHelpers.cpp b/extern/bullet2/src/BulletSoftBody/btSoftBodyHelpers.cpp index 0fb3560e94c..36f675a6c0c 100644 --- a/extern/bullet2/src/BulletSoftBody/btSoftBodyHelpers.cpp +++ b/extern/bullet2/src/BulletSoftBody/btSoftBodyHelpers.cpp @@ -911,9 +911,9 @@ btSoftBody* btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldI &hres.m_OutputVertices[0],0); for(int i=0;i<(int)hres.mNumFaces;++i) { - const int idx[]={ hres.m_Indices[i*3+0], - hres.m_Indices[i*3+1], - hres.m_Indices[i*3+2]}; + const int idx[]={ static_cast(hres.m_Indices[i*3+0]), + static_cast(hres.m_Indices[i*3+1]), + static_cast(hres.m_Indices[i*3+2])}; if(idx[0]appendLink( idx[0],idx[1]); if(idx[1]appendLink( idx[1],idx[2]); if(idx[2]appendLink( idx[2],idx[0]); diff --git a/extern/bullet2/src/BulletSoftBody/btSparseSDF.h b/extern/bullet2/src/BulletSoftBody/btSparseSDF.h index 180e3c218cc..bcf0c798253 100644 --- a/extern/bullet2/src/BulletSoftBody/btSparseSDF.h +++ b/extern/bullet2/src/BulletSoftBody/btSparseSDF.h @@ -69,6 +69,7 @@ struct btSparseSdf btScalar voxelsz; int puid; int ncells; + int m_clampCells; int nprobes; int nqueries; @@ -77,10 +78,13 @@ struct btSparseSdf // // - void Initialize(int hashsize=2383) + void Initialize(int hashsize=2383, int clampCells = 256*1024) { + //avoid a crash due to running out of memory, so clamp the maximum number of cells allocated + //if this limit is reached, the SDF is reset (at the cost of some performance during the reset) + m_clampCells = clampCells; cells.resize(hashsize,0); - Reset(); + Reset(); } // void Reset() @@ -181,6 +185,15 @@ struct btSparseSdf { ++nprobes; ++ncells; + int sz = sizeof(Cell); + if (ncells>m_clampCells) + { + static int numResets=0; + numResets++; +// printf("numResets=%d\n",numResets); + Reset(); + } + c=new Cell(); c->next=root;root=c; c->pclient=shape; diff --git a/extern/bullet2/src/LinearMath/btIDebugDraw.h b/extern/bullet2/src/LinearMath/btIDebugDraw.h index a00d7763a75..de97c3f87fd 100644 --- a/extern/bullet2/src/LinearMath/btIDebugDraw.h +++ b/extern/bullet2/src/LinearMath/btIDebugDraw.h @@ -62,29 +62,17 @@ class btIDebugDraw virtual void drawSphere(btScalar radius, const btTransform& transform, const btVector3& color) { - btVector3 start = transform.getOrigin(); - - const btVector3 xoffs = transform.getBasis() * btVector3(radius,0,0); - const btVector3 yoffs = transform.getBasis() * btVector3(0,radius,0); - const btVector3 zoffs = transform.getBasis() * btVector3(0,0,radius); - - // XY - drawLine(start-xoffs, start+yoffs, color); - drawLine(start+yoffs, start+xoffs, color); - drawLine(start+xoffs, start-yoffs, color); - drawLine(start-yoffs, start-xoffs, color); - - // XZ - drawLine(start-xoffs, start+zoffs, color); - drawLine(start+zoffs, start+xoffs, color); - drawLine(start+xoffs, start-zoffs, color); - drawLine(start-zoffs, start-xoffs, color); - - // YZ - drawLine(start-yoffs, start+zoffs, color); - drawLine(start+zoffs, start+yoffs, color); - drawLine(start+yoffs, start-zoffs, color); - drawLine(start-zoffs, start-yoffs, color); + + btVector3 center = transform.getOrigin(); + btVector3 up = transform.getBasis().getColumn(1); + btVector3 axis = transform.getBasis().getColumn(0); + btScalar minTh = -SIMD_HALF_PI; + btScalar maxTh = SIMD_HALF_PI; + btScalar minPs = -SIMD_HALF_PI; + btScalar maxPs = SIMD_HALF_PI; + btScalar stepDegrees = 30.f; + drawSpherePatch(center, up, axis, radius,minTh, maxTh, minPs, maxPs, color, stepDegrees ,false); + drawSpherePatch(center, up, -axis, radius,minTh, maxTh, minPs, maxPs, color, stepDegrees,false ); } virtual void drawSphere (const btVector3& p, btScalar radius, const btVector3& color) @@ -179,7 +167,7 @@ class btIDebugDraw } } virtual void drawSpherePatch(const btVector3& center, const btVector3& up, const btVector3& axis, btScalar radius, - btScalar minTh, btScalar maxTh, btScalar minPs, btScalar maxPs, const btVector3& color, btScalar stepDegrees = btScalar(10.f)) + btScalar minTh, btScalar maxTh, btScalar minPs, btScalar maxPs, const btVector3& color, btScalar stepDegrees = btScalar(10.f),bool drawCenter = true) { btVector3 vA[74]; btVector3 vB[74]; @@ -261,18 +249,22 @@ class btIDebugDraw { drawLine(npole, pvB[j], color); } - if(isClosed) + + if (drawCenter) { - if(j == (n_vert-1)) + if(isClosed) { - drawLine(arcStart, pvB[j], color); + if(j == (n_vert-1)) + { + drawLine(arcStart, pvB[j], color); + } } - } - else - { - if(((!i) || (i == (n_hor-1))) && ((!j) || (j == (n_vert-1)))) + else { - drawLine(center, pvB[j], color); + if(((!i) || (i == (n_hor-1))) && ((!j) || (j == (n_vert-1)))) + { + drawLine(center, pvB[j], color); + } } } } @@ -314,6 +306,8 @@ class btIDebugDraw virtual void drawCapsule(btScalar radius, btScalar halfHeight, int upAxis, const btTransform& transform, const btVector3& color) { + int stepDegrees = 30; + btVector3 capStart(0.f,0.f,0.f); capStart[upAxis] = -halfHeight; @@ -325,34 +319,47 @@ class btIDebugDraw btTransform childTransform = transform; childTransform.getOrigin() = transform * capStart; - drawSphere(radius, childTransform, color); + { + btVector3 center = childTransform.getOrigin(); + btVector3 up = childTransform.getBasis().getColumn((upAxis+1)%3); + btVector3 axis = -childTransform.getBasis().getColumn(upAxis); + btScalar minTh = -SIMD_HALF_PI; + btScalar maxTh = SIMD_HALF_PI; + btScalar minPs = -SIMD_HALF_PI; + btScalar maxPs = SIMD_HALF_PI; + + drawSpherePatch(center, up, axis, radius,minTh, maxTh, minPs, maxPs, color, btScalar(stepDegrees) ,false); + } + + + } { btTransform childTransform = transform; childTransform.getOrigin() = transform * capEnd; - drawSphere(radius, childTransform, color); + { + btVector3 center = childTransform.getOrigin(); + btVector3 up = childTransform.getBasis().getColumn((upAxis+1)%3); + btVector3 axis = childTransform.getBasis().getColumn(upAxis); + btScalar minTh = -SIMD_HALF_PI; + btScalar maxTh = SIMD_HALF_PI; + btScalar minPs = -SIMD_HALF_PI; + btScalar maxPs = SIMD_HALF_PI; + drawSpherePatch(center, up, axis, radius,minTh, maxTh, minPs, maxPs, color, btScalar(stepDegrees) ,false); + } } // Draw some additional lines btVector3 start = transform.getOrigin(); - capStart[(upAxis+1)%3] = radius; - capEnd[(upAxis+1)%3] = radius; - drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color); - capStart[(upAxis+1)%3] = -radius; - capEnd[(upAxis+1)%3] = -radius; - drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color); - - capStart[(upAxis+1)%3] = 0.f; - capEnd[(upAxis+1)%3] = 0.f; - - capStart[(upAxis+2)%3] = radius; - capEnd[(upAxis+2)%3] = radius; - drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color); - capStart[(upAxis+2)%3] = -radius; - capEnd[(upAxis+2)%3] = -radius; - drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color); + for (int i=0;i<360;i+=stepDegrees) + { + capEnd[(upAxis+1)%3] = capStart[(upAxis+1)%3] = btSin(btScalar(i)*SIMD_RADS_PER_DEG)*radius; + capEnd[(upAxis+2)%3] = capStart[(upAxis+2)%3] = btCos(btScalar(i)*SIMD_RADS_PER_DEG)*radius; + drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color); + } + } virtual void drawCylinder(btScalar radius, btScalar halfHeight, int upAxis, const btTransform& transform, const btVector3& color) @@ -360,11 +367,18 @@ class btIDebugDraw btVector3 start = transform.getOrigin(); btVector3 offsetHeight(0,0,0); offsetHeight[upAxis] = halfHeight; - btVector3 offsetRadius(0,0,0); - offsetRadius[(upAxis+1)%3] = radius; - drawLine(start+transform.getBasis() * (offsetHeight+offsetRadius),start+transform.getBasis() * (-offsetHeight+offsetRadius),color); - drawLine(start+transform.getBasis() * (offsetHeight-offsetRadius),start+transform.getBasis() * (-offsetHeight-offsetRadius),color); + int stepDegrees=30; + btVector3 capStart(0.f,0.f,0.f); + capStart[upAxis] = -halfHeight; + btVector3 capEnd(0.f,0.f,0.f); + capEnd[upAxis] = halfHeight; + for (int i=0;i<360;i+=stepDegrees) + { + capEnd[(upAxis+1)%3] = capStart[(upAxis+1)%3] = btSin(btScalar(i)*SIMD_RADS_PER_DEG)*radius; + capEnd[(upAxis+2)%3] = capStart[(upAxis+2)%3] = btCos(btScalar(i)*SIMD_RADS_PER_DEG)*radius; + drawLine(start+transform.getBasis() * capStart,start+transform.getBasis() * capEnd, color); + } // Drawing top and bottom caps of the cylinder btVector3 yaxis(0,0,0); yaxis[upAxis] = btScalar(1.0); @@ -376,16 +390,28 @@ class btIDebugDraw virtual void drawCone(btScalar radius, btScalar height, int upAxis, const btTransform& transform, const btVector3& color) { - + int stepDegrees = 30; btVector3 start = transform.getOrigin(); btVector3 offsetHeight(0,0,0); - offsetHeight[upAxis] = height * btScalar(0.5); + btScalar halfHeight = height * btScalar(0.5); + offsetHeight[upAxis] = halfHeight; btVector3 offsetRadius(0,0,0); offsetRadius[(upAxis+1)%3] = radius; btVector3 offset2Radius(0,0,0); offset2Radius[(upAxis+2)%3] = radius; + + btVector3 capEnd(0.f,0.f,0.f); + capEnd[upAxis] = -halfHeight; + + for (int i=0;i<360;i+=stepDegrees) + { + capEnd[(upAxis+1)%3] = btSin(btScalar(i)*SIMD_RADS_PER_DEG)*radius; + capEnd[(upAxis+2)%3] = btCos(btScalar(i)*SIMD_RADS_PER_DEG)*radius; + drawLine(start+transform.getBasis() * (offsetHeight),start+transform.getBasis() * capEnd, color); + } + drawLine(start+transform.getBasis() * (offsetHeight),start+transform.getBasis() * (-offsetHeight+offsetRadius),color); drawLine(start+transform.getBasis() * (offsetHeight),start+transform.getBasis() * (-offsetHeight-offsetRadius),color); drawLine(start+transform.getBasis() * (offsetHeight),start+transform.getBasis() * (-offsetHeight+offset2Radius),color); diff --git a/extern/bullet2/src/LinearMath/btMatrix3x3.h b/extern/bullet2/src/LinearMath/btMatrix3x3.h index d4f5c95aa64..14fe704f81a 100644 --- a/extern/bullet2/src/LinearMath/btMatrix3x3.h +++ b/extern/bullet2/src/LinearMath/btMatrix3x3.h @@ -22,10 +22,15 @@ subject to the following restrictions: #ifdef BT_USE_SSE //const __m128 ATTRIBUTE_ALIGNED16(v2220) = {2.0f, 2.0f, 2.0f, 0.0f}; -const __m128 ATTRIBUTE_ALIGNED16(vMPPP) = {-0.0f, +0.0f, +0.0f, +0.0f}; +//const __m128 ATTRIBUTE_ALIGNED16(vMPPP) = {-0.0f, +0.0f, +0.0f, +0.0f}; +#define vMPPP (_mm_set_ps (+0.0f, +0.0f, +0.0f, -0.0f)) #endif -#if defined(BT_USE_SSE) || defined(BT_USE_NEON) +#if defined(BT_USE_SSE) +#define v1000 (_mm_set_ps(0.0f,0.0f,0.0f,1.0f)) +#define v0100 (_mm_set_ps(0.0f,0.0f,1.0f,0.0f)) +#define v0010 (_mm_set_ps(0.0f,1.0f,0.0f,0.0f)) +#elif defined(BT_USE_NEON) const btSimdFloat4 ATTRIBUTE_ALIGNED16(v1000) = {1.0f, 0.0f, 0.0f, 0.0f}; const btSimdFloat4 ATTRIBUTE_ALIGNED16(v0100) = {0.0f, 1.0f, 0.0f, 0.0f}; const btSimdFloat4 ATTRIBUTE_ALIGNED16(v0010) = {0.0f, 0.0f, 1.0f, 0.0f}; @@ -207,7 +212,7 @@ public: btFullAssert(d != btScalar(0.0)); btScalar s = btScalar(2.0) / d; - #if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) + #if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) __m128 vs, Q = q.get128(); __m128i Qi = btCastfTo128i(Q); __m128 Y, Z; @@ -341,7 +346,7 @@ public: * @param m The array to be filled */ void getOpenGLSubMatrix(btScalar *m) const { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) __m128 v0 = m_el[0].mVec128; __m128 v1 = m_el[1].mVec128; __m128 v2 = m_el[2].mVec128; // x2 y2 z2 w2 @@ -362,7 +367,7 @@ public: vm[2] = v2; #elif defined(BT_USE_NEON) // note: zeros the w channel. We can preserve it at the cost of two more vtrn instructions. - static const uint32x2_t zMask = (const uint32x2_t) {-1, 0 }; + static const uint32x2_t zMask = (const uint32x2_t) {static_cast(-1), 0 }; float32x4_t *vm = (float32x4_t *)m; float32x4x2_t top = vtrnq_f32( m_el[0].mVec128, m_el[1].mVec128 ); // {x0 x1 z0 z1}, {y0 y1 w0 w1} float32x2x2_t bl = vtrn_f32( vget_low_f32(m_el[2].mVec128), vdup_n_f32(0.0f) ); // {x2 0 }, {y2 0} @@ -740,7 +745,7 @@ public: SIMD_FORCE_INLINE btMatrix3x3& btMatrix3x3::operator*=(const btMatrix3x3& m) { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) __m128 rv00, rv01, rv02; __m128 rv10, rv11, rv12; __m128 rv20, rv21, rv22; @@ -953,7 +958,7 @@ btMatrix3x3::determinant() const SIMD_FORCE_INLINE btMatrix3x3 btMatrix3x3::absolute() const { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) return btMatrix3x3( _mm_and_ps(m_el[0].mVec128, btvAbsfMask), _mm_and_ps(m_el[1].mVec128, btvAbsfMask), @@ -974,7 +979,7 @@ btMatrix3x3::absolute() const SIMD_FORCE_INLINE btMatrix3x3 btMatrix3x3::transpose() const { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) __m128 v0 = m_el[0].mVec128; __m128 v1 = m_el[1].mVec128; __m128 v2 = m_el[2].mVec128; // x2 y2 z2 w2 @@ -993,7 +998,7 @@ btMatrix3x3::transpose() const return btMatrix3x3( v0, v1, v2 ); #elif defined(BT_USE_NEON) // note: zeros the w channel. We can preserve it at the cost of two more vtrn instructions. - static const uint32x2_t zMask = (const uint32x2_t) {-1, 0 }; + static const uint32x2_t zMask = (const uint32x2_t) {static_cast(-1), 0 }; float32x4x2_t top = vtrnq_f32( m_el[0].mVec128, m_el[1].mVec128 ); // {x0 x1 z0 z1}, {y0 y1 w0 w1} float32x2x2_t bl = vtrn_f32( vget_low_f32(m_el[2].mVec128), vdup_n_f32(0.0f) ); // {x2 0 }, {y2 0} float32x4_t v0 = vcombine_f32( vget_low_f32(top.val[0]), bl.val[0] ); @@ -1031,7 +1036,7 @@ btMatrix3x3::inverse() const SIMD_FORCE_INLINE btMatrix3x3 btMatrix3x3::transposeTimes(const btMatrix3x3& m) const { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) // zeros w // static const __m128i xyzMask = (const __m128i){ -1ULL, 0xffffffffULL }; __m128 row = m_el[0].mVec128; @@ -1053,7 +1058,7 @@ btMatrix3x3::transposeTimes(const btMatrix3x3& m) const #elif defined BT_USE_NEON // zeros w - static const uint32x4_t xyzMask = (const uint32x4_t){ -1, -1, -1, 0 }; + static const uint32x4_t xyzMask = (const uint32x4_t){ static_cast(-1), static_cast(-1), static_cast(-1), 0 }; float32x4_t m0 = (float32x4_t) vandq_u32( (uint32x4_t) m.getRow(0).mVec128, xyzMask ); float32x4_t m1 = (float32x4_t) vandq_u32( (uint32x4_t) m.getRow(1).mVec128, xyzMask ); float32x4_t m2 = (float32x4_t) vandq_u32( (uint32x4_t) m.getRow(2).mVec128, xyzMask ); @@ -1151,7 +1156,7 @@ operator*(const btMatrix3x3& m, const btVector3& v) SIMD_FORCE_INLINE btVector3 operator*(const btVector3& v, const btMatrix3x3& m) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) const __m128 vv = v.mVec128; @@ -1191,7 +1196,7 @@ operator*(const btVector3& v, const btMatrix3x3& m) SIMD_FORCE_INLINE btMatrix3x3 operator*(const btMatrix3x3& m1, const btMatrix3x3& m2) { -#if (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) +#if defined BT_USE_SIMD_VECTOR3 && (defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE)) __m128 m10 = m1[0].mVec128; __m128 m11 = m1[1].mVec128; diff --git a/extern/bullet2/src/LinearMath/btMatrixX.h b/extern/bullet2/src/LinearMath/btMatrixX.h new file mode 100644 index 00000000000..1c29632c536 --- /dev/null +++ b/extern/bullet2/src/LinearMath/btMatrixX.h @@ -0,0 +1,504 @@ +/* +Bullet Continuous Collision Detection and Physics Library +Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. +*/ +///original version written by Erwin Coumans, October 2013 + +#ifndef BT_MATRIX_X_H +#define BT_MATRIX_X_H + +#include "LinearMath/btQuickprof.h" +#include "LinearMath/btAlignedObjectArray.h" + +class btIntSortPredicate +{ + public: + bool operator() ( const int& a, const int& b ) const + { + return a < b; + } +}; + + +template +struct btMatrixX +{ + int m_rows; + int m_cols; + int m_operations; + int m_resizeOperations; + int m_setElemOperations; + + btAlignedObjectArray m_storage; + btAlignedObjectArray< btAlignedObjectArray > m_rowNonZeroElements1; + btAlignedObjectArray< btAlignedObjectArray > m_colNonZeroElements; + + T* getBufferPointerWritable() + { + return m_storage.size() ? &m_storage[0] : 0; + } + + const T* getBufferPointer() const + { + return m_storage.size() ? &m_storage[0] : 0; + } + btMatrixX() + :m_rows(0), + m_cols(0), + m_operations(0), + m_resizeOperations(0), + m_setElemOperations(0) + { + } + btMatrixX(int rows,int cols) + :m_rows(rows), + m_cols(cols), + m_operations(0), + m_resizeOperations(0), + m_setElemOperations(0) + { + resize(rows,cols); + } + void resize(int rows, int cols) + { + m_resizeOperations++; + m_rows = rows; + m_cols = cols; + { + BT_PROFILE("m_storage.resize"); + m_storage.resize(rows*cols); + } + clearSparseInfo(); + } + int cols() const + { + return m_cols; + } + int rows() const + { + return m_rows; + } + ///we don't want this read/write operator(), because we cannot keep track of non-zero elements, use setElem instead + /*T& operator() (int row,int col) + { + return m_storage[col*m_rows+row]; + } + */ + + void addElem(int row,int col, T val) + { + if (val) + { + if (m_storage[col+row*m_cols]==0.f) + { + setElem(row,col,val); + } else + { + m_storage[row*m_cols+col] += val; + } + } + } + + void copyLowerToUpperTriangle() + { + int count=0; + for (int row=0;row0 && numRowsOther>0 && B && C); + const btScalar *bb = B; + for ( int i = 0;i +struct btVectorX +{ + btAlignedObjectArray m_storage; + + btVectorX() + { + } + btVectorX(int numRows) + { + m_storage.resize(numRows); + } + + void resize(int rows) + { + m_storage.resize(rows); + } + int cols() const + { + return 1; + } + int rows() const + { + return m_storage.size(); + } + int size() const + { + return rows(); + } + void setZero() + { + // for (int i=0;i +void setElem(btMatrixX& mat, int row, int col, T val) +{ + mat.setElem(row,col,val); +} +*/ + + +typedef btMatrixX btMatrixXf; +typedef btVectorX btVectorXf; + +typedef btMatrixX btMatrixXd; +typedef btVectorX btVectorXd; + + + +inline void setElem(btMatrixXd& mat, int row, int col, double val) +{ + mat.setElem(row,col,val); +} + +inline void setElem(btMatrixXf& mat, int row, int col, float val) +{ + mat.setElem(row,col,val); +} + +#ifdef BT_USE_DOUBLE_PRECISION + #define btVectorXu btVectorXd + #define btMatrixXu btMatrixXd +#else + #define btVectorXu btVectorXf + #define btMatrixXu btMatrixXf +#endif //BT_USE_DOUBLE_PRECISION + + + +#endif//BT_MATRIX_H_H diff --git a/extern/bullet2/src/LinearMath/btQuaternion.h b/extern/bullet2/src/LinearMath/btQuaternion.h index 7d7f25fb4d3..665421de1e4 100644 --- a/extern/bullet2/src/LinearMath/btQuaternion.h +++ b/extern/bullet2/src/LinearMath/btQuaternion.h @@ -27,11 +27,17 @@ subject to the following restrictions: #ifdef BT_USE_SSE -const __m128 ATTRIBUTE_ALIGNED16(vOnes) = {1.0f, 1.0f, 1.0f, 1.0f}; +//const __m128 ATTRIBUTE_ALIGNED16(vOnes) = {1.0f, 1.0f, 1.0f, 1.0f}; +#define vOnes (_mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f)) #endif -#if defined(BT_USE_SSE) || defined(BT_USE_NEON) +#if defined(BT_USE_SSE) + +#define vQInv (_mm_set_ps(+0.0f, -0.0f, -0.0f, -0.0f)) +#define vPPPM (_mm_set_ps(-0.0f, +0.0f, +0.0f, +0.0f)) + +#elif defined(BT_USE_NEON) const btSimdFloat4 ATTRIBUTE_ALIGNED16(vQInv) = {-0.0f, -0.0f, -0.0f, +0.0f}; const btSimdFloat4 ATTRIBUTE_ALIGNED16(vPPPM) = {+0.0f, +0.0f, +0.0f, -0.0f}; @@ -285,7 +291,7 @@ public: * @param q The other quaternion */ btScalar dot(const btQuaternion& q) const { -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) __m128 vd; vd = _mm_mul_ps(mVec128, q.mVec128); @@ -384,7 +390,7 @@ public: { return *this / length(); } - /**@brief Return the angle between this quaternion and the other + /**@brief Return the ***half*** angle between this quaternion and the other * @param q The other quaternion */ btScalar angle(const btQuaternion& q) const { @@ -392,6 +398,19 @@ public: btAssert(s != btScalar(0.0)); return btAcos(dot(q) / s); } + + /**@brief Return the angle between this quaternion and the other along the shortest path + * @param q The other quaternion */ + btScalar angleShortestPath(const btQuaternion& q) const + { + btScalar s = btSqrt(length2() * q.length2()); + btAssert(s != btScalar(0.0)); + if (dot(q) < 0) // Take care of long angle case see http://en.wikipedia.org/wiki/Slerp + return btAcos(dot(-q) / s) * btScalar(2.0); + else + return btAcos(dot(q) / s) * btScalar(2.0); + } + /**@brief Return the angle of rotation represented by this quaternion */ btScalar getAngle() const { @@ -399,6 +418,19 @@ public: return s; } + /**@brief Return the angle of rotation represented by this quaternion along the shortest path*/ + btScalar getAngleShortestPath() const + { + btScalar s; + if (dot(*this) < 0) + s = btScalar(2.) * btAcos(m_floats[3]); + else + s = btScalar(2.) * btAcos(-m_floats[3]); + + return s; + } + + /**@brief Return the axis of the rotation represented by this quaternion */ btVector3 getAxis() const { @@ -835,7 +867,7 @@ quatRotate(const btQuaternion& rotation, const btVector3& v) { btQuaternion q = rotation * v; q *= rotation.inverse(); -#if defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) +#if defined BT_USE_SIMD_VECTOR3 && defined (BT_USE_SSE_IN_API) && defined (BT_USE_SSE) return btVector3(_mm_and_ps(q.get128(), btvFFF0fMask)); #elif defined(BT_USE_NEON) return btVector3((float32x4_t)vandq_s32((int32x4_t)q.get128(), btvFFF0Mask)); diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h index aaa1d6de6b4..37c6dec191d 100644 --- a/extern/bullet2/src/LinearMath/btScalar.h +++ b/extern/bullet2/src/LinearMath/btScalar.h @@ -28,7 +28,7 @@ subject to the following restrictions: #include /* SVN $Revision$ on $Date$ from http://bullet.googlecode.com*/ -#define BT_BULLET_VERSION 281 +#define BT_BULLET_VERSION 282 inline int btGetVersion() { @@ -180,7 +180,7 @@ inline int btGetVersion() #include #endif #endif //BT_USE_SSE - #elif defined( __armv7__ ) + #elif defined( __ARM_NEON__ ) #ifdef __clang__ #define BT_USE_NEON 1 #define BT_USE_SIMD_VECTOR3 @@ -257,10 +257,12 @@ inline int btGetVersion() ///The btScalar type abstracts floating point numbers, to easily switch between double and single floating point precision. #if defined(BT_USE_DOUBLE_PRECISION) + typedef double btScalar; //this number could be bigger in double precision #define BT_LARGE_FLOAT 1e30 #else + typedef float btScalar; //keep BT_LARGE_FLOAT*BT_LARGE_FLOAT < FLT_MAX #define BT_LARGE_FLOAT 1e18f @@ -284,6 +286,8 @@ static int btInfinityMask = 0x7F800000; #define BT_INFINITY (*(float*)&btInfinityMask) #endif +//use this, in case there are clashes (such as xnamath.h) +#ifndef BT_NO_SIMD_OPERATOR_OVERLOADS inline __m128 operator + (const __m128 A, const __m128 B) { return _mm_add_ps(A, B); @@ -298,6 +302,7 @@ inline __m128 operator * (const __m128 A, const __m128 B) { return _mm_mul_ps(A, B); } +#endif //BT_NO_SIMD_OPERATOR_OVERLOADS #define btCastfTo128i(a) (_mm_castps_si128(a)) #define btCastfTo128d(a) (_mm_castps_pd(a)) @@ -317,7 +322,24 @@ inline __m128 operator * (const __m128 A, const __m128 B) #define BT_INFINITY INFINITY #define BT_NAN NAN #endif//_WIN32 -#endif //BT_USE_SSE_IN_API +#else + +#ifdef BT_USE_NEON + #include + + typedef float32x4_t btSimdFloat4; + #define BT_INFINITY INFINITY + #define BT_NAN NAN + #define btAssign128(r0,r1,r2,r3) (float32x4_t){r0,r1,r2,r3} +#else//BT_USE_NEON + + #ifndef BT_INFINITY + static int btInfinityMask = 0x7F800000; + #define BT_INFINITY (*(float*)&btInfinityMask) + #endif +#endif//BT_USE_NEON + +#endif //BT_USE_SSE #ifdef BT_USE_NEON #include @@ -409,15 +431,15 @@ SIMD_FORCE_INLINE btScalar btFmod(btScalar x,btScalar y) { return fmodf(x,y); } #endif -#define SIMD_2_PI btScalar(6.283185307179586232) -#define SIMD_PI (SIMD_2_PI * btScalar(0.5)) -#define SIMD_HALF_PI (SIMD_2_PI * btScalar(0.25)) +#define SIMD_PI btScalar(3.1415926535897932384626433832795029) +#define SIMD_2_PI btScalar(2.0) * SIMD_PI +#define SIMD_HALF_PI (SIMD_PI * btScalar(0.5)) #define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0)) #define SIMD_DEGS_PER_RAD (btScalar(360.0) / SIMD_2_PI) #define SIMDSQRT12 btScalar(0.7071067811865475244008443621048490) #define btRecipSqrt(x) ((btScalar)(btScalar(1.0)/btSqrt(btScalar(x)))) /* reciprocal square root */ - +#define btRecip(x) (btScalar(1.0)/btScalar(x)) #ifdef BT_USE_DOUBLE_PRECISION #define SIMD_EPSILON DBL_EPSILON @@ -608,6 +630,46 @@ SIMD_FORCE_INLINE double btUnswapEndianDouble(const unsigned char *src) return d; } +template +SIMD_FORCE_INLINE void btSetZero(T* a, int n) +{ + T* acurr = a; + size_t ncurr = n; + while (ncurr > 0) + { + *(acurr++) = 0; + --ncurr; + } +} + + +SIMD_FORCE_INLINE btScalar btLargeDot(const btScalar *a, const btScalar *b, int n) +{ + btScalar p0,q0,m0,p1,q1,m1,sum; + sum = 0; + n -= 2; + while (n >= 0) { + p0 = a[0]; q0 = b[0]; + m0 = p0 * q0; + p1 = a[1]; q1 = b[1]; + m1 = p1 * q1; + sum += m0; + sum += m1; + a += 2; + b += 2; + n -= 2; + } + n += 2; + while (n > 0) { + sum += (*a) * (*b); + a++; + b++; + n--; + } + return sum; +} + + // returns normalized value in range [-SIMD_PI, SIMD_PI] SIMD_FORCE_INLINE btScalar btNormalizeAngle(btScalar angleInRadians) { @@ -626,6 +688,8 @@ SIMD_FORCE_INLINE btScalar btNormalizeAngle(btScalar angleInRadians) } } + + ///rudimentary class to provide type info struct btTypedObject { diff --git a/extern/bullet2/src/LinearMath/btSerializer.cpp b/extern/bullet2/src/LinearMath/btSerializer.cpp index d6b2b3a5a5c..ba344939530 100644 --- a/extern/bullet2/src/LinearMath/btSerializer.cpp +++ b/extern/bullet2/src/LinearMath/btSerializer.cpp @@ -1,5 +1,5 @@ char sBulletDNAstr[]= { -char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(63),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109), +char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(69),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109), char(95),char(99),char(97),char(112),char(97),char(99),char(105),char(116),char(121),char(0),char(42),char(109),char(95),char(100),char(97),char(116),char(97),char(0),char(109),char(95), char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(115),char(0),char(109),char(95),char(99),char(111), char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99),char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110), @@ -58,238 +58,242 @@ char(102),char(111),char(114),char(109),char(0),char(42),char(109),char(95),char char(95),char(99),char(104),char(105),char(108),char(100),char(83),char(104),char(97),char(112),char(101),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(99),char(104), char(105),char(108),char(100),char(77),char(97),char(114),char(103),char(105),char(110),char(0),char(42),char(109),char(95),char(99),char(104),char(105),char(108),char(100),char(83),char(104), char(97),char(112),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117),char(109),char(67),char(104),char(105),char(108),char(100),char(83),char(104),char(97), -char(112),char(101),char(115),char(0),char(109),char(95),char(117),char(112),char(65),char(120),char(105),char(115),char(0),char(109),char(95),char(102),char(108),char(97),char(103),char(115), -char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(48),char(86),char(49),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101), -char(100),char(103),char(101),char(86),char(49),char(86),char(50),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86), -char(50),char(86),char(48),char(65),char(110),char(103),char(108),char(101),char(0),char(42),char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108), -char(101),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(110),char(101),char(120),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(118), -char(97),char(108),char(117),char(101),char(65),char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(107),char(101),char(121),char(65), -char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(118),char(101),char(120),char(69),char(112),char(115),char(105), -char(108),char(111),char(110),char(0),char(109),char(95),char(112),char(108),char(97),char(110),char(97),char(114),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0), -char(109),char(95),char(101),char(113),char(117),char(97),char(108),char(86),char(101),char(114),char(116),char(101),char(120),char(84),char(104),char(114),char(101),char(115),char(104),char(111), -char(108),char(100),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(68),char(105),char(115),char(116),char(97),char(110),char(99),char(101),char(84),char(104),char(114), -char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(122),char(101),char(114),char(111),char(65),char(114),char(101),char(97),char(84),char(104),char(114), -char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(101),char(120),char(116),char(83),char(105),char(122),char(101),char(0),char(109),char(95), -char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(110),char(117),char(109),char(86), -char(97),char(108),char(117),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(75),char(101),char(121),char(115),char(0),char(109),char(95),char(103),char(105), -char(109),char(112),char(97),char(99),char(116),char(83),char(117),char(98),char(84),char(121),char(112),char(101),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99), -char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(70),char(108),char(111),char(97),char(116),char(80),char(116),char(114),char(0),char(42), -char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(68),char(111),char(117),char(98), -char(108),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117),char(109),char(85),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80), -char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(112),char(97),char(100),char(100),char(105),char(110),char(103),char(51),char(91),char(52),char(93),char(0), -char(42),char(109),char(95),char(98),char(114),char(111),char(97),char(100),char(112),char(104),char(97),char(115),char(101),char(72),char(97),char(110),char(100),char(108),char(101),char(0), -char(42),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(42),char(109), -char(95),char(114),char(111),char(111),char(116),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0), -char(109),char(95),char(119),char(111),char(114),char(108),char(100),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105), -char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(87),char(111),char(114),char(108),char(100),char(84),char(114),char(97), +char(112),char(101),char(115),char(0),char(109),char(95),char(117),char(112),char(65),char(120),char(105),char(115),char(0),char(109),char(95),char(117),char(112),char(73),char(110),char(100), +char(101),char(120),char(0),char(109),char(95),char(102),char(108),char(97),char(103),char(115),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(48),char(86), +char(49),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(49),char(86),char(50),char(65),char(110),char(103), +char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(50),char(86),char(48),char(65),char(110),char(103),char(108),char(101),char(0),char(42), +char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(110),char(101), +char(120),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(118),char(97),char(108),char(117),char(101),char(65),char(114),char(114),char(97),char(121),char(80), +char(116),char(114),char(0),char(42),char(109),char(95),char(107),char(101),char(121),char(65),char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(109),char(95), +char(99),char(111),char(110),char(118),char(101),char(120),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0),char(109),char(95),char(112),char(108),char(97),char(110), +char(97),char(114),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0),char(109),char(95),char(101),char(113),char(117),char(97),char(108),char(86),char(101),char(114), +char(116),char(101),char(120),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(68), +char(105),char(115),char(116),char(97),char(110),char(99),char(101),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(122), +char(101),char(114),char(111),char(65),char(114),char(101),char(97),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110), +char(101),char(120),char(116),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(83), +char(105),char(122),char(101),char(0),char(109),char(95),char(110),char(117),char(109),char(86),char(97),char(108),char(117),char(101),char(115),char(0),char(109),char(95),char(110),char(117), +char(109),char(75),char(101),char(121),char(115),char(0),char(109),char(95),char(103),char(105),char(109),char(112),char(97),char(99),char(116),char(83),char(117),char(98),char(84),char(121), +char(112),char(101),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115), +char(70),char(108),char(111),char(97),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100), +char(80),char(111),char(105),char(110),char(116),char(115),char(68),char(111),char(117),char(98),char(108),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117), +char(109),char(85),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(112),char(97), +char(100),char(100),char(105),char(110),char(103),char(51),char(91),char(52),char(93),char(0),char(42),char(109),char(95),char(98),char(114),char(111),char(97),char(100),char(112),char(104), +char(97),char(115),char(101),char(72),char(97),char(110),char(100),char(108),char(101),char(0),char(42),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105), +char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(42),char(109),char(95),char(114),char(111),char(111),char(116),char(67),char(111),char(108),char(108),char(105), +char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(109),char(95),char(119),char(111),char(114),char(108),char(100),char(84),char(114),char(97), char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105), -char(111),char(110),char(76),char(105),char(110),char(101),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(105), -char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(86), -char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105), -char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(99),char(116),char(80), -char(114),char(111),char(99),char(101),char(115),char(115),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109), -char(95),char(100),char(101),char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110),char(84),char(105),char(109),char(101),char(0),char(109),char(95), -char(102),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114), -char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110), -char(0),char(109),char(95),char(104),char(105),char(116),char(70),char(114),char(97),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(99),char(100), -char(83),char(119),char(101),char(112),char(116),char(83),char(112),char(104),char(101),char(114),char(101),char(82),char(97),char(100),char(105),char(117),char(115),char(0),char(109),char(95), -char(99),char(99),char(100),char(77),char(111),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109), -char(95),char(104),char(97),char(115),char(65),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116), -char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(70),char(108),char(97),char(103),char(115), -char(0),char(109),char(95),char(105),char(115),char(108),char(97),char(110),char(100),char(84),char(97),char(103),char(49),char(0),char(109),char(95),char(99),char(111),char(109),char(112), -char(97),char(110),char(105),char(111),char(110),char(73),char(100),char(0),char(109),char(95),char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110), -char(83),char(116),char(97),char(116),char(101),char(49),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(84),char(121),char(112), -char(101),char(0),char(109),char(95),char(99),char(104),char(101),char(99),char(107),char(67),char(111),char(108),char(108),char(105),char(100),char(101),char(87),char(105),char(116),char(104), -char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(73),char(110),char(102),char(111),char(0),char(109),char(95),char(103),char(114),char(97),char(118), -char(105),char(116),char(121),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99), -char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(84),char(101), -char(110),char(115),char(111),char(114),char(87),char(111),char(114),char(108),char(100),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(86),char(101), -char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111), -char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114), -char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(103),char(114), -char(97),char(118),char(105),char(116),char(121),char(95),char(97),char(99),char(99),char(101),char(108),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(0),char(109), -char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(76),char(111),char(99),char(97),char(108),char(0),char(109),char(95),char(116), -char(111),char(116),char(97),char(108),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(84),char(111),char(114), -char(113),char(117),char(101),char(0),char(109),char(95),char(105),char(110),char(118),char(101),char(114),char(115),char(101),char(77),char(97),char(115),char(115),char(0),char(109),char(95), -char(108),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(110),char(103),char(117), -char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111), -char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(97), -char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(76),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105), -char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100), -char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110), -char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105), -char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103), -char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(101),char(101),char(112), -char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108), -char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0), -char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0), -char(109),char(95),char(110),char(117),char(109),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(82),char(111),char(119),char(115),char(0), -char(110),char(117),char(98),char(0),char(42),char(109),char(95),char(114),char(98),char(65),char(0),char(42),char(109),char(95),char(114),char(98),char(66),char(0),char(109),char(95), -char(111),char(98),char(106),char(101),char(99),char(116),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110), -char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111), -char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(100),char(0),char(109),char(95),char(110),char(101),char(101),char(100),char(115),char(70),char(101), -char(101),char(100),char(98),char(97),char(99),char(107),char(0),char(109),char(95),char(97),char(112),char(112),char(108),char(105),char(101),char(100),char(73),char(109),char(112),char(117), -char(108),char(115),char(101),char(0),char(109),char(95),char(100),char(98),char(103),char(68),char(114),char(97),char(119),char(83),char(105),char(122),char(101),char(0),char(109),char(95), -char(100),char(105),char(115),char(97),char(98),char(108),char(101),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(115),char(66),char(101),char(116), -char(119),char(101),char(101),char(110),char(76),char(105),char(110),char(107),char(101),char(100),char(66),char(111),char(100),char(105),char(101),char(115),char(0),char(109),char(95),char(111), -char(118),char(101),char(114),char(114),char(105),char(100),char(101),char(78),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(116),char(101),char(114), -char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(98),char(114),char(101),char(97),char(107),char(105),char(110),char(103),char(73),char(109),char(112), -char(117),char(108),char(115),char(101),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(105),char(115),char(69),char(110), -char(97),char(98),char(108),char(101),char(100),char(0),char(109),char(95),char(116),char(121),char(112),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105), -char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(65),char(0),char(109),char(95), -char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(98),char(65),char(70),char(114),char(97),char(109),char(101),char(0), -char(109),char(95),char(114),char(98),char(66),char(70),char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(82),char(101),char(102),char(101), -char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97), -char(114),char(79),char(110),char(108),char(121),char(0),char(109),char(95),char(101),char(110),char(97),char(98),char(108),char(101),char(65),char(110),char(103),char(117),char(108),char(97), -char(114),char(77),char(111),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(111),char(116),char(111),char(114),char(84),char(97),char(114),char(103),char(101),char(116), -char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(109),char(97),char(120),char(77),char(111),char(116),char(111),char(114),char(73), -char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(108),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0), -char(109),char(95),char(117),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(109),char(105),char(116), -char(83),char(111),char(102),char(116),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(98),char(105),char(97),char(115),char(70),char(97),char(99),char(116),char(111), -char(114),char(0),char(109),char(95),char(114),char(101),char(108),char(97),char(120),char(97),char(116),char(105),char(111),char(110),char(70),char(97),char(99),char(116),char(111),char(114), -char(0),char(109),char(95),char(115),char(119),char(105),char(110),char(103),char(83),char(112),char(97),char(110),char(49),char(0),char(109),char(95),char(115),char(119),char(105),char(110), -char(103),char(83),char(112),char(97),char(110),char(50),char(0),char(109),char(95),char(116),char(119),char(105),char(115),char(116),char(83),char(112),char(97),char(110),char(0),char(109), -char(95),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(85),char(112),char(112), -char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(76),char(111),char(119),char(101), -char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(85),char(112),char(112),char(101), -char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(76),char(111),char(119),char(101), -char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(117),char(115),char(101),char(76),char(105),char(110),char(101),char(97),char(114),char(82),char(101), -char(102),char(101),char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(117),char(115),char(101),char(79), -char(102),char(102),char(115),char(101),char(116),char(70),char(111),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(114), -char(97),char(109),char(101),char(0),char(109),char(95),char(54),char(100),char(111),char(102),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(115),char(112),char(114), -char(105),char(110),char(103),char(69),char(110),char(97),char(98),char(108),char(101),char(100),char(91),char(54),char(93),char(0),char(109),char(95),char(101),char(113),char(117),char(105), -char(108),char(105),char(98),char(114),char(105),char(117),char(109),char(80),char(111),char(105),char(110),char(116),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112), -char(114),char(105),char(110),char(103),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(91),char(54),char(93),char(0),char(109),char(95),char(115), -char(112),char(114),char(105),char(110),char(103),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(91),char(54),char(93),char(0),char(109),char(95),char(116),char(97), -char(117),char(0),char(109),char(95),char(116),char(105),char(109),char(101),char(83),char(116),char(101),char(112),char(0),char(109),char(95),char(109),char(97),char(120),char(69),char(114), -char(114),char(111),char(114),char(82),char(101),char(100),char(117),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(115),char(111),char(114),char(0),char(109), -char(95),char(101),char(114),char(112),char(0),char(109),char(95),char(101),char(114),char(112),char(50),char(0),char(109),char(95),char(103),char(108),char(111),char(98),char(97),char(108), -char(67),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(80),char(101), -char(110),char(101),char(116),char(114),char(97),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109), -char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(117),char(114),char(110),char(69),char(114),char(112), -char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(111),char(112),char(0),char(109),char(95),char(119),char(97),char(114),char(109), -char(115),char(116),char(97),char(114),char(116),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(97),char(120), -char(71),char(121),char(114),char(111),char(115),char(99),char(111),char(112),char(105),char(99),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(115),char(105), -char(110),char(103),char(108),char(101),char(65),char(120),char(105),char(115),char(82),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),char(105),char(99),char(116), -char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(117),char(109),char(73),char(116), -char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(77),char(111),char(100), -char(101),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(110),char(103),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(82),char(101), -char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109), -char(95),char(109),char(105),char(110),char(105),char(109),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(66),char(97),char(116),char(99),char(104),char(83), -char(105),char(122),char(101),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109), -char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97), -char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(118),char(111), -char(108),char(117),char(109),char(101),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(42),char(109),char(95),char(109),char(97),char(116), -char(101),char(114),char(105),char(97),char(108),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112), -char(114),char(101),char(118),char(105),char(111),char(117),char(115),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(118),char(101), -char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(99),char(99),char(117),char(109),char(117),char(108),char(97),char(116),char(101),char(100), -char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(110),char(111),char(114),char(109),char(97),char(108),char(0),char(109),char(95),char(97),char(114),char(101), -char(97),char(0),char(109),char(95),char(97),char(116),char(116),char(97),char(99),char(104),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100), -char(105),char(99),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(76),char(101),char(110),char(103),char(116),char(104), -char(0),char(109),char(95),char(98),char(98),char(101),char(110),char(100),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110), -char(100),char(105),char(99),char(101),char(115),char(91),char(51),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(65),char(114),char(101),char(97),char(0), -char(109),char(95),char(99),char(48),char(91),char(52),char(93),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101), -char(115),char(91),char(52),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95), -char(99),char(49),char(0),char(109),char(95),char(99),char(50),char(0),char(109),char(95),char(99),char(48),char(0),char(109),char(95),char(108),char(111),char(99),char(97),char(108), -char(70),char(114),char(97),char(109),char(101),char(0),char(42),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(0),char(109), -char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(101),char(120),char(0),char(109),char(95),char(97),char(101),char(114),char(111),char(77),char(111),char(100), -char(101),char(108),char(0),char(109),char(95),char(98),char(97),char(117),char(109),char(103),char(97),char(114),char(116),char(101),char(0),char(109),char(95),char(100),char(114),char(97), -char(103),char(0),char(109),char(95),char(108),char(105),char(102),char(116),char(0),char(109),char(95),char(112),char(114),char(101),char(115),char(115),char(117),char(114),char(101),char(0), -char(109),char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(100),char(121),char(110),char(97),char(109),char(105),char(99),char(70),char(114), -char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112),char(111),char(115),char(101),char(77),char(97),char(116),char(99),char(104),char(0),char(109), -char(95),char(114),char(105),char(103),char(105),char(100),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115), -char(115),char(0),char(109),char(95),char(107),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97), -char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(67),char(111),char(110),char(116),char(97),char(99),char(116), -char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(72),char(97),char(114), -char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(67),char(108),char(117), -char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(75), -char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115), -char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72), -char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(67), -char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109), -char(95),char(115),char(111),char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73), -char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111), -char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105), -char(116),char(0),char(109),char(95),char(109),char(97),char(120),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(116),char(105),char(109),char(101), -char(83),char(99),char(97),char(108),char(101),char(0),char(109),char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(73),char(116),char(101),char(114), -char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(73),char(116),char(101), -char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(100),char(114),char(105),char(102),char(116),char(73),char(116),char(101),char(114),char(97), -char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(116),char(101),char(114),char(97), -char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(114),char(111),char(116),char(0),char(109),char(95),char(115),char(99),char(97),char(108),char(101),char(0), -char(109),char(95),char(97),char(113),char(113),char(0),char(109),char(95),char(99),char(111),char(109),char(0),char(42),char(109),char(95),char(112),char(111),char(115),char(105),char(116), -char(105),char(111),char(110),char(115),char(0),char(42),char(109),char(95),char(119),char(101),char(105),char(103),char(104),char(116),char(115),char(0),char(109),char(95),char(110),char(117), -char(109),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(87),char(101),char(105),char(103), -char(116),char(115),char(0),char(109),char(95),char(98),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(98),char(102),char(114),char(97),char(109), -char(101),char(0),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(120),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(108),char(111),char(99), -char(105),char(105),char(0),char(109),char(95),char(105),char(110),char(118),char(119),char(105),char(0),char(109),char(95),char(118),char(105),char(109),char(112),char(117),char(108),char(115), -char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(91),char(50),char(93), -char(0),char(109),char(95),char(108),char(118),char(0),char(109),char(95),char(97),char(118),char(0),char(42),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(114), -char(101),char(102),char(115),char(0),char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(0),char(42), -char(109),char(95),char(109),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(70),char(114),char(97),char(109),char(101),char(82), -char(101),char(102),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(78),char(111),char(100),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109), -char(77),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(105),char(100),char(109),char(97),char(115),char(115),char(0),char(109),char(95),char(105),char(109), -char(97),char(115),char(115),char(0),char(109),char(95),char(110),char(118),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110), -char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(100),char(97),char(109),char(112),char(105),char(110),char(103), -char(0),char(109),char(95),char(108),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(97),char(109),char(112),char(105), -char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(116),char(99),char(104),char(105),char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(120),char(83), -char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0), -char(109),char(95),char(115),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108), -char(115),char(101),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(105),char(110),char(115),char(65), -char(110),char(99),char(104),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(100),char(101),char(0),char(109),char(95),char(99),char(108), -char(117),char(115),char(116),char(101),char(114),char(73),char(110),char(100),char(101),char(120),char(0),char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(65),char(0), -char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(0),char(109),char(95),char(114),char(101),char(102),char(115),char(91),char(50),char(93),char(0),char(109), -char(95),char(99),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(100),char(101),char(108),char(101),char(116), -char(101),char(0),char(109),char(95),char(114),char(101),char(108),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(91),char(50),char(93),char(0),char(109), -char(95),char(98),char(111),char(100),char(121),char(65),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(116),char(121), -char(112),char(101),char(0),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(42),char(109),char(95),char(112),char(111), -char(115),char(101),char(0),char(42),char(42),char(109),char(95),char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0),char(42),char(109),char(95), -char(110),char(111),char(100),char(101),char(115),char(0),char(42),char(109),char(95),char(108),char(105),char(110),char(107),char(115),char(0),char(42),char(109),char(95),char(102),char(97), -char(99),char(101),char(115),char(0),char(42),char(109),char(95),char(116),char(101),char(116),char(114),char(97),char(104),char(101),char(100),char(114),char(97),char(0),char(42),char(109), -char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(42),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(115), -char(0),char(42),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(77),char(97),char(116),char(101), -char(114),char(105),char(97),char(108),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(76),char(105),char(110),char(107),char(115),char(0),char(109),char(95),char(110), -char(117),char(109),char(70),char(97),char(99),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(84),char(101),char(116),char(114),char(97),char(104),char(101), -char(100),char(114),char(97),char(0),char(109),char(95),char(110),char(117),char(109),char(65),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(109),char(95),char(110), -char(117),char(109),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(74),char(111),char(105),char(110), -char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110),char(102),char(105),char(103),char(0),char(84),char(89),char(80),char(69),char(76),char(0),char(0),char(0), -char(99),char(104),char(97),char(114),char(0),char(117),char(99),char(104),char(97),char(114),char(0),char(115),char(104),char(111),char(114),char(116),char(0),char(117),char(115),char(104), -char(111),char(114),char(116),char(0),char(105),char(110),char(116),char(0),char(108),char(111),char(110),char(103),char(0),char(117),char(108),char(111),char(110),char(103),char(0),char(102), -char(108),char(111),char(97),char(116),char(0),char(100),char(111),char(117),char(98),char(108),char(101),char(0),char(118),char(111),char(105),char(100),char(0),char(80),char(111),char(105), -char(110),char(116),char(101),char(114),char(65),char(114),char(114),char(97),char(121),char(0),char(98),char(116),char(80),char(104),char(121),char(115),char(105),char(99),char(115),char(83), -char(121),char(115),char(116),char(101),char(109),char(0),char(76),char(105),char(115),char(116),char(66),char(97),char(115),char(101),char(0),char(98),char(116),char(86),char(101),char(99), -char(116),char(111),char(114),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(86),char(101),char(99),char(116), -char(111),char(114),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(97),char(116),char(114), -char(105),char(120),char(51),char(120),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(97),char(116), -char(114),char(105),char(120),char(51),char(120),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84), -char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0), -char(98),char(116),char(66),char(118),char(104),char(83),char(117),char(98),char(116),char(114),char(101),char(101),char(73),char(110),char(102),char(111),char(68),char(97),char(116),char(97), -char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(70), -char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100), -char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97), -char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(70),char(108),char(111),char(97),char(116), -char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(68), -char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111), -char(110),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(97),char(116),char(105),char(99),char(80), -char(108),char(97),char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(118), -char(101),char(120),char(73),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0), -char(98),char(116),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(65),char(110),char(100),char(82),char(97),char(100),char(105),char(117),char(115),char(0), -char(98),char(116),char(77),char(117),char(108),char(116),char(105),char(83),char(112),char(104),char(101),char(114),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97), -char(116),char(97),char(0),char(98),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105),char(112),char(108),char(101),char(116), -char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(104),char(97),char(114),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105),char(112), -char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(101),char(115),char(104),char(80),char(97),char(114),char(116),char(68),char(97), -char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(114),char(105),char(100),char(105),char(110),char(103),char(77),char(101),char(115),char(104),char(73),char(110),char(116), -char(101),char(114),char(102),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108), -char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105), -char(97),char(110),char(103),char(108),char(101),char(73),char(110),char(102),char(111),char(77),char(97),char(112),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83), -char(99),char(97),char(108),char(101),char(100),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97), -char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117),char(110),char(100),char(83),char(104),char(97), -char(112),char(101),char(67),char(104),char(105),char(108),char(100),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117), -char(110),char(100),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(121),char(108),char(105),char(110),char(100), -char(101),char(114),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(97),char(112),char(115),char(117),char(108), +char(111),char(110),char(87),char(111),char(114),char(108),char(100),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105), +char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(76),char(105),char(110),char(101),char(97),char(114),char(86),char(101), +char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105), +char(111),char(110),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95), +char(97),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0), +char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(99),char(116),char(80),char(114),char(111),char(99),char(101),char(115),char(115),char(105),char(110),char(103),char(84), +char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(100),char(101),char(97),char(99),char(116),char(105),char(118),char(97),char(116), +char(105),char(111),char(110),char(84),char(105),char(109),char(101),char(0),char(109),char(95),char(102),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109), +char(95),char(114),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114), +char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(104),char(105),char(116),char(70),char(114),char(97),char(99), +char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(99),char(100),char(83),char(119),char(101),char(112),char(116),char(83),char(112),char(104),char(101),char(114), +char(101),char(82),char(97),char(100),char(105),char(117),char(115),char(0),char(109),char(95),char(99),char(99),char(100),char(77),char(111),char(116),char(105),char(111),char(110),char(84), +char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(104),char(97),char(115),char(65),char(110),char(105),char(115),char(111),char(116), +char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(108),char(108), +char(105),char(115),char(105),char(111),char(110),char(70),char(108),char(97),char(103),char(115),char(0),char(109),char(95),char(105),char(115),char(108),char(97),char(110),char(100),char(84), +char(97),char(103),char(49),char(0),char(109),char(95),char(99),char(111),char(109),char(112),char(97),char(110),char(105),char(111),char(110),char(73),char(100),char(0),char(109),char(95), +char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110),char(83),char(116),char(97),char(116),char(101),char(49),char(0),char(109),char(95),char(105), +char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(99),char(104),char(101),char(99),char(107),char(67), +char(111),char(108),char(108),char(105),char(100),char(101),char(87),char(105),char(116),char(104),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(73), +char(110),char(102),char(111),char(0),char(109),char(95),char(103),char(114),char(97),char(118),char(105),char(116),char(121),char(0),char(109),char(95),char(99),char(111),char(108),char(108), +char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(105),char(110), +char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(84),char(101),char(110),char(115),char(111),char(114),char(87),char(111),char(114),char(108),char(100),char(0), +char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97), +char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103), +char(117),char(108),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(70), +char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(103),char(114),char(97),char(118),char(105),char(116),char(121),char(95),char(97),char(99),char(99),char(101), +char(108),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105), +char(97),char(76),char(111),char(99),char(97),char(108),char(0),char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(70),char(111),char(114),char(99),char(101),char(0), +char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(84),char(111),char(114),char(113),char(117),char(101),char(0),char(109),char(95),char(105),char(110),char(118),char(101), +char(114),char(115),char(101),char(77),char(97),char(115),char(115),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112), +char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103), +char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103), +char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(76), +char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108), +char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103), +char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100), +char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117), +char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108), +char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111), +char(108),char(100),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103), +char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110), +char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(117),char(109),char(67),char(111),char(110),char(115),char(116), +char(114),char(97),char(105),char(110),char(116),char(82),char(111),char(119),char(115),char(0),char(110),char(117),char(98),char(0),char(42),char(109),char(95),char(114),char(98),char(65), +char(0),char(42),char(109),char(95),char(114),char(98),char(66),char(0),char(109),char(95),char(111),char(98),char(106),char(101),char(99),char(116),char(84),char(121),char(112),char(101), +char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(84),char(121),char(112), +char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(100), +char(0),char(109),char(95),char(110),char(101),char(101),char(100),char(115),char(70),char(101),char(101),char(100),char(98),char(97),char(99),char(107),char(0),char(109),char(95),char(97), +char(112),char(112),char(108),char(105),char(101),char(100),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(100),char(98),char(103),char(68), +char(114),char(97),char(119),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(100),char(105),char(115),char(97),char(98),char(108),char(101),char(67),char(111),char(108), +char(108),char(105),char(115),char(105),char(111),char(110),char(115),char(66),char(101),char(116),char(119),char(101),char(101),char(110),char(76),char(105),char(110),char(107),char(101),char(100), +char(66),char(111),char(100),char(105),char(101),char(115),char(0),char(109),char(95),char(111),char(118),char(101),char(114),char(114),char(105),char(100),char(101),char(78),char(117),char(109), +char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(98), +char(114),char(101),char(97),char(107),char(105),char(110),char(103),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(104),char(114),char(101),char(115),char(104), +char(111),char(108),char(100),char(0),char(109),char(95),char(105),char(115),char(69),char(110),char(97),char(98),char(108),char(101),char(100),char(0),char(112),char(97),char(100),char(100), +char(105),char(110),char(103),char(91),char(52),char(93),char(0),char(109),char(95),char(116),char(121),char(112),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97), +char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(65),char(0),char(109), +char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(98),char(65),char(70),char(114),char(97),char(109),char(101), +char(0),char(109),char(95),char(114),char(98),char(66),char(70),char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(82),char(101),char(102), +char(101),char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108), +char(97),char(114),char(79),char(110),char(108),char(121),char(0),char(109),char(95),char(101),char(110),char(97),char(98),char(108),char(101),char(65),char(110),char(103),char(117),char(108), +char(97),char(114),char(77),char(111),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(111),char(116),char(111),char(114),char(84),char(97),char(114),char(103),char(101), +char(116),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(109),char(97),char(120),char(77),char(111),char(116),char(111),char(114), +char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(108),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),char(116), +char(0),char(109),char(95),char(117),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(109),char(105), +char(116),char(83),char(111),char(102),char(116),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(98),char(105),char(97),char(115),char(70),char(97),char(99),char(116), +char(111),char(114),char(0),char(109),char(95),char(114),char(101),char(108),char(97),char(120),char(97),char(116),char(105),char(111),char(110),char(70),char(97),char(99),char(116),char(111), +char(114),char(0),char(109),char(95),char(112),char(97),char(100),char(100),char(105),char(110),char(103),char(49),char(91),char(52),char(93),char(0),char(109),char(95),char(115),char(119), +char(105),char(110),char(103),char(83),char(112),char(97),char(110),char(49),char(0),char(109),char(95),char(115),char(119),char(105),char(110),char(103),char(83),char(112),char(97),char(110), +char(50),char(0),char(109),char(95),char(116),char(119),char(105),char(115),char(116),char(83),char(112),char(97),char(110),char(0),char(109),char(95),char(100),char(97),char(109),char(112), +char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(85),char(112),char(112),char(101),char(114),char(76),char(105),char(109), +char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(76),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105), +char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(85),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105), +char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(76),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105), +char(116),char(0),char(109),char(95),char(117),char(115),char(101),char(76),char(105),char(110),char(101),char(97),char(114),char(82),char(101),char(102),char(101),char(114),char(101),char(110), +char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(117),char(115),char(101),char(79),char(102),char(102),char(115),char(101),char(116), +char(70),char(111),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(114),char(97),char(109),char(101),char(0),char(109), +char(95),char(54),char(100),char(111),char(102),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103),char(69),char(110), +char(97),char(98),char(108),char(101),char(100),char(91),char(54),char(93),char(0),char(109),char(95),char(101),char(113),char(117),char(105),char(108),char(105),char(98),char(114),char(105), +char(117),char(109),char(80),char(111),char(105),char(110),char(116),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103),char(83), +char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103), +char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(91),char(54),char(93),char(0),char(109),char(95),char(97),char(120),char(105),char(115),char(73),char(110),char(65), +char(0),char(109),char(95),char(97),char(120),char(105),char(115),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(97),char(116),char(105),char(111),char(0),char(109), +char(95),char(116),char(97),char(117),char(0),char(109),char(95),char(116),char(105),char(109),char(101),char(83),char(116),char(101),char(112),char(0),char(109),char(95),char(109),char(97), +char(120),char(69),char(114),char(114),char(111),char(114),char(82),char(101),char(100),char(117),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(115),char(111), +char(114),char(0),char(109),char(95),char(101),char(114),char(112),char(0),char(109),char(95),char(101),char(114),char(112),char(50),char(0),char(109),char(95),char(103),char(108),char(111), +char(98),char(97),char(108),char(67),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115), +char(101),char(80),char(101),char(110),char(101),char(116),char(114),char(97),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108), +char(100),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(117),char(114),char(110), +char(69),char(114),char(112),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(111),char(112),char(0),char(109),char(95),char(119), +char(97),char(114),char(109),char(115),char(116),char(97),char(114),char(116),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95), +char(109),char(97),char(120),char(71),char(121),char(114),char(111),char(115),char(99),char(111),char(112),char(105),char(99),char(70),char(111),char(114),char(99),char(101),char(0),char(109), +char(95),char(115),char(105),char(110),char(103),char(108),char(101),char(65),char(120),char(105),char(115),char(82),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114), +char(105),char(99),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(117), +char(109),char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114), +char(77),char(111),char(100),char(101),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(110),char(103),char(67),char(111),char(110),char(116),char(97),char(99), +char(116),char(82),char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108), +char(100),char(0),char(109),char(95),char(109),char(105),char(110),char(105),char(109),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(66),char(97),char(116), +char(99),char(104),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115), +char(101),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0), +char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109), +char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(42),char(109),char(95), +char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0), +char(109),char(95),char(112),char(114),char(101),char(118),char(105),char(111),char(117),char(115),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109), +char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(99),char(99),char(117),char(109),char(117),char(108),char(97), +char(116),char(101),char(100),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(110),char(111),char(114),char(109),char(97),char(108),char(0),char(109),char(95), +char(97),char(114),char(101),char(97),char(0),char(109),char(95),char(97),char(116),char(116),char(97),char(99),char(104),char(0),char(109),char(95),char(110),char(111),char(100),char(101), +char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(76),char(101),char(110), +char(103),char(116),char(104),char(0),char(109),char(95),char(98),char(98),char(101),char(110),char(100),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(111),char(100), +char(101),char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(91),char(51),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(65),char(114), +char(101),char(97),char(0),char(109),char(95),char(99),char(48),char(91),char(52),char(93),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100), +char(105),char(99),char(101),char(115),char(91),char(52),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(86),char(111),char(108),char(117),char(109),char(101), +char(0),char(109),char(95),char(99),char(49),char(0),char(109),char(95),char(99),char(50),char(0),char(109),char(95),char(99),char(48),char(0),char(109),char(95),char(108),char(111), +char(99),char(97),char(108),char(70),char(114),char(97),char(109),char(101),char(0),char(42),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(66),char(111),char(100), +char(121),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(101),char(120),char(0),char(109),char(95),char(97),char(101),char(114),char(111), +char(77),char(111),char(100),char(101),char(108),char(0),char(109),char(95),char(98),char(97),char(117),char(109),char(103),char(97),char(114),char(116),char(101),char(0),char(109),char(95), +char(100),char(114),char(97),char(103),char(0),char(109),char(95),char(108),char(105),char(102),char(116),char(0),char(109),char(95),char(112),char(114),char(101),char(115),char(115),char(117), +char(114),char(101),char(0),char(109),char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(100),char(121),char(110),char(97),char(109),char(105), +char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112),char(111),char(115),char(101),char(77),char(97),char(116),char(99), +char(104),char(0),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97),char(114),char(100), +char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(107),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(111),char(110),char(116),char(97),char(99), +char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(67),char(111),char(110),char(116), +char(97),char(99),char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114), +char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100), +char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111), +char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100), +char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116), +char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103), +char(105),char(100),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105), +char(116),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116), +char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(115),char(111),char(102), +char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83), +char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(109),char(97),char(120),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(116), +char(105),char(109),char(101),char(83),char(99),char(97),char(108),char(101),char(0),char(109),char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(73), +char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110), +char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(100),char(114),char(105),char(102),char(116),char(73),char(116), +char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(116), +char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(114),char(111),char(116),char(0),char(109),char(95),char(115),char(99),char(97), +char(108),char(101),char(0),char(109),char(95),char(97),char(113),char(113),char(0),char(109),char(95),char(99),char(111),char(109),char(0),char(42),char(109),char(95),char(112),char(111), +char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(42),char(109),char(95),char(119),char(101),char(105),char(103),char(104),char(116),char(115),char(0),char(109), +char(95),char(110),char(117),char(109),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(87), +char(101),char(105),char(103),char(116),char(115),char(0),char(109),char(95),char(98),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(98),char(102), +char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(120),char(102),char(111),char(114),char(109),char(0),char(109),char(95), +char(108),char(111),char(99),char(105),char(105),char(0),char(109),char(95),char(105),char(110),char(118),char(119),char(105),char(0),char(109),char(95),char(118),char(105),char(109),char(112), +char(117),char(108),char(115),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115), +char(91),char(50),char(93),char(0),char(109),char(95),char(108),char(118),char(0),char(109),char(95),char(97),char(118),char(0),char(42),char(109),char(95),char(102),char(114),char(97), +char(109),char(101),char(114),char(101),char(102),char(115),char(0),char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101), +char(115),char(0),char(42),char(109),char(95),char(109),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(70),char(114),char(97), +char(109),char(101),char(82),char(101),char(102),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(78),char(111),char(100),char(101),char(115),char(0),char(109),char(95), +char(110),char(117),char(109),char(77),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(105),char(100),char(109),char(97),char(115),char(115),char(0),char(109), +char(95),char(105),char(109),char(97),char(115),char(115),char(0),char(109),char(95),char(110),char(118),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0), +char(109),char(95),char(110),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(100),char(97),char(109),char(112), +char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(97), +char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(116),char(99),char(104),char(105),char(110),char(103),char(0),char(109),char(95),char(109), +char(97),char(120),char(83),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108), +char(115),char(101),char(0),char(109),char(95),char(115),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109), +char(112),char(117),char(108),char(115),char(101),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(105), +char(110),char(115),char(65),char(110),char(99),char(104),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(100),char(101),char(0),char(109), +char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(110),char(100),char(101),char(120),char(0),char(42),char(109),char(95),char(98),char(111),char(100), +char(121),char(65),char(0),char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(0),char(109),char(95),char(114),char(101),char(102),char(115),char(91),char(50), +char(93),char(0),char(109),char(95),char(99),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(100),char(101), +char(108),char(101),char(116),char(101),char(0),char(109),char(95),char(114),char(101),char(108),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(91),char(50), +char(93),char(0),char(109),char(95),char(98),char(111),char(100),char(121),char(65),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(98),char(111),char(100),char(121), +char(66),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(42),char(109), +char(95),char(112),char(111),char(115),char(101),char(0),char(42),char(42),char(109),char(95),char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0), +char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(115),char(0),char(42),char(109),char(95),char(108),char(105),char(110),char(107),char(115),char(0),char(42),char(109), +char(95),char(102),char(97),char(99),char(101),char(115),char(0),char(42),char(109),char(95),char(116),char(101),char(116),char(114),char(97),char(104),char(101),char(100),char(114),char(97), +char(0),char(42),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(42),char(109),char(95),char(99),char(108),char(117),char(115),char(116), +char(101),char(114),char(115),char(0),char(42),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(77), +char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(76),char(105),char(110),char(107),char(115),char(0), +char(109),char(95),char(110),char(117),char(109),char(70),char(97),char(99),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(84),char(101),char(116),char(114), +char(97),char(104),char(101),char(100),char(114),char(97),char(0),char(109),char(95),char(110),char(117),char(109),char(65),char(110),char(99),char(104),char(111),char(114),char(115),char(0), +char(109),char(95),char(110),char(117),char(109),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(74), +char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110),char(102),char(105),char(103),char(0),char(0),char(84),char(89),char(80),char(69), +char(87),char(0),char(0),char(0),char(99),char(104),char(97),char(114),char(0),char(117),char(99),char(104),char(97),char(114),char(0),char(115),char(104),char(111),char(114),char(116), +char(0),char(117),char(115),char(104),char(111),char(114),char(116),char(0),char(105),char(110),char(116),char(0),char(108),char(111),char(110),char(103),char(0),char(117),char(108),char(111), +char(110),char(103),char(0),char(102),char(108),char(111),char(97),char(116),char(0),char(100),char(111),char(117),char(98),char(108),char(101),char(0),char(118),char(111),char(105),char(100), +char(0),char(80),char(111),char(105),char(110),char(116),char(101),char(114),char(65),char(114),char(114),char(97),char(121),char(0),char(98),char(116),char(80),char(104),char(121),char(115), +char(105),char(99),char(115),char(83),char(121),char(115),char(116),char(101),char(109),char(0),char(76),char(105),char(115),char(116),char(66),char(97),char(115),char(101),char(0),char(98), +char(116),char(86),char(101),char(99),char(116),char(111),char(114),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116), +char(86),char(101),char(99),char(116),char(111),char(114),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116), +char(77),char(97),char(116),char(114),char(105),char(120),char(51),char(120),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98), +char(116),char(77),char(97),char(116),char(114),char(105),char(120),char(51),char(120),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97), +char(0),char(98),char(116),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116), +char(97),char(0),char(98),char(116),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(68),char(111),char(117),char(98),char(108),char(101),char(68), +char(97),char(116),char(97),char(0),char(98),char(116),char(66),char(118),char(104),char(83),char(117),char(98),char(116),char(114),char(101),char(101),char(73),char(110),char(102),char(111), +char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78), +char(111),char(100),char(101),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109), +char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116), +char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101), +char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(70), +char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100), +char(66),char(118),char(104),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(108),char(108), +char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(97), +char(116),char(105),char(99),char(80),char(108),char(97),char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116), +char(67),char(111),char(110),char(118),char(101),char(120),char(73),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(83),char(104),char(97),char(112),char(101),char(68), +char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(65),char(110),char(100),char(82),char(97),char(100), +char(105),char(117),char(115),char(0),char(98),char(116),char(77),char(117),char(108),char(116),char(105),char(83),char(112),char(104),char(101),char(114),char(101),char(83),char(104),char(97), +char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116), +char(97),char(0),char(98),char(116),char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116), +char(97),char(0),char(98),char(116),char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105), +char(112),char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(104),char(97),char(114),char(73),char(110),char(100),char(101),char(120), +char(84),char(114),char(105),char(112),char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(101),char(115),char(104),char(80),char(97), +char(114),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(114),char(105),char(100),char(105),char(110),char(103),char(77),char(101),char(115), +char(104),char(73),char(110),char(116),char(101),char(114),char(102),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105), +char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98), +char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(73),char(110),char(102),char(111),char(77),char(97),char(112),char(68),char(97),char(116),char(97), +char(0),char(98),char(116),char(83),char(99),char(97),char(108),char(101),char(100),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115), +char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117),char(110), +char(100),char(83),char(104),char(97),char(112),char(101),char(67),char(104),char(105),char(108),char(100),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111), +char(109),char(112),char(111),char(117),char(110),char(100),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(121), +char(108),char(105),char(110),char(100),char(101),char(114),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111), +char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(97),char(112),char(115),char(117),char(108), char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108), char(101),char(73),char(110),char(102),char(111),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(73),char(109),char(112),char(97),char(99),char(116),char(77), char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(118),char(101), @@ -305,155 +309,193 @@ char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(110),ch char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97), char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97), char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(110),char(102),char(111),char(49), -char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97), -char(116),char(97),char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(68),char(97),char(116),char(97),char(0),char(98), -char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105), -char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50), -char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108), -char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97), -char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103), -char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97), -char(0),char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119),char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105), -char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102), +char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108), +char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116), +char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100), +char(121),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97), +char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110), +char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108),char(111), +char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116), +char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97), +char(50),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116), +char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105), +char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68), +char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110), +char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111), +char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50),char(0), +char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119),char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110), +char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119), +char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116), +char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110), +char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(67), +char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50), +char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(83),char(112),char(114),char(105),char(110),char(103), char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110), char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(83),char(112),char(114),char(105),char(110),char(103),char(67),char(111),char(110),char(115),char(116),char(114), -char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(108),char(105),char(100),char(101),char(114),char(67),char(111),char(110), -char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121), -char(77),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100), -char(121),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(76),char(105), -char(110),char(107),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(97),char(99),char(101),char(68), -char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(84),char(101),char(116),char(114),char(97),char(68),char(97),char(116), -char(97),char(0),char(83),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(65),char(110),char(99),char(104),char(111),char(114),char(68),char(97),char(116), -char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(111),char(110),char(102),char(105),char(103),char(68),char(97),char(116),char(97), -char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(80),char(111),char(115),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111), -char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(74),char(111),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(0),char(0), -char(84),char(76),char(69),char(78),char(1),char(0),char(1),char(0),char(2),char(0),char(2),char(0),char(4),char(0),char(4),char(0),char(4),char(0),char(4),char(0), -char(8),char(0),char(0),char(0),char(12),char(0),char(36),char(0),char(8),char(0),char(16),char(0),char(32),char(0),char(48),char(0),char(96),char(0),char(64),char(0), -char(-128),char(0),char(20),char(0),char(48),char(0),char(80),char(0),char(16),char(0),char(84),char(0),char(-124),char(0),char(12),char(0),char(52),char(0),char(52),char(0), -char(20),char(0),char(64),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(4),char(0),char(32),char(0),char(28),char(0),char(60),char(0),char(56),char(0), -char(76),char(0),char(76),char(0),char(24),char(0),char(60),char(0),char(60),char(0),char(16),char(0),char(64),char(0),char(68),char(0),char(-48),char(1),char(0),char(1), -char(-72),char(0),char(-104),char(0),char(104),char(0),char(88),char(0),char(-24),char(1),char(-96),char(3),char(8),char(0),char(52),char(0),char(0),char(0),char(84),char(0), -char(116),char(0),char(92),char(1),char(-36),char(0),char(-44),char(0),char(-4),char(0),char(92),char(1),char(-52),char(0),char(16),char(0),char(100),char(0),char(20),char(0), -char(36),char(0),char(100),char(0),char(92),char(0),char(104),char(0),char(-64),char(0),char(92),char(1),char(104),char(0),char(-84),char(1),char(83),char(84),char(82),char(67), -char(65),char(0),char(0),char(0),char(10),char(0),char(3),char(0),char(4),char(0),char(0),char(0),char(4),char(0),char(1),char(0),char(9),char(0),char(2),char(0), -char(11),char(0),char(3),char(0),char(10),char(0),char(3),char(0),char(10),char(0),char(4),char(0),char(10),char(0),char(5),char(0),char(12),char(0),char(2),char(0), -char(9),char(0),char(6),char(0),char(9),char(0),char(7),char(0),char(13),char(0),char(1),char(0),char(7),char(0),char(8),char(0),char(14),char(0),char(1),char(0), -char(8),char(0),char(8),char(0),char(15),char(0),char(1),char(0),char(13),char(0),char(9),char(0),char(16),char(0),char(1),char(0),char(14),char(0),char(9),char(0), -char(17),char(0),char(2),char(0),char(15),char(0),char(10),char(0),char(13),char(0),char(11),char(0),char(18),char(0),char(2),char(0),char(16),char(0),char(10),char(0), -char(14),char(0),char(11),char(0),char(19),char(0),char(4),char(0),char(4),char(0),char(12),char(0),char(4),char(0),char(13),char(0),char(2),char(0),char(14),char(0), -char(2),char(0),char(15),char(0),char(20),char(0),char(6),char(0),char(13),char(0),char(16),char(0),char(13),char(0),char(17),char(0),char(4),char(0),char(18),char(0), -char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0),char(21),char(0),char(6),char(0),char(14),char(0),char(16),char(0), -char(14),char(0),char(17),char(0),char(4),char(0),char(18),char(0),char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0), -char(22),char(0),char(3),char(0),char(2),char(0),char(14),char(0),char(2),char(0),char(15),char(0),char(4),char(0),char(22),char(0),char(23),char(0),char(12),char(0), -char(13),char(0),char(23),char(0),char(13),char(0),char(24),char(0),char(13),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0), -char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),char(20),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(19),char(0),char(32),char(0), -char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(24),char(0),char(12),char(0),char(14),char(0),char(23),char(0),char(14),char(0),char(24),char(0), -char(14),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0), -char(21),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(19),char(0),char(32),char(0), -char(25),char(0),char(3),char(0),char(0),char(0),char(35),char(0),char(4),char(0),char(36),char(0),char(0),char(0),char(37),char(0),char(26),char(0),char(5),char(0), -char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0),char(13),char(0),char(40),char(0),char(7),char(0),char(41),char(0),char(0),char(0),char(21),char(0), -char(27),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0),char(13),char(0),char(42),char(0),char(7),char(0),char(43),char(0), -char(4),char(0),char(44),char(0),char(28),char(0),char(2),char(0),char(13),char(0),char(45),char(0),char(7),char(0),char(46),char(0),char(29),char(0),char(4),char(0), -char(27),char(0),char(47),char(0),char(28),char(0),char(48),char(0),char(4),char(0),char(49),char(0),char(0),char(0),char(37),char(0),char(30),char(0),char(1),char(0), -char(4),char(0),char(50),char(0),char(31),char(0),char(2),char(0),char(2),char(0),char(50),char(0),char(0),char(0),char(51),char(0),char(32),char(0),char(2),char(0), -char(2),char(0),char(52),char(0),char(0),char(0),char(51),char(0),char(33),char(0),char(2),char(0),char(0),char(0),char(52),char(0),char(0),char(0),char(53),char(0), -char(34),char(0),char(8),char(0),char(13),char(0),char(54),char(0),char(14),char(0),char(55),char(0),char(30),char(0),char(56),char(0),char(32),char(0),char(57),char(0), -char(33),char(0),char(58),char(0),char(31),char(0),char(59),char(0),char(4),char(0),char(60),char(0),char(4),char(0),char(61),char(0),char(35),char(0),char(4),char(0), -char(34),char(0),char(62),char(0),char(13),char(0),char(63),char(0),char(4),char(0),char(64),char(0),char(0),char(0),char(37),char(0),char(36),char(0),char(7),char(0), -char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0),char(23),char(0),char(66),char(0),char(24),char(0),char(67),char(0),char(37),char(0),char(68),char(0), -char(7),char(0),char(43),char(0),char(0),char(0),char(69),char(0),char(38),char(0),char(2),char(0),char(36),char(0),char(70),char(0),char(13),char(0),char(39),char(0), -char(39),char(0),char(4),char(0),char(17),char(0),char(71),char(0),char(25),char(0),char(72),char(0),char(4),char(0),char(73),char(0),char(7),char(0),char(74),char(0), -char(40),char(0),char(4),char(0),char(25),char(0),char(38),char(0),char(39),char(0),char(75),char(0),char(4),char(0),char(76),char(0),char(7),char(0),char(43),char(0), -char(41),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(42),char(0),char(3),char(0), -char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(43),char(0),char(4),char(0),char(4),char(0),char(78),char(0), -char(7),char(0),char(79),char(0),char(7),char(0),char(80),char(0),char(7),char(0),char(81),char(0),char(37),char(0),char(14),char(0),char(4),char(0),char(82),char(0), -char(4),char(0),char(83),char(0),char(43),char(0),char(84),char(0),char(4),char(0),char(85),char(0),char(7),char(0),char(86),char(0),char(7),char(0),char(87),char(0), -char(7),char(0),char(88),char(0),char(7),char(0),char(89),char(0),char(7),char(0),char(90),char(0),char(4),char(0),char(91),char(0),char(4),char(0),char(92),char(0), -char(4),char(0),char(93),char(0),char(4),char(0),char(94),char(0),char(0),char(0),char(37),char(0),char(44),char(0),char(5),char(0),char(25),char(0),char(38),char(0), -char(35),char(0),char(65),char(0),char(13),char(0),char(39),char(0),char(7),char(0),char(43),char(0),char(4),char(0),char(95),char(0),char(45),char(0),char(5),char(0), -char(27),char(0),char(47),char(0),char(13),char(0),char(96),char(0),char(14),char(0),char(97),char(0),char(4),char(0),char(98),char(0),char(0),char(0),char(99),char(0), -char(46),char(0),char(25),char(0),char(9),char(0),char(100),char(0),char(9),char(0),char(101),char(0),char(25),char(0),char(102),char(0),char(0),char(0),char(35),char(0), -char(18),char(0),char(103),char(0),char(18),char(0),char(104),char(0),char(14),char(0),char(105),char(0),char(14),char(0),char(106),char(0),char(14),char(0),char(107),char(0), -char(8),char(0),char(108),char(0),char(8),char(0),char(109),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(111),char(0),char(8),char(0),char(112),char(0), -char(8),char(0),char(113),char(0),char(8),char(0),char(114),char(0),char(8),char(0),char(115),char(0),char(4),char(0),char(116),char(0),char(4),char(0),char(117),char(0), -char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0),char(4),char(0),char(121),char(0),char(4),char(0),char(122),char(0), -char(0),char(0),char(37),char(0),char(47),char(0),char(25),char(0),char(9),char(0),char(100),char(0),char(9),char(0),char(101),char(0),char(25),char(0),char(102),char(0), -char(0),char(0),char(35),char(0),char(17),char(0),char(103),char(0),char(17),char(0),char(104),char(0),char(13),char(0),char(105),char(0),char(13),char(0),char(106),char(0), -char(13),char(0),char(107),char(0),char(7),char(0),char(108),char(0),char(7),char(0),char(109),char(0),char(7),char(0),char(110),char(0),char(7),char(0),char(111),char(0), -char(7),char(0),char(112),char(0),char(7),char(0),char(113),char(0),char(7),char(0),char(114),char(0),char(7),char(0),char(115),char(0),char(4),char(0),char(116),char(0), +char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50),char(0),char(98),char(116),char(83),char(108), +char(105),char(100),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98), +char(116),char(83),char(108),char(105),char(100),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117), +char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(97),char(114),char(67),char(111),char(110),char(115),char(116),char(114), +char(97),char(105),char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(97),char(114), +char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97), +char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(77),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(68),char(97),char(116), +char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97),char(0),char(83), +char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(76),char(105),char(110),char(107),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116), +char(66),char(111),char(100),char(121),char(70),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100), +char(121),char(84),char(101),char(116),char(114),char(97),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100), +char(65),char(110),char(99),char(104),char(111),char(114),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67), +char(111),char(110),char(102),char(105),char(103),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(80),char(111), +char(115),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(108),char(117),char(115),char(116), +char(101),char(114),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(74),char(111),char(105), +char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(108),char(111), +char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(0),char(84),char(76),char(69),char(78),char(1),char(0),char(1),char(0),char(2),char(0),char(2),char(0), +char(4),char(0),char(4),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(0),char(0),char(12),char(0),char(36),char(0),char(8),char(0),char(16),char(0), +char(32),char(0),char(48),char(0),char(96),char(0),char(64),char(0),char(-128),char(0),char(20),char(0),char(48),char(0),char(80),char(0),char(16),char(0),char(84),char(0), +char(-124),char(0),char(12),char(0),char(52),char(0),char(52),char(0),char(20),char(0),char(64),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(4),char(0), +char(32),char(0),char(28),char(0),char(60),char(0),char(56),char(0),char(76),char(0),char(76),char(0),char(24),char(0),char(60),char(0),char(60),char(0),char(60),char(0), +char(16),char(0),char(64),char(0),char(68),char(0),char(-48),char(1),char(0),char(1),char(-72),char(0),char(-104),char(0),char(104),char(0),char(88),char(0),char(-24),char(1), +char(-96),char(3),char(8),char(0),char(52),char(0),char(52),char(0),char(0),char(0),char(68),char(0),char(84),char(0),char(-124),char(0),char(116),char(0),char(92),char(1), +char(-36),char(0),char(-116),char(1),char(124),char(1),char(-44),char(0),char(-4),char(0),char(-52),char(1),char(92),char(1),char(116),char(2),char(-52),char(0),char(108),char(1), +char(92),char(0),char(-116),char(0),char(16),char(0),char(100),char(0),char(20),char(0),char(36),char(0),char(100),char(0),char(92),char(0),char(104),char(0),char(-64),char(0), +char(92),char(1),char(104),char(0),char(-84),char(1),char(0),char(0),char(83),char(84),char(82),char(67),char(76),char(0),char(0),char(0),char(10),char(0),char(3),char(0), +char(4),char(0),char(0),char(0),char(4),char(0),char(1),char(0),char(9),char(0),char(2),char(0),char(11),char(0),char(3),char(0),char(10),char(0),char(3),char(0), +char(10),char(0),char(4),char(0),char(10),char(0),char(5),char(0),char(12),char(0),char(2),char(0),char(9),char(0),char(6),char(0),char(9),char(0),char(7),char(0), +char(13),char(0),char(1),char(0),char(7),char(0),char(8),char(0),char(14),char(0),char(1),char(0),char(8),char(0),char(8),char(0),char(15),char(0),char(1),char(0), +char(13),char(0),char(9),char(0),char(16),char(0),char(1),char(0),char(14),char(0),char(9),char(0),char(17),char(0),char(2),char(0),char(15),char(0),char(10),char(0), +char(13),char(0),char(11),char(0),char(18),char(0),char(2),char(0),char(16),char(0),char(10),char(0),char(14),char(0),char(11),char(0),char(19),char(0),char(4),char(0), +char(4),char(0),char(12),char(0),char(4),char(0),char(13),char(0),char(2),char(0),char(14),char(0),char(2),char(0),char(15),char(0),char(20),char(0),char(6),char(0), +char(13),char(0),char(16),char(0),char(13),char(0),char(17),char(0),char(4),char(0),char(18),char(0),char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0), +char(0),char(0),char(21),char(0),char(21),char(0),char(6),char(0),char(14),char(0),char(16),char(0),char(14),char(0),char(17),char(0),char(4),char(0),char(18),char(0), +char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0),char(22),char(0),char(3),char(0),char(2),char(0),char(14),char(0), +char(2),char(0),char(15),char(0),char(4),char(0),char(22),char(0),char(23),char(0),char(12),char(0),char(13),char(0),char(23),char(0),char(13),char(0),char(24),char(0), +char(13),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0), +char(20),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(19),char(0),char(32),char(0),char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0), +char(24),char(0),char(12),char(0),char(14),char(0),char(23),char(0),char(14),char(0),char(24),char(0),char(14),char(0),char(25),char(0),char(4),char(0),char(26),char(0), +char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),char(21),char(0),char(30),char(0),char(22),char(0),char(31),char(0), +char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(19),char(0),char(32),char(0),char(25),char(0),char(3),char(0),char(0),char(0),char(35),char(0), +char(4),char(0),char(36),char(0),char(0),char(0),char(37),char(0),char(26),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0), +char(13),char(0),char(40),char(0),char(7),char(0),char(41),char(0),char(0),char(0),char(21),char(0),char(27),char(0),char(5),char(0),char(25),char(0),char(38),char(0), +char(13),char(0),char(39),char(0),char(13),char(0),char(42),char(0),char(7),char(0),char(43),char(0),char(4),char(0),char(44),char(0),char(28),char(0),char(2),char(0), +char(13),char(0),char(45),char(0),char(7),char(0),char(46),char(0),char(29),char(0),char(4),char(0),char(27),char(0),char(47),char(0),char(28),char(0),char(48),char(0), +char(4),char(0),char(49),char(0),char(0),char(0),char(37),char(0),char(30),char(0),char(1),char(0),char(4),char(0),char(50),char(0),char(31),char(0),char(2),char(0), +char(2),char(0),char(50),char(0),char(0),char(0),char(51),char(0),char(32),char(0),char(2),char(0),char(2),char(0),char(52),char(0),char(0),char(0),char(51),char(0), +char(33),char(0),char(2),char(0),char(0),char(0),char(52),char(0),char(0),char(0),char(53),char(0),char(34),char(0),char(8),char(0),char(13),char(0),char(54),char(0), +char(14),char(0),char(55),char(0),char(30),char(0),char(56),char(0),char(32),char(0),char(57),char(0),char(33),char(0),char(58),char(0),char(31),char(0),char(59),char(0), +char(4),char(0),char(60),char(0),char(4),char(0),char(61),char(0),char(35),char(0),char(4),char(0),char(34),char(0),char(62),char(0),char(13),char(0),char(63),char(0), +char(4),char(0),char(64),char(0),char(0),char(0),char(37),char(0),char(36),char(0),char(7),char(0),char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0), +char(23),char(0),char(66),char(0),char(24),char(0),char(67),char(0),char(37),char(0),char(68),char(0),char(7),char(0),char(43),char(0),char(0),char(0),char(69),char(0), +char(38),char(0),char(2),char(0),char(36),char(0),char(70),char(0),char(13),char(0),char(39),char(0),char(39),char(0),char(4),char(0),char(17),char(0),char(71),char(0), +char(25),char(0),char(72),char(0),char(4),char(0),char(73),char(0),char(7),char(0),char(74),char(0),char(40),char(0),char(4),char(0),char(25),char(0),char(38),char(0), +char(39),char(0),char(75),char(0),char(4),char(0),char(76),char(0),char(7),char(0),char(43),char(0),char(41),char(0),char(3),char(0),char(27),char(0),char(47),char(0), +char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(42),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(78),char(0), +char(0),char(0),char(37),char(0),char(43),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0), +char(44),char(0),char(4),char(0),char(4),char(0),char(79),char(0),char(7),char(0),char(80),char(0),char(7),char(0),char(81),char(0),char(7),char(0),char(82),char(0), +char(37),char(0),char(14),char(0),char(4),char(0),char(83),char(0),char(4),char(0),char(84),char(0),char(44),char(0),char(85),char(0),char(4),char(0),char(86),char(0), +char(7),char(0),char(87),char(0),char(7),char(0),char(88),char(0),char(7),char(0),char(89),char(0),char(7),char(0),char(90),char(0),char(7),char(0),char(91),char(0), +char(4),char(0),char(92),char(0),char(4),char(0),char(93),char(0),char(4),char(0),char(94),char(0),char(4),char(0),char(95),char(0),char(0),char(0),char(37),char(0), +char(45),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0),char(13),char(0),char(39),char(0),char(7),char(0),char(43),char(0), +char(4),char(0),char(96),char(0),char(46),char(0),char(5),char(0),char(27),char(0),char(47),char(0),char(13),char(0),char(97),char(0),char(14),char(0),char(98),char(0), +char(4),char(0),char(99),char(0),char(0),char(0),char(100),char(0),char(47),char(0),char(25),char(0),char(9),char(0),char(101),char(0),char(9),char(0),char(102),char(0), +char(25),char(0),char(103),char(0),char(0),char(0),char(35),char(0),char(18),char(0),char(104),char(0),char(18),char(0),char(105),char(0),char(14),char(0),char(106),char(0), +char(14),char(0),char(107),char(0),char(14),char(0),char(108),char(0),char(8),char(0),char(109),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(111),char(0), +char(8),char(0),char(112),char(0),char(8),char(0),char(113),char(0),char(8),char(0),char(114),char(0),char(8),char(0),char(115),char(0),char(8),char(0),char(116),char(0), char(4),char(0),char(117),char(0),char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0),char(4),char(0),char(121),char(0), -char(4),char(0),char(122),char(0),char(0),char(0),char(37),char(0),char(48),char(0),char(2),char(0),char(49),char(0),char(123),char(0),char(14),char(0),char(124),char(0), -char(50),char(0),char(2),char(0),char(51),char(0),char(123),char(0),char(13),char(0),char(124),char(0),char(52),char(0),char(21),char(0),char(47),char(0),char(125),char(0), -char(15),char(0),char(126),char(0),char(13),char(0),char(127),char(0),char(13),char(0),char(-128),char(0),char(13),char(0),char(-127),char(0),char(13),char(0),char(-126),char(0), -char(13),char(0),char(124),char(0),char(13),char(0),char(-125),char(0),char(13),char(0),char(-124),char(0),char(13),char(0),char(-123),char(0),char(13),char(0),char(-122),char(0), -char(7),char(0),char(-121),char(0),char(7),char(0),char(-120),char(0),char(7),char(0),char(-119),char(0),char(7),char(0),char(-118),char(0),char(7),char(0),char(-117),char(0), -char(7),char(0),char(-116),char(0),char(7),char(0),char(-115),char(0),char(7),char(0),char(-114),char(0),char(7),char(0),char(-113),char(0),char(4),char(0),char(-112),char(0), -char(53),char(0),char(22),char(0),char(46),char(0),char(125),char(0),char(16),char(0),char(126),char(0),char(14),char(0),char(127),char(0),char(14),char(0),char(-128),char(0), -char(14),char(0),char(-127),char(0),char(14),char(0),char(-126),char(0),char(14),char(0),char(124),char(0),char(14),char(0),char(-125),char(0),char(14),char(0),char(-124),char(0), -char(14),char(0),char(-123),char(0),char(14),char(0),char(-122),char(0),char(8),char(0),char(-121),char(0),char(8),char(0),char(-120),char(0),char(8),char(0),char(-119),char(0), -char(8),char(0),char(-118),char(0),char(8),char(0),char(-117),char(0),char(8),char(0),char(-116),char(0),char(8),char(0),char(-115),char(0),char(8),char(0),char(-114),char(0), -char(8),char(0),char(-113),char(0),char(4),char(0),char(-112),char(0),char(0),char(0),char(37),char(0),char(54),char(0),char(2),char(0),char(4),char(0),char(-111),char(0), -char(4),char(0),char(-110),char(0),char(55),char(0),char(13),char(0),char(56),char(0),char(-109),char(0),char(56),char(0),char(-108),char(0),char(0),char(0),char(35),char(0), -char(4),char(0),char(-107),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(7),char(0),char(-103),char(0), -char(7),char(0),char(-102),char(0),char(4),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(7),char(0),char(-99),char(0),char(4),char(0),char(-98),char(0), -char(57),char(0),char(3),char(0),char(55),char(0),char(-97),char(0),char(13),char(0),char(-96),char(0),char(13),char(0),char(-95),char(0),char(58),char(0),char(3),char(0), -char(55),char(0),char(-97),char(0),char(14),char(0),char(-96),char(0),char(14),char(0),char(-95),char(0),char(59),char(0),char(13),char(0),char(55),char(0),char(-97),char(0), -char(18),char(0),char(-94),char(0),char(18),char(0),char(-93),char(0),char(4),char(0),char(-92),char(0),char(4),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0), -char(7),char(0),char(-89),char(0),char(7),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0), -char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0),char(60),char(0),char(13),char(0),char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0), -char(17),char(0),char(-93),char(0),char(4),char(0),char(-92),char(0),char(4),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(7),char(0),char(-89),char(0), -char(7),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0), -char(7),char(0),char(-83),char(0),char(61),char(0),char(11),char(0),char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0), -char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(7),char(0),char(-80),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0), -char(7),char(0),char(-83),char(0),char(7),char(0),char(-79),char(0),char(0),char(0),char(21),char(0),char(62),char(0),char(9),char(0),char(55),char(0),char(-97),char(0), -char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0),char(13),char(0),char(-78),char(0),char(13),char(0),char(-77),char(0),char(13),char(0),char(-76),char(0), -char(13),char(0),char(-75),char(0),char(4),char(0),char(-74),char(0),char(4),char(0),char(-73),char(0),char(63),char(0),char(5),char(0),char(62),char(0),char(-72),char(0), -char(4),char(0),char(-71),char(0),char(7),char(0),char(-70),char(0),char(7),char(0),char(-69),char(0),char(7),char(0),char(-68),char(0),char(64),char(0),char(9),char(0), -char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0),char(7),char(0),char(-78),char(0),char(7),char(0),char(-77),char(0), -char(7),char(0),char(-76),char(0),char(7),char(0),char(-75),char(0),char(4),char(0),char(-74),char(0),char(4),char(0),char(-73),char(0),char(49),char(0),char(22),char(0), -char(8),char(0),char(-67),char(0),char(8),char(0),char(-79),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(-66),char(0),char(8),char(0),char(112),char(0), -char(8),char(0),char(-65),char(0),char(8),char(0),char(-64),char(0),char(8),char(0),char(-63),char(0),char(8),char(0),char(-62),char(0),char(8),char(0),char(-61),char(0), -char(8),char(0),char(-60),char(0),char(8),char(0),char(-59),char(0),char(8),char(0),char(-58),char(0),char(8),char(0),char(-57),char(0),char(8),char(0),char(-56),char(0), -char(8),char(0),char(-55),char(0),char(4),char(0),char(-54),char(0),char(4),char(0),char(-53),char(0),char(4),char(0),char(-52),char(0),char(4),char(0),char(-51),char(0), -char(4),char(0),char(-50),char(0),char(0),char(0),char(37),char(0),char(51),char(0),char(22),char(0),char(7),char(0),char(-67),char(0),char(7),char(0),char(-79),char(0), -char(7),char(0),char(110),char(0),char(7),char(0),char(-66),char(0),char(7),char(0),char(112),char(0),char(7),char(0),char(-65),char(0),char(7),char(0),char(-64),char(0), -char(7),char(0),char(-63),char(0),char(7),char(0),char(-62),char(0),char(7),char(0),char(-61),char(0),char(7),char(0),char(-60),char(0),char(7),char(0),char(-59),char(0), -char(7),char(0),char(-58),char(0),char(7),char(0),char(-57),char(0),char(7),char(0),char(-56),char(0),char(7),char(0),char(-55),char(0),char(4),char(0),char(-54),char(0), -char(4),char(0),char(-53),char(0),char(4),char(0),char(-52),char(0),char(4),char(0),char(-51),char(0),char(4),char(0),char(-50),char(0),char(0),char(0),char(37),char(0), -char(65),char(0),char(4),char(0),char(7),char(0),char(-49),char(0),char(7),char(0),char(-48),char(0),char(7),char(0),char(-47),char(0),char(4),char(0),char(78),char(0), -char(66),char(0),char(10),char(0),char(65),char(0),char(-46),char(0),char(13),char(0),char(-45),char(0),char(13),char(0),char(-44),char(0),char(13),char(0),char(-43),char(0), -char(13),char(0),char(-42),char(0),char(13),char(0),char(-41),char(0),char(7),char(0),char(-121),char(0),char(7),char(0),char(-40),char(0),char(4),char(0),char(-39),char(0), -char(4),char(0),char(53),char(0),char(67),char(0),char(4),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-38),char(0),char(7),char(0),char(-37),char(0), -char(4),char(0),char(-36),char(0),char(68),char(0),char(4),char(0),char(13),char(0),char(-41),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-35),char(0), -char(7),char(0),char(-34),char(0),char(69),char(0),char(7),char(0),char(13),char(0),char(-33),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-32),char(0), -char(7),char(0),char(-31),char(0),char(7),char(0),char(-30),char(0),char(7),char(0),char(-29),char(0),char(4),char(0),char(53),char(0),char(70),char(0),char(6),char(0), -char(15),char(0),char(-28),char(0),char(13),char(0),char(-30),char(0),char(13),char(0),char(-27),char(0),char(56),char(0),char(-26),char(0),char(4),char(0),char(-25),char(0), -char(7),char(0),char(-29),char(0),char(71),char(0),char(26),char(0),char(4),char(0),char(-24),char(0),char(7),char(0),char(-23),char(0),char(7),char(0),char(-79),char(0), -char(7),char(0),char(-22),char(0),char(7),char(0),char(-21),char(0),char(7),char(0),char(-20),char(0),char(7),char(0),char(-19),char(0),char(7),char(0),char(-18),char(0), -char(7),char(0),char(-17),char(0),char(7),char(0),char(-16),char(0),char(7),char(0),char(-15),char(0),char(7),char(0),char(-14),char(0),char(7),char(0),char(-13),char(0), -char(7),char(0),char(-12),char(0),char(7),char(0),char(-11),char(0),char(7),char(0),char(-10),char(0),char(7),char(0),char(-9),char(0),char(7),char(0),char(-8),char(0), -char(7),char(0),char(-7),char(0),char(7),char(0),char(-6),char(0),char(7),char(0),char(-5),char(0),char(4),char(0),char(-4),char(0),char(4),char(0),char(-3),char(0), -char(4),char(0),char(-2),char(0),char(4),char(0),char(-1),char(0),char(4),char(0),char(117),char(0),char(72),char(0),char(12),char(0),char(15),char(0),char(0),char(1), -char(15),char(0),char(1),char(1),char(15),char(0),char(2),char(1),char(13),char(0),char(3),char(1),char(13),char(0),char(4),char(1),char(7),char(0),char(5),char(1), -char(4),char(0),char(6),char(1),char(4),char(0),char(7),char(1),char(4),char(0),char(8),char(1),char(4),char(0),char(9),char(1),char(7),char(0),char(-31),char(0), -char(4),char(0),char(53),char(0),char(73),char(0),char(27),char(0),char(17),char(0),char(10),char(1),char(15),char(0),char(11),char(1),char(15),char(0),char(12),char(1), -char(13),char(0),char(3),char(1),char(13),char(0),char(13),char(1),char(13),char(0),char(14),char(1),char(13),char(0),char(15),char(1),char(13),char(0),char(16),char(1), -char(13),char(0),char(17),char(1),char(4),char(0),char(18),char(1),char(7),char(0),char(19),char(1),char(4),char(0),char(20),char(1),char(4),char(0),char(21),char(1), -char(4),char(0),char(22),char(1),char(7),char(0),char(23),char(1),char(7),char(0),char(24),char(1),char(4),char(0),char(25),char(1),char(4),char(0),char(26),char(1), -char(7),char(0),char(27),char(1),char(7),char(0),char(28),char(1),char(7),char(0),char(29),char(1),char(7),char(0),char(30),char(1),char(7),char(0),char(31),char(1), -char(7),char(0),char(32),char(1),char(4),char(0),char(33),char(1),char(4),char(0),char(34),char(1),char(4),char(0),char(35),char(1),char(74),char(0),char(12),char(0), -char(9),char(0),char(36),char(1),char(9),char(0),char(37),char(1),char(13),char(0),char(38),char(1),char(7),char(0),char(39),char(1),char(7),char(0),char(-63),char(0), -char(7),char(0),char(40),char(1),char(4),char(0),char(41),char(1),char(13),char(0),char(42),char(1),char(4),char(0),char(43),char(1),char(4),char(0),char(44),char(1), -char(4),char(0),char(45),char(1),char(4),char(0),char(53),char(0),char(75),char(0),char(19),char(0),char(47),char(0),char(125),char(0),char(72),char(0),char(46),char(1), -char(65),char(0),char(47),char(1),char(66),char(0),char(48),char(1),char(67),char(0),char(49),char(1),char(68),char(0),char(50),char(1),char(69),char(0),char(51),char(1), -char(70),char(0),char(52),char(1),char(73),char(0),char(53),char(1),char(74),char(0),char(54),char(1),char(4),char(0),char(55),char(1),char(4),char(0),char(21),char(1), -char(4),char(0),char(56),char(1),char(4),char(0),char(57),char(1),char(4),char(0),char(58),char(1),char(4),char(0),char(59),char(1),char(4),char(0),char(60),char(1), -char(4),char(0),char(61),char(1),char(71),char(0),char(62),char(1),}; +char(4),char(0),char(122),char(0),char(4),char(0),char(123),char(0),char(0),char(0),char(37),char(0),char(48),char(0),char(25),char(0),char(9),char(0),char(101),char(0), +char(9),char(0),char(102),char(0),char(25),char(0),char(103),char(0),char(0),char(0),char(35),char(0),char(17),char(0),char(104),char(0),char(17),char(0),char(105),char(0), +char(13),char(0),char(106),char(0),char(13),char(0),char(107),char(0),char(13),char(0),char(108),char(0),char(7),char(0),char(109),char(0),char(7),char(0),char(110),char(0), +char(7),char(0),char(111),char(0),char(7),char(0),char(112),char(0),char(7),char(0),char(113),char(0),char(7),char(0),char(114),char(0),char(7),char(0),char(115),char(0), +char(7),char(0),char(116),char(0),char(4),char(0),char(117),char(0),char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0), +char(4),char(0),char(121),char(0),char(4),char(0),char(122),char(0),char(4),char(0),char(123),char(0),char(0),char(0),char(37),char(0),char(49),char(0),char(2),char(0), +char(50),char(0),char(124),char(0),char(14),char(0),char(125),char(0),char(51),char(0),char(2),char(0),char(52),char(0),char(124),char(0),char(13),char(0),char(125),char(0), +char(53),char(0),char(21),char(0),char(48),char(0),char(126),char(0),char(15),char(0),char(127),char(0),char(13),char(0),char(-128),char(0),char(13),char(0),char(-127),char(0), +char(13),char(0),char(-126),char(0),char(13),char(0),char(-125),char(0),char(13),char(0),char(125),char(0),char(13),char(0),char(-124),char(0),char(13),char(0),char(-123),char(0), +char(13),char(0),char(-122),char(0),char(13),char(0),char(-121),char(0),char(7),char(0),char(-120),char(0),char(7),char(0),char(-119),char(0),char(7),char(0),char(-118),char(0), +char(7),char(0),char(-117),char(0),char(7),char(0),char(-116),char(0),char(7),char(0),char(-115),char(0),char(7),char(0),char(-114),char(0),char(7),char(0),char(-113),char(0), +char(7),char(0),char(-112),char(0),char(4),char(0),char(-111),char(0),char(54),char(0),char(22),char(0),char(47),char(0),char(126),char(0),char(16),char(0),char(127),char(0), +char(14),char(0),char(-128),char(0),char(14),char(0),char(-127),char(0),char(14),char(0),char(-126),char(0),char(14),char(0),char(-125),char(0),char(14),char(0),char(125),char(0), +char(14),char(0),char(-124),char(0),char(14),char(0),char(-123),char(0),char(14),char(0),char(-122),char(0),char(14),char(0),char(-121),char(0),char(8),char(0),char(-120),char(0), +char(8),char(0),char(-119),char(0),char(8),char(0),char(-118),char(0),char(8),char(0),char(-117),char(0),char(8),char(0),char(-116),char(0),char(8),char(0),char(-115),char(0), +char(8),char(0),char(-114),char(0),char(8),char(0),char(-113),char(0),char(8),char(0),char(-112),char(0),char(4),char(0),char(-111),char(0),char(0),char(0),char(37),char(0), +char(55),char(0),char(2),char(0),char(4),char(0),char(-110),char(0),char(4),char(0),char(-109),char(0),char(56),char(0),char(13),char(0),char(53),char(0),char(-108),char(0), +char(53),char(0),char(-107),char(0),char(0),char(0),char(35),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0), +char(4),char(0),char(-103),char(0),char(7),char(0),char(-102),char(0),char(7),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0), +char(7),char(0),char(-98),char(0),char(4),char(0),char(-97),char(0),char(57),char(0),char(13),char(0),char(58),char(0),char(-108),char(0),char(58),char(0),char(-107),char(0), +char(0),char(0),char(35),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(4),char(0),char(-103),char(0), +char(7),char(0),char(-102),char(0),char(7),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0),char(7),char(0),char(-98),char(0), +char(4),char(0),char(-97),char(0),char(59),char(0),char(14),char(0),char(54),char(0),char(-108),char(0),char(54),char(0),char(-107),char(0),char(0),char(0),char(35),char(0), +char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(4),char(0),char(-103),char(0),char(8),char(0),char(-102),char(0), +char(8),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0),char(8),char(0),char(-98),char(0),char(4),char(0),char(-97),char(0), +char(0),char(0),char(-96),char(0),char(60),char(0),char(3),char(0),char(57),char(0),char(-95),char(0),char(13),char(0),char(-94),char(0),char(13),char(0),char(-93),char(0), +char(61),char(0),char(3),char(0),char(59),char(0),char(-95),char(0),char(14),char(0),char(-94),char(0),char(14),char(0),char(-93),char(0),char(62),char(0),char(3),char(0), +char(57),char(0),char(-95),char(0),char(14),char(0),char(-94),char(0),char(14),char(0),char(-93),char(0),char(63),char(0),char(13),char(0),char(57),char(0),char(-95),char(0), +char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0), +char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0), +char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(64),char(0),char(13),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0), +char(17),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0), +char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0),char(7),char(0),char(-82),char(0), +char(7),char(0),char(-81),char(0),char(65),char(0),char(14),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0), +char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0),char(8),char(0),char(-87),char(0),char(8),char(0),char(-86),char(0), +char(8),char(0),char(-85),char(0),char(8),char(0),char(-84),char(0),char(8),char(0),char(-83),char(0),char(8),char(0),char(-82),char(0),char(8),char(0),char(-81),char(0), +char(0),char(0),char(-80),char(0),char(66),char(0),char(10),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0), +char(8),char(0),char(-79),char(0),char(8),char(0),char(-78),char(0),char(8),char(0),char(-77),char(0),char(8),char(0),char(-83),char(0),char(8),char(0),char(-82),char(0), +char(8),char(0),char(-81),char(0),char(8),char(0),char(-76),char(0),char(67),char(0),char(11),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0), +char(17),char(0),char(-91),char(0),char(7),char(0),char(-79),char(0),char(7),char(0),char(-78),char(0),char(7),char(0),char(-77),char(0),char(7),char(0),char(-83),char(0), +char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(7),char(0),char(-76),char(0),char(0),char(0),char(21),char(0),char(68),char(0),char(9),char(0), +char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),char(17),char(0),char(-91),char(0),char(13),char(0),char(-75),char(0),char(13),char(0),char(-74),char(0), +char(13),char(0),char(-73),char(0),char(13),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),char(4),char(0),char(-70),char(0),char(69),char(0),char(9),char(0), +char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),char(14),char(0),char(-75),char(0),char(14),char(0),char(-74),char(0), +char(14),char(0),char(-73),char(0),char(14),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),char(4),char(0),char(-70),char(0),char(70),char(0),char(5),char(0), +char(68),char(0),char(-69),char(0),char(4),char(0),char(-68),char(0),char(7),char(0),char(-67),char(0),char(7),char(0),char(-66),char(0),char(7),char(0),char(-65),char(0), +char(71),char(0),char(5),char(0),char(69),char(0),char(-69),char(0),char(4),char(0),char(-68),char(0),char(8),char(0),char(-67),char(0),char(8),char(0),char(-66),char(0), +char(8),char(0),char(-65),char(0),char(72),char(0),char(9),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),char(17),char(0),char(-91),char(0), +char(7),char(0),char(-75),char(0),char(7),char(0),char(-74),char(0),char(7),char(0),char(-73),char(0),char(7),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0), +char(4),char(0),char(-70),char(0),char(73),char(0),char(9),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0), +char(8),char(0),char(-75),char(0),char(8),char(0),char(-74),char(0),char(8),char(0),char(-73),char(0),char(8),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0), +char(4),char(0),char(-70),char(0),char(74),char(0),char(5),char(0),char(56),char(0),char(-95),char(0),char(13),char(0),char(-64),char(0),char(13),char(0),char(-63),char(0), +char(7),char(0),char(-62),char(0),char(0),char(0),char(37),char(0),char(75),char(0),char(4),char(0),char(59),char(0),char(-95),char(0),char(14),char(0),char(-64),char(0), +char(14),char(0),char(-63),char(0),char(8),char(0),char(-62),char(0),char(50),char(0),char(22),char(0),char(8),char(0),char(-61),char(0),char(8),char(0),char(-76),char(0), +char(8),char(0),char(111),char(0),char(8),char(0),char(-60),char(0),char(8),char(0),char(113),char(0),char(8),char(0),char(-59),char(0),char(8),char(0),char(-58),char(0), +char(8),char(0),char(-57),char(0),char(8),char(0),char(-56),char(0),char(8),char(0),char(-55),char(0),char(8),char(0),char(-54),char(0),char(8),char(0),char(-53),char(0), +char(8),char(0),char(-52),char(0),char(8),char(0),char(-51),char(0),char(8),char(0),char(-50),char(0),char(8),char(0),char(-49),char(0),char(4),char(0),char(-48),char(0), +char(4),char(0),char(-47),char(0),char(4),char(0),char(-46),char(0),char(4),char(0),char(-45),char(0),char(4),char(0),char(-44),char(0),char(0),char(0),char(37),char(0), +char(52),char(0),char(22),char(0),char(7),char(0),char(-61),char(0),char(7),char(0),char(-76),char(0),char(7),char(0),char(111),char(0),char(7),char(0),char(-60),char(0), +char(7),char(0),char(113),char(0),char(7),char(0),char(-59),char(0),char(7),char(0),char(-58),char(0),char(7),char(0),char(-57),char(0),char(7),char(0),char(-56),char(0), +char(7),char(0),char(-55),char(0),char(7),char(0),char(-54),char(0),char(7),char(0),char(-53),char(0),char(7),char(0),char(-52),char(0),char(7),char(0),char(-51),char(0), +char(7),char(0),char(-50),char(0),char(7),char(0),char(-49),char(0),char(4),char(0),char(-48),char(0),char(4),char(0),char(-47),char(0),char(4),char(0),char(-46),char(0), +char(4),char(0),char(-45),char(0),char(4),char(0),char(-44),char(0),char(0),char(0),char(37),char(0),char(76),char(0),char(4),char(0),char(7),char(0),char(-43),char(0), +char(7),char(0),char(-42),char(0),char(7),char(0),char(-41),char(0),char(4),char(0),char(79),char(0),char(77),char(0),char(10),char(0),char(76),char(0),char(-40),char(0), +char(13),char(0),char(-39),char(0),char(13),char(0),char(-38),char(0),char(13),char(0),char(-37),char(0),char(13),char(0),char(-36),char(0),char(13),char(0),char(-35),char(0), +char(7),char(0),char(-120),char(0),char(7),char(0),char(-34),char(0),char(4),char(0),char(-33),char(0),char(4),char(0),char(53),char(0),char(78),char(0),char(4),char(0), +char(76),char(0),char(-40),char(0),char(4),char(0),char(-32),char(0),char(7),char(0),char(-31),char(0),char(4),char(0),char(-30),char(0),char(79),char(0),char(4),char(0), +char(13),char(0),char(-35),char(0),char(76),char(0),char(-40),char(0),char(4),char(0),char(-29),char(0),char(7),char(0),char(-28),char(0),char(80),char(0),char(7),char(0), +char(13),char(0),char(-27),char(0),char(76),char(0),char(-40),char(0),char(4),char(0),char(-26),char(0),char(7),char(0),char(-25),char(0),char(7),char(0),char(-24),char(0), +char(7),char(0),char(-23),char(0),char(4),char(0),char(53),char(0),char(81),char(0),char(6),char(0),char(15),char(0),char(-22),char(0),char(13),char(0),char(-24),char(0), +char(13),char(0),char(-21),char(0),char(58),char(0),char(-20),char(0),char(4),char(0),char(-19),char(0),char(7),char(0),char(-23),char(0),char(82),char(0),char(26),char(0), +char(4),char(0),char(-18),char(0),char(7),char(0),char(-17),char(0),char(7),char(0),char(-76),char(0),char(7),char(0),char(-16),char(0),char(7),char(0),char(-15),char(0), +char(7),char(0),char(-14),char(0),char(7),char(0),char(-13),char(0),char(7),char(0),char(-12),char(0),char(7),char(0),char(-11),char(0),char(7),char(0),char(-10),char(0), +char(7),char(0),char(-9),char(0),char(7),char(0),char(-8),char(0),char(7),char(0),char(-7),char(0),char(7),char(0),char(-6),char(0),char(7),char(0),char(-5),char(0), +char(7),char(0),char(-4),char(0),char(7),char(0),char(-3),char(0),char(7),char(0),char(-2),char(0),char(7),char(0),char(-1),char(0),char(7),char(0),char(0),char(1), +char(7),char(0),char(1),char(1),char(4),char(0),char(2),char(1),char(4),char(0),char(3),char(1),char(4),char(0),char(4),char(1),char(4),char(0),char(5),char(1), +char(4),char(0),char(118),char(0),char(83),char(0),char(12),char(0),char(15),char(0),char(6),char(1),char(15),char(0),char(7),char(1),char(15),char(0),char(8),char(1), +char(13),char(0),char(9),char(1),char(13),char(0),char(10),char(1),char(7),char(0),char(11),char(1),char(4),char(0),char(12),char(1),char(4),char(0),char(13),char(1), +char(4),char(0),char(14),char(1),char(4),char(0),char(15),char(1),char(7),char(0),char(-25),char(0),char(4),char(0),char(53),char(0),char(84),char(0),char(27),char(0), +char(17),char(0),char(16),char(1),char(15),char(0),char(17),char(1),char(15),char(0),char(18),char(1),char(13),char(0),char(9),char(1),char(13),char(0),char(19),char(1), +char(13),char(0),char(20),char(1),char(13),char(0),char(21),char(1),char(13),char(0),char(22),char(1),char(13),char(0),char(23),char(1),char(4),char(0),char(24),char(1), +char(7),char(0),char(25),char(1),char(4),char(0),char(26),char(1),char(4),char(0),char(27),char(1),char(4),char(0),char(28),char(1),char(7),char(0),char(29),char(1), +char(7),char(0),char(30),char(1),char(4),char(0),char(31),char(1),char(4),char(0),char(32),char(1),char(7),char(0),char(33),char(1),char(7),char(0),char(34),char(1), +char(7),char(0),char(35),char(1),char(7),char(0),char(36),char(1),char(7),char(0),char(37),char(1),char(7),char(0),char(38),char(1),char(4),char(0),char(39),char(1), +char(4),char(0),char(40),char(1),char(4),char(0),char(41),char(1),char(85),char(0),char(12),char(0),char(9),char(0),char(42),char(1),char(9),char(0),char(43),char(1), +char(13),char(0),char(44),char(1),char(7),char(0),char(45),char(1),char(7),char(0),char(-57),char(0),char(7),char(0),char(46),char(1),char(4),char(0),char(47),char(1), +char(13),char(0),char(48),char(1),char(4),char(0),char(49),char(1),char(4),char(0),char(50),char(1),char(4),char(0),char(51),char(1),char(4),char(0),char(53),char(0), +char(86),char(0),char(19),char(0),char(48),char(0),char(126),char(0),char(83),char(0),char(52),char(1),char(76),char(0),char(53),char(1),char(77),char(0),char(54),char(1), +char(78),char(0),char(55),char(1),char(79),char(0),char(56),char(1),char(80),char(0),char(57),char(1),char(81),char(0),char(58),char(1),char(84),char(0),char(59),char(1), +char(85),char(0),char(60),char(1),char(4),char(0),char(61),char(1),char(4),char(0),char(27),char(1),char(4),char(0),char(62),char(1),char(4),char(0),char(63),char(1), +char(4),char(0),char(64),char(1),char(4),char(0),char(65),char(1),char(4),char(0),char(66),char(1),char(4),char(0),char(67),char(1),char(82),char(0),char(68),char(1), +}; int sBulletDNAlen= sizeof(sBulletDNAstr); + char sBulletDNAstr64[]= { -char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(63),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109), +char(83),char(68),char(78),char(65),char(78),char(65),char(77),char(69),char(69),char(1),char(0),char(0),char(109),char(95),char(115),char(105),char(122),char(101),char(0),char(109), char(95),char(99),char(97),char(112),char(97),char(99),char(105),char(116),char(121),char(0),char(42),char(109),char(95),char(100),char(97),char(116),char(97),char(0),char(109),char(95), char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(115),char(0),char(109),char(95),char(99),char(111), char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99),char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110), @@ -512,238 +554,242 @@ char(102),char(111),char(114),char(109),char(0),char(42),char(109),char(95),char char(95),char(99),char(104),char(105),char(108),char(100),char(83),char(104),char(97),char(112),char(101),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(99),char(104), char(105),char(108),char(100),char(77),char(97),char(114),char(103),char(105),char(110),char(0),char(42),char(109),char(95),char(99),char(104),char(105),char(108),char(100),char(83),char(104), char(97),char(112),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117),char(109),char(67),char(104),char(105),char(108),char(100),char(83),char(104),char(97), -char(112),char(101),char(115),char(0),char(109),char(95),char(117),char(112),char(65),char(120),char(105),char(115),char(0),char(109),char(95),char(102),char(108),char(97),char(103),char(115), -char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(48),char(86),char(49),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101), -char(100),char(103),char(101),char(86),char(49),char(86),char(50),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86), -char(50),char(86),char(48),char(65),char(110),char(103),char(108),char(101),char(0),char(42),char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108), -char(101),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(110),char(101),char(120),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(118), -char(97),char(108),char(117),char(101),char(65),char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(107),char(101),char(121),char(65), -char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(118),char(101),char(120),char(69),char(112),char(115),char(105), -char(108),char(111),char(110),char(0),char(109),char(95),char(112),char(108),char(97),char(110),char(97),char(114),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0), -char(109),char(95),char(101),char(113),char(117),char(97),char(108),char(86),char(101),char(114),char(116),char(101),char(120),char(84),char(104),char(114),char(101),char(115),char(104),char(111), -char(108),char(100),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(68),char(105),char(115),char(116),char(97),char(110),char(99),char(101),char(84),char(104),char(114), -char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(122),char(101),char(114),char(111),char(65),char(114),char(101),char(97),char(84),char(104),char(114), -char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(101),char(120),char(116),char(83),char(105),char(122),char(101),char(0),char(109),char(95), -char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(110),char(117),char(109),char(86), -char(97),char(108),char(117),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(75),char(101),char(121),char(115),char(0),char(109),char(95),char(103),char(105), -char(109),char(112),char(97),char(99),char(116),char(83),char(117),char(98),char(84),char(121),char(112),char(101),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99), -char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(70),char(108),char(111),char(97),char(116),char(80),char(116),char(114),char(0),char(42), -char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(68),char(111),char(117),char(98), -char(108),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117),char(109),char(85),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80), -char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(112),char(97),char(100),char(100),char(105),char(110),char(103),char(51),char(91),char(52),char(93),char(0), -char(42),char(109),char(95),char(98),char(114),char(111),char(97),char(100),char(112),char(104),char(97),char(115),char(101),char(72),char(97),char(110),char(100),char(108),char(101),char(0), -char(42),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(42),char(109), -char(95),char(114),char(111),char(111),char(116),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0), -char(109),char(95),char(119),char(111),char(114),char(108),char(100),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105), -char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(87),char(111),char(114),char(108),char(100),char(84),char(114),char(97), +char(112),char(101),char(115),char(0),char(109),char(95),char(117),char(112),char(65),char(120),char(105),char(115),char(0),char(109),char(95),char(117),char(112),char(73),char(110),char(100), +char(101),char(120),char(0),char(109),char(95),char(102),char(108),char(97),char(103),char(115),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(48),char(86), +char(49),char(65),char(110),char(103),char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(49),char(86),char(50),char(65),char(110),char(103), +char(108),char(101),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(86),char(50),char(86),char(48),char(65),char(110),char(103),char(108),char(101),char(0),char(42), +char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(110),char(101), +char(120),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(118),char(97),char(108),char(117),char(101),char(65),char(114),char(114),char(97),char(121),char(80), +char(116),char(114),char(0),char(42),char(109),char(95),char(107),char(101),char(121),char(65),char(114),char(114),char(97),char(121),char(80),char(116),char(114),char(0),char(109),char(95), +char(99),char(111),char(110),char(118),char(101),char(120),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0),char(109),char(95),char(112),char(108),char(97),char(110), +char(97),char(114),char(69),char(112),char(115),char(105),char(108),char(111),char(110),char(0),char(109),char(95),char(101),char(113),char(117),char(97),char(108),char(86),char(101),char(114), +char(116),char(101),char(120),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(101),char(100),char(103),char(101),char(68), +char(105),char(115),char(116),char(97),char(110),char(99),char(101),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(122), +char(101),char(114),char(111),char(65),char(114),char(101),char(97),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110), +char(101),char(120),char(116),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(104),char(97),char(115),char(104),char(84),char(97),char(98),char(108),char(101),char(83), +char(105),char(122),char(101),char(0),char(109),char(95),char(110),char(117),char(109),char(86),char(97),char(108),char(117),char(101),char(115),char(0),char(109),char(95),char(110),char(117), +char(109),char(75),char(101),char(121),char(115),char(0),char(109),char(95),char(103),char(105),char(109),char(112),char(97),char(99),char(116),char(83),char(117),char(98),char(84),char(121), +char(112),char(101),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115), +char(70),char(108),char(111),char(97),char(116),char(80),char(116),char(114),char(0),char(42),char(109),char(95),char(117),char(110),char(115),char(99),char(97),char(108),char(101),char(100), +char(80),char(111),char(105),char(110),char(116),char(115),char(68),char(111),char(117),char(98),char(108),char(101),char(80),char(116),char(114),char(0),char(109),char(95),char(110),char(117), +char(109),char(85),char(110),char(115),char(99),char(97),char(108),char(101),char(100),char(80),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(112),char(97), +char(100),char(100),char(105),char(110),char(103),char(51),char(91),char(52),char(93),char(0),char(42),char(109),char(95),char(98),char(114),char(111),char(97),char(100),char(112),char(104), +char(97),char(115),char(101),char(72),char(97),char(110),char(100),char(108),char(101),char(0),char(42),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105), +char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(42),char(109),char(95),char(114),char(111),char(111),char(116),char(67),char(111),char(108),char(108),char(105), +char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(0),char(109),char(95),char(119),char(111),char(114),char(108),char(100),char(84),char(114),char(97), char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105), -char(111),char(110),char(76),char(105),char(110),char(101),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(105), -char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(86), -char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105), -char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(99),char(116),char(80), -char(114),char(111),char(99),char(101),char(115),char(115),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109), -char(95),char(100),char(101),char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110),char(84),char(105),char(109),char(101),char(0),char(109),char(95), -char(102),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114), -char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110), -char(0),char(109),char(95),char(104),char(105),char(116),char(70),char(114),char(97),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(99),char(100), -char(83),char(119),char(101),char(112),char(116),char(83),char(112),char(104),char(101),char(114),char(101),char(82),char(97),char(100),char(105),char(117),char(115),char(0),char(109),char(95), -char(99),char(99),char(100),char(77),char(111),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109), -char(95),char(104),char(97),char(115),char(65),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116), -char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(70),char(108),char(97),char(103),char(115), -char(0),char(109),char(95),char(105),char(115),char(108),char(97),char(110),char(100),char(84),char(97),char(103),char(49),char(0),char(109),char(95),char(99),char(111),char(109),char(112), -char(97),char(110),char(105),char(111),char(110),char(73),char(100),char(0),char(109),char(95),char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110), -char(83),char(116),char(97),char(116),char(101),char(49),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(84),char(121),char(112), -char(101),char(0),char(109),char(95),char(99),char(104),char(101),char(99),char(107),char(67),char(111),char(108),char(108),char(105),char(100),char(101),char(87),char(105),char(116),char(104), -char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(73),char(110),char(102),char(111),char(0),char(109),char(95),char(103),char(114),char(97),char(118), -char(105),char(116),char(121),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99), -char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(84),char(101), -char(110),char(115),char(111),char(114),char(87),char(111),char(114),char(108),char(100),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(86),char(101), -char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111), -char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114), -char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(103),char(114), -char(97),char(118),char(105),char(116),char(121),char(95),char(97),char(99),char(99),char(101),char(108),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(0),char(109), -char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(76),char(111),char(99),char(97),char(108),char(0),char(109),char(95),char(116), -char(111),char(116),char(97),char(108),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(84),char(111),char(114), -char(113),char(117),char(101),char(0),char(109),char(95),char(105),char(110),char(118),char(101),char(114),char(115),char(101),char(77),char(97),char(115),char(115),char(0),char(109),char(95), -char(108),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(110),char(103),char(117), -char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111), -char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(97), -char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(76),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105), -char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100), -char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110), -char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105), -char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103), -char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(101),char(101),char(112), -char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108), -char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0), -char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0), -char(109),char(95),char(110),char(117),char(109),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(82),char(111),char(119),char(115),char(0), -char(110),char(117),char(98),char(0),char(42),char(109),char(95),char(114),char(98),char(65),char(0),char(42),char(109),char(95),char(114),char(98),char(66),char(0),char(109),char(95), -char(111),char(98),char(106),char(101),char(99),char(116),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110), -char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111), -char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(100),char(0),char(109),char(95),char(110),char(101),char(101),char(100),char(115),char(70),char(101), -char(101),char(100),char(98),char(97),char(99),char(107),char(0),char(109),char(95),char(97),char(112),char(112),char(108),char(105),char(101),char(100),char(73),char(109),char(112),char(117), -char(108),char(115),char(101),char(0),char(109),char(95),char(100),char(98),char(103),char(68),char(114),char(97),char(119),char(83),char(105),char(122),char(101),char(0),char(109),char(95), -char(100),char(105),char(115),char(97),char(98),char(108),char(101),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(115),char(66),char(101),char(116), -char(119),char(101),char(101),char(110),char(76),char(105),char(110),char(107),char(101),char(100),char(66),char(111),char(100),char(105),char(101),char(115),char(0),char(109),char(95),char(111), -char(118),char(101),char(114),char(114),char(105),char(100),char(101),char(78),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(116),char(101),char(114), -char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(98),char(114),char(101),char(97),char(107),char(105),char(110),char(103),char(73),char(109),char(112), -char(117),char(108),char(115),char(101),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(105),char(115),char(69),char(110), -char(97),char(98),char(108),char(101),char(100),char(0),char(109),char(95),char(116),char(121),char(112),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105), -char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(65),char(0),char(109),char(95), -char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(98),char(65),char(70),char(114),char(97),char(109),char(101),char(0), -char(109),char(95),char(114),char(98),char(66),char(70),char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(82),char(101),char(102),char(101), -char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97), -char(114),char(79),char(110),char(108),char(121),char(0),char(109),char(95),char(101),char(110),char(97),char(98),char(108),char(101),char(65),char(110),char(103),char(117),char(108),char(97), -char(114),char(77),char(111),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(111),char(116),char(111),char(114),char(84),char(97),char(114),char(103),char(101),char(116), -char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(109),char(97),char(120),char(77),char(111),char(116),char(111),char(114),char(73), -char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(108),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0), -char(109),char(95),char(117),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(109),char(105),char(116), -char(83),char(111),char(102),char(116),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(98),char(105),char(97),char(115),char(70),char(97),char(99),char(116),char(111), -char(114),char(0),char(109),char(95),char(114),char(101),char(108),char(97),char(120),char(97),char(116),char(105),char(111),char(110),char(70),char(97),char(99),char(116),char(111),char(114), -char(0),char(109),char(95),char(115),char(119),char(105),char(110),char(103),char(83),char(112),char(97),char(110),char(49),char(0),char(109),char(95),char(115),char(119),char(105),char(110), -char(103),char(83),char(112),char(97),char(110),char(50),char(0),char(109),char(95),char(116),char(119),char(105),char(115),char(116),char(83),char(112),char(97),char(110),char(0),char(109), -char(95),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(85),char(112),char(112), -char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(76),char(111),char(119),char(101), -char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(85),char(112),char(112),char(101), -char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(76),char(111),char(119),char(101), -char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(117),char(115),char(101),char(76),char(105),char(110),char(101),char(97),char(114),char(82),char(101), -char(102),char(101),char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(117),char(115),char(101),char(79), -char(102),char(102),char(115),char(101),char(116),char(70),char(111),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(114), -char(97),char(109),char(101),char(0),char(109),char(95),char(54),char(100),char(111),char(102),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(115),char(112),char(114), -char(105),char(110),char(103),char(69),char(110),char(97),char(98),char(108),char(101),char(100),char(91),char(54),char(93),char(0),char(109),char(95),char(101),char(113),char(117),char(105), -char(108),char(105),char(98),char(114),char(105),char(117),char(109),char(80),char(111),char(105),char(110),char(116),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112), -char(114),char(105),char(110),char(103),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(91),char(54),char(93),char(0),char(109),char(95),char(115), -char(112),char(114),char(105),char(110),char(103),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(91),char(54),char(93),char(0),char(109),char(95),char(116),char(97), -char(117),char(0),char(109),char(95),char(116),char(105),char(109),char(101),char(83),char(116),char(101),char(112),char(0),char(109),char(95),char(109),char(97),char(120),char(69),char(114), -char(114),char(111),char(114),char(82),char(101),char(100),char(117),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(115),char(111),char(114),char(0),char(109), -char(95),char(101),char(114),char(112),char(0),char(109),char(95),char(101),char(114),char(112),char(50),char(0),char(109),char(95),char(103),char(108),char(111),char(98),char(97),char(108), -char(67),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(80),char(101), -char(110),char(101),char(116),char(114),char(97),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109), -char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(117),char(114),char(110),char(69),char(114),char(112), -char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(111),char(112),char(0),char(109),char(95),char(119),char(97),char(114),char(109), -char(115),char(116),char(97),char(114),char(116),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(97),char(120), -char(71),char(121),char(114),char(111),char(115),char(99),char(111),char(112),char(105),char(99),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(115),char(105), -char(110),char(103),char(108),char(101),char(65),char(120),char(105),char(115),char(82),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),char(105),char(99),char(116), -char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(117),char(109),char(73),char(116), -char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(77),char(111),char(100), -char(101),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(110),char(103),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(82),char(101), -char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109), -char(95),char(109),char(105),char(110),char(105),char(109),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(66),char(97),char(116),char(99),char(104),char(83), -char(105),char(122),char(101),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109), -char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97), -char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(118),char(111), -char(108),char(117),char(109),char(101),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(42),char(109),char(95),char(109),char(97),char(116), -char(101),char(114),char(105),char(97),char(108),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112), -char(114),char(101),char(118),char(105),char(111),char(117),char(115),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(118),char(101), -char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(99),char(99),char(117),char(109),char(117),char(108),char(97),char(116),char(101),char(100), -char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(110),char(111),char(114),char(109),char(97),char(108),char(0),char(109),char(95),char(97),char(114),char(101), -char(97),char(0),char(109),char(95),char(97),char(116),char(116),char(97),char(99),char(104),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100), -char(105),char(99),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(76),char(101),char(110),char(103),char(116),char(104), -char(0),char(109),char(95),char(98),char(98),char(101),char(110),char(100),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110), -char(100),char(105),char(99),char(101),char(115),char(91),char(51),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(65),char(114),char(101),char(97),char(0), -char(109),char(95),char(99),char(48),char(91),char(52),char(93),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101), -char(115),char(91),char(52),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95), -char(99),char(49),char(0),char(109),char(95),char(99),char(50),char(0),char(109),char(95),char(99),char(48),char(0),char(109),char(95),char(108),char(111),char(99),char(97),char(108), -char(70),char(114),char(97),char(109),char(101),char(0),char(42),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(0),char(109), -char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(101),char(120),char(0),char(109),char(95),char(97),char(101),char(114),char(111),char(77),char(111),char(100), -char(101),char(108),char(0),char(109),char(95),char(98),char(97),char(117),char(109),char(103),char(97),char(114),char(116),char(101),char(0),char(109),char(95),char(100),char(114),char(97), -char(103),char(0),char(109),char(95),char(108),char(105),char(102),char(116),char(0),char(109),char(95),char(112),char(114),char(101),char(115),char(115),char(117),char(114),char(101),char(0), -char(109),char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(100),char(121),char(110),char(97),char(109),char(105),char(99),char(70),char(114), -char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112),char(111),char(115),char(101),char(77),char(97),char(116),char(99),char(104),char(0),char(109), -char(95),char(114),char(105),char(103),char(105),char(100),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115), -char(115),char(0),char(109),char(95),char(107),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97), -char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(67),char(111),char(110),char(116),char(97),char(99),char(116), -char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(72),char(97),char(114), -char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(67),char(108),char(117), -char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(75), -char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115), -char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72), -char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(67), -char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109), -char(95),char(115),char(111),char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73), -char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111), -char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105), -char(116),char(0),char(109),char(95),char(109),char(97),char(120),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(116),char(105),char(109),char(101), -char(83),char(99),char(97),char(108),char(101),char(0),char(109),char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(73),char(116),char(101),char(114), -char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(73),char(116),char(101), -char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(100),char(114),char(105),char(102),char(116),char(73),char(116),char(101),char(114),char(97), -char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(116),char(101),char(114),char(97), -char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(114),char(111),char(116),char(0),char(109),char(95),char(115),char(99),char(97),char(108),char(101),char(0), -char(109),char(95),char(97),char(113),char(113),char(0),char(109),char(95),char(99),char(111),char(109),char(0),char(42),char(109),char(95),char(112),char(111),char(115),char(105),char(116), -char(105),char(111),char(110),char(115),char(0),char(42),char(109),char(95),char(119),char(101),char(105),char(103),char(104),char(116),char(115),char(0),char(109),char(95),char(110),char(117), -char(109),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(87),char(101),char(105),char(103), -char(116),char(115),char(0),char(109),char(95),char(98),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(98),char(102),char(114),char(97),char(109), -char(101),char(0),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(120),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(108),char(111),char(99), -char(105),char(105),char(0),char(109),char(95),char(105),char(110),char(118),char(119),char(105),char(0),char(109),char(95),char(118),char(105),char(109),char(112),char(117),char(108),char(115), -char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(91),char(50),char(93), -char(0),char(109),char(95),char(108),char(118),char(0),char(109),char(95),char(97),char(118),char(0),char(42),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(114), -char(101),char(102),char(115),char(0),char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(0),char(42), -char(109),char(95),char(109),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(70),char(114),char(97),char(109),char(101),char(82), -char(101),char(102),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(78),char(111),char(100),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109), -char(77),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(105),char(100),char(109),char(97),char(115),char(115),char(0),char(109),char(95),char(105),char(109), -char(97),char(115),char(115),char(0),char(109),char(95),char(110),char(118),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110), -char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(100),char(97),char(109),char(112),char(105),char(110),char(103), -char(0),char(109),char(95),char(108),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(97),char(109),char(112),char(105), -char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(116),char(99),char(104),char(105),char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(120),char(83), -char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0), -char(109),char(95),char(115),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108), -char(115),char(101),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(105),char(110),char(115),char(65), -char(110),char(99),char(104),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(100),char(101),char(0),char(109),char(95),char(99),char(108), -char(117),char(115),char(116),char(101),char(114),char(73),char(110),char(100),char(101),char(120),char(0),char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(65),char(0), -char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(0),char(109),char(95),char(114),char(101),char(102),char(115),char(91),char(50),char(93),char(0),char(109), -char(95),char(99),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(100),char(101),char(108),char(101),char(116), -char(101),char(0),char(109),char(95),char(114),char(101),char(108),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(91),char(50),char(93),char(0),char(109), -char(95),char(98),char(111),char(100),char(121),char(65),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(116),char(121), -char(112),char(101),char(0),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(42),char(109),char(95),char(112),char(111), -char(115),char(101),char(0),char(42),char(42),char(109),char(95),char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0),char(42),char(109),char(95), -char(110),char(111),char(100),char(101),char(115),char(0),char(42),char(109),char(95),char(108),char(105),char(110),char(107),char(115),char(0),char(42),char(109),char(95),char(102),char(97), -char(99),char(101),char(115),char(0),char(42),char(109),char(95),char(116),char(101),char(116),char(114),char(97),char(104),char(101),char(100),char(114),char(97),char(0),char(42),char(109), -char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(42),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(115), -char(0),char(42),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(77),char(97),char(116),char(101), -char(114),char(105),char(97),char(108),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(76),char(105),char(110),char(107),char(115),char(0),char(109),char(95),char(110), -char(117),char(109),char(70),char(97),char(99),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(84),char(101),char(116),char(114),char(97),char(104),char(101), -char(100),char(114),char(97),char(0),char(109),char(95),char(110),char(117),char(109),char(65),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(109),char(95),char(110), -char(117),char(109),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(74),char(111),char(105),char(110), -char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110),char(102),char(105),char(103),char(0),char(84),char(89),char(80),char(69),char(76),char(0),char(0),char(0), -char(99),char(104),char(97),char(114),char(0),char(117),char(99),char(104),char(97),char(114),char(0),char(115),char(104),char(111),char(114),char(116),char(0),char(117),char(115),char(104), -char(111),char(114),char(116),char(0),char(105),char(110),char(116),char(0),char(108),char(111),char(110),char(103),char(0),char(117),char(108),char(111),char(110),char(103),char(0),char(102), -char(108),char(111),char(97),char(116),char(0),char(100),char(111),char(117),char(98),char(108),char(101),char(0),char(118),char(111),char(105),char(100),char(0),char(80),char(111),char(105), -char(110),char(116),char(101),char(114),char(65),char(114),char(114),char(97),char(121),char(0),char(98),char(116),char(80),char(104),char(121),char(115),char(105),char(99),char(115),char(83), -char(121),char(115),char(116),char(101),char(109),char(0),char(76),char(105),char(115),char(116),char(66),char(97),char(115),char(101),char(0),char(98),char(116),char(86),char(101),char(99), -char(116),char(111),char(114),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(86),char(101),char(99),char(116), -char(111),char(114),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(97),char(116),char(114), -char(105),char(120),char(51),char(120),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(97),char(116), -char(114),char(105),char(120),char(51),char(120),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84), -char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0), -char(98),char(116),char(66),char(118),char(104),char(83),char(117),char(98),char(116),char(114),char(101),char(101),char(73),char(110),char(102),char(111),char(68),char(97),char(116),char(97), -char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(70), -char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100), -char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97), -char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(70),char(108),char(111),char(97),char(116), -char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(68), -char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111), -char(110),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(97),char(116),char(105),char(99),char(80), -char(108),char(97),char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(118), -char(101),char(120),char(73),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0), -char(98),char(116),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(65),char(110),char(100),char(82),char(97),char(100),char(105),char(117),char(115),char(0), -char(98),char(116),char(77),char(117),char(108),char(116),char(105),char(83),char(112),char(104),char(101),char(114),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97), -char(116),char(97),char(0),char(98),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105),char(112),char(108),char(101),char(116), -char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(104),char(97),char(114),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105),char(112), -char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(101),char(115),char(104),char(80),char(97),char(114),char(116),char(68),char(97), -char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(114),char(105),char(100),char(105),char(110),char(103),char(77),char(101),char(115),char(104),char(73),char(110),char(116), -char(101),char(114),char(102),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108), -char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105), -char(97),char(110),char(103),char(108),char(101),char(73),char(110),char(102),char(111),char(77),char(97),char(112),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83), -char(99),char(97),char(108),char(101),char(100),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97), -char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117),char(110),char(100),char(83),char(104),char(97), -char(112),char(101),char(67),char(104),char(105),char(108),char(100),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117), -char(110),char(100),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(121),char(108),char(105),char(110),char(100), -char(101),char(114),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(97),char(112),char(115),char(117),char(108), +char(111),char(110),char(87),char(111),char(114),char(108),char(100),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(0),char(109),char(95),char(105), +char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105),char(111),char(110),char(76),char(105),char(110),char(101),char(97),char(114),char(86),char(101), +char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(105),char(110),char(116),char(101),char(114),char(112),char(111),char(108),char(97),char(116),char(105), +char(111),char(110),char(65),char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95), +char(97),char(110),char(105),char(115),char(111),char(116),char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0), +char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(99),char(116),char(80),char(114),char(111),char(99),char(101),char(115),char(115),char(105),char(110),char(103),char(84), +char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(100),char(101),char(97),char(99),char(116),char(105),char(118),char(97),char(116), +char(105),char(111),char(110),char(84),char(105),char(109),char(101),char(0),char(109),char(95),char(102),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109), +char(95),char(114),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(114), +char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(104),char(105),char(116),char(70),char(114),char(97),char(99), +char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(99),char(100),char(83),char(119),char(101),char(112),char(116),char(83),char(112),char(104),char(101),char(114), +char(101),char(82),char(97),char(100),char(105),char(117),char(115),char(0),char(109),char(95),char(99),char(99),char(100),char(77),char(111),char(116),char(105),char(111),char(110),char(84), +char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(104),char(97),char(115),char(65),char(110),char(105),char(115),char(111),char(116), +char(114),char(111),char(112),char(105),char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(99),char(111),char(108),char(108), +char(105),char(115),char(105),char(111),char(110),char(70),char(108),char(97),char(103),char(115),char(0),char(109),char(95),char(105),char(115),char(108),char(97),char(110),char(100),char(84), +char(97),char(103),char(49),char(0),char(109),char(95),char(99),char(111),char(109),char(112),char(97),char(110),char(105),char(111),char(110),char(73),char(100),char(0),char(109),char(95), +char(97),char(99),char(116),char(105),char(118),char(97),char(116),char(105),char(111),char(110),char(83),char(116),char(97),char(116),char(101),char(49),char(0),char(109),char(95),char(105), +char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(84),char(121),char(112),char(101),char(0),char(109),char(95),char(99),char(104),char(101),char(99),char(107),char(67), +char(111),char(108),char(108),char(105),char(100),char(101),char(87),char(105),char(116),char(104),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114),char(73), +char(110),char(102),char(111),char(0),char(109),char(95),char(103),char(114),char(97),char(118),char(105),char(116),char(121),char(0),char(109),char(95),char(99),char(111),char(108),char(108), +char(105),char(115),char(105),char(111),char(110),char(79),char(98),char(106),char(101),char(99),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(105),char(110), +char(118),char(73),char(110),char(101),char(114),char(116),char(105),char(97),char(84),char(101),char(110),char(115),char(111),char(114),char(87),char(111),char(114),char(108),char(100),char(0), +char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97), +char(110),char(103),char(117),char(108),char(97),char(114),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(110),char(103), +char(117),char(108),char(97),char(114),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(70), +char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(103),char(114),char(97),char(118),char(105),char(116),char(121),char(95),char(97),char(99),char(99),char(101), +char(108),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(105),char(110),char(118),char(73),char(110),char(101),char(114),char(116),char(105), +char(97),char(76),char(111),char(99),char(97),char(108),char(0),char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(70),char(111),char(114),char(99),char(101),char(0), +char(109),char(95),char(116),char(111),char(116),char(97),char(108),char(84),char(111),char(114),char(113),char(117),char(101),char(0),char(109),char(95),char(105),char(110),char(118),char(101), +char(114),char(115),char(101),char(77),char(97),char(115),char(115),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112), +char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103), +char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103), +char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(76), +char(105),char(110),char(101),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108), +char(100),char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103), +char(117),char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100), +char(83),char(113),char(114),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110),char(97),char(108),char(65),char(110),char(103),char(117), +char(108),char(97),char(114),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(108), +char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103),char(84),char(104),char(114),char(101),char(115),char(104),char(111), +char(108),char(100),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(108),char(101),char(101),char(112),char(105),char(110),char(103), +char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(97),char(100),char(100),char(105),char(116),char(105),char(111),char(110), +char(97),char(108),char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(117),char(109),char(67),char(111),char(110),char(115),char(116), +char(114),char(97),char(105),char(110),char(116),char(82),char(111),char(119),char(115),char(0),char(110),char(117),char(98),char(0),char(42),char(109),char(95),char(114),char(98),char(65), +char(0),char(42),char(109),char(95),char(114),char(98),char(66),char(0),char(109),char(95),char(111),char(98),char(106),char(101),char(99),char(116),char(84),char(121),char(112),char(101), +char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(84),char(121),char(112), +char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(100), +char(0),char(109),char(95),char(110),char(101),char(101),char(100),char(115),char(70),char(101),char(101),char(100),char(98),char(97),char(99),char(107),char(0),char(109),char(95),char(97), +char(112),char(112),char(108),char(105),char(101),char(100),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(100),char(98),char(103),char(68), +char(114),char(97),char(119),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(100),char(105),char(115),char(97),char(98),char(108),char(101),char(67),char(111),char(108), +char(108),char(105),char(115),char(105),char(111),char(110),char(115),char(66),char(101),char(116),char(119),char(101),char(101),char(110),char(76),char(105),char(110),char(107),char(101),char(100), +char(66),char(111),char(100),char(105),char(101),char(115),char(0),char(109),char(95),char(111),char(118),char(101),char(114),char(114),char(105),char(100),char(101),char(78),char(117),char(109), +char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(98), +char(114),char(101),char(97),char(107),char(105),char(110),char(103),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(104),char(114),char(101),char(115),char(104), +char(111),char(108),char(100),char(0),char(109),char(95),char(105),char(115),char(69),char(110),char(97),char(98),char(108),char(101),char(100),char(0),char(112),char(97),char(100),char(100), +char(105),char(110),char(103),char(91),char(52),char(93),char(0),char(109),char(95),char(116),char(121),char(112),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97), +char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(65),char(0),char(109), +char(95),char(112),char(105),char(118),char(111),char(116),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(98),char(65),char(70),char(114),char(97),char(109),char(101), +char(0),char(109),char(95),char(114),char(98),char(66),char(70),char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(117),char(115),char(101),char(82),char(101),char(102), +char(101),char(114),char(101),char(110),char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108), +char(97),char(114),char(79),char(110),char(108),char(121),char(0),char(109),char(95),char(101),char(110),char(97),char(98),char(108),char(101),char(65),char(110),char(103),char(117),char(108), +char(97),char(114),char(77),char(111),char(116),char(111),char(114),char(0),char(109),char(95),char(109),char(111),char(116),char(111),char(114),char(84),char(97),char(114),char(103),char(101), +char(116),char(86),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(109),char(97),char(120),char(77),char(111),char(116),char(111),char(114), +char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(0),char(109),char(95),char(108),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105),char(116), +char(0),char(109),char(95),char(117),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(109),char(105), +char(116),char(83),char(111),char(102),char(116),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(98),char(105),char(97),char(115),char(70),char(97),char(99),char(116), +char(111),char(114),char(0),char(109),char(95),char(114),char(101),char(108),char(97),char(120),char(97),char(116),char(105),char(111),char(110),char(70),char(97),char(99),char(116),char(111), +char(114),char(0),char(109),char(95),char(112),char(97),char(100),char(100),char(105),char(110),char(103),char(49),char(91),char(52),char(93),char(0),char(109),char(95),char(115),char(119), +char(105),char(110),char(103),char(83),char(112),char(97),char(110),char(49),char(0),char(109),char(95),char(115),char(119),char(105),char(110),char(103),char(83),char(112),char(97),char(110), +char(50),char(0),char(109),char(95),char(116),char(119),char(105),char(115),char(116),char(83),char(112),char(97),char(110),char(0),char(109),char(95),char(100),char(97),char(109),char(112), +char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(85),char(112),char(112),char(101),char(114),char(76),char(105),char(109), +char(105),char(116),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(76),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105), +char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(85),char(112),char(112),char(101),char(114),char(76),char(105),char(109),char(105), +char(116),char(0),char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(76),char(111),char(119),char(101),char(114),char(76),char(105),char(109),char(105), +char(116),char(0),char(109),char(95),char(117),char(115),char(101),char(76),char(105),char(110),char(101),char(97),char(114),char(82),char(101),char(102),char(101),char(114),char(101),char(110), +char(99),char(101),char(70),char(114),char(97),char(109),char(101),char(65),char(0),char(109),char(95),char(117),char(115),char(101),char(79),char(102),char(102),char(115),char(101),char(116), +char(70),char(111),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(114),char(97),char(109),char(101),char(0),char(109), +char(95),char(54),char(100),char(111),char(102),char(68),char(97),char(116),char(97),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103),char(69),char(110), +char(97),char(98),char(108),char(101),char(100),char(91),char(54),char(93),char(0),char(109),char(95),char(101),char(113),char(117),char(105),char(108),char(105),char(98),char(114),char(105), +char(117),char(109),char(80),char(111),char(105),char(110),char(116),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103),char(83), +char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(91),char(54),char(93),char(0),char(109),char(95),char(115),char(112),char(114),char(105),char(110),char(103), +char(68),char(97),char(109),char(112),char(105),char(110),char(103),char(91),char(54),char(93),char(0),char(109),char(95),char(97),char(120),char(105),char(115),char(73),char(110),char(65), +char(0),char(109),char(95),char(97),char(120),char(105),char(115),char(73),char(110),char(66),char(0),char(109),char(95),char(114),char(97),char(116),char(105),char(111),char(0),char(109), +char(95),char(116),char(97),char(117),char(0),char(109),char(95),char(116),char(105),char(109),char(101),char(83),char(116),char(101),char(112),char(0),char(109),char(95),char(109),char(97), +char(120),char(69),char(114),char(114),char(111),char(114),char(82),char(101),char(100),char(117),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(115),char(111), +char(114),char(0),char(109),char(95),char(101),char(114),char(112),char(0),char(109),char(95),char(101),char(114),char(112),char(50),char(0),char(109),char(95),char(103),char(108),char(111), +char(98),char(97),char(108),char(67),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115), +char(101),char(80),char(101),char(110),char(101),char(116),char(114),char(97),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108), +char(100),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(84),char(117),char(114),char(110), +char(69),char(114),char(112),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(108),char(111),char(112),char(0),char(109),char(95),char(119), +char(97),char(114),char(109),char(115),char(116),char(97),char(114),char(116),char(105),char(110),char(103),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95), +char(109),char(97),char(120),char(71),char(121),char(114),char(111),char(115),char(99),char(111),char(112),char(105),char(99),char(70),char(111),char(114),char(99),char(101),char(0),char(109), +char(95),char(115),char(105),char(110),char(103),char(108),char(101),char(65),char(120),char(105),char(115),char(82),char(111),char(108),char(108),char(105),char(110),char(103),char(70),char(114), +char(105),char(99),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108),char(100),char(0),char(109),char(95),char(110),char(117), +char(109),char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(115),char(111),char(108),char(118),char(101),char(114), +char(77),char(111),char(100),char(101),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(105),char(110),char(103),char(67),char(111),char(110),char(116),char(97),char(99), +char(116),char(82),char(101),char(115),char(116),char(105),char(116),char(117),char(116),char(105),char(111),char(110),char(84),char(104),char(114),char(101),char(115),char(104),char(111),char(108), +char(100),char(0),char(109),char(95),char(109),char(105),char(110),char(105),char(109),char(117),char(109),char(83),char(111),char(108),char(118),char(101),char(114),char(66),char(97),char(116), +char(99),char(104),char(83),char(105),char(122),char(101),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(73),char(109),char(112),char(117),char(108),char(115), +char(101),char(0),char(109),char(95),char(108),char(105),char(110),char(101),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0), +char(109),char(95),char(97),char(110),char(103),char(117),char(108),char(97),char(114),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(109), +char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(83),char(116),char(105),char(102),char(102),char(110),char(101),char(115),char(115),char(0),char(42),char(109),char(95), +char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0), +char(109),char(95),char(112),char(114),char(101),char(118),char(105),char(111),char(117),char(115),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(0),char(109), +char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(0),char(109),char(95),char(97),char(99),char(99),char(117),char(109),char(117),char(108),char(97), +char(116),char(101),char(100),char(70),char(111),char(114),char(99),char(101),char(0),char(109),char(95),char(110),char(111),char(114),char(109),char(97),char(108),char(0),char(109),char(95), +char(97),char(114),char(101),char(97),char(0),char(109),char(95),char(97),char(116),char(116),char(97),char(99),char(104),char(0),char(109),char(95),char(110),char(111),char(100),char(101), +char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(76),char(101),char(110), +char(103),char(116),char(104),char(0),char(109),char(95),char(98),char(98),char(101),char(110),char(100),char(105),char(110),char(103),char(0),char(109),char(95),char(110),char(111),char(100), +char(101),char(73),char(110),char(100),char(105),char(99),char(101),char(115),char(91),char(51),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(65),char(114), +char(101),char(97),char(0),char(109),char(95),char(99),char(48),char(91),char(52),char(93),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100), +char(105),char(99),char(101),char(115),char(91),char(52),char(93),char(0),char(109),char(95),char(114),char(101),char(115),char(116),char(86),char(111),char(108),char(117),char(109),char(101), +char(0),char(109),char(95),char(99),char(49),char(0),char(109),char(95),char(99),char(50),char(0),char(109),char(95),char(99),char(48),char(0),char(109),char(95),char(108),char(111), +char(99),char(97),char(108),char(70),char(114),char(97),char(109),char(101),char(0),char(42),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(66),char(111),char(100), +char(121),char(0),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(101),char(120),char(0),char(109),char(95),char(97),char(101),char(114),char(111), +char(77),char(111),char(100),char(101),char(108),char(0),char(109),char(95),char(98),char(97),char(117),char(109),char(103),char(97),char(114),char(116),char(101),char(0),char(109),char(95), +char(100),char(114),char(97),char(103),char(0),char(109),char(95),char(108),char(105),char(102),char(116),char(0),char(109),char(95),char(112),char(114),char(101),char(115),char(115),char(117), +char(114),char(101),char(0),char(109),char(95),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(100),char(121),char(110),char(97),char(109),char(105), +char(99),char(70),char(114),char(105),char(99),char(116),char(105),char(111),char(110),char(0),char(109),char(95),char(112),char(111),char(115),char(101),char(77),char(97),char(116),char(99), +char(104),char(0),char(109),char(95),char(114),char(105),char(103),char(105),char(100),char(67),char(111),char(110),char(116),char(97),char(99),char(116),char(72),char(97),char(114),char(100), +char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(107),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(111),char(110),char(116),char(97),char(99), +char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(67),char(111),char(110),char(116), +char(97),char(99),char(116),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114), +char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100), +char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111), +char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(72),char(97),char(114),char(100), +char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116), +char(101),char(114),char(72),char(97),char(114),char(100),char(110),char(101),char(115),char(115),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(82),char(105),char(103), +char(105),char(100),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105), +char(116),char(0),char(109),char(95),char(115),char(111),char(102),char(116),char(75),char(105),char(110),char(101),char(116),char(105),char(99),char(67),char(108),char(117),char(115),char(116), +char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(115),char(111),char(102), +char(116),char(83),char(111),char(102),char(116),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(109),char(112),char(117),char(108),char(115),char(101),char(83), +char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(109),char(97),char(120),char(86),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(116), +char(105),char(109),char(101),char(83),char(99),char(97),char(108),char(101),char(0),char(109),char(95),char(118),char(101),char(108),char(111),char(99),char(105),char(116),char(121),char(73), +char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(112),char(111),char(115),char(105),char(116),char(105),char(111),char(110), +char(73),char(116),char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(100),char(114),char(105),char(102),char(116),char(73),char(116), +char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(116), +char(101),char(114),char(97),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(114),char(111),char(116),char(0),char(109),char(95),char(115),char(99),char(97), +char(108),char(101),char(0),char(109),char(95),char(97),char(113),char(113),char(0),char(109),char(95),char(99),char(111),char(109),char(0),char(42),char(109),char(95),char(112),char(111), +char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(42),char(109),char(95),char(119),char(101),char(105),char(103),char(104),char(116),char(115),char(0),char(109), +char(95),char(110),char(117),char(109),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(87), +char(101),char(105),char(103),char(116),char(115),char(0),char(109),char(95),char(98),char(118),char(111),char(108),char(117),char(109),char(101),char(0),char(109),char(95),char(98),char(102), +char(114),char(97),char(109),char(101),char(0),char(109),char(95),char(102),char(114),char(97),char(109),char(101),char(120),char(102),char(111),char(114),char(109),char(0),char(109),char(95), +char(108),char(111),char(99),char(105),char(105),char(0),char(109),char(95),char(105),char(110),char(118),char(119),char(105),char(0),char(109),char(95),char(118),char(105),char(109),char(112), +char(117),char(108),char(115),char(101),char(115),char(91),char(50),char(93),char(0),char(109),char(95),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115), +char(91),char(50),char(93),char(0),char(109),char(95),char(108),char(118),char(0),char(109),char(95),char(97),char(118),char(0),char(42),char(109),char(95),char(102),char(114),char(97), +char(109),char(101),char(114),char(101),char(102),char(115),char(0),char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(73),char(110),char(100),char(105),char(99),char(101), +char(115),char(0),char(42),char(109),char(95),char(109),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(70),char(114),char(97), +char(109),char(101),char(82),char(101),char(102),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(78),char(111),char(100),char(101),char(115),char(0),char(109),char(95), +char(110),char(117),char(109),char(77),char(97),char(115),char(115),char(101),char(115),char(0),char(109),char(95),char(105),char(100),char(109),char(97),char(115),char(115),char(0),char(109), +char(95),char(105),char(109),char(97),char(115),char(115),char(0),char(109),char(95),char(110),char(118),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0), +char(109),char(95),char(110),char(100),char(105),char(109),char(112),char(117),char(108),char(115),char(101),char(115),char(0),char(109),char(95),char(110),char(100),char(97),char(109),char(112), +char(105),char(110),char(103),char(0),char(109),char(95),char(108),char(100),char(97),char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(97),char(100),char(97), +char(109),char(112),char(105),char(110),char(103),char(0),char(109),char(95),char(109),char(97),char(116),char(99),char(104),char(105),char(110),char(103),char(0),char(109),char(95),char(109), +char(97),char(120),char(83),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109),char(112),char(117),char(108), +char(115),char(101),char(0),char(109),char(95),char(115),char(101),char(108),char(102),char(67),char(111),char(108),char(108),char(105),char(115),char(105),char(111),char(110),char(73),char(109), +char(112),char(117),char(108),char(115),char(101),char(70),char(97),char(99),char(116),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(110),char(116),char(97),char(105), +char(110),char(115),char(65),char(110),char(99),char(104),char(111),char(114),char(0),char(109),char(95),char(99),char(111),char(108),char(108),char(105),char(100),char(101),char(0),char(109), +char(95),char(99),char(108),char(117),char(115),char(116),char(101),char(114),char(73),char(110),char(100),char(101),char(120),char(0),char(42),char(109),char(95),char(98),char(111),char(100), +char(121),char(65),char(0),char(42),char(109),char(95),char(98),char(111),char(100),char(121),char(66),char(0),char(109),char(95),char(114),char(101),char(102),char(115),char(91),char(50), +char(93),char(0),char(109),char(95),char(99),char(102),char(109),char(0),char(109),char(95),char(115),char(112),char(108),char(105),char(116),char(0),char(109),char(95),char(100),char(101), +char(108),char(101),char(116),char(101),char(0),char(109),char(95),char(114),char(101),char(108),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(91),char(50), +char(93),char(0),char(109),char(95),char(98),char(111),char(100),char(121),char(65),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(98),char(111),char(100),char(121), +char(66),char(116),char(121),char(112),char(101),char(0),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(84),char(121),char(112),char(101),char(0),char(42),char(109), +char(95),char(112),char(111),char(115),char(101),char(0),char(42),char(42),char(109),char(95),char(109),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0), +char(42),char(109),char(95),char(110),char(111),char(100),char(101),char(115),char(0),char(42),char(109),char(95),char(108),char(105),char(110),char(107),char(115),char(0),char(42),char(109), +char(95),char(102),char(97),char(99),char(101),char(115),char(0),char(42),char(109),char(95),char(116),char(101),char(116),char(114),char(97),char(104),char(101),char(100),char(114),char(97), +char(0),char(42),char(109),char(95),char(97),char(110),char(99),char(104),char(111),char(114),char(115),char(0),char(42),char(109),char(95),char(99),char(108),char(117),char(115),char(116), +char(101),char(114),char(115),char(0),char(42),char(109),char(95),char(106),char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(77), +char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(76),char(105),char(110),char(107),char(115),char(0), +char(109),char(95),char(110),char(117),char(109),char(70),char(97),char(99),char(101),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(84),char(101),char(116),char(114), +char(97),char(104),char(101),char(100),char(114),char(97),char(0),char(109),char(95),char(110),char(117),char(109),char(65),char(110),char(99),char(104),char(111),char(114),char(115),char(0), +char(109),char(95),char(110),char(117),char(109),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(115),char(0),char(109),char(95),char(110),char(117),char(109),char(74), +char(111),char(105),char(110),char(116),char(115),char(0),char(109),char(95),char(99),char(111),char(110),char(102),char(105),char(103),char(0),char(0),char(84),char(89),char(80),char(69), +char(87),char(0),char(0),char(0),char(99),char(104),char(97),char(114),char(0),char(117),char(99),char(104),char(97),char(114),char(0),char(115),char(104),char(111),char(114),char(116), +char(0),char(117),char(115),char(104),char(111),char(114),char(116),char(0),char(105),char(110),char(116),char(0),char(108),char(111),char(110),char(103),char(0),char(117),char(108),char(111), +char(110),char(103),char(0),char(102),char(108),char(111),char(97),char(116),char(0),char(100),char(111),char(117),char(98),char(108),char(101),char(0),char(118),char(111),char(105),char(100), +char(0),char(80),char(111),char(105),char(110),char(116),char(101),char(114),char(65),char(114),char(114),char(97),char(121),char(0),char(98),char(116),char(80),char(104),char(121),char(115), +char(105),char(99),char(115),char(83),char(121),char(115),char(116),char(101),char(109),char(0),char(76),char(105),char(115),char(116),char(66),char(97),char(115),char(101),char(0),char(98), +char(116),char(86),char(101),char(99),char(116),char(111),char(114),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116), +char(86),char(101),char(99),char(116),char(111),char(114),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116), +char(77),char(97),char(116),char(114),char(105),char(120),char(51),char(120),char(51),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98), +char(116),char(77),char(97),char(116),char(114),char(105),char(120),char(51),char(120),char(51),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97), +char(0),char(98),char(116),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116), +char(97),char(0),char(98),char(116),char(84),char(114),char(97),char(110),char(115),char(102),char(111),char(114),char(109),char(68),char(111),char(117),char(98),char(108),char(101),char(68), +char(97),char(116),char(97),char(0),char(98),char(116),char(66),char(118),char(104),char(83),char(117),char(98),char(116),char(114),char(101),char(101),char(73),char(110),char(102),char(111), +char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78), +char(111),char(100),char(101),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(79),char(112),char(116),char(105),char(109), +char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116), +char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(78),char(111),char(100),char(101), +char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100),char(66),char(118),char(104),char(70), +char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(81),char(117),char(97),char(110),char(116),char(105),char(122),char(101),char(100), +char(66),char(118),char(104),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(108),char(108), +char(105),char(115),char(105),char(111),char(110),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(97), +char(116),char(105),char(99),char(80),char(108),char(97),char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116), +char(67),char(111),char(110),char(118),char(101),char(120),char(73),char(110),char(116),char(101),char(114),char(110),char(97),char(108),char(83),char(104),char(97),char(112),char(101),char(68), +char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(115),char(105),char(116),char(105),char(111),char(110),char(65),char(110),char(100),char(82),char(97),char(100), +char(105),char(117),char(115),char(0),char(98),char(116),char(77),char(117),char(108),char(116),char(105),char(83),char(112),char(104),char(101),char(114),char(101),char(83),char(104),char(97), +char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116), +char(97),char(0),char(98),char(116),char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(68),char(97),char(116), +char(97),char(0),char(98),char(116),char(83),char(104),char(111),char(114),char(116),char(73),char(110),char(116),char(73),char(110),char(100),char(101),char(120),char(84),char(114),char(105), +char(112),char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(104),char(97),char(114),char(73),char(110),char(100),char(101),char(120), +char(84),char(114),char(105),char(112),char(108),char(101),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(77),char(101),char(115),char(104),char(80),char(97), +char(114),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(116),char(114),char(105),char(100),char(105),char(110),char(103),char(77),char(101),char(115), +char(104),char(73),char(110),char(116),char(101),char(114),char(102),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105), +char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98), +char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(73),char(110),char(102),char(111),char(77),char(97),char(112),char(68),char(97),char(116),char(97), +char(0),char(98),char(116),char(83),char(99),char(97),char(108),char(101),char(100),char(84),char(114),char(105),char(97),char(110),char(103),char(108),char(101),char(77),char(101),char(115), +char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(109),char(112),char(111),char(117),char(110), +char(100),char(83),char(104),char(97),char(112),char(101),char(67),char(104),char(105),char(108),char(100),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111), +char(109),char(112),char(111),char(117),char(110),char(100),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(121), +char(108),char(105),char(110),char(100),char(101),char(114),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111), +char(110),char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(97),char(112),char(115),char(117),char(108), char(101),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(114),char(105),char(97),char(110),char(103),char(108), char(101),char(73),char(110),char(102),char(111),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(73),char(109),char(112),char(97),char(99),char(116),char(77), char(101),char(115),char(104),char(83),char(104),char(97),char(112),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(118),char(101), @@ -759,150 +805,187 @@ char(83),char(111),char(108),char(118),char(101),char(114),char(73),char(110),ch char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97), char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97), char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(73),char(110),char(102),char(111),char(49), -char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97), -char(116),char(97),char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100),char(121),char(68),char(97),char(116),char(97),char(0),char(98), -char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105), -char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50), -char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108), -char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97), -char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103), -char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97), -char(0),char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119),char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105), -char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102), +char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108), +char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116), +char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(82),char(105),char(103),char(105),char(100),char(66),char(111),char(100), +char(121),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(84),char(121),char(112),char(101),char(100),char(67),char(111),char(110),char(115),char(116),char(114),char(97), +char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110), +char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(70),char(108),char(111), +char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116), +char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97), +char(50),char(0),char(98),char(116),char(80),char(111),char(105),char(110),char(116),char(50),char(80),char(111),char(105),char(110),char(116),char(67),char(111),char(110),char(115),char(116), +char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105), +char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68), +char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110), +char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(72),char(105),char(110),char(103),char(101),char(67),char(111), +char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50),char(0), +char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119),char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110), +char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(67),char(111),char(110),char(101),char(84),char(119), +char(105),char(115),char(116),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116), +char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110), +char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(67), +char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50), +char(0),char(98),char(116),char(71),char(101),char(110),char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(83),char(112),char(114),char(105),char(110),char(103), char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(110), char(101),char(114),char(105),char(99),char(54),char(68),char(111),char(102),char(83),char(112),char(114),char(105),char(110),char(103),char(67),char(111),char(110),char(115),char(116),char(114), -char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(108),char(105),char(100),char(101),char(114),char(67),char(111),char(110), -char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121), -char(77),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100), -char(121),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(76),char(105), -char(110),char(107),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(97),char(99),char(101),char(68), -char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(84),char(101),char(116),char(114),char(97),char(68),char(97),char(116), -char(97),char(0),char(83),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100),char(65),char(110),char(99),char(104),char(111),char(114),char(68),char(97),char(116), -char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(111),char(110),char(102),char(105),char(103),char(68),char(97),char(116),char(97), -char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(80),char(111),char(115),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111), -char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(108),char(117),char(115),char(116),char(101),char(114),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(74),char(111),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116), -char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(0),char(0), -char(84),char(76),char(69),char(78),char(1),char(0),char(1),char(0),char(2),char(0),char(2),char(0),char(4),char(0),char(4),char(0),char(4),char(0),char(4),char(0), -char(8),char(0),char(0),char(0),char(16),char(0),char(48),char(0),char(16),char(0),char(16),char(0),char(32),char(0),char(48),char(0),char(96),char(0),char(64),char(0), -char(-128),char(0),char(20),char(0),char(48),char(0),char(80),char(0),char(16),char(0),char(96),char(0),char(-112),char(0),char(16),char(0),char(56),char(0),char(56),char(0), -char(20),char(0),char(72),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(4),char(0),char(56),char(0),char(32),char(0),char(80),char(0),char(72),char(0), -char(96),char(0),char(80),char(0),char(32),char(0),char(64),char(0),char(64),char(0),char(16),char(0),char(72),char(0),char(80),char(0),char(-32),char(1),char(16),char(1), -char(-72),char(0),char(-104),char(0),char(104),char(0),char(88),char(0),char(-8),char(1),char(-80),char(3),char(8),char(0),char(64),char(0),char(0),char(0),char(96),char(0), -char(-128),char(0),char(104),char(1),char(-24),char(0),char(-32),char(0),char(8),char(1),char(104),char(1),char(-40),char(0),char(16),char(0),char(104),char(0),char(24),char(0), -char(40),char(0),char(104),char(0),char(96),char(0),char(104),char(0),char(-56),char(0),char(104),char(1),char(112),char(0),char(-32),char(1),char(83),char(84),char(82),char(67), -char(65),char(0),char(0),char(0),char(10),char(0),char(3),char(0),char(4),char(0),char(0),char(0),char(4),char(0),char(1),char(0),char(9),char(0),char(2),char(0), -char(11),char(0),char(3),char(0),char(10),char(0),char(3),char(0),char(10),char(0),char(4),char(0),char(10),char(0),char(5),char(0),char(12),char(0),char(2),char(0), -char(9),char(0),char(6),char(0),char(9),char(0),char(7),char(0),char(13),char(0),char(1),char(0),char(7),char(0),char(8),char(0),char(14),char(0),char(1),char(0), -char(8),char(0),char(8),char(0),char(15),char(0),char(1),char(0),char(13),char(0),char(9),char(0),char(16),char(0),char(1),char(0),char(14),char(0),char(9),char(0), -char(17),char(0),char(2),char(0),char(15),char(0),char(10),char(0),char(13),char(0),char(11),char(0),char(18),char(0),char(2),char(0),char(16),char(0),char(10),char(0), -char(14),char(0),char(11),char(0),char(19),char(0),char(4),char(0),char(4),char(0),char(12),char(0),char(4),char(0),char(13),char(0),char(2),char(0),char(14),char(0), -char(2),char(0),char(15),char(0),char(20),char(0),char(6),char(0),char(13),char(0),char(16),char(0),char(13),char(0),char(17),char(0),char(4),char(0),char(18),char(0), -char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0),char(21),char(0),char(6),char(0),char(14),char(0),char(16),char(0), -char(14),char(0),char(17),char(0),char(4),char(0),char(18),char(0),char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0), -char(22),char(0),char(3),char(0),char(2),char(0),char(14),char(0),char(2),char(0),char(15),char(0),char(4),char(0),char(22),char(0),char(23),char(0),char(12),char(0), -char(13),char(0),char(23),char(0),char(13),char(0),char(24),char(0),char(13),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0), -char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),char(20),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(19),char(0),char(32),char(0), -char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(24),char(0),char(12),char(0),char(14),char(0),char(23),char(0),char(14),char(0),char(24),char(0), -char(14),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0), -char(21),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(19),char(0),char(32),char(0), -char(25),char(0),char(3),char(0),char(0),char(0),char(35),char(0),char(4),char(0),char(36),char(0),char(0),char(0),char(37),char(0),char(26),char(0),char(5),char(0), -char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0),char(13),char(0),char(40),char(0),char(7),char(0),char(41),char(0),char(0),char(0),char(21),char(0), -char(27),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0),char(13),char(0),char(42),char(0),char(7),char(0),char(43),char(0), -char(4),char(0),char(44),char(0),char(28),char(0),char(2),char(0),char(13),char(0),char(45),char(0),char(7),char(0),char(46),char(0),char(29),char(0),char(4),char(0), -char(27),char(0),char(47),char(0),char(28),char(0),char(48),char(0),char(4),char(0),char(49),char(0),char(0),char(0),char(37),char(0),char(30),char(0),char(1),char(0), -char(4),char(0),char(50),char(0),char(31),char(0),char(2),char(0),char(2),char(0),char(50),char(0),char(0),char(0),char(51),char(0),char(32),char(0),char(2),char(0), -char(2),char(0),char(52),char(0),char(0),char(0),char(51),char(0),char(33),char(0),char(2),char(0),char(0),char(0),char(52),char(0),char(0),char(0),char(53),char(0), -char(34),char(0),char(8),char(0),char(13),char(0),char(54),char(0),char(14),char(0),char(55),char(0),char(30),char(0),char(56),char(0),char(32),char(0),char(57),char(0), -char(33),char(0),char(58),char(0),char(31),char(0),char(59),char(0),char(4),char(0),char(60),char(0),char(4),char(0),char(61),char(0),char(35),char(0),char(4),char(0), -char(34),char(0),char(62),char(0),char(13),char(0),char(63),char(0),char(4),char(0),char(64),char(0),char(0),char(0),char(37),char(0),char(36),char(0),char(7),char(0), -char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0),char(23),char(0),char(66),char(0),char(24),char(0),char(67),char(0),char(37),char(0),char(68),char(0), -char(7),char(0),char(43),char(0),char(0),char(0),char(69),char(0),char(38),char(0),char(2),char(0),char(36),char(0),char(70),char(0),char(13),char(0),char(39),char(0), -char(39),char(0),char(4),char(0),char(17),char(0),char(71),char(0),char(25),char(0),char(72),char(0),char(4),char(0),char(73),char(0),char(7),char(0),char(74),char(0), -char(40),char(0),char(4),char(0),char(25),char(0),char(38),char(0),char(39),char(0),char(75),char(0),char(4),char(0),char(76),char(0),char(7),char(0),char(43),char(0), -char(41),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(42),char(0),char(3),char(0), -char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(43),char(0),char(4),char(0),char(4),char(0),char(78),char(0), -char(7),char(0),char(79),char(0),char(7),char(0),char(80),char(0),char(7),char(0),char(81),char(0),char(37),char(0),char(14),char(0),char(4),char(0),char(82),char(0), -char(4),char(0),char(83),char(0),char(43),char(0),char(84),char(0),char(4),char(0),char(85),char(0),char(7),char(0),char(86),char(0),char(7),char(0),char(87),char(0), -char(7),char(0),char(88),char(0),char(7),char(0),char(89),char(0),char(7),char(0),char(90),char(0),char(4),char(0),char(91),char(0),char(4),char(0),char(92),char(0), -char(4),char(0),char(93),char(0),char(4),char(0),char(94),char(0),char(0),char(0),char(37),char(0),char(44),char(0),char(5),char(0),char(25),char(0),char(38),char(0), -char(35),char(0),char(65),char(0),char(13),char(0),char(39),char(0),char(7),char(0),char(43),char(0),char(4),char(0),char(95),char(0),char(45),char(0),char(5),char(0), -char(27),char(0),char(47),char(0),char(13),char(0),char(96),char(0),char(14),char(0),char(97),char(0),char(4),char(0),char(98),char(0),char(0),char(0),char(99),char(0), -char(46),char(0),char(25),char(0),char(9),char(0),char(100),char(0),char(9),char(0),char(101),char(0),char(25),char(0),char(102),char(0),char(0),char(0),char(35),char(0), -char(18),char(0),char(103),char(0),char(18),char(0),char(104),char(0),char(14),char(0),char(105),char(0),char(14),char(0),char(106),char(0),char(14),char(0),char(107),char(0), -char(8),char(0),char(108),char(0),char(8),char(0),char(109),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(111),char(0),char(8),char(0),char(112),char(0), -char(8),char(0),char(113),char(0),char(8),char(0),char(114),char(0),char(8),char(0),char(115),char(0),char(4),char(0),char(116),char(0),char(4),char(0),char(117),char(0), -char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0),char(4),char(0),char(121),char(0),char(4),char(0),char(122),char(0), -char(0),char(0),char(37),char(0),char(47),char(0),char(25),char(0),char(9),char(0),char(100),char(0),char(9),char(0),char(101),char(0),char(25),char(0),char(102),char(0), -char(0),char(0),char(35),char(0),char(17),char(0),char(103),char(0),char(17),char(0),char(104),char(0),char(13),char(0),char(105),char(0),char(13),char(0),char(106),char(0), -char(13),char(0),char(107),char(0),char(7),char(0),char(108),char(0),char(7),char(0),char(109),char(0),char(7),char(0),char(110),char(0),char(7),char(0),char(111),char(0), -char(7),char(0),char(112),char(0),char(7),char(0),char(113),char(0),char(7),char(0),char(114),char(0),char(7),char(0),char(115),char(0),char(4),char(0),char(116),char(0), +char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(50),char(0),char(98),char(116),char(83),char(108), +char(105),char(100),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98), +char(116),char(83),char(108),char(105),char(100),char(101),char(114),char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117), +char(98),char(108),char(101),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(97),char(114),char(67),char(111),char(110),char(115),char(116),char(114), +char(97),char(105),char(110),char(116),char(70),char(108),char(111),char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(71),char(101),char(97),char(114), +char(67),char(111),char(110),char(115),char(116),char(114),char(97),char(105),char(110),char(116),char(68),char(111),char(117),char(98),char(108),char(101),char(68),char(97),char(116),char(97), +char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(77),char(97),char(116),char(101),char(114),char(105),char(97),char(108),char(68),char(97),char(116), +char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(78),char(111),char(100),char(101),char(68),char(97),char(116),char(97),char(0),char(83), +char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(76),char(105),char(110),char(107),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116), +char(66),char(111),char(100),char(121),char(70),char(97),char(99),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100), +char(121),char(84),char(101),char(116),char(114),char(97),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(82),char(105),char(103),char(105),char(100), +char(65),char(110),char(99),char(104),char(111),char(114),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67), +char(111),char(110),char(102),char(105),char(103),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(80),char(111), +char(115),char(101),char(68),char(97),char(116),char(97),char(0),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(67),char(108),char(117),char(115),char(116), +char(101),char(114),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(74),char(111),char(105), +char(110),char(116),char(68),char(97),char(116),char(97),char(0),char(98),char(116),char(83),char(111),char(102),char(116),char(66),char(111),char(100),char(121),char(70),char(108),char(111), +char(97),char(116),char(68),char(97),char(116),char(97),char(0),char(0),char(84),char(76),char(69),char(78),char(1),char(0),char(1),char(0),char(2),char(0),char(2),char(0), +char(4),char(0),char(4),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(0),char(0),char(16),char(0),char(48),char(0),char(16),char(0),char(16),char(0), +char(32),char(0),char(48),char(0),char(96),char(0),char(64),char(0),char(-128),char(0),char(20),char(0),char(48),char(0),char(80),char(0),char(16),char(0),char(96),char(0), +char(-112),char(0),char(16),char(0),char(56),char(0),char(56),char(0),char(20),char(0),char(72),char(0),char(4),char(0),char(4),char(0),char(8),char(0),char(4),char(0), +char(56),char(0),char(32),char(0),char(80),char(0),char(72),char(0),char(96),char(0),char(80),char(0),char(32),char(0),char(64),char(0),char(64),char(0),char(64),char(0), +char(16),char(0),char(72),char(0),char(80),char(0),char(-32),char(1),char(16),char(1),char(-72),char(0),char(-104),char(0),char(104),char(0),char(88),char(0),char(-8),char(1), +char(-80),char(3),char(8),char(0),char(64),char(0),char(64),char(0),char(0),char(0),char(80),char(0),char(96),char(0),char(-112),char(0),char(-128),char(0),char(104),char(1), +char(-24),char(0),char(-104),char(1),char(-120),char(1),char(-32),char(0),char(8),char(1),char(-40),char(1),char(104),char(1),char(-128),char(2),char(-40),char(0),char(120),char(1), +char(104),char(0),char(-104),char(0),char(16),char(0),char(104),char(0),char(24),char(0),char(40),char(0),char(104),char(0),char(96),char(0),char(104),char(0),char(-56),char(0), +char(104),char(1),char(112),char(0),char(-32),char(1),char(0),char(0),char(83),char(84),char(82),char(67),char(76),char(0),char(0),char(0),char(10),char(0),char(3),char(0), +char(4),char(0),char(0),char(0),char(4),char(0),char(1),char(0),char(9),char(0),char(2),char(0),char(11),char(0),char(3),char(0),char(10),char(0),char(3),char(0), +char(10),char(0),char(4),char(0),char(10),char(0),char(5),char(0),char(12),char(0),char(2),char(0),char(9),char(0),char(6),char(0),char(9),char(0),char(7),char(0), +char(13),char(0),char(1),char(0),char(7),char(0),char(8),char(0),char(14),char(0),char(1),char(0),char(8),char(0),char(8),char(0),char(15),char(0),char(1),char(0), +char(13),char(0),char(9),char(0),char(16),char(0),char(1),char(0),char(14),char(0),char(9),char(0),char(17),char(0),char(2),char(0),char(15),char(0),char(10),char(0), +char(13),char(0),char(11),char(0),char(18),char(0),char(2),char(0),char(16),char(0),char(10),char(0),char(14),char(0),char(11),char(0),char(19),char(0),char(4),char(0), +char(4),char(0),char(12),char(0),char(4),char(0),char(13),char(0),char(2),char(0),char(14),char(0),char(2),char(0),char(15),char(0),char(20),char(0),char(6),char(0), +char(13),char(0),char(16),char(0),char(13),char(0),char(17),char(0),char(4),char(0),char(18),char(0),char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0), +char(0),char(0),char(21),char(0),char(21),char(0),char(6),char(0),char(14),char(0),char(16),char(0),char(14),char(0),char(17),char(0),char(4),char(0),char(18),char(0), +char(4),char(0),char(19),char(0),char(4),char(0),char(20),char(0),char(0),char(0),char(21),char(0),char(22),char(0),char(3),char(0),char(2),char(0),char(14),char(0), +char(2),char(0),char(15),char(0),char(4),char(0),char(22),char(0),char(23),char(0),char(12),char(0),char(13),char(0),char(23),char(0),char(13),char(0),char(24),char(0), +char(13),char(0),char(25),char(0),char(4),char(0),char(26),char(0),char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0), +char(20),char(0),char(30),char(0),char(22),char(0),char(31),char(0),char(19),char(0),char(32),char(0),char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0), +char(24),char(0),char(12),char(0),char(14),char(0),char(23),char(0),char(14),char(0),char(24),char(0),char(14),char(0),char(25),char(0),char(4),char(0),char(26),char(0), +char(4),char(0),char(27),char(0),char(4),char(0),char(28),char(0),char(4),char(0),char(29),char(0),char(21),char(0),char(30),char(0),char(22),char(0),char(31),char(0), +char(4),char(0),char(33),char(0),char(4),char(0),char(34),char(0),char(19),char(0),char(32),char(0),char(25),char(0),char(3),char(0),char(0),char(0),char(35),char(0), +char(4),char(0),char(36),char(0),char(0),char(0),char(37),char(0),char(26),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(13),char(0),char(39),char(0), +char(13),char(0),char(40),char(0),char(7),char(0),char(41),char(0),char(0),char(0),char(21),char(0),char(27),char(0),char(5),char(0),char(25),char(0),char(38),char(0), +char(13),char(0),char(39),char(0),char(13),char(0),char(42),char(0),char(7),char(0),char(43),char(0),char(4),char(0),char(44),char(0),char(28),char(0),char(2),char(0), +char(13),char(0),char(45),char(0),char(7),char(0),char(46),char(0),char(29),char(0),char(4),char(0),char(27),char(0),char(47),char(0),char(28),char(0),char(48),char(0), +char(4),char(0),char(49),char(0),char(0),char(0),char(37),char(0),char(30),char(0),char(1),char(0),char(4),char(0),char(50),char(0),char(31),char(0),char(2),char(0), +char(2),char(0),char(50),char(0),char(0),char(0),char(51),char(0),char(32),char(0),char(2),char(0),char(2),char(0),char(52),char(0),char(0),char(0),char(51),char(0), +char(33),char(0),char(2),char(0),char(0),char(0),char(52),char(0),char(0),char(0),char(53),char(0),char(34),char(0),char(8),char(0),char(13),char(0),char(54),char(0), +char(14),char(0),char(55),char(0),char(30),char(0),char(56),char(0),char(32),char(0),char(57),char(0),char(33),char(0),char(58),char(0),char(31),char(0),char(59),char(0), +char(4),char(0),char(60),char(0),char(4),char(0),char(61),char(0),char(35),char(0),char(4),char(0),char(34),char(0),char(62),char(0),char(13),char(0),char(63),char(0), +char(4),char(0),char(64),char(0),char(0),char(0),char(37),char(0),char(36),char(0),char(7),char(0),char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0), +char(23),char(0),char(66),char(0),char(24),char(0),char(67),char(0),char(37),char(0),char(68),char(0),char(7),char(0),char(43),char(0),char(0),char(0),char(69),char(0), +char(38),char(0),char(2),char(0),char(36),char(0),char(70),char(0),char(13),char(0),char(39),char(0),char(39),char(0),char(4),char(0),char(17),char(0),char(71),char(0), +char(25),char(0),char(72),char(0),char(4),char(0),char(73),char(0),char(7),char(0),char(74),char(0),char(40),char(0),char(4),char(0),char(25),char(0),char(38),char(0), +char(39),char(0),char(75),char(0),char(4),char(0),char(76),char(0),char(7),char(0),char(43),char(0),char(41),char(0),char(3),char(0),char(27),char(0),char(47),char(0), +char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0),char(42),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(78),char(0), +char(0),char(0),char(37),char(0),char(43),char(0),char(3),char(0),char(27),char(0),char(47),char(0),char(4),char(0),char(77),char(0),char(0),char(0),char(37),char(0), +char(44),char(0),char(4),char(0),char(4),char(0),char(79),char(0),char(7),char(0),char(80),char(0),char(7),char(0),char(81),char(0),char(7),char(0),char(82),char(0), +char(37),char(0),char(14),char(0),char(4),char(0),char(83),char(0),char(4),char(0),char(84),char(0),char(44),char(0),char(85),char(0),char(4),char(0),char(86),char(0), +char(7),char(0),char(87),char(0),char(7),char(0),char(88),char(0),char(7),char(0),char(89),char(0),char(7),char(0),char(90),char(0),char(7),char(0),char(91),char(0), +char(4),char(0),char(92),char(0),char(4),char(0),char(93),char(0),char(4),char(0),char(94),char(0),char(4),char(0),char(95),char(0),char(0),char(0),char(37),char(0), +char(45),char(0),char(5),char(0),char(25),char(0),char(38),char(0),char(35),char(0),char(65),char(0),char(13),char(0),char(39),char(0),char(7),char(0),char(43),char(0), +char(4),char(0),char(96),char(0),char(46),char(0),char(5),char(0),char(27),char(0),char(47),char(0),char(13),char(0),char(97),char(0),char(14),char(0),char(98),char(0), +char(4),char(0),char(99),char(0),char(0),char(0),char(100),char(0),char(47),char(0),char(25),char(0),char(9),char(0),char(101),char(0),char(9),char(0),char(102),char(0), +char(25),char(0),char(103),char(0),char(0),char(0),char(35),char(0),char(18),char(0),char(104),char(0),char(18),char(0),char(105),char(0),char(14),char(0),char(106),char(0), +char(14),char(0),char(107),char(0),char(14),char(0),char(108),char(0),char(8),char(0),char(109),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(111),char(0), +char(8),char(0),char(112),char(0),char(8),char(0),char(113),char(0),char(8),char(0),char(114),char(0),char(8),char(0),char(115),char(0),char(8),char(0),char(116),char(0), char(4),char(0),char(117),char(0),char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0),char(4),char(0),char(121),char(0), -char(4),char(0),char(122),char(0),char(0),char(0),char(37),char(0),char(48),char(0),char(2),char(0),char(49),char(0),char(123),char(0),char(14),char(0),char(124),char(0), -char(50),char(0),char(2),char(0),char(51),char(0),char(123),char(0),char(13),char(0),char(124),char(0),char(52),char(0),char(21),char(0),char(47),char(0),char(125),char(0), -char(15),char(0),char(126),char(0),char(13),char(0),char(127),char(0),char(13),char(0),char(-128),char(0),char(13),char(0),char(-127),char(0),char(13),char(0),char(-126),char(0), -char(13),char(0),char(124),char(0),char(13),char(0),char(-125),char(0),char(13),char(0),char(-124),char(0),char(13),char(0),char(-123),char(0),char(13),char(0),char(-122),char(0), -char(7),char(0),char(-121),char(0),char(7),char(0),char(-120),char(0),char(7),char(0),char(-119),char(0),char(7),char(0),char(-118),char(0),char(7),char(0),char(-117),char(0), -char(7),char(0),char(-116),char(0),char(7),char(0),char(-115),char(0),char(7),char(0),char(-114),char(0),char(7),char(0),char(-113),char(0),char(4),char(0),char(-112),char(0), -char(53),char(0),char(22),char(0),char(46),char(0),char(125),char(0),char(16),char(0),char(126),char(0),char(14),char(0),char(127),char(0),char(14),char(0),char(-128),char(0), -char(14),char(0),char(-127),char(0),char(14),char(0),char(-126),char(0),char(14),char(0),char(124),char(0),char(14),char(0),char(-125),char(0),char(14),char(0),char(-124),char(0), -char(14),char(0),char(-123),char(0),char(14),char(0),char(-122),char(0),char(8),char(0),char(-121),char(0),char(8),char(0),char(-120),char(0),char(8),char(0),char(-119),char(0), -char(8),char(0),char(-118),char(0),char(8),char(0),char(-117),char(0),char(8),char(0),char(-116),char(0),char(8),char(0),char(-115),char(0),char(8),char(0),char(-114),char(0), -char(8),char(0),char(-113),char(0),char(4),char(0),char(-112),char(0),char(0),char(0),char(37),char(0),char(54),char(0),char(2),char(0),char(4),char(0),char(-111),char(0), -char(4),char(0),char(-110),char(0),char(55),char(0),char(13),char(0),char(56),char(0),char(-109),char(0),char(56),char(0),char(-108),char(0),char(0),char(0),char(35),char(0), -char(4),char(0),char(-107),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(7),char(0),char(-103),char(0), -char(7),char(0),char(-102),char(0),char(4),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(7),char(0),char(-99),char(0),char(4),char(0),char(-98),char(0), -char(57),char(0),char(3),char(0),char(55),char(0),char(-97),char(0),char(13),char(0),char(-96),char(0),char(13),char(0),char(-95),char(0),char(58),char(0),char(3),char(0), -char(55),char(0),char(-97),char(0),char(14),char(0),char(-96),char(0),char(14),char(0),char(-95),char(0),char(59),char(0),char(13),char(0),char(55),char(0),char(-97),char(0), -char(18),char(0),char(-94),char(0),char(18),char(0),char(-93),char(0),char(4),char(0),char(-92),char(0),char(4),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0), -char(7),char(0),char(-89),char(0),char(7),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0), -char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0),char(60),char(0),char(13),char(0),char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0), -char(17),char(0),char(-93),char(0),char(4),char(0),char(-92),char(0),char(4),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(7),char(0),char(-89),char(0), -char(7),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0), -char(7),char(0),char(-83),char(0),char(61),char(0),char(11),char(0),char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0), -char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(7),char(0),char(-80),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0), -char(7),char(0),char(-83),char(0),char(7),char(0),char(-79),char(0),char(0),char(0),char(21),char(0),char(62),char(0),char(9),char(0),char(55),char(0),char(-97),char(0), -char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0),char(13),char(0),char(-78),char(0),char(13),char(0),char(-77),char(0),char(13),char(0),char(-76),char(0), -char(13),char(0),char(-75),char(0),char(4),char(0),char(-74),char(0),char(4),char(0),char(-73),char(0),char(63),char(0),char(5),char(0),char(62),char(0),char(-72),char(0), -char(4),char(0),char(-71),char(0),char(7),char(0),char(-70),char(0),char(7),char(0),char(-69),char(0),char(7),char(0),char(-68),char(0),char(64),char(0),char(9),char(0), -char(55),char(0),char(-97),char(0),char(17),char(0),char(-94),char(0),char(17),char(0),char(-93),char(0),char(7),char(0),char(-78),char(0),char(7),char(0),char(-77),char(0), -char(7),char(0),char(-76),char(0),char(7),char(0),char(-75),char(0),char(4),char(0),char(-74),char(0),char(4),char(0),char(-73),char(0),char(49),char(0),char(22),char(0), -char(8),char(0),char(-67),char(0),char(8),char(0),char(-79),char(0),char(8),char(0),char(110),char(0),char(8),char(0),char(-66),char(0),char(8),char(0),char(112),char(0), -char(8),char(0),char(-65),char(0),char(8),char(0),char(-64),char(0),char(8),char(0),char(-63),char(0),char(8),char(0),char(-62),char(0),char(8),char(0),char(-61),char(0), -char(8),char(0),char(-60),char(0),char(8),char(0),char(-59),char(0),char(8),char(0),char(-58),char(0),char(8),char(0),char(-57),char(0),char(8),char(0),char(-56),char(0), -char(8),char(0),char(-55),char(0),char(4),char(0),char(-54),char(0),char(4),char(0),char(-53),char(0),char(4),char(0),char(-52),char(0),char(4),char(0),char(-51),char(0), -char(4),char(0),char(-50),char(0),char(0),char(0),char(37),char(0),char(51),char(0),char(22),char(0),char(7),char(0),char(-67),char(0),char(7),char(0),char(-79),char(0), -char(7),char(0),char(110),char(0),char(7),char(0),char(-66),char(0),char(7),char(0),char(112),char(0),char(7),char(0),char(-65),char(0),char(7),char(0),char(-64),char(0), -char(7),char(0),char(-63),char(0),char(7),char(0),char(-62),char(0),char(7),char(0),char(-61),char(0),char(7),char(0),char(-60),char(0),char(7),char(0),char(-59),char(0), -char(7),char(0),char(-58),char(0),char(7),char(0),char(-57),char(0),char(7),char(0),char(-56),char(0),char(7),char(0),char(-55),char(0),char(4),char(0),char(-54),char(0), -char(4),char(0),char(-53),char(0),char(4),char(0),char(-52),char(0),char(4),char(0),char(-51),char(0),char(4),char(0),char(-50),char(0),char(0),char(0),char(37),char(0), -char(65),char(0),char(4),char(0),char(7),char(0),char(-49),char(0),char(7),char(0),char(-48),char(0),char(7),char(0),char(-47),char(0),char(4),char(0),char(78),char(0), -char(66),char(0),char(10),char(0),char(65),char(0),char(-46),char(0),char(13),char(0),char(-45),char(0),char(13),char(0),char(-44),char(0),char(13),char(0),char(-43),char(0), -char(13),char(0),char(-42),char(0),char(13),char(0),char(-41),char(0),char(7),char(0),char(-121),char(0),char(7),char(0),char(-40),char(0),char(4),char(0),char(-39),char(0), -char(4),char(0),char(53),char(0),char(67),char(0),char(4),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-38),char(0),char(7),char(0),char(-37),char(0), -char(4),char(0),char(-36),char(0),char(68),char(0),char(4),char(0),char(13),char(0),char(-41),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-35),char(0), -char(7),char(0),char(-34),char(0),char(69),char(0),char(7),char(0),char(13),char(0),char(-33),char(0),char(65),char(0),char(-46),char(0),char(4),char(0),char(-32),char(0), -char(7),char(0),char(-31),char(0),char(7),char(0),char(-30),char(0),char(7),char(0),char(-29),char(0),char(4),char(0),char(53),char(0),char(70),char(0),char(6),char(0), -char(15),char(0),char(-28),char(0),char(13),char(0),char(-30),char(0),char(13),char(0),char(-27),char(0),char(56),char(0),char(-26),char(0),char(4),char(0),char(-25),char(0), -char(7),char(0),char(-29),char(0),char(71),char(0),char(26),char(0),char(4),char(0),char(-24),char(0),char(7),char(0),char(-23),char(0),char(7),char(0),char(-79),char(0), -char(7),char(0),char(-22),char(0),char(7),char(0),char(-21),char(0),char(7),char(0),char(-20),char(0),char(7),char(0),char(-19),char(0),char(7),char(0),char(-18),char(0), -char(7),char(0),char(-17),char(0),char(7),char(0),char(-16),char(0),char(7),char(0),char(-15),char(0),char(7),char(0),char(-14),char(0),char(7),char(0),char(-13),char(0), -char(7),char(0),char(-12),char(0),char(7),char(0),char(-11),char(0),char(7),char(0),char(-10),char(0),char(7),char(0),char(-9),char(0),char(7),char(0),char(-8),char(0), -char(7),char(0),char(-7),char(0),char(7),char(0),char(-6),char(0),char(7),char(0),char(-5),char(0),char(4),char(0),char(-4),char(0),char(4),char(0),char(-3),char(0), -char(4),char(0),char(-2),char(0),char(4),char(0),char(-1),char(0),char(4),char(0),char(117),char(0),char(72),char(0),char(12),char(0),char(15),char(0),char(0),char(1), -char(15),char(0),char(1),char(1),char(15),char(0),char(2),char(1),char(13),char(0),char(3),char(1),char(13),char(0),char(4),char(1),char(7),char(0),char(5),char(1), -char(4),char(0),char(6),char(1),char(4),char(0),char(7),char(1),char(4),char(0),char(8),char(1),char(4),char(0),char(9),char(1),char(7),char(0),char(-31),char(0), -char(4),char(0),char(53),char(0),char(73),char(0),char(27),char(0),char(17),char(0),char(10),char(1),char(15),char(0),char(11),char(1),char(15),char(0),char(12),char(1), -char(13),char(0),char(3),char(1),char(13),char(0),char(13),char(1),char(13),char(0),char(14),char(1),char(13),char(0),char(15),char(1),char(13),char(0),char(16),char(1), -char(13),char(0),char(17),char(1),char(4),char(0),char(18),char(1),char(7),char(0),char(19),char(1),char(4),char(0),char(20),char(1),char(4),char(0),char(21),char(1), -char(4),char(0),char(22),char(1),char(7),char(0),char(23),char(1),char(7),char(0),char(24),char(1),char(4),char(0),char(25),char(1),char(4),char(0),char(26),char(1), -char(7),char(0),char(27),char(1),char(7),char(0),char(28),char(1),char(7),char(0),char(29),char(1),char(7),char(0),char(30),char(1),char(7),char(0),char(31),char(1), -char(7),char(0),char(32),char(1),char(4),char(0),char(33),char(1),char(4),char(0),char(34),char(1),char(4),char(0),char(35),char(1),char(74),char(0),char(12),char(0), -char(9),char(0),char(36),char(1),char(9),char(0),char(37),char(1),char(13),char(0),char(38),char(1),char(7),char(0),char(39),char(1),char(7),char(0),char(-63),char(0), -char(7),char(0),char(40),char(1),char(4),char(0),char(41),char(1),char(13),char(0),char(42),char(1),char(4),char(0),char(43),char(1),char(4),char(0),char(44),char(1), -char(4),char(0),char(45),char(1),char(4),char(0),char(53),char(0),char(75),char(0),char(19),char(0),char(47),char(0),char(125),char(0),char(72),char(0),char(46),char(1), -char(65),char(0),char(47),char(1),char(66),char(0),char(48),char(1),char(67),char(0),char(49),char(1),char(68),char(0),char(50),char(1),char(69),char(0),char(51),char(1), -char(70),char(0),char(52),char(1),char(73),char(0),char(53),char(1),char(74),char(0),char(54),char(1),char(4),char(0),char(55),char(1),char(4),char(0),char(21),char(1), -char(4),char(0),char(56),char(1),char(4),char(0),char(57),char(1),char(4),char(0),char(58),char(1),char(4),char(0),char(59),char(1),char(4),char(0),char(60),char(1), -char(4),char(0),char(61),char(1),char(71),char(0),char(62),char(1),}; +char(4),char(0),char(122),char(0),char(4),char(0),char(123),char(0),char(0),char(0),char(37),char(0),char(48),char(0),char(25),char(0),char(9),char(0),char(101),char(0), +char(9),char(0),char(102),char(0),char(25),char(0),char(103),char(0),char(0),char(0),char(35),char(0),char(17),char(0),char(104),char(0),char(17),char(0),char(105),char(0), +char(13),char(0),char(106),char(0),char(13),char(0),char(107),char(0),char(13),char(0),char(108),char(0),char(7),char(0),char(109),char(0),char(7),char(0),char(110),char(0), +char(7),char(0),char(111),char(0),char(7),char(0),char(112),char(0),char(7),char(0),char(113),char(0),char(7),char(0),char(114),char(0),char(7),char(0),char(115),char(0), +char(7),char(0),char(116),char(0),char(4),char(0),char(117),char(0),char(4),char(0),char(118),char(0),char(4),char(0),char(119),char(0),char(4),char(0),char(120),char(0), +char(4),char(0),char(121),char(0),char(4),char(0),char(122),char(0),char(4),char(0),char(123),char(0),char(0),char(0),char(37),char(0),char(49),char(0),char(2),char(0), +char(50),char(0),char(124),char(0),char(14),char(0),char(125),char(0),char(51),char(0),char(2),char(0),char(52),char(0),char(124),char(0),char(13),char(0),char(125),char(0), +char(53),char(0),char(21),char(0),char(48),char(0),char(126),char(0),char(15),char(0),char(127),char(0),char(13),char(0),char(-128),char(0),char(13),char(0),char(-127),char(0), +char(13),char(0),char(-126),char(0),char(13),char(0),char(-125),char(0),char(13),char(0),char(125),char(0),char(13),char(0),char(-124),char(0),char(13),char(0),char(-123),char(0), +char(13),char(0),char(-122),char(0),char(13),char(0),char(-121),char(0),char(7),char(0),char(-120),char(0),char(7),char(0),char(-119),char(0),char(7),char(0),char(-118),char(0), +char(7),char(0),char(-117),char(0),char(7),char(0),char(-116),char(0),char(7),char(0),char(-115),char(0),char(7),char(0),char(-114),char(0),char(7),char(0),char(-113),char(0), +char(7),char(0),char(-112),char(0),char(4),char(0),char(-111),char(0),char(54),char(0),char(22),char(0),char(47),char(0),char(126),char(0),char(16),char(0),char(127),char(0), +char(14),char(0),char(-128),char(0),char(14),char(0),char(-127),char(0),char(14),char(0),char(-126),char(0),char(14),char(0),char(-125),char(0),char(14),char(0),char(125),char(0), +char(14),char(0),char(-124),char(0),char(14),char(0),char(-123),char(0),char(14),char(0),char(-122),char(0),char(14),char(0),char(-121),char(0),char(8),char(0),char(-120),char(0), +char(8),char(0),char(-119),char(0),char(8),char(0),char(-118),char(0),char(8),char(0),char(-117),char(0),char(8),char(0),char(-116),char(0),char(8),char(0),char(-115),char(0), +char(8),char(0),char(-114),char(0),char(8),char(0),char(-113),char(0),char(8),char(0),char(-112),char(0),char(4),char(0),char(-111),char(0),char(0),char(0),char(37),char(0), +char(55),char(0),char(2),char(0),char(4),char(0),char(-110),char(0),char(4),char(0),char(-109),char(0),char(56),char(0),char(13),char(0),char(53),char(0),char(-108),char(0), +char(53),char(0),char(-107),char(0),char(0),char(0),char(35),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0), +char(4),char(0),char(-103),char(0),char(7),char(0),char(-102),char(0),char(7),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0), +char(7),char(0),char(-98),char(0),char(4),char(0),char(-97),char(0),char(57),char(0),char(13),char(0),char(58),char(0),char(-108),char(0),char(58),char(0),char(-107),char(0), +char(0),char(0),char(35),char(0),char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(4),char(0),char(-103),char(0), +char(7),char(0),char(-102),char(0),char(7),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0),char(7),char(0),char(-98),char(0), +char(4),char(0),char(-97),char(0),char(59),char(0),char(14),char(0),char(54),char(0),char(-108),char(0),char(54),char(0),char(-107),char(0),char(0),char(0),char(35),char(0), +char(4),char(0),char(-106),char(0),char(4),char(0),char(-105),char(0),char(4),char(0),char(-104),char(0),char(4),char(0),char(-103),char(0),char(8),char(0),char(-102),char(0), +char(8),char(0),char(-101),char(0),char(4),char(0),char(-100),char(0),char(4),char(0),char(-99),char(0),char(8),char(0),char(-98),char(0),char(4),char(0),char(-97),char(0), +char(0),char(0),char(-96),char(0),char(60),char(0),char(3),char(0),char(57),char(0),char(-95),char(0),char(13),char(0),char(-94),char(0),char(13),char(0),char(-93),char(0), +char(61),char(0),char(3),char(0),char(59),char(0),char(-95),char(0),char(14),char(0),char(-94),char(0),char(14),char(0),char(-93),char(0),char(62),char(0),char(3),char(0), +char(57),char(0),char(-95),char(0),char(14),char(0),char(-94),char(0),char(14),char(0),char(-93),char(0),char(63),char(0),char(13),char(0),char(57),char(0),char(-95),char(0), +char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0), +char(7),char(0),char(-87),char(0),char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0), +char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(64),char(0),char(13),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0), +char(17),char(0),char(-91),char(0),char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0),char(7),char(0),char(-87),char(0), +char(7),char(0),char(-86),char(0),char(7),char(0),char(-85),char(0),char(7),char(0),char(-84),char(0),char(7),char(0),char(-83),char(0),char(7),char(0),char(-82),char(0), +char(7),char(0),char(-81),char(0),char(65),char(0),char(14),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0), +char(4),char(0),char(-90),char(0),char(4),char(0),char(-89),char(0),char(4),char(0),char(-88),char(0),char(8),char(0),char(-87),char(0),char(8),char(0),char(-86),char(0), +char(8),char(0),char(-85),char(0),char(8),char(0),char(-84),char(0),char(8),char(0),char(-83),char(0),char(8),char(0),char(-82),char(0),char(8),char(0),char(-81),char(0), +char(0),char(0),char(-80),char(0),char(66),char(0),char(10),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0), +char(8),char(0),char(-79),char(0),char(8),char(0),char(-78),char(0),char(8),char(0),char(-77),char(0),char(8),char(0),char(-83),char(0),char(8),char(0),char(-82),char(0), +char(8),char(0),char(-81),char(0),char(8),char(0),char(-76),char(0),char(67),char(0),char(11),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0), +char(17),char(0),char(-91),char(0),char(7),char(0),char(-79),char(0),char(7),char(0),char(-78),char(0),char(7),char(0),char(-77),char(0),char(7),char(0),char(-83),char(0), +char(7),char(0),char(-82),char(0),char(7),char(0),char(-81),char(0),char(7),char(0),char(-76),char(0),char(0),char(0),char(21),char(0),char(68),char(0),char(9),char(0), +char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),char(17),char(0),char(-91),char(0),char(13),char(0),char(-75),char(0),char(13),char(0),char(-74),char(0), +char(13),char(0),char(-73),char(0),char(13),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),char(4),char(0),char(-70),char(0),char(69),char(0),char(9),char(0), +char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0),char(14),char(0),char(-75),char(0),char(14),char(0),char(-74),char(0), +char(14),char(0),char(-73),char(0),char(14),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0),char(4),char(0),char(-70),char(0),char(70),char(0),char(5),char(0), +char(68),char(0),char(-69),char(0),char(4),char(0),char(-68),char(0),char(7),char(0),char(-67),char(0),char(7),char(0),char(-66),char(0),char(7),char(0),char(-65),char(0), +char(71),char(0),char(5),char(0),char(69),char(0),char(-69),char(0),char(4),char(0),char(-68),char(0),char(8),char(0),char(-67),char(0),char(8),char(0),char(-66),char(0), +char(8),char(0),char(-65),char(0),char(72),char(0),char(9),char(0),char(57),char(0),char(-95),char(0),char(17),char(0),char(-92),char(0),char(17),char(0),char(-91),char(0), +char(7),char(0),char(-75),char(0),char(7),char(0),char(-74),char(0),char(7),char(0),char(-73),char(0),char(7),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0), +char(4),char(0),char(-70),char(0),char(73),char(0),char(9),char(0),char(59),char(0),char(-95),char(0),char(18),char(0),char(-92),char(0),char(18),char(0),char(-91),char(0), +char(8),char(0),char(-75),char(0),char(8),char(0),char(-74),char(0),char(8),char(0),char(-73),char(0),char(8),char(0),char(-72),char(0),char(4),char(0),char(-71),char(0), +char(4),char(0),char(-70),char(0),char(74),char(0),char(5),char(0),char(56),char(0),char(-95),char(0),char(13),char(0),char(-64),char(0),char(13),char(0),char(-63),char(0), +char(7),char(0),char(-62),char(0),char(0),char(0),char(37),char(0),char(75),char(0),char(4),char(0),char(59),char(0),char(-95),char(0),char(14),char(0),char(-64),char(0), +char(14),char(0),char(-63),char(0),char(8),char(0),char(-62),char(0),char(50),char(0),char(22),char(0),char(8),char(0),char(-61),char(0),char(8),char(0),char(-76),char(0), +char(8),char(0),char(111),char(0),char(8),char(0),char(-60),char(0),char(8),char(0),char(113),char(0),char(8),char(0),char(-59),char(0),char(8),char(0),char(-58),char(0), +char(8),char(0),char(-57),char(0),char(8),char(0),char(-56),char(0),char(8),char(0),char(-55),char(0),char(8),char(0),char(-54),char(0),char(8),char(0),char(-53),char(0), +char(8),char(0),char(-52),char(0),char(8),char(0),char(-51),char(0),char(8),char(0),char(-50),char(0),char(8),char(0),char(-49),char(0),char(4),char(0),char(-48),char(0), +char(4),char(0),char(-47),char(0),char(4),char(0),char(-46),char(0),char(4),char(0),char(-45),char(0),char(4),char(0),char(-44),char(0),char(0),char(0),char(37),char(0), +char(52),char(0),char(22),char(0),char(7),char(0),char(-61),char(0),char(7),char(0),char(-76),char(0),char(7),char(0),char(111),char(0),char(7),char(0),char(-60),char(0), +char(7),char(0),char(113),char(0),char(7),char(0),char(-59),char(0),char(7),char(0),char(-58),char(0),char(7),char(0),char(-57),char(0),char(7),char(0),char(-56),char(0), +char(7),char(0),char(-55),char(0),char(7),char(0),char(-54),char(0),char(7),char(0),char(-53),char(0),char(7),char(0),char(-52),char(0),char(7),char(0),char(-51),char(0), +char(7),char(0),char(-50),char(0),char(7),char(0),char(-49),char(0),char(4),char(0),char(-48),char(0),char(4),char(0),char(-47),char(0),char(4),char(0),char(-46),char(0), +char(4),char(0),char(-45),char(0),char(4),char(0),char(-44),char(0),char(0),char(0),char(37),char(0),char(76),char(0),char(4),char(0),char(7),char(0),char(-43),char(0), +char(7),char(0),char(-42),char(0),char(7),char(0),char(-41),char(0),char(4),char(0),char(79),char(0),char(77),char(0),char(10),char(0),char(76),char(0),char(-40),char(0), +char(13),char(0),char(-39),char(0),char(13),char(0),char(-38),char(0),char(13),char(0),char(-37),char(0),char(13),char(0),char(-36),char(0),char(13),char(0),char(-35),char(0), +char(7),char(0),char(-120),char(0),char(7),char(0),char(-34),char(0),char(4),char(0),char(-33),char(0),char(4),char(0),char(53),char(0),char(78),char(0),char(4),char(0), +char(76),char(0),char(-40),char(0),char(4),char(0),char(-32),char(0),char(7),char(0),char(-31),char(0),char(4),char(0),char(-30),char(0),char(79),char(0),char(4),char(0), +char(13),char(0),char(-35),char(0),char(76),char(0),char(-40),char(0),char(4),char(0),char(-29),char(0),char(7),char(0),char(-28),char(0),char(80),char(0),char(7),char(0), +char(13),char(0),char(-27),char(0),char(76),char(0),char(-40),char(0),char(4),char(0),char(-26),char(0),char(7),char(0),char(-25),char(0),char(7),char(0),char(-24),char(0), +char(7),char(0),char(-23),char(0),char(4),char(0),char(53),char(0),char(81),char(0),char(6),char(0),char(15),char(0),char(-22),char(0),char(13),char(0),char(-24),char(0), +char(13),char(0),char(-21),char(0),char(58),char(0),char(-20),char(0),char(4),char(0),char(-19),char(0),char(7),char(0),char(-23),char(0),char(82),char(0),char(26),char(0), +char(4),char(0),char(-18),char(0),char(7),char(0),char(-17),char(0),char(7),char(0),char(-76),char(0),char(7),char(0),char(-16),char(0),char(7),char(0),char(-15),char(0), +char(7),char(0),char(-14),char(0),char(7),char(0),char(-13),char(0),char(7),char(0),char(-12),char(0),char(7),char(0),char(-11),char(0),char(7),char(0),char(-10),char(0), +char(7),char(0),char(-9),char(0),char(7),char(0),char(-8),char(0),char(7),char(0),char(-7),char(0),char(7),char(0),char(-6),char(0),char(7),char(0),char(-5),char(0), +char(7),char(0),char(-4),char(0),char(7),char(0),char(-3),char(0),char(7),char(0),char(-2),char(0),char(7),char(0),char(-1),char(0),char(7),char(0),char(0),char(1), +char(7),char(0),char(1),char(1),char(4),char(0),char(2),char(1),char(4),char(0),char(3),char(1),char(4),char(0),char(4),char(1),char(4),char(0),char(5),char(1), +char(4),char(0),char(118),char(0),char(83),char(0),char(12),char(0),char(15),char(0),char(6),char(1),char(15),char(0),char(7),char(1),char(15),char(0),char(8),char(1), +char(13),char(0),char(9),char(1),char(13),char(0),char(10),char(1),char(7),char(0),char(11),char(1),char(4),char(0),char(12),char(1),char(4),char(0),char(13),char(1), +char(4),char(0),char(14),char(1),char(4),char(0),char(15),char(1),char(7),char(0),char(-25),char(0),char(4),char(0),char(53),char(0),char(84),char(0),char(27),char(0), +char(17),char(0),char(16),char(1),char(15),char(0),char(17),char(1),char(15),char(0),char(18),char(1),char(13),char(0),char(9),char(1),char(13),char(0),char(19),char(1), +char(13),char(0),char(20),char(1),char(13),char(0),char(21),char(1),char(13),char(0),char(22),char(1),char(13),char(0),char(23),char(1),char(4),char(0),char(24),char(1), +char(7),char(0),char(25),char(1),char(4),char(0),char(26),char(1),char(4),char(0),char(27),char(1),char(4),char(0),char(28),char(1),char(7),char(0),char(29),char(1), +char(7),char(0),char(30),char(1),char(4),char(0),char(31),char(1),char(4),char(0),char(32),char(1),char(7),char(0),char(33),char(1),char(7),char(0),char(34),char(1), +char(7),char(0),char(35),char(1),char(7),char(0),char(36),char(1),char(7),char(0),char(37),char(1),char(7),char(0),char(38),char(1),char(4),char(0),char(39),char(1), +char(4),char(0),char(40),char(1),char(4),char(0),char(41),char(1),char(85),char(0),char(12),char(0),char(9),char(0),char(42),char(1),char(9),char(0),char(43),char(1), +char(13),char(0),char(44),char(1),char(7),char(0),char(45),char(1),char(7),char(0),char(-57),char(0),char(7),char(0),char(46),char(1),char(4),char(0),char(47),char(1), +char(13),char(0),char(48),char(1),char(4),char(0),char(49),char(1),char(4),char(0),char(50),char(1),char(4),char(0),char(51),char(1),char(4),char(0),char(53),char(0), +char(86),char(0),char(19),char(0),char(48),char(0),char(126),char(0),char(83),char(0),char(52),char(1),char(76),char(0),char(53),char(1),char(77),char(0),char(54),char(1), +char(78),char(0),char(55),char(1),char(79),char(0),char(56),char(1),char(80),char(0),char(57),char(1),char(81),char(0),char(58),char(1),char(84),char(0),char(59),char(1), +char(85),char(0),char(60),char(1),char(4),char(0),char(61),char(1),char(4),char(0),char(27),char(1),char(4),char(0),char(62),char(1),char(4),char(0),char(63),char(1), +char(4),char(0),char(64),char(1),char(4),char(0),char(65),char(1),char(4),char(0),char(66),char(1),char(4),char(0),char(67),char(1),char(82),char(0),char(68),char(1), +}; int sBulletDNAlen64= sizeof(sBulletDNAstr64); diff --git a/extern/bullet2/src/LinearMath/btSerializer.h b/extern/bullet2/src/LinearMath/btSerializer.h index c5bc96b7839..ff1dc574c5d 100644 --- a/extern/bullet2/src/LinearMath/btSerializer.h +++ b/extern/bullet2/src/LinearMath/btSerializer.h @@ -17,7 +17,6 @@ subject to the following restrictions: #define BT_SERIALIZER_H #include "btScalar.h" // has definitions like SIMD_FORCE_INLINE -#include "btStackAlloc.h" #include "btHashMap.h" #if !defined( __CELLOS_LV2__) && !defined(__MWERKS__) @@ -439,7 +438,7 @@ public: buffer[9] = '2'; buffer[10] = '8'; - buffer[11] = '1'; + buffer[11] = '2'; } diff --git a/extern/bullet2/src/LinearMath/btVector3.cpp b/extern/bullet2/src/LinearMath/btVector3.cpp index bcb18704b93..a84f7baee2e 100644 --- a/extern/bullet2/src/LinearMath/btVector3.cpp +++ b/extern/bullet2/src/LinearMath/btVector3.cpp @@ -51,7 +51,7 @@ long _maxdot_large( const float *vv, const float *vec, unsigned long count, floa long _maxdot_large( const float *vv, const float *vec, unsigned long count, float *dotResult ) { const float4 *vertices = (const float4*) vv; - static const unsigned char indexTable[16] = {-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; + static const unsigned char indexTable[16] = {(unsigned char)-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; float4 dotMax = btAssign128( -BT_INFINITY, -BT_INFINITY, -BT_INFINITY, -BT_INFINITY ); float4 vvec = _mm_loadu_ps( vec ); float4 vHi = btCastiTo128f(_mm_shuffle_epi32( btCastfTo128i( vvec), 0xaa )); /// zzzz @@ -436,7 +436,7 @@ long _mindot_large( const float *vv, const float *vec, unsigned long count, floa long _mindot_large( const float *vv, const float *vec, unsigned long count, float *dotResult ) { const float4 *vertices = (const float4*) vv; - static const unsigned char indexTable[16] = {-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; + static const unsigned char indexTable[16] = {(unsigned char)-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; float4 dotmin = btAssign128( BT_INFINITY, BT_INFINITY, BT_INFINITY, BT_INFINITY ); float4 vvec = _mm_loadu_ps( vec ); float4 vHi = btCastiTo128f(_mm_shuffle_epi32( btCastfTo128i( vvec), 0xaa )); /// zzzz @@ -823,7 +823,8 @@ long _mindot_large( const float *vv, const float *vec, unsigned long count, floa #elif defined BT_USE_NEON #define ARM_NEON_GCC_COMPATIBILITY 1 #include - +#include +#include //for sysctlbyname static long _maxdot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult ); static long _maxdot_large_v1( const float *vv, const float *vec, unsigned long count, float *dotResult ); @@ -835,11 +836,34 @@ static long _mindot_large_sel( const float *vv, const float *vec, unsigned long long (*_maxdot_large)( const float *vv, const float *vec, unsigned long count, float *dotResult ) = _maxdot_large_sel; long (*_mindot_large)( const float *vv, const float *vec, unsigned long count, float *dotResult ) = _mindot_large_sel; -extern "C" {int _get_cpu_capabilities( void );} + +static inline uint32_t btGetCpuCapabilities( void ) +{ + static uint32_t capabilities = 0; + static bool testedCapabilities = false; + + if( 0 == testedCapabilities) + { + uint32_t hasFeature = 0; + size_t featureSize = sizeof( hasFeature ); + int err = sysctlbyname( "hw.optional.neon_hpfp", &hasFeature, &featureSize, NULL, 0 ); + + if( 0 == err && hasFeature) + capabilities |= 0x2000; + + testedCapabilities = true; + } + + return capabilities; +} + + + static long _maxdot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult ) { - if( _get_cpu_capabilities() & 0x2000 ) + + if( btGetCpuCapabilities() & 0x2000 ) _maxdot_large = _maxdot_large_v1; else _maxdot_large = _maxdot_large_v0; @@ -849,7 +873,8 @@ static long _maxdot_large_sel( const float *vv, const float *vec, unsigned long static long _mindot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult ) { - if( _get_cpu_capabilities() & 0x2000 ) + + if( btGetCpuCapabilities() & 0x2000 ) _mindot_large = _mindot_large_v1; else _mindot_large = _mindot_large_v0; @@ -872,8 +897,8 @@ long _maxdot_large_v0( const float *vv, const float *vec, unsigned long count, f float32x2_t dotMaxHi = (float32x2_t) { -BT_INFINITY, -BT_INFINITY }; uint32x2_t indexLo = (uint32x2_t) {0, 1}; uint32x2_t indexHi = (uint32x2_t) {2, 3}; - uint32x2_t iLo = (uint32x2_t) {-1, -1}; - uint32x2_t iHi = (uint32x2_t) {-1, -1}; + uint32x2_t iLo = (uint32x2_t) {static_cast(-1), static_cast(-1)}; + uint32x2_t iHi = (uint32x2_t) {static_cast(-1), static_cast(-1)}; const uint32x2_t four = (uint32x2_t) {4,4}; for( ; i+8 <= count; i+= 8 ) @@ -1059,7 +1084,7 @@ long _maxdot_large_v1( const float *vv, const float *vec, unsigned long count, f float32x4_t vHi = vdupq_lane_f32(vget_high_f32(vvec), 0); const uint32x4_t four = (uint32x4_t){ 4, 4, 4, 4 }; uint32x4_t local_index = (uint32x4_t) {0, 1, 2, 3}; - uint32x4_t index = (uint32x4_t) { -1, -1, -1, -1 }; + uint32x4_t index = (uint32x4_t) { static_cast(-1), static_cast(-1), static_cast(-1), static_cast(-1) }; float32x4_t maxDot = (float32x4_t) { -BT_INFINITY, -BT_INFINITY, -BT_INFINITY, -BT_INFINITY }; unsigned long i = 0; @@ -1257,8 +1282,8 @@ long _mindot_large_v0( const float *vv, const float *vec, unsigned long count, f float32x2_t dotMinHi = (float32x2_t) { BT_INFINITY, BT_INFINITY }; uint32x2_t indexLo = (uint32x2_t) {0, 1}; uint32x2_t indexHi = (uint32x2_t) {2, 3}; - uint32x2_t iLo = (uint32x2_t) {-1, -1}; - uint32x2_t iHi = (uint32x2_t) {-1, -1}; + uint32x2_t iLo = (uint32x2_t) {static_cast(-1), static_cast(-1)}; + uint32x2_t iHi = (uint32x2_t) {static_cast(-1), static_cast(-1)}; const uint32x2_t four = (uint32x2_t) {4,4}; for( ; i+8 <= count; i+= 8 ) @@ -1442,7 +1467,7 @@ long _mindot_large_v1( const float *vv, const float *vec, unsigned long count, f float32x4_t vHi = vdupq_lane_f32(vget_high_f32(vvec), 0); const uint32x4_t four = (uint32x4_t){ 4, 4, 4, 4 }; uint32x4_t local_index = (uint32x4_t) {0, 1, 2, 3}; - uint32x4_t index = (uint32x4_t) { -1, -1, -1, -1 }; + uint32x4_t index = (uint32x4_t) { static_cast(-1), static_cast(-1), static_cast(-1), static_cast(-1) }; float32x4_t minDot = (float32x4_t) { BT_INFINITY, BT_INFINITY, BT_INFINITY, BT_INFINITY }; unsigned long i = 0; diff --git a/extern/bullet2/src/LinearMath/btVector3.h b/extern/bullet2/src/LinearMath/btVector3.h index 1cf65358803..89685929288 100644 --- a/extern/bullet2/src/LinearMath/btVector3.h +++ b/extern/bullet2/src/LinearMath/btVector3.h @@ -53,19 +53,24 @@ subject to the following restrictions: #define btvxyzMaskf btvFFF0fMask #define btvAbsfMask btCastiTo128f(btvAbsMask) +//there is an issue with XCode 3.2 (LCx errors) +#define btvMzeroMask (_mm_set_ps(-0.0f, -0.0f, -0.0f, -0.0f)) +#define v1110 (_mm_set_ps(0.0f, 1.0f, 1.0f, 1.0f)) +#define vHalf (_mm_set_ps(0.5f, 0.5f, 0.5f, 0.5f)) +#define v1_5 (_mm_set_ps(1.5f, 1.5f, 1.5f, 1.5f)) - -const __m128 ATTRIBUTE_ALIGNED16(btvMzeroMask) = {-0.0f, -0.0f, -0.0f, -0.0f}; -const __m128 ATTRIBUTE_ALIGNED16(v1110) = {1.0f, 1.0f, 1.0f, 0.0f}; -const __m128 ATTRIBUTE_ALIGNED16(vHalf) = {0.5f, 0.5f, 0.5f, 0.5f}; -const __m128 ATTRIBUTE_ALIGNED16(v1_5) = {1.5f, 1.5f, 1.5f, 1.5f}; +//const __m128 ATTRIBUTE_ALIGNED16(btvMzeroMask) = {-0.0f, -0.0f, -0.0f, -0.0f}; +//const __m128 ATTRIBUTE_ALIGNED16(v1110) = {1.0f, 1.0f, 1.0f, 0.0f}; +//const __m128 ATTRIBUTE_ALIGNED16(vHalf) = {0.5f, 0.5f, 0.5f, 0.5f}; +//const __m128 ATTRIBUTE_ALIGNED16(v1_5) = {1.5f, 1.5f, 1.5f, 1.5f}; #endif #ifdef BT_USE_NEON const float32x4_t ATTRIBUTE_ALIGNED16(btvMzeroMask) = (float32x4_t){-0.0f, -0.0f, -0.0f, -0.0f}; -const int32x4_t ATTRIBUTE_ALIGNED16(btvFFF0Mask) = (int32x4_t){0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0}; +const int32x4_t ATTRIBUTE_ALIGNED16(btvFFF0Mask) = (int32x4_t){static_cast(0xFFFFFFFF), + static_cast(0xFFFFFFFF), static_cast(0xFFFFFFFF), 0x0}; const int32x4_t ATTRIBUTE_ALIGNED16(btvAbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF}; const int32x4_t ATTRIBUTE_ALIGNED16(btv3AbsMask) = (int32x4_t){0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x0}; @@ -260,6 +265,12 @@ public: return btSqrt(length2()); } + /**@brief Return the norm (length) of the vector */ + SIMD_FORCE_INLINE btScalar norm() const + { + return length(); + } + /**@brief Return the distance squared between the ends of this and another vector * This is symantically treating the vector like a point */ SIMD_FORCE_INLINE btScalar distance2(const btVector3& v) const; @@ -285,6 +296,9 @@ public: * x^2 + y^2 + z^2 = 1 */ SIMD_FORCE_INLINE btVector3& normalize() { + + btAssert(length() != btScalar(0)); + #if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) // dot product first __m128 vd = _mm_mul_ps(mVec128, mVec128); @@ -718,7 +732,7 @@ public: return btVector3(r); #elif defined(BT_USE_NEON) - static const uint32x4_t xyzMask = (const uint32x4_t){ -1, -1, -1, 0 }; + static const uint32x4_t xyzMask = (const uint32x4_t){ static_cast(-1), static_cast(-1), static_cast(-1), 0 }; float32x4_t a0 = vmulq_f32( v0.mVec128, this->mVec128); float32x4_t a1 = vmulq_f32( v1.mVec128, this->mVec128); float32x4_t a2 = vmulq_f32( v2.mVec128, this->mVec128); @@ -936,13 +950,9 @@ SIMD_FORCE_INLINE btScalar btVector3::distance(const btVector3& v) const SIMD_FORCE_INLINE btVector3 btVector3::normalized() const { -#if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) btVector3 norm = *this; return norm.normalize(); -#else - return *this / length(); -#endif } SIMD_FORCE_INLINE btVector3 btVector3::rotate( const btVector3& wAxis, const btScalar _angle ) const diff --git a/extern/bullet2/src/btBulletDynamicsCommon.h b/extern/bullet2/src/btBulletDynamicsCommon.h index dbd175c3fe6..50282bf2105 100644 --- a/extern/bullet2/src/btBulletDynamicsCommon.h +++ b/extern/bullet2/src/btBulletDynamicsCommon.h @@ -33,6 +33,8 @@ subject to the following restrictions: #include "BulletDynamics/ConstraintSolver/btUniversalConstraint.h" #include "BulletDynamics/ConstraintSolver/btHinge2Constraint.h" #include "BulletDynamics/ConstraintSolver/btGearConstraint.h" +#include "BulletDynamics/ConstraintSolver/btFixedConstraint.h" + #include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" -- cgit v1.2.3 From 92729bc77641d9c0d6fa0dc3ab7bfa22d7c7285c Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Fri, 25 Oct 2013 03:45:00 +0000 Subject: rigidbody: Use bullet's own fixed constraint Should be no functional changes. --- intern/rigidbody/rb_bullet_api.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp index 5724d1992d9..ecb07c628d2 100644 --- a/intern/rigidbody/rb_bullet_api.cpp +++ b/intern/rigidbody/rb_bullet_api.cpp @@ -826,11 +826,7 @@ rbConstraint *RB_constraint_new_fixed(float pivot[3], float orn[4], rbRigidBody make_constraint_transforms(transform1, transform2, body1, body2, pivot, orn); - btGeneric6DofConstraint *con = new btGeneric6DofConstraint(*body1, *body2, transform1, transform2, true); - - /* lock all axes */ - for (int i = 0; i < 6; i++) - con->setLimit(i, 0, 0); + btFixedConstraint *con = new btFixedConstraint(*body1, *body2, transform1, transform2); return (rbConstraint *)con; } -- cgit v1.2.3 From 451b60f1a39e496b49dc392650ddc554ff77b722 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Fri, 25 Oct 2013 03:56:17 +0000 Subject: Fix building with scons Can't actually test here so hope this is enough. --- extern/bullet2/src/SConscript | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extern/bullet2/src/SConscript b/extern/bullet2/src/SConscript index 3ffff9c80fc..ff2e86affb4 100644 --- a/extern/bullet2/src/SConscript +++ b/extern/bullet2/src/SConscript @@ -31,6 +31,8 @@ bullet2_src += env.Glob("BulletDynamics/Vehicle/*.cpp") bullet2_src += env.Glob("BulletDynamics/ConstraintSolver/*.cpp") bullet2_src += env.Glob("BulletDynamics/Dynamics/*.cpp") bullet2_src += env.Glob("BulletDynamics/Character/*.cpp") +bullet2_src += env.Glob("BulletDynamics/Featherstone/*.cpp") +bullet2_src += env.Glob("BulletDynamics/MLCPSolvers/*.cpp") bullet2_src += env.Glob("BulletSoftBody/*.cpp") incs = '. BulletCollision BulletDynamics LinearMath BulletSoftBody' -- cgit v1.2.3 From d78899dafbcbb05196e76541b7a584c37b04a571 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2013 05:17:55 +0000 Subject: patch [#30689] select similar for metaballs from Cyrille Ruggero (kalado) with some edits. --- source/blender/editors/metaball/mball_edit.c | 186 +++++++++++++++++++++++++ source/blender/editors/metaball/mball_intern.h | 1 + source/blender/editors/metaball/mball_ops.c | 3 + 3 files changed, 190 insertions(+) diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 68ca55651a8..c513b402fcd 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -178,6 +178,192 @@ void MBALL_OT_select_all(wmOperatorType *ot) WM_operator_properties_select_all(ot); } + +/* -------------------------------------------------------------------- */ +/* Select Similar */ + +enum { + SIMMBALL_TYPE = 1, + SIMMBALL_RADIUS, + SIMMBALL_STIFFNESS, + SIMMBALL_ROTATION +}; + +static EnumPropertyItem prop_similar_types[] = { + {SIMMBALL_TYPE, "TYPE", 0, "Type", ""}, + {SIMMBALL_RADIUS, "RADIUS", 0, "Radius", ""}, + {SIMMBALL_STIFFNESS, "STIFFNESS", 0, "Stiffness", ""}, + {SIMMBALL_ROTATION, "ROTATION", 0, "Rotation", ""}, + {0, NULL, 0, NULL, NULL} +}; + +static bool mball_select_similar_type(MetaBall *mb) +{ + MetaElem *ml; + bool change = false; + + for (ml = mb->editelems->first; ml; ml = ml->next) { + if (ml->flag & SELECT) { + MetaElem *ml_iter; + + for (ml_iter = mb->editelems->first; ml_iter; ml_iter = ml_iter->next) { + if ((ml_iter->flag & SELECT) == 0) { + if (ml->type == ml_iter->type) { + ml_iter->flag |=SELECT; + change = true; + } + } + } + } + } + + return change; +} + +static bool mball_select_similar_radius(MetaBall *mb, const float thresh) +{ + MetaElem *ml; + bool change = false; + + for (ml = mb->editelems->first; ml; ml = ml->next) { + if (ml->flag & SELECT) { + MetaElem *ml_iter; + + for (ml_iter = mb->editelems->first; ml_iter; ml_iter = ml_iter->next) { + if ((ml_iter->flag & SELECT) == 0) { + if (fabsf(ml_iter->rad - ml->rad) <= (thresh * ml->rad)) { + ml_iter->flag |= SELECT; + change = true; + } + } + } + } + } + + return change; +} + +static bool mball_select_similar_stiffness(MetaBall *mb, const float thresh) +{ + MetaElem *ml; + bool change = false; + + for (ml = mb->editelems->first; ml; ml = ml->next) { + if (ml->flag & SELECT) { + MetaElem *ml_iter; + + for (ml_iter = mb->editelems->first; ml_iter; ml_iter = ml_iter->next) { + if ((ml_iter->flag & SELECT) == 0) { + if (fabsf(ml_iter->s - ml->s) <= thresh) { + ml_iter->flag |= SELECT; + change = true; + } + } + } + } + } + + return change; +} + +static bool mball_select_similar_rotation(MetaBall *mb, const float thresh) +{ + const float thresh_rad = thresh * (float)M_PI_2; + MetaElem *ml; + bool change = false; + + for (ml = mb->editelems->first; ml; ml = ml->next) { + if (ml->flag & SELECT) { + MetaElem *ml_iter; + + float ml_mat[3][3]; + + unit_m3(ml_mat); + mul_qt_v3(ml->quat, ml_mat[0]); + mul_qt_v3(ml->quat, ml_mat[1]); + mul_qt_v3(ml->quat, ml_mat[2]); + normalize_m3(ml_mat); + + for (ml_iter = mb->editelems->first; ml_iter; ml_iter = ml_iter->next) { + if ((ml_iter->flag & SELECT) == 0) { + float ml_iter_mat[3][3]; + + unit_m3(ml_iter_mat); + mul_qt_v3(ml_iter->quat, ml_iter_mat[0]); + mul_qt_v3(ml_iter->quat, ml_iter_mat[1]); + mul_qt_v3(ml_iter->quat, ml_iter_mat[2]); + normalize_m3(ml_iter_mat); + + if ((angle_normalized_v3v3(ml_mat[0], ml_iter_mat[0]) + + angle_normalized_v3v3(ml_mat[1], ml_iter_mat[1]) + + angle_normalized_v3v3(ml_mat[2], ml_iter_mat[2])) < thresh_rad) + { + ml_iter->flag |= SELECT; + change = true; + } + } + } + } + } + + return change; +} + +static int mball_select_similar_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + MetaBall *mb = (MetaBall*)obedit->data; + + int type = RNA_enum_get(op->ptr, "type"); + float thresh = RNA_float_get(op->ptr, "threshold"); + bool change = false; + + switch (type) { + case SIMMBALL_TYPE: + change = mball_select_similar_type(mb); + break; + case SIMMBALL_RADIUS: + change = mball_select_similar_radius(mb, thresh); + break; + case SIMMBALL_STIFFNESS: + change = mball_select_similar_stiffness(mb, thresh); + break; + case SIMMBALL_ROTATION: + change = mball_select_similar_rotation(mb, thresh); + break; + default: + BLI_assert(0); + } + + if (change) { + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); + } + + return OPERATOR_FINISHED; +} + +void MBALL_OT_select_similar(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Similar"; + ot->idname = "MBALL_OT_select_similar"; + + /* callback functions */ + ot->invoke = WM_menu_invoke; + ot->exec = mball_select_similar_exec; + ot->poll = ED_operator_editmball; + ot->description = "Select similar metaballs by property types"; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, 0, "Type", ""); + + RNA_def_float(ot->srna, "threshold", 0.1, 0.0, 1.0, "Threshold", "", 0.01, 1.0); +} + + /***************************** Select random operator *****************************/ /* Random metaball selection */ diff --git a/source/blender/editors/metaball/mball_intern.h b/source/blender/editors/metaball/mball_intern.h index 0329f8e5bfa..24a4ea86d87 100644 --- a/source/blender/editors/metaball/mball_intern.h +++ b/source/blender/editors/metaball/mball_intern.h @@ -43,6 +43,7 @@ void MBALL_OT_delete_metaelems(struct wmOperatorType *ot); void MBALL_OT_duplicate_metaelems(struct wmOperatorType *ot); void MBALL_OT_select_all(struct wmOperatorType *ot); +void MBALL_OT_select_similar(struct wmOperatorType *ot); void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot); #endif diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index bba0dc5000b..74d47d9db17 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -52,6 +52,7 @@ void ED_operatortypes_metaball(void) WM_operatortype_append(MBALL_OT_reveal_metaelems); WM_operatortype_append(MBALL_OT_select_all); + WM_operatortype_append(MBALL_OT_select_similar); WM_operatortype_append(MBALL_OT_select_random_metaelems); } @@ -80,6 +81,8 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + WM_keymap_add_item(keymap, "MBALL_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); + ED_keymap_proportional_cycle(keyconf, keymap); ED_keymap_proportional_editmode(keyconf, keymap, TRUE); } -- cgit v1.2.3 From 4aa02d8038ccb9062b4ab522c41e54cacb0217ce Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2013 05:21:17 +0000 Subject: patch [#37188] Remove filename entry specified twice from Lawrence D'Oliveiro (ldo) --- intern/ghost/CMakeLists.txt | 1 - source/blender/editors/metaball/mball_edit.c | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 3873bae1eea..2cc0f476d30 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -44,7 +44,6 @@ set(SRC intern/GHOST_ISystemPaths.cpp intern/GHOST_ModifierKeys.cpp intern/GHOST_Path-api.cpp - intern/GHOST_Path-api.cpp intern/GHOST_Rect.cpp intern/GHOST_System.cpp intern/GHOST_TimerManager.cpp diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index c513b402fcd..24c46bd7966 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -209,7 +209,7 @@ static bool mball_select_similar_type(MetaBall *mb) for (ml_iter = mb->editelems->first; ml_iter; ml_iter = ml_iter->next) { if ((ml_iter->flag & SELECT) == 0) { if (ml->type == ml_iter->type) { - ml_iter->flag |=SELECT; + ml_iter->flag |= SELECT; change = true; } } @@ -311,8 +311,8 @@ static bool mball_select_similar_rotation(MetaBall *mb, const float thresh) static int mball_select_similar_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; int type = RNA_enum_get(op->ptr, "type"); float thresh = RNA_float_get(op->ptr, "threshold"); @@ -355,7 +355,7 @@ void MBALL_OT_select_similar(wmOperatorType *ot) ot->description = "Select similar metaballs by property types"; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, 0, "Type", ""); -- cgit v1.2.3 From 93edbf3510927a02cfb01f5569eb0f3838670f08 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2013 06:21:38 +0000 Subject: add check for cmake that source files are not included multiple times --- build_files/cmake/macros.cmake | 23 +++++++++++++++++++++++ source/blender/render/CMakeLists.txt | 1 - 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 9ded803f45b..fdc0fb63c8e 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -48,6 +48,24 @@ macro(list_insert_before unset(_index) endmacro() +function (list_assert_duplicates + list_id + ) + + # message(STATUS "list data: ${list_id}") + + list(LENGTH list_id _len_before) + list(REMOVE_DUPLICATES list_id) + list(LENGTH list_id _len_after) + # message(STATUS "list size ${_len_before} -> ${_len_after}") + if(NOT _len_before EQUAL _len_after) + message(FATAL_ERROR "duplicate found in list which should not contain duplicates: ${list_id}") + endif() + unset(_len_before) + unset(_len_after) +endfunction() + + # foo_bar.spam --> foo_barMySuffix.spam macro(file_suffix file_name_new file_name file_suffix @@ -177,6 +195,11 @@ macro(blender_add_lib_nolist # listed is helpful for IDE's (QtCreator/MSVC) blender_source_group("${sources}") + list_assert_duplicates("${sources}") + list_assert_duplicates("${includes}") + # Not for system includes because they can resolve to the same path + # list_assert_duplicates("${includes_sys}") + endmacro() diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index 94a95974009..db23cd97b74 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -98,7 +98,6 @@ set(SRC intern/include/raycounter.h intern/include/rayobject.h intern/include/rayintersection.h - intern/include/raycounter.h intern/include/render_types.h intern/include/render_result.h intern/include/rendercore.h -- cgit v1.2.3 From 5b6e6b7285972bfce922669d35fc1c452c03b54c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2013 06:22:15 +0000 Subject: code cleanup and add mball select similar into the menu --- release/scripts/startup/bl_ui/space_view3d.py | 4 ++++ .../blender/compositor/operations/COM_FastGaussianBlurOperation.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 09719433102..4a36b714c33 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -716,6 +716,10 @@ class VIEW3D_MT_select_edit_metaball(Menu): layout.operator("mball.select_random_metaelems") + layout.separator() + + layout.operator_menu_enum("mball.select_similar", "type", text="Similar") + class VIEW3D_MT_select_edit_lattice(Menu): bl_label = "Select" diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index caf71040483..a6be9254f6f 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -294,13 +294,13 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign int offset; for (y = 0; y < src_height; ++y) { const int yx = y * src_width; - offset = yx*COM_NUMBER_OF_CHANNELS + chan; + offset = yx * COM_NUMBER_OF_CHANNELS + chan; for (x = 0; x < src_width; ++x) { X[x] = buffer[offset]; offset += COM_NUMBER_OF_CHANNELS; } YVV(src_width); - offset = yx*COM_NUMBER_OF_CHANNELS + chan; + offset = yx * COM_NUMBER_OF_CHANNELS + chan; for (x = 0; x < src_width; ++x) { buffer[offset] = Y[x]; offset += COM_NUMBER_OF_CHANNELS; -- cgit v1.2.3 From d859bcf3ad1c0499cd8d034edd119f8a443da0ad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2013 06:59:57 +0000 Subject: patch [#37197] angle snapping for NORMAL button from Philipp Oeser (lichtwerk) with minor edits. --- .../blender/editors/interface/interface_handlers.c | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ad36958f6f8..bc08f44d5c0 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3664,7 +3664,8 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co return WM_UI_HANDLER_CONTINUE; } -static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, int my) +static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, int my, + const bool snap) { float dx, dy, rad, radsq, mrad, *fp; int mdx, mdy; @@ -3720,6 +3721,23 @@ static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, } normalize_v3(fp); + if (snap) { + const int snap_steps = 4; /* 45deg increments */ + const float snap_steps_angle = M_PI / snap_steps; + float angle, angle_snap; + int i; + + /* round each axis of 'fp' to the next increment + * do this in "angle" space - this gives increments of same size */ + for (i = 0; i < 3; i++) { + angle = asinf(fp[i]); + angle_snap = floorf(0.5f + (angle / snap_steps_angle)) * snap_steps_angle; + fp[i] = sinf(angle_snap); + } + normalize_v3(fp); + changed = !compare_v3v3(fp, data->origvec, FLT_EPSILON); + } + data->draglastx = mx; data->draglasty = my; @@ -3778,7 +3796,7 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_NORMAL(but, data, mx, my)) + if (ui_numedit_but_NORMAL(but, data, mx, my, event->ctrl != 0)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; @@ -3787,7 +3805,7 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_NORMAL(but, data, mx, my)) + if (ui_numedit_but_NORMAL(but, data, mx, my, event->ctrl != 0)) ui_numedit_apply(C, block, but, data); } } -- cgit v1.2.3 From 03aa664b23d82cdb33bac60fd80594b69fb8babb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2013 07:47:08 +0000 Subject: replace snap values with enum and bool depending on use (it wasn't clear which was used when both were int's). Ctrl+Shift now snaps normal button to 15deg increments. --- .../blender/editors/interface/interface_handlers.c | 56 ++++++++++++++-------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index bc08f44d5c0..949050ae689 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -248,6 +248,16 @@ static CurveMapping but_copypaste_curve = {0}; static bool but_copypaste_curve_alive = false; /* ******************** menu navigation helpers ************** */ +enum eSnapType { + SNAP_OFF = 0, + SNAP_ON, + SNAP_ON_SMALL, +}; + +static enum eSnapType ui_event_to_snap(const wmEvent *event) +{ + return (event->ctrl) ? (event->shift) ? SNAP_ON_SMALL : SNAP_ON : SNAP_OFF; +} /* assumes event type is MOUSEPAN */ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) @@ -2817,9 +2827,10 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con } /* var names match ui_numedit_but_NUM */ -static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange, int snap) +static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange, + const enum eSnapType snap) { - if (tempf == softmin || tempf == softmax || snap == 0) { + if (tempf == softmin || tempf == softmax || snap == SNAP_OFF) { /* pass */ } else { @@ -2845,16 +2856,19 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa softrange /= fac; } - if (snap == 1) { + if (snap == SNAP_ON) { if (softrange < 2.10f) tempf = 0.1f * floorf(10.0f * tempf); else if (softrange < 21.0f) tempf = floorf(tempf); else tempf = 10.0f * floorf(tempf / 10.0f); } - else if (snap == 2) { + else if (snap == SNAP_ON_SMALL) { if (softrange < 2.10f) tempf = 0.01f * floorf(100.0f * tempf); else if (softrange < 21.0f) tempf = 0.1f * floorf(10.0f * tempf); else tempf = floor(tempf); } + else { + BLI_assert(0); + } if (fac != 1.0f) tempf *= fac; @@ -2863,18 +2877,19 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa return tempf; } -static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int snap) +static float ui_numedit_apply_snap(int temp, float softmin, float softmax, + const enum eSnapType snap) { if (temp == softmin || temp == softmax) return temp; switch (snap) { - case 0: + case SNAP_OFF: break; - case 1: + case SNAP_ON: temp = 10 * (temp / 10); break; - case 2: + case SNAP_ON_SMALL: temp = 100 * (temp / 100); break; } @@ -2882,7 +2897,8 @@ static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int s return temp; } -static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, int snap, int mx) +static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, + const enum eSnapType snap, int mx) { float deler, tempf, softmin, softmax, softrange; int lvalue, temp; @@ -3091,14 +3107,12 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton click = 1; } else if (event->type == MOUSEMOVE) { + const enum eSnapType snap = ui_event_to_snap(event); float fac; - int snap; fac = 1.0f; if (event->shift) fac /= 10.0f; if (event->alt) fac /= 20.0f; - - snap = (event->ctrl) ? (event->shift) ? 2 : 1 : 0; if (ui_numedit_but_NUM(but, data, fac, snap, (ui_is_a_warp_but(but) ? screen_mx : mx))) ui_numedit_apply(C, block, but, data); @@ -3665,7 +3679,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co } static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, int my, - const bool snap) + const enum eSnapType snap) { float dx, dy, rad, radsq, mrad, *fp; int mdx, mdy; @@ -3721,8 +3735,8 @@ static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, } normalize_v3(fp); - if (snap) { - const int snap_steps = 4; /* 45deg increments */ + if (snap != SNAP_OFF) { + const int snap_steps = (snap == SNAP_ON) ? 4 : 12; /* 45 or 15 degree increments */ const float snap_steps_angle = M_PI / snap_steps; float angle, angle_snap; int i; @@ -3789,6 +3803,7 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut if (data->state == BUTTON_STATE_HIGHLIGHT) { if (event->type == LEFTMOUSE && event->val == KM_PRESS) { + const enum eSnapType snap = ui_event_to_snap(event); data->dragstartx = mx; data->dragstarty = my; data->draglastx = mx; @@ -3796,7 +3811,7 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_NORMAL(but, data, mx, my, event->ctrl != 0)) + if (ui_numedit_but_NORMAL(but, data, mx, my, snap)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; @@ -3805,7 +3820,8 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_NORMAL(but, data, mx, my, event->ctrl != 0)) + const enum eSnapType snap = ui_event_to_snap(event); + if (ui_numedit_but_NORMAL(but, data, mx, my, snap)) ui_numedit_apply(C, block, but, data); } } @@ -4406,7 +4422,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle return WM_UI_HANDLER_CONTINUE; } -static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data, int snap, +static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data, bool snap, int evtx, int evty, const short shift) { CurveMapping *cumap = (CurveMapping *)but->poin; @@ -4435,7 +4451,7 @@ static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData d[1] = my - data->dragstarty; if (len_v2(d) < 3.0f) - snap = 0; + snap = false; } if (data->dragsel != -1) { @@ -4630,7 +4646,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt if (event->type == MOUSEMOVE) { if (event->x != data->draglastx || event->y != data->draglasty) { - if (ui_numedit_but_CURVE(block, but, data, event->ctrl, event->x, event->y, event->shift)) + if (ui_numedit_but_CURVE(block, but, data, event->ctrl != 0, event->x, event->y, event->shift)) ui_numedit_apply(C, block, but, data); } } -- cgit v1.2.3 From 692693b92f8183ba6ee8fd58cda956ff55570df0 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Fri, 25 Oct 2013 11:00:16 +0000 Subject: Remove duplicate cmake enries in game engine and compositor --- source/blender/compositor/CMakeLists.txt | 3 --- source/gameengine/Converter/CMakeLists.txt | 1 - 2 files changed, 4 deletions(-) diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index e6a3c33ea5d..11add975db5 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -30,7 +30,6 @@ set(INC operations ../blenkernel ../blenlib - ../blenlib ../imbuf ../makesdna ../makesrna @@ -230,8 +229,6 @@ set(SRC nodes/COM_SetAlphaNode.h nodes/COM_ConvertAlphaNode.cpp nodes/COM_ConvertAlphaNode.h - nodes/COM_AlphaOverNode.cpp - nodes/COM_AlphaOverNode.h nodes/COM_HueSaturationValueNode.cpp nodes/COM_HueSaturationValueNode.h nodes/COM_HueSaturationValueCorrectNode.cpp diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index 084a85c8a1f..9c0d25e56ff 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -37,7 +37,6 @@ set(INC ../Physics/common ../Rasterizer ../Rasterizer/RAS_OpenGLRasterizer - ../Rasterizer/RAS_OpenGLRasterizer ../SceneGraph ../../blender ../../blender/blenkernel -- cgit v1.2.3 From 826713809ea8301ad1fc89ffc2a63195d407bdf6 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Fri, 25 Oct 2013 11:54:10 +0000 Subject: rigidbody: Add "Apply Transformation" button This is just the "Apply Visual Transform" operator. It's very usefull for rigid body simulations but hard to find and users usually don't know about it/don't know it's usefull to apply rigid body transformations. It seems bit out of place (especially the tooltip) so we might need to do a bit more here. --- release/scripts/startup/bl_ui/space_view3d_toolbar.py | 1 + 1 file changed, 1 insertion(+) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 0bb31f51c1b..088dfc31973 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -135,6 +135,7 @@ class VIEW3D_PT_tools_rigidbody(View3DPanel, Panel): col.operator("rigidbody.shape_change", text="Change Shape") col.operator("rigidbody.mass_calculate", text="Calculate Mass") col.operator("rigidbody.object_settings_copy", text="Copy from Active") + col.operator("object.visual_transform_apply", text="Apply Transformation") col.operator("rigidbody.bake_to_keyframes", text="Bake To Keyframes") col.label(text="Constraints:") col.operator("rigidbody.connect", text="Connect") -- cgit v1.2.3 From b7f0a1fabee000a5ed39f07536e56e95dea232a7 Mon Sep 17 00:00:00 2001 From: Jonathan Williamson Date: Fri, 25 Oct 2013 14:12:22 +0000 Subject: Updating tooltip for Fill Holes "Sides" option. This makes the tooltip much more descriptive to tell the user what the setting does. Suggestion by Thomas Beck and bcon13. --- source/blender/editors/mesh/editmesh_tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 5c9858fee58..06afc3a4103 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3100,7 +3100,7 @@ void MESH_OT_fill_holes(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_int(ot->srna, "sides", 4, 0, INT_MAX, "Sides", "Number of sides (zero disables)", 0, 100); + RNA_def_int(ot->srna, "sides", 4, 0, INT_MAX, "Sides", "Number of sides in hole required to fill (zero fills all holes)", 0, 100); } static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) -- cgit v1.2.3 From 2a387436bb526de183972cbe4328252865a92f57 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2013 22:09:31 +0000 Subject: code cleanup: use bool for shift arg, order args more consistently between functions. --- .../blender/editors/interface/interface_handlers.c | 77 +++++++++++++--------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 949050ae689..f14d4046457 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -350,7 +350,7 @@ static bool ui_is_a_warp_but(uiBut *but) return false; } -static float ui_mouse_scale_warp_factor(const short shift) +static float ui_mouse_scale_warp_factor(const bool shift) { return shift ? 0.05f : 1.0f; } @@ -358,7 +358,7 @@ static float ui_mouse_scale_warp_factor(const short shift) static void ui_mouse_scale_warp(uiHandleButtonData *data, const float mx, const float my, float *r_mx, float *r_my, - const short shift) + const bool shift) { const float fac = ui_mouse_scale_warp_factor(shift); @@ -1778,7 +1778,7 @@ static bool ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char as } static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJumpDirection direction, - int select, strCursorJumpType jump) + const bool select, strCursorJumpType jump) { const char *str = data->str; const int len = strlen(str); @@ -2199,7 +2199,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle /* only select a word in button if there was no selection before */ if (event->val == KM_DBL_CLICK && had_selection == false) { - ui_textedit_move(but, data, STRCUR_DIR_PREV, 0, STRCUR_JUMP_DELIM); + ui_textedit_move(but, data, STRCUR_DIR_PREV, false, STRCUR_JUMP_DELIM); ui_textedit_move(but, data, STRCUR_DIR_NEXT, true, STRCUR_JUMP_DELIM); retval = WM_UI_HANDLER_BREAK; changed = true; @@ -2233,12 +2233,12 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle break; case RIGHTARROWKEY: ui_textedit_move(but, data, STRCUR_DIR_NEXT, - event->shift, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); + event->shift != 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); retval = WM_UI_HANDLER_BREAK; break; case LEFTARROWKEY: ui_textedit_move(but, data, STRCUR_DIR_PREV, - event->shift, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); + event->shift != 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE); retval = WM_UI_HANDLER_BREAK; break; case WHEELDOWNMOUSE: @@ -2253,7 +2253,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle /* fall-through */ case ENDKEY: ui_textedit_move(but, data, STRCUR_DIR_NEXT, - event->shift, STRCUR_JUMP_ALL); + event->shift != 0, STRCUR_JUMP_ALL); retval = WM_UI_HANDLER_BREAK; break; case WHEELUPMOUSE: @@ -2268,7 +2268,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle /* fall-through */ case HOMEKEY: ui_textedit_move(but, data, STRCUR_DIR_PREV, - event->shift, STRCUR_JUMP_ALL); + event->shift != 0, STRCUR_JUMP_ALL); retval = WM_UI_HANDLER_BREAK; break; case PADENTER: @@ -2897,8 +2897,9 @@ static float ui_numedit_apply_snap(int temp, float softmin, float softmax, return temp; } -static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, - const enum eSnapType snap, int mx) +static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, + int mx, + const enum eSnapType snap, float fac) { float deler, tempf, softmin, softmax, softrange; int lvalue, temp; @@ -3114,7 +3115,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (event->shift) fac /= 10.0f; if (event->alt) fac /= 20.0f; - if (ui_numedit_but_NUM(but, data, fac, snap, (ui_is_a_warp_but(but) ? screen_mx : mx))) + if (ui_numedit_but_NUM(but, data, (ui_is_a_warp_but(but) ? screen_mx : mx), snap, fac)) ui_numedit_apply(C, block, but, data); } retval = WM_UI_HANDLER_BREAK; @@ -3195,7 +3196,8 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, - const bool is_horizontal, const bool shift, const bool ctrl, int mx) + int mx, const bool is_horizontal, + const bool snap, const bool shift) { float deler, f, tempf, softmin, softmax, softrange; int temp, lvalue; @@ -3250,7 +3252,7 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, tempf = softmin + f * softrange; temp = floorf(tempf + 0.5f); - if (ctrl) { + if (snap) { if (tempf == softmin || tempf == softmax) { /* pass */ } @@ -3371,7 +3373,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton click = 1; } else if (event->type == MOUSEMOVE) { - if (ui_numedit_but_SLI(but, data, true, event->shift, event->ctrl, mx)) + if (ui_numedit_but_SLI(but, data, mx, true, event->ctrl != 0, event->shift != 0)) ui_numedit_apply(C, block, but, data); } retval = WM_UI_HANDLER_BREAK; @@ -3487,7 +3489,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut button_activate_state(C, but, BUTTON_STATE_EXIT); } else if (event->type == MOUSEMOVE) { - if (ui_numedit_but_SLI(but, data, horizontal, false, false, (horizontal) ? mx : my)) + if (ui_numedit_but_SLI(but, data, (horizontal) ? mx : my, horizontal, false, false)) ui_numedit_apply(C, block, but, data); } @@ -3678,7 +3680,8 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co return WM_UI_HANDLER_CONTINUE; } -static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, int my, +static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, + int mx, int my, const enum eSnapType snap) { float dx, dy, rad, radsq, mrad, *fp; @@ -3848,7 +3851,9 @@ static void clamp_axis_max_v3(float v[3], const float max) } } -static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, int my, const short shift) +static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, + int mx, int my, + const bool shift) { float rgb[3]; float *hsv = ui_block_hsv_get(but->block); @@ -3960,7 +3965,9 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, return changed; } -static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, const short shift) +static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, + wmNDOFMotionData *ndof, + const bool shift) { float *hsv = ui_block_hsv_get(but->block); float rgb[3]; @@ -4041,7 +4048,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_HSVCUBE(but, data, mx, my, event->shift)) + if (ui_numedit_but_HSVCUBE(but, data, mx, my, event->shift != 0)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; @@ -4049,7 +4056,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu else if (event->type == NDOF_MOTION) { wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; - ui_ndofedit_but_HSVCUBE(but, data, ndof, event->shift); + ui_ndofedit_but_HSVCUBE(but, data, ndof, event->shift != 0); button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_button(C, but->block, but, data, true); @@ -4100,7 +4107,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu } else if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_HSVCUBE(but, data, mx, my, event->shift)) + if (ui_numedit_but_HSVCUBE(but, data, mx, my, event->shift != 0)) ui_numedit_apply(C, block, but, data); } } @@ -4114,7 +4121,9 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu return WM_UI_HANDLER_CONTINUE; } -static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float mx, float my, int shift) +static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, + float mx, float my, + const bool shift) { rcti rect; bool changed = true; @@ -4187,7 +4196,9 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float return changed; } -static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, const short shift) +static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, + wmNDOFMotionData *ndof, + const bool shift) { float *hsv = ui_block_hsv_get(but->block); float rgb[3]; @@ -4256,7 +4267,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift)) + if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift != 0)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; @@ -4264,7 +4275,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle else if (event->type == NDOF_MOTION) { wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; - ui_ndofedit_but_HSVCIRCLE(but, data, ndof, event->shift); + ui_ndofedit_but_HSVCIRCLE(but, data, ndof, event->shift != 0); button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_button(C, but->block, but, data, true); @@ -4326,7 +4337,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle } else if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift)) + if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift != 0)) ui_numedit_apply(C, block, but, data); } } @@ -4422,8 +4433,9 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle return WM_UI_HANDLER_CONTINUE; } -static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data, bool snap, - int evtx, int evty, const short shift) +static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data, + int evtx, int evty, + bool snap, const bool shift) { CurveMapping *cumap = (CurveMapping *)but->poin; CurveMap *cuma = cumap->cm + cumap->cur; @@ -4646,7 +4658,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt if (event->type == MOUSEMOVE) { if (event->x != data->draglastx || event->y != data->draglasty) { - if (ui_numedit_but_CURVE(block, but, data, event->ctrl != 0, event->x, event->y, event->shift)) + if (ui_numedit_but_CURVE(block, but, data, event->x, event->y, event->ctrl != 0, event->shift != 0)) ui_numedit_apply(C, block, but, data); } } @@ -4955,7 +4967,8 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, con } static bool ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonData *data, - int mx, int my, const short shift) + int mx, int my, + const bool shift) { MovieClipScopes *scopes = (MovieClipScopes *)but->poin; bool changed = true; @@ -5011,7 +5024,7 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift)) + if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; @@ -5027,7 +5040,7 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan } else if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift)) + if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0)) ui_numedit_apply(C, block, but, data); } } -- cgit v1.2.3 From a304b5a9886634bbb7d8806ddb87bcf2687640a0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2013 22:12:05 +0000 Subject: correct typo --- source/blender/blenkernel/intern/tracking.c | 4 ++-- source/blender/blenlib/BLI_math_matrix.h | 2 +- source/blender/blenlib/intern/math_matrix.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 3c2eca1a157..0ce4d54a74c 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -3324,7 +3324,7 @@ static void track_plane_from_existing_motion(MovieTrackingPlaneTrack *plane_trac libmv_homography2DFromCorrespondencesEuc(x1, x2, num_correspondences, H_double); - copt_m3_m3d(H, H_double); + copy_m3_m3d(H, H_double); for (i = 0; i < 4; i++) { float vec[3] = {0.0f, 0.0f, 1.0f}, vec2[3]; @@ -3428,7 +3428,7 @@ void BKE_tracking_homography_between_two_quads(/*const*/ float reference_corners libmv_homography2DFromCorrespondencesEuc(x1, x2, 4, H_double); - copt_m3_m3d(H, H_double); + copy_m3_m3d(H, H_double); } /*********************** Camera solving *************************/ diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index cb0d95301fb..c83494790a8 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -61,7 +61,7 @@ void copy_m3_m4(float R[3][3], float A[4][4]); void copy_m4_m3(float R[4][4], float A[3][3]); /* double->float */ -void copt_m3_m3d(float R[3][3], double A[3][3]); +void copy_m3_m3d(float R[3][3], double A[3][3]); void swap_m3m3(float A[3][3], float B[3][3]); void swap_m4m4(float A[4][4], float B[4][4]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 2cda4425d8e..1f52caac8e9 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -112,7 +112,7 @@ void copy_m4_m3(float m1[4][4], float m2[3][3]) /* no clear */ } -void copt_m3_m3d(float R[3][3], double A[3][3]) +void copy_m3_m3d(float R[3][3], double A[3][3]) { /* Keep it stupid simple for better data flow in CPU. */ R[0][0] = A[0][0]; -- cgit v1.2.3 From bb66da5e02590c9828983e7c2cb956de79fba706 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2013 23:05:34 +0000 Subject: holding ctrl now snaps the hue for color wheel and hsvcube. this makes it easy to set primary colors without using RGB sliders. --- .../blender/editors/interface/interface_handlers.c | 59 ++++++++++++++++++---- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index f14d4046457..7e9c90d51a1 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -259,6 +259,13 @@ static enum eSnapType ui_event_to_snap(const wmEvent *event) return (event->ctrl) ? (event->shift) ? SNAP_ON_SMALL : SNAP_ON : SNAP_OFF; } +static void ui_color_snap_hue(const enum eSnapType snap, float *r_hue) +{ + const float snap_increment = (snap == SNAP_ON_SMALL) ? 24 : 12; + BLI_assert(snap != SNAP_OFF); + *r_hue = floorf(0.5f + ((*r_hue) * snap_increment)) / snap_increment; +} + /* assumes event type is MOUSEPAN */ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) { @@ -3853,7 +3860,7 @@ static void clamp_axis_max_v3(float v[3], const float max) static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, int my, - const bool shift) + const enum eSnapType snap, const bool shift) { float rgb[3]; float *hsv = ui_block_hsv_get(but->block); @@ -3947,6 +3954,12 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, break; } + if (snap != SNAP_OFF) { + if (ELEM3((int)but->a1, UI_GRAD_HV, UI_GRAD_HS, UI_GRAD_H)) { + ui_color_snap_hue(snap, &hsv[0]); + } + } + hsv_to_rgb_v(hsv, rgb); if (color_profile && ((int)but->a1 != UI_GRAD_SV)) @@ -3967,7 +3980,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, - const bool shift) + const enum eSnapType snap, const bool shift) { float *hsv = ui_block_hsv_get(but->block); float rgb[3]; @@ -4022,6 +4035,12 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, break; } + if (snap != SNAP_OFF) { + if (ELEM3((int)but->a1, UI_GRAD_HV, UI_GRAD_HS, UI_GRAD_H)) { + ui_color_snap_hue(snap, &hsv[0]); + } + } + hsv_to_rgb_v(hsv, rgb); if (color_profile && (int)but->a1 != UI_GRAD_SV) @@ -4041,6 +4060,8 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu if (data->state == BUTTON_STATE_HIGHLIGHT) { if (event->type == LEFTMOUSE && event->val == KM_PRESS) { + const enum eSnapType snap = ui_event_to_snap(event); + data->dragstartx = mx; data->dragstarty = my; data->draglastx = mx; @@ -4048,15 +4069,16 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_HSVCUBE(but, data, mx, my, event->shift != 0)) + if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; } else if (event->type == NDOF_MOTION) { wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; + const enum eSnapType snap = ui_event_to_snap(event); - ui_ndofedit_but_HSVCUBE(but, data, ndof, event->shift != 0); + ui_ndofedit_but_HSVCUBE(but, data, ndof, snap, event->shift != 0); button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_button(C, but->block, but, data, true); @@ -4107,7 +4129,9 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu } else if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_HSVCUBE(but, data, mx, my, event->shift != 0)) + const enum eSnapType snap = ui_event_to_snap(event); + + if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0)) ui_numedit_apply(C, block, but, data); } } @@ -4123,7 +4147,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float mx, float my, - const bool shift) + const enum eSnapType snap, const bool shift) { rcti rect; bool changed = true; @@ -4181,6 +4205,10 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, if (but->flag & UI_BUT_COLOR_CUBIC) hsv[1] = 1.0f - sqrt3f(1.0f - hsv[1]); + if (snap != SNAP_OFF) { + ui_color_snap_hue(snap, &hsv[0]); + } + hsv_to_rgb_v(hsv, rgb); if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) { @@ -4198,7 +4226,7 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, - const bool shift) + const enum eSnapType snap, const bool shift) { float *hsv = ui_block_hsv_get(but->block); float rgb[3]; @@ -4239,7 +4267,11 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, if (but->flag & UI_BUT_COLOR_LOCK) { // lock if (hsv[2] == 0.0f) hsv[2] = 0.0001f; } - + + if (snap != SNAP_OFF) { + ui_color_snap_hue(snap, &hsv[0]); + } + hsv_to_rgb_v(hsv, data->vec); if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) { @@ -4260,6 +4292,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle if (data->state == BUTTON_STATE_HIGHLIGHT) { if (event->type == LEFTMOUSE && event->val == KM_PRESS) { + const enum eSnapType snap = ui_event_to_snap(event); data->dragstartx = mx; data->dragstarty = my; data->draglastx = mx; @@ -4267,15 +4300,16 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift != 0)) + if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; } else if (event->type == NDOF_MOTION) { + const enum eSnapType snap = ui_event_to_snap(event); wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; - ui_ndofedit_but_HSVCIRCLE(but, data, ndof, event->shift != 0); + ui_ndofedit_but_HSVCIRCLE(but, data, ndof, snap, event->shift != 0); button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_button(C, but->block, but, data, true); @@ -4337,8 +4371,11 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle } else if (event->type == MOUSEMOVE) { if (mx != data->draglastx || my != data->draglasty) { - if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift != 0)) + const enum eSnapType snap = ui_event_to_snap(event); + + if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0)) { ui_numedit_apply(C, block, but, data); + } } } else if (event->type == LEFTMOUSE && event->val != KM_PRESS) { -- cgit v1.2.3 From 2b2c03aa7c916ca94f898c84a5a45403bd430b12 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Oct 2013 23:50:55 +0000 Subject: fix for UI glitch with HSVCUBE color picker, color was noticeably not very smooth or aligned. - HSV values need to be shifted. - drawing the quads wasnt aligned well to colors. --- .../blender/editors/interface/interface_widgets.c | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 215e9df4ae1..c26998a7541 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2004,10 +2004,11 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * /* ************ custom buttons, old stuff ************** */ -/* draws in resolution of 20x4 colors */ +/* draws in resolution of 48x4 colors */ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, const float alpha) { - const float color_step = (type == UI_GRAD_H) ? 0.02f : 0.05f; + /* allows for 4 steps (red->yellow) */ + const float color_step = (1.0 / 48.0); int a; float h = hsv[0], s = hsv[1], v = hsv[2]; float dx, dy, sx1, sx2, sy; @@ -2066,6 +2067,8 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons /* old below */ for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */ + const float dx_next = dx + color_step; + /* previous color */ copy_v3_v3(col0[0], col1[0]); copy_v3_v3(col0[1], col1[1]); @@ -2081,22 +2084,22 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons hsv_to_rgb(h, 1.0, dx, &col1[3][0], &col1[3][1], &col1[3][2]); break; case UI_GRAD_HV: - hsv_to_rgb(dx, s, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]); - hsv_to_rgb(dx, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]); - hsv_to_rgb(dx, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]); - hsv_to_rgb(dx, s, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]); + hsv_to_rgb(dx_next, s, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]); + hsv_to_rgb(dx_next, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]); + hsv_to_rgb(dx_next, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]); + hsv_to_rgb(dx_next, s, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]); break; case UI_GRAD_HS: - hsv_to_rgb(dx, 0.0, v, &col1[0][0], &col1[0][1], &col1[0][2]); - hsv_to_rgb(dx, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]); - hsv_to_rgb(dx, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]); - hsv_to_rgb(dx, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]); + hsv_to_rgb(dx_next, 0.0, v, &col1[0][0], &col1[0][1], &col1[0][2]); + hsv_to_rgb(dx_next, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]); + hsv_to_rgb(dx_next, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]); + hsv_to_rgb(dx_next, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]); break; case UI_GRAD_H: { /* annoying but without this the color shifts - could be solved some other way * - campbell */ - hsv_to_rgb(dx + color_step, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]); + hsv_to_rgb(dx_next, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]); copy_v3_v3(col1[1], col1[0]); copy_v3_v3(col1[2], col1[0]); copy_v3_v3(col1[3], col1[0]); @@ -2117,8 +2120,8 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons } /* rect */ - sx1 = rect->xmin + dx * BLI_rcti_size_x(rect); - sx2 = rect->xmin + (dx + color_step) * BLI_rcti_size_x(rect); + sx1 = rect->xmin + dx * BLI_rcti_size_x(rect); + sx2 = rect->xmin + dx_next * BLI_rcti_size_x(rect); sy = rect->ymin; dy = (float)BLI_rcti_size_y(rect) / 3.0f; -- cgit v1.2.3 From 00160d4a1be401b789bc470cc397b1172353b116 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Oct 2013 01:03:16 +0000 Subject: remove unused var --- intern/cycles/render/shader.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 26af60572f6..8dbff224225 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -217,7 +217,6 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc uint shader_flag_size = scene->shaders.size()*4; uint *shader_flag = dscene->shader_flag.resize(shader_flag_size); uint i = 0; - bool has_surface_bssrdf = false; bool has_converter_blackbody = false; foreach(Shader *shader, scene->shaders) { @@ -231,8 +230,6 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc flag |= SD_HAS_VOLUME; if(shader->homogeneous_volume) flag |= SD_HOMOGENEOUS_VOLUME; - if(shader->has_surface_bssrdf) - has_surface_bssrdf = true; if(shader->has_bssrdf_bump) flag |= SD_HAS_BSSRDF_BUMP; if(shader->has_converter_blackbody) -- cgit v1.2.3 From 48c1e0c0fcb66502026721a50ae5e17470aee816 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Oct 2013 01:06:19 +0000 Subject: spelling: use American spelling for canceled --- intern/cycles/app/cycles_standalone.cpp | 2 +- intern/cycles/bvh/bvh_build.cpp | 2 +- intern/cycles/device/device_cpu.cpp | 16 ++++++++-------- intern/cycles/util/util_task.cpp | 4 ++-- intern/cycles/util/util_task.h | 4 ++-- intern/ghost/intern/GHOST_SystemCocoa.mm | 2 +- source/blender/blenlib/BLI_task.h | 4 ++-- source/blender/blenlib/intern/task.c | 2 +- source/blender/blenlib/intern/threads.c | 2 +- source/blender/editors/object/object_vgroup.c | 2 +- source/blender/editors/transform/transform.h | 2 +- source/blender/editors/transform/transform_conversions.c | 2 +- source/blender/makesrna/intern/rna_render.c | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp index 2a438397ae0..6b201017c46 100644 --- a/intern/cycles/app/cycles_standalone.cpp +++ b/intern/cycles/app/cycles_standalone.cpp @@ -190,7 +190,7 @@ static void keyboard(unsigned char key) if(key == 'r') options.session->reset(session_buffer_params(), options.session_params.samples); else if(key == 27) // escape - options.session->progress.set_cancel("Cancelled"); + options.session->progress.set_cancel("Canceled"); } #endif diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp index 2c3c31b5429..b21b20a87e5 100644 --- a/intern/cycles/bvh/bvh_build.cpp +++ b/intern/cycles/bvh/bvh_build.cpp @@ -225,7 +225,7 @@ BVHNode* BVHBuild::run() task_pool.wait_work(); } - /* delete if we cancelled */ + /* delete if we canceled */ if(rootnode) { if(progress.get_cancel()) { rootnode->deleteSubtree(); diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index b1dbdec9d36..d04c5df82fb 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -144,7 +144,7 @@ public: void thread_path_trace(DeviceTask& task) { - if(task_pool.cancelled()) { + if(task_pool.canceled()) { if(task.need_finish_queue == false) return; } @@ -166,7 +166,7 @@ public: #ifdef WITH_OPTIMIZED_KERNEL if(system_cpu_support_sse3()) { for(int sample = start_sample; sample < end_sample; sample++) { - if (task.get_cancel() || task_pool.cancelled()) { + if (task.get_cancel() || task_pool.canceled()) { if(task.need_finish_queue == false) break; } @@ -185,7 +185,7 @@ public: } else if(system_cpu_support_sse2()) { for(int sample = start_sample; sample < end_sample; sample++) { - if (task.get_cancel() || task_pool.cancelled()) { + if (task.get_cancel() || task_pool.canceled()) { if(task.need_finish_queue == false) break; } @@ -206,7 +206,7 @@ public: #endif { for(int sample = start_sample; sample < end_sample; sample++) { - if (task.get_cancel() || task_pool.cancelled()) { + if (task.get_cancel() || task_pool.canceled()) { if(task.need_finish_queue == false) break; } @@ -226,7 +226,7 @@ public: task.release_tile(tile); - if(task_pool.cancelled()) { + if(task_pool.canceled()) { if(task.need_finish_queue == false) break; } @@ -302,7 +302,7 @@ public: for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) { kernel_cpu_sse3_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x); - if(task_pool.cancelled()) + if(task_pool.canceled()) break; } } @@ -310,7 +310,7 @@ public: for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) { kernel_cpu_sse2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x); - if(task_pool.cancelled()) + if(task_pool.canceled()) break; } } @@ -320,7 +320,7 @@ public: for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) { kernel_cpu_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x); - if(task_pool.cancelled()) + if(task_pool.canceled()) break; } } diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp index e5a5ac8cddf..14a81ecbb05 100644 --- a/intern/cycles/util/util_task.cpp +++ b/intern/cycles/util/util_task.cpp @@ -136,7 +136,7 @@ void TaskPool::stop() assert(num == 0); } -bool TaskPool::cancelled() +bool TaskPool::canceled() { return do_cancel; } @@ -366,7 +366,7 @@ void DedicatedTaskPool::stop() assert(num == 0); } -bool DedicatedTaskPool::cancelled() +bool DedicatedTaskPool::canceled() { return do_cancel; } diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h index 22515e3e433..42a1e2f5a58 100644 --- a/intern/cycles/util/util_task.h +++ b/intern/cycles/util/util_task.h @@ -66,7 +66,7 @@ public: void cancel(); /* cancel all tasks, keep worker threads running */ void stop(); /* stop all worker threads */ - bool cancelled(); /* for worker threads, test if cancelled */ + bool canceled(); /* for worker threads, test if canceled */ protected: friend class TaskScheduler; @@ -142,7 +142,7 @@ public: void cancel(); /* cancel all tasks, keep worker thread running */ void stop(); /* stop worker thread */ - bool cancelled(); /* for worker thread, test if cancelled */ + bool canceled(); /* for worker thread, test if canceled */ protected: void num_decrease(int done); diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index fcf39523917..84b4bb35768 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -517,7 +517,7 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op) - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { - //TODO: implement graceful termination through Cocoa mechanism to avoid session log off to be cancelled + //TODO: implement graceful termination through Cocoa mechanism to avoid session log off to be canceled //Note that Cmd+Q is already handled by keyhandler if (systemCocoa->handleQuitRequest() == GHOST_kExitNow) return NSTerminateCancel;//NSTerminateNow; diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h index f57d42858c7..c9cbaf997fb 100644 --- a/source/blender/blenlib/BLI_task.h +++ b/source/blender/blenlib/BLI_task.h @@ -88,8 +88,8 @@ void BLI_task_pool_cancel(TaskPool *pool); /* stop all worker threads */ void BLI_task_pool_stop(TaskPool *pool); -/* for worker threads, test if cancelled */ -bool BLI_task_pool_cancelled(TaskPool *pool); +/* for worker threads, test if canceled */ +bool BLI_task_pool_canceled(TaskPool *pool); /* optional userdata pointer to pass along to run function */ void *BLI_task_pool_userdata(TaskPool *pool); diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c index 7fa108b906f..4ae60abb2c8 100644 --- a/source/blender/blenlib/intern/task.c +++ b/source/blender/blenlib/intern/task.c @@ -402,7 +402,7 @@ void BLI_task_pool_stop(TaskPool *pool) BLI_assert(pool->num == 0); } -bool BLI_task_pool_cancelled(TaskPool *pool) +bool BLI_task_pool_canceled(TaskPool *pool) { return pool->do_cancel; } diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 64682965649..4361583dafc 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -624,7 +624,7 @@ struct ThreadQueue { pthread_cond_t push_cond; pthread_cond_t finish_cond; volatile int nowait; - volatile int cancelled; + volatile int canceled; }; ThreadQueue *BLI_thread_queue_init(void) diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index d6c365e9247..d75c50b3f28 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -3777,7 +3777,7 @@ static int vertex_group_limit_total_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } else { - /* note, would normally return cancelled, except we want the redo + /* note, would normally return canceled, except we want the redo * UI to show up for users to change */ return OPERATOR_FINISHED; } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 376847937f3..73b8c47eb63 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -349,7 +349,7 @@ typedef struct TransInfo { float axis[3]; float axis_orig[3]; /* TransCon can change 'axis', store the original value here */ - short remove_on_cancel; /* remove elements if operator is cancelled */ + short remove_on_cancel; /* remove elements if operator is canceled */ void *view; struct bContext *context; /* Only valid (non null) during an operator called function. */ diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index f7010898fc3..d3756ea5973 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4589,7 +4589,7 @@ static void freeSeqData(TransInfo *t) BKE_sequencer_sort(t->scene); } else { - /* Cancelled, need to update the strips display */ + /* Canceled, need to update the strips display */ for (a = 0; a < t->total; a++, td++) { seq = ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev) && (seq->depth == 0)) { diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 7ebbcf7b39b..1cd27e27f01 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -395,7 +395,7 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_boolean(func, "cancel", 0, "Cancel", "Don't merge back results"); func = RNA_def_function(srna, "test_break", "RE_engine_test_break"); - RNA_def_function_ui_description(func, "Test if the render operation should been cancelled, this is a fast call that should be used regularly for responsiveness"); + RNA_def_function_ui_description(func, "Test if the render operation should been canceled, this is a fast call that should be used regularly for responsiveness"); prop = RNA_def_boolean(func, "do_break", 0, "Break", ""); RNA_def_function_return(func, prop); -- cgit v1.2.3 From 7f9cdae28082fee4a05cc3dd4fddfbb40a411281 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Oct 2013 02:14:07 +0000 Subject: fix for outline width theme option being ignored for non mesh object types. --- source/blender/editors/space_view3d/drawobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 06aedb2c36d..03f081476b3 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6325,7 +6325,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base, RegionView3D *rv3d = ar->regiondata; Object *ob = base->object; - glLineWidth(2.0); + glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); glDepthMask(0); if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { -- cgit v1.2.3 From b461cc9cd4f9e1827feec81b88ffc8c3b981755f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Oct 2013 03:56:32 +0000 Subject: code cleanup: merge doxygen comments into C source. --- source/blender/blenkernel/BKE_action.h | 55 ++++----------------------- source/blender/blenkernel/intern/action.c | 63 +++++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 60 deletions(-) diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 698098d28c3..5c155a46182 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -132,60 +132,19 @@ struct bActionGroup *BKE_action_group_find_name(struct bAction *act, const char void action_groups_clear_tempflags(struct bAction *act); /* Pose API ----------------- */ - -/** - * Deallocates a pose channel. - * Does not free the pose channel itself. - */ -void BKE_pose_channel_free(struct bPoseChannel *pchan); - -/** - * Removes and deallocates all channels from a pose. - * Does not free the pose itself. - */ -void BKE_pose_channels_free(struct bPose *pose); -/** - * Removes the hash for quick lookup of channels, must - * be done when adding/removing channels. - */ -void BKE_pose_channels_hash_make(struct bPose *pose); -void BKE_pose_channels_hash_free(struct bPose *pose); - -/** - * Removes and deallocates all data from a pose, and also frees the pose. - */ -void BKE_pose_free(struct bPose *pose); +void BKE_pose_channel_free(struct bPoseChannel *pchan); -/** - * Allocate a new pose on the heap, and copy the src pose and it's channels - * into the new pose. *dst is set to the newly allocated structure, and assumed to be NULL. - */ -void BKE_pose_copy_data(struct bPose **dst, struct bPose *src, int copyconstraints); +void BKE_pose_channels_free(struct bPose *pose); -/** - * Copy the internal members of each pose channel including constraints - * and ID-Props, used when duplicating bones in editmode. - */ -void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from); +void BKE_pose_channels_hash_make(struct bPose *pose); +void BKE_pose_channels_hash_free(struct bPose *pose); -/** - * Return a pointer to the pose channel of the given name - * from this pose. - */ +void BKE_pose_free(struct bPose *pose); +void BKE_pose_copy_data(struct bPose **dst, struct bPose *src, const bool copy_constraints); +void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from); struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name); - -/** - * Return a pointer to the active pose channel from this Object. - * (Note: Object, not bPose is used here, as we need layer info from Armature) - */ struct bPoseChannel *BKE_pose_channel_active(struct Object *ob); - -/** - * Looks to see if the channel with the given name - * already exists in this pose - if not a new one is - * allocated and initialized. - */ struct bPoseChannel *BKE_pose_channel_verify(struct bPose *pose, const char *name); #ifndef NDEBUG diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index b0644da4598..94da2a330c1 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -440,6 +440,10 @@ void action_groups_clear_tempflags(bAction *act) /* *************** Pose channels *************** */ +/** + * Return a pointer to the pose channel of the given name + * from this pose. + */ bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name) { if (ELEM(NULL, pose, name) || (name[0] == '\0')) @@ -451,8 +455,14 @@ bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name) return BLI_findstring(&((bPose *)pose)->chanbase, name, offsetof(bPoseChannel, name)); } -/* Use with care, not on Armature poses but for temporal ones */ -/* (currently used for action constraints and in rebuild_pose) */ +/** + * Looks to see if the channel with the given name + * already exists in this pose - if not a new one is + * allocated and initialized. + * + * \note Use with care, not on Armature poses but for temporal ones. + * \note (currently used for action constraints and in rebuild_pose). + */ bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name) { bPoseChannel *chan; @@ -505,7 +515,12 @@ bool BKE_pose_channels_is_valid(const bPose *pose) } #endif -/* Find the active posechannel for an object (we can't just use pose, as layer info is in armature) */ + +/** + * Find the active posechannel for an object (we can't just use pose, as layer info is in armature) + * + * \note: Object, not bPose is used here, as we need layer info from Armature) + */ bPoseChannel *BKE_pose_channel_active(Object *ob) { bArmature *arm = (ob) ? ob->data : NULL; @@ -536,8 +551,14 @@ const char *BKE_pose_ikparam_get_name(bPose *pose) } return NULL; } -/* dst should be freed already, makes entire duplicate */ -void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon) + +/** + * Allocate a new pose on the heap, and copy the src pose and it's channels + * into the new pose. *dst is set to the newly allocated structure, and assumed to be NULL. + * + * \param dst Should be freed already, makes entire duplicate. + */ +void BKE_pose_copy_data(bPose **dst, bPose *src, const bool copy_constraints) { bPose *outPose; bPoseChannel *pchan; @@ -558,8 +579,7 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon) outPose->avs = src->avs; for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) { - /* TODO: rename this argument... */ - if (copycon) { + if (copy_constraints) { BKE_copy_constraints(&listb, &pchan->constraints, TRUE); // BKE_copy_constraints NULLs listb pchan->constraints = listb; pchan->mpath = NULL; /* motion paths should not get copied yet... */ @@ -571,8 +591,9 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon) } /* for now, duplicate Bone Groups too when doing this */ - if (copycon) + if (copy_constraints) { BLI_duplicatelist(&outPose->agroups, &src->agroups); + } *dst = outPose; } @@ -641,7 +662,10 @@ bool BKE_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan) return pose_channel_in_IK_chain(ob, pchan, 0); } - +/** + * Removes the hash for quick lookup of channels, must + * be done when adding/removing channels. + */ void BKE_pose_channels_hash_make(bPose *pose) { if (!pose->chanhash) { @@ -661,6 +685,10 @@ void BKE_pose_channels_hash_free(bPose *pose) } } +/** + * Deallocates a pose channel. + * Does not free the pose channel itself. + */ void BKE_pose_channel_free(bPoseChannel *pchan) { if (pchan->custom) { @@ -681,6 +709,10 @@ void BKE_pose_channel_free(bPoseChannel *pchan) } } +/** + * Removes and deallocates all channels from a pose. + * Does not free the pose itself. + */ void BKE_pose_channels_free(bPose *pose) { bPoseChannel *pchan; @@ -695,6 +727,9 @@ void BKE_pose_channels_free(bPose *pose) BKE_pose_channels_hash_free(pose); } +/** + * Removes and deallocates all data from a pose, and also frees the pose. + */ void BKE_pose_free(bPose *pose) { if (pose) { @@ -739,9 +774,13 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan } } -/* makes copies of internal data, unlike copy_pose_channel_data which only - * copies the pose state. - * hint: use when copying bones in editmode (on returned value from BKE_pose_channel_verify) */ +/** + * Copy the internal members of each pose channel including constraints + * and ID-Props, used when duplicating bones in editmode. + * (unlike copy_pose_channel_data which only). + * + * \note use when copying bones in editmode (on returned value from #BKE_pose_channel_verify) + */ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_from) { /* copy transform locks */ -- cgit v1.2.3 From ff7dbdbaeef1e1be0d8da18cb97a9e91be27f934 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Oct 2013 04:07:18 +0000 Subject: rename give_cursor to ED_view3d_cursor3d_get --- source/blender/editors/armature/armature_add.c | 6 +++--- source/blender/editors/armature/armature_edit.c | 6 +++--- source/blender/editors/curve/editcurve.c | 4 ++-- source/blender/editors/gpencil/gpencil_edit.c | 2 +- source/blender/editors/gpencil/gpencil_paint.c | 2 +- source/blender/editors/include/ED_view3d.h | 4 ++-- source/blender/editors/mesh/editmesh_bisect.c | 2 +- source/blender/editors/mesh/editmesh_extrude.c | 6 +++--- source/blender/editors/mesh/editmesh_tools.c | 2 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_transform.c | 2 +- source/blender/editors/sculpt_paint/paint_image_proj.c | 4 ++-- source/blender/editors/space_view3d/view3d_draw.c | 2 +- source/blender/editors/space_view3d/view3d_edit.c | 6 +++--- source/blender/editors/space_view3d/view3d_snap.c | 10 +++++----- source/blender/editors/space_view3d/view3d_view.c | 4 ++-- source/blender/editors/transform/transform.c | 4 ++-- source/blender/editors/transform/transform_generics.c | 2 +- source/blender/editors/transform/transform_manipulator.c | 2 +- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 2 +- source/blender/makesrna/intern/rna_space.c | 4 ++-- source/blenderplayer/bad_level_call_stubs/stubs.c | 2 +- 22 files changed, 40 insertions(+), 40 deletions(-) diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index d480d41f5d6..351fd2844c9 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -176,7 +176,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) newbone->flag |= BONE_CONNECTED; } - curs = give_cursor(scene, v3d); + curs = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(newbone->tail, curs); sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]); @@ -216,7 +216,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEv ar = CTX_wm_region(C); v3d = CTX_wm_view3d(C); - fp = give_cursor(scene, v3d); + fp = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(oldcurs, fp); @@ -691,7 +691,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "name", name); - copy_v3_v3(curs, give_cursor(CTX_data_scene(C), CTX_wm_view3d(C))); + copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C))); /* Get inverse point for head and orientation for tail */ invert_m4_m4(obedit->imat, obedit->obmat); diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 90c1a439a19..1c6ba1d3562 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -252,7 +252,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ float cursor_local[3]; - const float *cursor = give_cursor(scene, v3d); + const float *cursor = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(cursor_local, cursor); @@ -502,7 +502,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) /* Get points - cursor (tail) */ invert_m4_m4(obedit->imat, obedit->obmat); - mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d)); + mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d)); /* Create a bone */ /* newbone = */ add_points_bone(obedit, ebp->vec, curs); @@ -536,7 +536,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) /* get cursor location */ invert_m4_m4(obedit->imat, obedit->obmat); - mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d)); + mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d)); /* get distances */ sub_v3_v3v3(vecA, ebp->vec, curs); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 7b03a15a011..bd91740521d 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4485,7 +4485,7 @@ static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event) if (rv3d) copy_v3_v3(axis, rv3d->viewinv[2]); - RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d)); + RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)); RNA_float_set_array(op->ptr, "axis", axis); return spin_exec(C, op); @@ -4821,7 +4821,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) mul_v3_m4v3(location, vc.obedit->obmat, bp->vec); } else { - copy_v3_v3(location, give_cursor(vc.scene, vc.v3d)); + copy_v3_v3(location, ED_view3d_cursor3d_get(vc.scene, vc.v3d)); } ED_view3d_win_to_3d_int(vc.ar, location, event->mval, location); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index c5dc8654e9d..0298699fac5 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -454,7 +454,7 @@ static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoin copy_v3_v3(p3d, &pt->x); } else { - const float *fp = give_cursor(scene, v3d); + const float *fp = ED_view3d_cursor3d_get(scene, v3d); float mvalf[2]; /* get screen coordinate */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 255f0b7cfba..98fff3d65ce 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -211,7 +211,7 @@ static int gpencil_project_check(tGPsdata *p) static void gp_get_3d_reference(tGPsdata *p, float vec[3]) { View3D *v3d = p->sa->spacedata.first; - const float *fp = give_cursor(p->scene, v3d); + const float *fp = ED_view3d_cursor3d_get(p->scene, v3d); /* the reference point used depends on the owner... */ #if 0 /* XXX: disabled for now, since we can't draw relative to the owner yet */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index e504c858efa..0f3106794f5 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -82,8 +82,8 @@ typedef struct ViewDepths { bool damaged; } ViewDepths; -float *give_cursor(struct Scene *scene, struct View3D *v3d); -void ED_view3d_cursor3d_position(struct bContext *C, float fp[3], const int mval[2]); +float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d); +void ED_view3d_cursor3d_position(struct bContext *C, float fp[3], const int mval[2]); void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist); void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist); diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 7b5a6e50d9f..7bc3ff3ab77 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -203,7 +203,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op) RNA_property_float_get_array(op->ptr, prop_plane_co, plane_co); } else { - copy_v3_v3(plane_co, give_cursor(scene, v3d)); + copy_v3_v3(plane_co, ED_view3d_cursor3d_get(scene, v3d)); RNA_property_float_set_array(op->ptr, prop_plane_co, plane_co); } diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index d3207d42983..ef300fa9db6 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -653,7 +653,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w BM_ELEM_SELECT, min); } else { - const float *curs = give_cursor(vc.scene, vc.v3d); + const float *curs = ED_view3d_cursor3d_get(vc.scene, vc.v3d); BMOperator bmop; BMOIter oiter; @@ -751,7 +751,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); - RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d)); + RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)); RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[2]); return edbm_spin_exec(C, op); @@ -871,7 +871,7 @@ static int edbm_screw_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); - RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d)); + RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)); RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[1]); return edbm_screw_exec(C, op); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 06afc3a4103..6a0a0694764 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -1615,7 +1615,7 @@ static bool merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, const float *vco = NULL; if (use_cursor) { - vco = give_cursor(scene, v3d); + vco = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(co, vco); mul_m4_v3(ob->imat, co); } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index db75acef267..0a390da2ae4 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -152,7 +152,7 @@ void ED_object_location_from_view(bContext *C, float loc[3]) Scene *scene = CTX_data_scene(C); const float *cursor; - cursor = give_cursor(scene, v3d); + cursor = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(loc, cursor); } diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 4d7abbe7c39..fef5ae392ea 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -712,7 +712,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) else { /* get the view settings if 'around' isn't set and the view is available */ View3D *v3d = CTX_wm_view3d(C); - copy_v3_v3(cursor, give_cursor(scene, v3d)); + copy_v3_v3(cursor, ED_view3d_cursor3d_get(scene, v3d)); if (v3d && !RNA_struct_property_is_set(op->ptr, "center")) around = v3d->around; } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 66d09c77cea..88cc954fb17 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -3307,7 +3307,7 @@ static void paint_proj_begin_clone(ProjPaintState *ps, const float mouse[2]) /* setup clone offset */ if (ps->tool == PAINT_TOOL_CLONE) { float projCo[4]; - copy_v3_v3(projCo, give_cursor(ps->scene, ps->v3d)); + copy_v3_v3(projCo, ED_view3d_cursor3d_get(ps->scene, ps->v3d)); mul_m4_v3(ps->ob->imat, projCo); projCo[3] = 1.0f; @@ -4163,7 +4163,7 @@ void paint_proj_stroke(bContext *C, void *pps, const float prev_pos[2], const fl if (ps->tool == PAINT_TOOL_CLONE && ps->mode == BRUSH_STROKE_INVERT) { Scene *scene = ps->scene; View3D *v3d = ps->v3d; - float *cursor = give_cursor(scene, v3d); + float *cursor = ED_view3d_cursor3d_get(scene, v3d); int mval_i[2] = {(int)pos[0], (int)pos[1]}; view3d_operator_needs_opengl(C); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index a37d98e416d..8b7d5756429 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -567,7 +567,7 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d) int co[2]; /* we don't want the clipping for cursor */ - if (ED_view3d_project_int_global(ar, give_cursor(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_int_global(ar, ED_view3d_cursor3d_get(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { const float f5 = 0.25f * U.widget_unit; const float f10 = 0.5f * U.widget_unit; const float f20 = U.widget_unit; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 67c9ea4599c..bb41e727d90 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2476,7 +2476,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in if (center) { /* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */ - curs = give_cursor(scene, v3d); + curs = ED_view3d_cursor3d_get(scene, v3d); zero_v3(min); zero_v3(max); zero_v3(curs); @@ -2757,7 +2757,7 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *op) /* non camera center */ float new_ofs[3]; - negate_v3_v3(new_ofs, give_cursor(scene, v3d)); + negate_v3_v3(new_ofs, ED_view3d_cursor3d_get(scene, v3d)); ED_view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, NULL, NULL, smooth_viewtx); @@ -4172,7 +4172,7 @@ static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), const wmE { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - float *fp = give_cursor(scene, v3d); + float *fp = ED_view3d_cursor3d_get(scene, v3d); ED_view3d_cursor3d_position(C, fp, event->mval); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 7c29ab01c24..8a099c7198b 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -687,7 +687,7 @@ static int snap_sel_to_curs_exec(bContext *C, wmOperator *op) const bool use_offset = RNA_boolean_get(op->ptr, "use_offset"); - cursor_global = give_cursor(scene, v3d); + cursor_global = ED_view3d_cursor3d_get(scene, v3d); if (use_offset) { snap_curs_to_sel_ex(C, center_global); @@ -852,7 +852,7 @@ static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) float gridf, *curs; gridf = rv3d->gridview; - curs = give_cursor(scene, v3d); + curs = ED_view3d_cursor3d_get(scene, v3d); curs[0] = gridf * floorf(0.5f + curs[0] / gridf); curs[1] = gridf * floorf(0.5f + curs[1] / gridf); @@ -1035,7 +1035,7 @@ static int snap_curs_to_sel_exec(bContext *C, wmOperator *UNUSED(op)) View3D *v3d = CTX_wm_view3d(C); float *curs; - curs = give_cursor(scene, v3d); + curs = ED_view3d_cursor3d_get(scene, v3d); if (snap_curs_to_sel_ex(C, curs)) { WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); @@ -1072,7 +1072,7 @@ static int snap_curs_to_active_exec(bContext *C, wmOperator *UNUSED(op)) View3D *v3d = CTX_wm_view3d(C); float *curs; - curs = give_cursor(scene, v3d); + curs = ED_view3d_cursor3d_get(scene, v3d); if (obedit) { if (obedit->type == OB_MESH) { @@ -1127,7 +1127,7 @@ static int snap_curs_to_center_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); float *curs; - curs = give_cursor(scene, v3d); + curs = ED_view3d_cursor3d_get(scene, v3d); zero_v3(curs); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 61c6d5c00dd..e321e7c9c4b 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -104,7 +104,7 @@ void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar) } } -float *give_cursor(Scene *scene, View3D *v3d) +float *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d) { if (v3d && v3d->localvd) return v3d->cursor; else return scene->cursor; @@ -847,7 +847,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) } else if (v3d->ob_centre_cursor) { float vec[3]; - copy_v3_v3(vec, give_cursor(scene, v3d)); + copy_v3_v3(vec, ED_view3d_cursor3d_get(scene, v3d)); translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]); use_lock_ofs = true; } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index c0fb959d6b5..9909f438734 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2711,14 +2711,14 @@ static void initWarp(TransInfo *t) t->flag |= T_NO_CONSTRAINT; - //copy_v3_v3(t->center, give_cursor(t->scene, t->view)); + //copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view)); calculateCenterCursor(t); t->val = 0.0f; data = MEM_callocN(sizeof(*data), __func__); - curs = give_cursor(t->scene, t->view); + curs = ED_view3d_cursor3d_get(t->scene, t->view); copy_v3_v3(data->warp_sta, curs); ED_view3d_win_to_3d(t->ar, curs, mval_fl, data->warp_end); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index a8248cc73e1..33eca0d6b89 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1500,7 +1500,7 @@ void calculateCenterCursor(TransInfo *t) { const float *cursor; - cursor = give_cursor(t->scene, t->view); + cursor = ED_view3d_cursor3d_get(t->scene, t->view); copy_v3_v3(t->center, cursor); /* If edit or pose mode, move cursor in local space */ diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index f667a98812b..132a46441e6 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1635,7 +1635,7 @@ void BIF_draw_manipulator(const bContext *C) copy_v3_v3(rv3d->twmat[3], scene->twcent); break; case V3D_CURSOR: - copy_v3_v3(rv3d->twmat[3], give_cursor(scene, v3d)); + copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d)); break; } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 87cc42001d6..0f42808b2d0 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -890,7 +890,7 @@ static void uv_map_transform_center(Scene *scene, View3D *v3d, float *result, } case V3D_CURSOR: /* cursor center */ { - const float *curs = give_cursor(scene, v3d); + const float *curs = ED_view3d_cursor3d_get(scene, v3d); /* shift to objects world */ sub_v3_v3v3(result, curs, ob->obmat[3]); break; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 167590d4c2e..5daeb4ae612 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -370,7 +370,7 @@ static void rna_View3D_CursorLocation_get(PointerRNA *ptr, float *values) View3D *v3d = (View3D *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; Scene *scene = (Scene *)sc->scene; - const float *loc = give_cursor(scene, v3d); + const float *loc = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(values, loc); } @@ -380,7 +380,7 @@ static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values) View3D *v3d = (View3D *)(ptr->data); bScreen *sc = (bScreen *)ptr->id.data; Scene *scene = (Scene *)sc->scene; - float *cursor = give_cursor(scene, v3d); + float *cursor = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(cursor, values); } diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 7c01058ec31..2af65c763b5 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -192,7 +192,7 @@ void RE_BlenderFrame(struct Render *re, struct Scene *scene, int frame) {STUB_AS int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, const char imtype, float layout[12]) {STUB_ASSERT(0); return 0; } /* rna */ -float *give_cursor(struct Scene *scene, struct View3D *v3d) {STUB_ASSERT(0); return (float *) NULL;} +float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d) {STUB_ASSERT(0); return (float *) NULL;} void WM_menutype_free(void) {STUB_ASSERT(0);} void WM_menutype_freelink(struct MenuType *mt) {STUB_ASSERT(0);} int WM_menutype_add(struct MenuType *mt) {STUB_ASSERT(0); return 0;} -- cgit v1.2.3 From 3c1dce0d9ba408bfe311132e3f287453537dded0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Oct 2013 05:05:37 +0000 Subject: fix for BM_faces_join_pair() making the assumption that only the 2 faces use an edge, face winding could be flipped incorrectly. also remove search for shared edges - all callers pass the edge in. --- source/blender/bmesh/intern/bmesh_mods.c | 49 ++++++++------------------------ 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index eb83f891038..4dc155e68c2 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -231,49 +231,24 @@ bool BM_disk_dissolve(BMesh *bm, BMVert *v) * to be reconsidered. * * If the windings do not match the winding of the new face will follow - * \a f1's winding (i.e. \a f2 will be reversed before the join). + * \a f_a's winding (i.e. \a f_b will be reversed before the join). * * \return pointer to the combined face */ -BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e, const bool do_del) +BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f_a, BMFace *f_b, BMEdge *e, const bool do_del) { - BMLoop *l1, *l2; - BMEdge *jed = NULL; - BMFace *faces[2] = {f1, f2}; - - jed = e; - if (!jed) { - BMLoop *l_first; - /* search for an edge that has both these faces in its radial cycle */ - l1 = l_first = BM_FACE_FIRST_LOOP(f1); - do { - if (l1->radial_next->f == f2) { - jed = l1->e; - break; - } - } while ((l1 = l1->next) != l_first); - } + BMFace *faces[2] = {f_a, f_b}; - if (UNLIKELY(!jed)) { - BMESH_ASSERT(0); - return NULL; - } - - l1 = jed->l; - - if (UNLIKELY(!l1)) { - BMESH_ASSERT(0); - return NULL; - } - - l2 = l1->radial_next; - if (l1->v == l2->v) { - bmesh_loop_reverse(bm, f2); - } + BMLoop *l_a = BM_face_edge_share_loop(f_a, e); + BMLoop *l_b = BM_face_edge_share_loop(f_b, e); - f1 = BM_faces_join(bm, faces, 2, do_del); + BLI_assert(l_a && l_b); + + if (l_a->v == l_b->v) { + bmesh_loop_reverse(bm, f_b); + } - return f1; + return BM_faces_join(bm, faces, 2, do_del); } /** @@ -1074,7 +1049,7 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const bool ccw, const short check_f f_hflag_prev_2 = l2->f->head.hflag; /* don't delete the edge, manually remove the edge after so we can copy its attributes */ - f = BM_faces_join_pair(bm, l1->f, l2->f, NULL, true); + f = BM_faces_join_pair(bm, l1->f, l2->f, e, true); if (f == NULL) { return NULL; -- cgit v1.2.3 From a4203573cb5c60dbdc0518251546814980973469 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Oct 2013 06:48:56 +0000 Subject: fix for metaball editmode duplicate with PET --- source/blender/editors/include/ED_mball.h | 1 + source/blender/editors/metaball/mball_edit.c | 17 ----------------- source/blender/editors/metaball/mball_ops.c | 15 ++++++++++++++- source/blender/editors/space_api/spacetypes.c | 1 + 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index 1842b84a3f5..22aec69838b 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -37,6 +37,7 @@ struct Object; struct wmKeyConfig; void ED_operatortypes_metaball(void); +void ED_operatormacros_metaball(void); void ED_keymap_metaball(struct wmKeyConfig *keyconf); struct MetaElem *add_metaball_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], float dia, int type); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 24c46bd7966..7130166ba0e 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -441,19 +441,6 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int duplicate_metaelems_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) -{ - int retv = duplicate_metaelems_exec(C, op); - - if (retv == OPERATOR_FINISHED) { - RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); - WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); - } - - return retv; -} - - void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) { /* identifiers */ @@ -463,14 +450,10 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) /* callback functions */ ot->exec = duplicate_metaelems_exec; - ot->invoke = duplicate_metaelems_invoke; ot->poll = ED_operator_editmball; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* to give to transform */ - RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); } /***************************** Delete operator *****************************/ diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index 74d47d9db17..249e7361cc0 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -56,6 +56,19 @@ void ED_operatortypes_metaball(void) WM_operatortype_append(MBALL_OT_select_random_metaelems); } +void ED_operatormacros_metaball(void) +{ + wmOperatorType *ot; + wmOperatorTypeMacro *otmacro; + + ot = WM_operatortype_append_macro("MBALL_OT_duplicate_move", "Duplicate", + "Make copies of the selected bones within the same armature and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); + WM_operatortype_macro_define(ot, "MBALL_OT_duplicate_metaelems"); + otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); + RNA_enum_set(otmacro->ptr, "proportional", 0); +} + void ED_keymap_metaball(wmKeyConfig *keyconf) { wmKeyMap *keymap; @@ -74,7 +87,7 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", DELKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "MBALL_OT_duplicate_metaelems", DKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "MBALL_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index bb0521d6589..e2262398a52 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -133,6 +133,7 @@ void ED_spacetypes_init(void) * maybe we'll need to have them go after python operators too? */ ED_operatormacros_armature(); ED_operatormacros_mesh(); + ED_operatormacros_metaball(); ED_operatormacros_node(); ED_operatormacros_object(); ED_operatormacros_file(); -- cgit v1.2.3 From 4a15df15711628c65282cc4d5a1dfd852776e014 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Oct 2013 08:01:33 +0000 Subject: remove null checks for macro definitions, if these fail then something is broken elsewhere, better not fail silently. --- source/blender/editors/armature/armature_ops.c | 32 ++++++++++-------------- source/blender/editors/space_action/action_ops.c | 9 +++---- source/blender/editors/space_graph/graph_ops.c | 8 +++--- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 0090522d1e1..3c41765034d 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -165,37 +165,31 @@ void ED_operatormacros_armature(void) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - + ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate", "Make copies of the selected bones within the same armature and move them", OPTYPE_UNDO | OPTYPE_REGISTER); - if (ot) { - WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate"); - otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); - } + WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate"); + otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); + RNA_enum_set(otmacro->ptr, "proportional", 0); ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", "Create new bones from the selected joints and move them", OPTYPE_UNDO | OPTYPE_REGISTER); - if (ot) { - otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); - RNA_boolean_set(otmacro->ptr, "forked", FALSE); - otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); - } - + otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); + RNA_boolean_set(otmacro->ptr, "forked", FALSE); + otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); + RNA_enum_set(otmacro->ptr, "proportional", 0); + /* XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate? * that would require fixing a properties bug 19733 */ ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", "Create new bones from the selected joints and move them", OPTYPE_UNDO | OPTYPE_REGISTER); - if (ot) { - otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); - RNA_boolean_set(otmacro->ptr, "forked", TRUE); - otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_enum_set(otmacro->ptr, "proportional", 0); - } + otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); + RNA_boolean_set(otmacro->ptr, "forked", TRUE); + otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); + RNA_enum_set(otmacro->ptr, "proportional", 0); } void ED_keymap_armature(wmKeyConfig *keyconf) diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 2ef61fa580a..346ffcbc3e2 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -97,12 +97,9 @@ void ED_operatormacros_action(void) ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate", "Make a copy of all selected keyframes and move them", OPTYPE_UNDO | OPTYPE_REGISTER); - if (ot) { - WM_operatortype_macro_define(ot, "ACTION_OT_duplicate"); - otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); - RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); - } - + WM_operatortype_macro_define(ot, "ACTION_OT_duplicate"); + otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); + RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); } /* ************************** registration - keymaps **********************************/ diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 6dc3f7ac3dc..74114f8ca9d 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -254,11 +254,9 @@ void ED_operatormacros_graph(void) ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate", "Make a copy of all selected keyframes and move them", OPTYPE_UNDO | OPTYPE_REGISTER); - if (ot) { - WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate"); - otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); - RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); - } + WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate"); + otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); + RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); } -- cgit v1.2.3 From 9f32e83175448eaf654cc228caa70065d63df13a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 26 Oct 2013 13:22:38 +0000 Subject: Weighted tracks Added a weight slider to track which defines how much particular track affects in a final reconstruction. This weight is for sure animateable. Currently it affects on BA step only which in most cases will work just fine. The usecase of this slider is to have it set to 1.0 most of the time where the track is good, but blend it's weight down to 0 when tracker looses the track. This will prevent camera from jump. Tutorial is to be done by Sebastian. --- extern/libmv/libmv-capi.cc | 4 +- extern/libmv/libmv-capi.h | 2 +- extern/libmv/libmv-capi_stub.cc | 2 +- extern/libmv/libmv/simple_pipeline/bundle.cc | 56 +++++++++++++--------- extern/libmv/libmv/simple_pipeline/modal_solver.cc | 27 ++++++----- extern/libmv/libmv/simple_pipeline/tracks.cc | 6 +-- extern/libmv/libmv/simple_pipeline/tracks.h | 13 ++++- release/scripts/startup/bl_ui/space_clip.py | 2 + source/blender/blenkernel/BKE_tracking.h | 2 +- source/blender/blenkernel/intern/tracking.c | 27 +++++++++-- source/blender/blenloader/intern/readfile.c | 21 ++++++++ source/blender/editors/space_clip/clip_utils.c | 9 +++- source/blender/editors/space_clip/tracking_ops.c | 2 +- source/blender/makesdna/DNA_tracking_types.h | 11 +++++ source/blender/makesrna/intern/rna_tracking.c | 6 +++ 15 files changed, 141 insertions(+), 49 deletions(-) diff --git a/extern/libmv/libmv-capi.cc b/extern/libmv/libmv-capi.cc index 91a3b845815..0585bd3e8ac 100644 --- a/extern/libmv/libmv-capi.cc +++ b/extern/libmv/libmv-capi.cc @@ -393,9 +393,9 @@ void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks) LIBMV_OBJECT_DELETE(libmv_tracks, Tracks); } -void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y) +void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y, double weight) { - ((libmv::Tracks*) libmv_tracks)->Insert(image, track, x, y); + ((libmv::Tracks*) libmv_tracks)->Insert(image, track, x, y, weight); } /* ************ Reconstruction ************ */ diff --git a/extern/libmv/libmv-capi.h b/extern/libmv/libmv-capi.h index 9541f411ba0..13cc3ae8499 100644 --- a/extern/libmv/libmv-capi.h +++ b/extern/libmv/libmv-capi.h @@ -73,7 +73,7 @@ void libmv_samplePlanarPatch(const float *image, int width, int height, /* Tracks */ struct libmv_Tracks *libmv_tracksNew(void); void libmv_tracksDestroy(struct libmv_Tracks *libmv_tracks); -void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y); +void libmv_tracksInsert(struct libmv_Tracks *libmv_tracks, int image, int track, double x, double y, double weight); /* Reconstruction */ #define LIBMV_REFINE_FOCAL_LENGTH (1 << 0) diff --git a/extern/libmv/libmv-capi_stub.cc b/extern/libmv/libmv-capi_stub.cc index e6d3753961b..bda9605b422 100644 --- a/extern/libmv/libmv-capi_stub.cc +++ b/extern/libmv/libmv-capi_stub.cc @@ -85,7 +85,7 @@ struct libmv_Tracks *libmv_tracksNew(void) } void libmv_tracksInsert(struct libmv_Tracks * /*libmv_tracks*/, int /*image*/, - int /*track*/, double /*x*/, double /*y*/) + int /*track*/, double /*x*/, double /*y*/, double /*weight*/) { } diff --git a/extern/libmv/libmv/simple_pipeline/bundle.cc b/extern/libmv/libmv/simple_pipeline/bundle.cc index c778c11b3f6..e7887256892 100644 --- a/extern/libmv/libmv/simple_pipeline/bundle.cc +++ b/extern/libmv/libmv/simple_pipeline/bundle.cc @@ -60,8 +60,11 @@ namespace { // // This functor uses a radial distortion model. struct OpenCVReprojectionError { - OpenCVReprojectionError(const double observed_x, const double observed_y) - : observed_x(observed_x), observed_y(observed_y) {} + OpenCVReprojectionError(const double observed_x, + const double observed_y, + const double weight) + : observed_x_(observed_x), observed_y_(observed_y), + weight_(weight) {} template bool operator()(const T* const intrinsics, @@ -112,13 +115,14 @@ struct OpenCVReprojectionError { &predicted_y); // The error is the difference between the predicted and observed position. - residuals[0] = predicted_x - T(observed_x); - residuals[1] = predicted_y - T(observed_y); + residuals[0] = (predicted_x - T(observed_x_)) * weight_; + residuals[1] = (predicted_y - T(observed_y_)) * weight_; return true; } - const double observed_x; - const double observed_y; + const double observed_x_; + const double observed_y_; + const double weight_; }; // Print a message to the log which camera intrinsics are gonna to be optimixed. @@ -378,25 +382,31 @@ void EuclideanBundleCommonIntrinsics(const Tracks &tracks, // camera translaiton. double *current_camera_R_t = &all_cameras_R_t[camera->image](0); - problem.AddResidualBlock(new ceres::AutoDiffCostFunction< - OpenCVReprojectionError, 2, 8, 6, 3>( - new OpenCVReprojectionError( - marker.x, - marker.y)), - NULL, - ceres_intrinsics, - current_camera_R_t, - &point->X(0)); - - // We lock the first camera to better deal with scene orientation ambiguity. - if (!have_locked_camera) { - problem.SetParameterBlockConstant(current_camera_R_t); - have_locked_camera = true; - } + // Skip residual block for markers which does have absolutely + // no affect on the final solution. + // This way ceres is not gonna to go crazy. + if (marker.weight != 0.0) { + problem.AddResidualBlock(new ceres::AutoDiffCostFunction< + OpenCVReprojectionError, 2, 8, 6, 3>( + new OpenCVReprojectionError( + marker.x, + marker.y, + marker.weight)), + NULL, + ceres_intrinsics, + current_camera_R_t, + &point->X(0)); + + // We lock the first camera to better deal with scene orientation ambiguity. + if (!have_locked_camera) { + problem.SetParameterBlockConstant(current_camera_R_t); + have_locked_camera = true; + } - if (bundle_constraints & BUNDLE_NO_TRANSLATION) { - problem.SetParameterization(current_camera_R_t, + if (bundle_constraints & BUNDLE_NO_TRANSLATION) { + problem.SetParameterization(current_camera_R_t, constant_translation_parameterization); + } } num_residuals++; diff --git a/extern/libmv/libmv/simple_pipeline/modal_solver.cc b/extern/libmv/libmv/simple_pipeline/modal_solver.cc index 90dfde15660..caccce68cbe 100644 --- a/extern/libmv/libmv/simple_pipeline/modal_solver.cc +++ b/extern/libmv/libmv/simple_pipeline/modal_solver.cc @@ -57,8 +57,10 @@ void ModalSolverLogProress(ProgressUpdateCallback *update_callback, struct ModalReprojectionError { ModalReprojectionError(double observed_x, double observed_y, + const double weight, const Vec3 &bundle) - : observed_x(observed_x), observed_y(observed_y), bundle(bundle) { } + : observed_x_(observed_x), observed_y_(observed_y), + weight_(weight), bundle_(bundle) { } template bool operator()(const T* quaternion, // Rotation quaternion @@ -68,9 +70,9 @@ struct ModalReprojectionError { // Convert bundle position from double to T. T X[3]; - X[0] = T(bundle(0)); - X[1] = T(bundle(1)); - X[2] = T(bundle(2)); + X[0] = T(bundle_(0)); + X[1] = T(bundle_(1)); + X[2] = T(bundle_(2)); // Compute projective coordinates: x = RX. T x[3]; @@ -84,15 +86,16 @@ struct ModalReprojectionError { // The error is the difference between reprojected // and observed marker position. - residuals[0] = xn - T(observed_x); - residuals[1] = yn - T(observed_y); + residuals[0] = xn - T(observed_x_); + residuals[1] = yn - T(observed_y_); return true; } - double observed_x; - double observed_y; - Vec3 bundle; + double observed_x_; + double observed_y_; + double weight_; + Vec3 bundle_; }; } // namespace @@ -180,11 +183,13 @@ void ModalSolver(const Tracks &tracks, Marker &marker = all_markers[i]; EuclideanPoint *point = reconstruction->PointForTrack(marker.track); - if (point) { + if (point && marker.weight != 0.0) { problem.AddResidualBlock(new ceres::AutoDiffCostFunction< ModalReprojectionError, 2, /* num_residuals */ - 4>(new ModalReprojectionError(marker.x, marker.y, + 4>(new ModalReprojectionError(marker.x, + marker.y, + marker.weight, point->X)), NULL, &quaternion(0)); diff --git a/extern/libmv/libmv/simple_pipeline/tracks.cc b/extern/libmv/libmv/simple_pipeline/tracks.cc index f9e50d20af9..d5d009708ba 100644 --- a/extern/libmv/libmv/simple_pipeline/tracks.cc +++ b/extern/libmv/libmv/simple_pipeline/tracks.cc @@ -34,7 +34,7 @@ Tracks::Tracks(const Tracks &other) { Tracks::Tracks(const vector &markers) : markers_(markers) {} -void Tracks::Insert(int image, int track, double x, double y) { +void Tracks::Insert(int image, int track, double x, double y, double weight) { // TODO(keir): Wow, this is quadratic for repeated insertions. Fix this by // adding a smarter data structure like a set<>. for (int i = 0; i < markers_.size(); ++i) { @@ -45,7 +45,7 @@ void Tracks::Insert(int image, int track, double x, double y) { return; } } - Marker marker = { image, track, x, y }; + Marker marker = { image, track, x, y, weight }; markers_.push_back(marker); } @@ -122,7 +122,7 @@ Marker Tracks::MarkerInImageForTrack(int image, int track) const { return markers_[i]; } } - Marker null = { -1, -1, -1, -1 }; + Marker null = { -1, -1, -1, -1, 0.0 }; return null; } diff --git a/extern/libmv/libmv/simple_pipeline/tracks.h b/extern/libmv/libmv/simple_pipeline/tracks.h index f9af3ada45b..e2f8cf6b459 100644 --- a/extern/libmv/libmv/simple_pipeline/tracks.h +++ b/extern/libmv/libmv/simple_pipeline/tracks.h @@ -33,14 +33,20 @@ namespace libmv { in the image identified by \a image. All markers for to the same target form a track identified by a common \a track number. + \a weight is used by bundle adjustment and weight means how much the + track affects on a final solution. + \note Markers are typically aggregated with the help of the \l Tracks class. \sa Tracks */ +// TODO(sergey): Consider using comment for every member separately +// instead of having one giantic comment block. struct Marker { int image; int track; double x, y; + double weight; }; /*! @@ -72,9 +78,14 @@ class Tracks { \a image and \a track are the keys used to retrieve the markers with the other methods in this class. + \a weight is used by bundle adjustment and weight means how much the + track affects on a final solution. + \note To get an identifier for a new track, use \l MaxTrack() + 1. */ - void Insert(int image, int track, double x, double y); + // TODO(sergey): Consider using InsetWeightedMarker istead of using + // stupid default value? + void Insert(int image, int track, double x, double y, double weight = 1.0); /// Returns all the markers. vector AllMarkers() const; diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 3247d2f5e4c..3db8697a457 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -569,6 +569,8 @@ class CLIP_PT_track(CLIP_PT_tracking_panel, Panel): if act_track.use_custom_color: row.prop(act_track, "color", text="") + layout.prop(act_track, "weight") + if act_track.has_bundle: label_text = "Average Error: %.4f" % (act_track.average_error) layout.label(text=label_text) diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 51f97180ddb..94e530529ec 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -225,7 +225,7 @@ void BKE_tracking_homography_between_two_quads(/*const*/ float reference_corners bool BKE_tracking_reconstruction_check(struct MovieTracking *tracking, struct MovieTrackingObject *object, char *error_msg, int error_size); -struct MovieReconstructContext *BKE_tracking_reconstruction_context_new(struct MovieTracking *tracking, +struct MovieReconstructContext *BKE_tracking_reconstruction_context_new(struct MovieClip *clip, struct MovieTrackingObject *object, int keyframe1, int keyframe2, int width, int height); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 0ce4d54a74c..d519b93f963 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_gpencil_types.h" #include "DNA_camera_types.h" #include "DNA_movieclip_types.h" @@ -53,6 +54,7 @@ #include "BLF_translation.h" +#include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_tracking.h" #include "BKE_movieclip.h" @@ -62,6 +64,8 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "RNA_access.h" + #include "raskter.h" #include "libmv-capi.h" @@ -590,6 +594,7 @@ MovieTrackingTrack *BKE_tracking_track_add(MovieTracking *tracking, ListBase *tr track->frames_limit = settings->default_frames_limit; track->flag = settings->default_flag; track->algorithm_flag = settings->default_algorithm_flag; + track->weight = 1.0f; memset(&marker, 0, sizeof(marker)); marker.pos[0] = x; @@ -3467,7 +3472,7 @@ typedef struct ReconstructProgressData { } ReconstructProgressData; /* Create new libmv Tracks structure from blender's tracks list. */ -static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, int height) +static struct libmv_Tracks *libmv_tracks_new(MovieClip *clip, ListBase *tracksbase, int width, int height) { int tracknr = 0; MovieTrackingTrack *track; @@ -3475,15 +3480,28 @@ static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, in track = tracksbase->first; while (track) { + FCurve *weight_fcurve; int a = 0; + weight_fcurve = id_data_find_fcurve(&clip->id, track, &RNA_MovieTrackingTrack, + "weight", 0, NULL); + for (a = 0; a < track->markersnr; a++) { MovieTrackingMarker *marker = &track->markers[a]; if ((marker->flag & MARKER_DISABLED) == 0) { + float weight = track->weight; + + if (weight_fcurve) { + int scene_framenr = + BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr); + weight = evaluate_fcurve(weight_fcurve, scene_framenr); + } + libmv_tracksInsert(tracks, marker->framenr, tracknr, (marker->pos[0] + track->offset[0]) * width, - (marker->pos[1] + track->offset[1]) * height); + (marker->pos[1] + track->offset[1]) * height, + weight); } } @@ -3730,9 +3748,10 @@ bool BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObj * clip datablock, so editing this clip is safe during * reconstruction job is in progress. */ -MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *tracking, MovieTrackingObject *object, +MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieClip *clip, MovieTrackingObject *object, int keyframe1, int keyframe2, int width, int height) { + MovieTracking *tracking = &clip->tracking; MovieReconstructContext *context = MEM_callocN(sizeof(MovieReconstructContext), "MovieReconstructContext data"); MovieTrackingCamera *camera = &tracking->camera; ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object); @@ -3793,7 +3812,7 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking * context->sfra = sfra; context->efra = efra; - context->tracks = libmv_tracks_new(tracksbase, width, height * aspy); + context->tracks = libmv_tracks_new(clip, tracksbase, width, height * aspy); context->keyframe1 = keyframe1; context->keyframe2 = keyframe2; context->refine_flags = reconstruct_refine_intrinsics_get_flags(tracking, object); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e6804725587..51158fc5321 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9735,6 +9735,27 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + + if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight")) { + MovieClip *clip; + for (clip = main->movieclip.first; clip; clip = clip->id.next) { + MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *tracking_object; + for (tracking_object = tracking->objects.first; + tracking_object; + tracking_object = tracking_object->next) + { + ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object); + MovieTrackingTrack *track; + for (track = tracksbase->first; + track; + track = track->next) + { + track->weight = 1.0f; + } + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index dfd2b6e259d..060531ae82c 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -37,7 +37,9 @@ #include "BLI_utildefines.h" #include "BLI_math.h" #include "BLI_listbase.h" +#include "BLI_string.h" +#include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_movieclip.h" #include "BKE_tracking.h" @@ -184,8 +186,8 @@ void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track) MovieTrackingPlaneTrack *plane_track, *next_plane_track; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking); - bool has_bundle = false, update_stab = false; + char track_name_escaped[MAX_NAME], prefix[MAX_NAME * 2]; if (track == act_track) tracking->act_track = NULL; @@ -245,6 +247,11 @@ void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track) } } + /* Delete f-curves associated with the track (such as weight, i.e.) */ + BLI_strescape(track_name_escaped, track->name, sizeof(track_name_escaped)); + BLI_snprintf(prefix, sizeof(prefix), "tracks[\"%s\"]", track_name_escaped); + BKE_animdata_fix_paths_remove(&clip->id, prefix); + BKE_tracking_track_free(track); BLI_freelinkN(tracksbase, track); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 246ea7fe140..51d7bc3139a 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1550,7 +1550,7 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op scj->reports = op->reports; scj->user = sc->user; - scj->context = BKE_tracking_reconstruction_context_new(tracking, object, + scj->context = BKE_tracking_reconstruction_context_new(clip, object, object->keyframe1, object->keyframe2, width, height); tracking->stats = MEM_callocN(sizeof(MovieTrackingStats), "solve camera stats"); diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 65d36adde18..ad9a2ea169c 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -142,6 +142,17 @@ typedef struct MovieTrackingTrack { float minimum_correlation; /* minimal correlation which is still treated as successful tracking */ struct bGPdata *gpd; /* grease-pencil data */ + + /* Weight of this track. + * + * Weight defines how much the track affects on the final reconstruction, + * usually gets animated in a way so when track has just appeared it's + * weight is zero and then it gets faded up. + * + * Used to prevent jumps of the camera when tracks are appearing or + * disappearing. + */ + float weight, pad; } MovieTrackingTrack; typedef struct MovieTrackingPlaneMarker { diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 8e26bb96a1f..f62778a5c1e 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1339,6 +1339,12 @@ static void rna_def_trackingTrack(BlenderRNA *brna) RNA_def_property_struct_type(prop, "GreasePencil"); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this track"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); + + /* weight */ + prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "weight"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Weight", "How much this track affects on a final solution"); } static void rna_def_trackingPlaneMarker(BlenderRNA *brna) -- cgit v1.2.3 From 01da2c0e53e8a3faf08375027ced7e7fb153726b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Oct 2013 22:38:12 +0000 Subject: fix [#37195] particles crash with viewport render --- build_files/scons/tools/Blender.py | 9 +++++++++ source/blender/render/intern/source/convertblender.c | 8 +++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index f181f290104..9bce91ba9a5 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -675,6 +675,15 @@ def AppIt(target=None, source=None, env=None): cmd = 'unzip -q %s/release/%s -d %s/%s.app/Contents/MacOS/%s/python/'%(libdir,python_zip,installdir,binary,VERSION) commands.getoutput(cmd) + if env['XCODE_CUR_VER'] >= 5: + # For OSX 10.9/Xcode5 subcomponents also must be codesigned. To make this work we need a plist in the versioned libdir + # We copy for now the plist from main bundle, note: Blender must be run once before codesigning to have the py caches generated and taken into account + # After this we can run: codesign -s IDENTITY blender.app --deep + cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/Resources/'%(installdir,binary, VERSION) + commands.getoutput(cmd) + cmd = 'cp %s/%s.app/Contents/Info.plist %s/%s.app/Contents/MacOS/%s/Resources'%(installdir,binary,installdir,binary, VERSION) + commands.getoutput(cmd) + cmd = 'chmod +x %s/%s.app/Contents/MacOS/%s'%(installdir,binary, binary) commands.getoutput(cmd) cmd = 'find %s/%s.app -name .svn -prune -exec rm -rf {} \;'%(installdir, binary) diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 8e90ddbb42b..b4873e7d310 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1836,9 +1836,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if (strandbuf) { int orignum = (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, cpa->num) : cpa->num; - if (orignum > sbound - strandbuf->bound) { - sbound= strandbuf->bound + orignum; - sbound->start= sbound->end= obr->totstrand; + if ((orignum > sbound - strandbuf->bound) && + (orignum < strandbuf->totbound)) + { + sbound = &strandbuf->bound[orignum]; + sbound->start = sbound->end = obr->totstrand; } } } -- cgit v1.2.3 From aed672ac1e1363b3fd4a7b5cbd415f5eda167306 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Sun, 27 Oct 2013 03:31:19 +0000 Subject: Border select for sculpting, using B shortcut, warmup for more advanced masking, like lasso selection. --- source/blender/editors/include/ED_sculpt.h | 4 ++ source/blender/editors/sculpt_paint/paint_intern.h | 1 + source/blender/editors/sculpt_paint/paint_mask.c | 71 ++++++++++++++++++++++ .../blender/editors/space_view3d/view3d_select.c | 6 +- 4 files changed, 78 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h index a50a8a50eaa..e85f11e5b78 100644 --- a/source/blender/editors/include/ED_sculpt.h +++ b/source/blender/editors/include/ED_sculpt.h @@ -37,6 +37,8 @@ struct Object; struct RegionView3D; struct wmKeyConfig; struct wmWindowManager; +struct ViewContext; +struct rcti; /* sculpt.c */ void ED_operatortypes_sculpt(void); @@ -48,6 +50,8 @@ void ED_sculpt_get_average_stroke(struct Object *ob, float stroke[3]); int ED_sculpt_minmax(struct bContext *C, float min[3], float max[3]); int ED_sculpt_mask_layers_ensure(struct Object *ob, struct MultiresModifierData *mmd); +int do_sculpt_mask_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend); + enum { ED_SCULPT_MASK_LAYER_CALC_VERT = (1 << 0), ED_SCULPT_MASK_LAYER_CALC_LOOP = (1 << 1) diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 2545328ec65..86b223ec2a0 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -264,5 +264,6 @@ typedef enum { } PaintMaskFloodMode; void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot); +void PAINT_OT_mask_box_fill(struct wmOperatorType *ot); #endif /* __PAINT_INTERN_H__ */ diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 8767b080355..13f11c8a816 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -36,6 +36,10 @@ #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "BIF_glutil.h" + +#include "BLI_math_matrix.h" +#include "BLI_math_geom.h" #include "BLI_utildefines.h" #include "BKE_pbvh.h" #include "BKE_ccg.h" @@ -53,6 +57,7 @@ #include "ED_screen.h" #include "ED_sculpt.h" +#include "ED_view3d.h" #include "bmesh.h" @@ -148,3 +153,69 @@ void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot) RNA_def_float(ot->srna, "value", 0, 0, 1, "Value", "Mask level to use when mode is 'Value'; zero means no masking and one is fully masked", 0, 1); } + +/* Box select, operator is VIEW3D_OT_select_border, defined in view3d_select.c */ + +static int is_effected(float planes[4][4], const float co[3]) +{ + return isect_point_planes_v3(planes, 4, co); +} + +int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNUSED(extend)) +{ + BoundBox bb; + bglMats mats = {{0}}; + float clip_planes[4][4]; + ARegion *ar = vc->ar; + struct Scene *scene = vc->scene; + Object *ob = vc->obact; + struct MultiresModifierData *mmd = sculpt_multires_active(scene, ob); + PaintMaskFloodMode mode; + float value; + DerivedMesh *dm; + PBVH *pbvh; + PBVHNode **nodes; + int totnode, i; + + mode = PAINT_MASK_FLOOD_VALUE; + value = select ? 1.0 : 0.0; + + /* transform the */ + view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, &mats); + ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect); + mul_m4_fl(clip_planes, -1.0f); + + ED_sculpt_mask_layers_ensure(ob, mmd); + + dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); + pbvh = dm->getPBVH(ob, dm); + ob->sculpt->pbvh = pbvh; + + BKE_pbvh_search_gather(pbvh, BKE_pbvh_node_planes_contain_AABB, clip_planes, &nodes, &totnode); + + sculpt_undo_push_begin("Mask box fill"); + + for (i = 0; i < totnode; i++) { + PBVHVertexIter vi; + + sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + + BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { + if (is_effected(clip_planes, vi.co)) + mask_flood_fill_set_elem(vi.mask, mode, value); + } BKE_pbvh_vertex_iter_end; + + BKE_pbvh_node_mark_update(nodes[i]); + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + } + + sculpt_undo_push_end(); + + if (nodes) + MEM_freeN(nodes); + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index ff17c2eedc1..a6ef70a5e33 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -89,6 +89,7 @@ #include "ED_mesh.h" #include "ED_object.h" #include "ED_screen.h" +#include "ED_sculpt.h" #include "ED_mball.h" #include "UI_interface.h" @@ -272,9 +273,6 @@ static int view3d_selectable_data(bContext *C) } } else { - if (ob->mode & OB_MODE_SCULPT) { - return 0; - } if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) && !paint_facesel_test(ob) && !paint_vertsel_test(ob)) { @@ -2125,7 +2123,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) } else { /* no editmode, unified for bones and objects */ if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) { - /* pass */ + ret = do_sculpt_mask_box_select(&vc, &rect, select, extend); } else if (vc.obact && paint_facesel_test(vc.obact)) { ret = do_paintface_box_select(&vc, &rect, select, extend); -- cgit v1.2.3 From e293a0b1536520de345a6b9aa467b1de832a8fad Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 27 Oct 2013 08:19:08 +0000 Subject: Update OpenEXR to 2.0.1, this seems to fix some issues. I *really* have to go back over all our patches in this script and try to port them back in respective projects! --- build_files/build_environment/install_deps.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index dc21f85e85c..6daa3831c08 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -200,10 +200,10 @@ OCIO_VERSION_MIN="1.0" OCIO_FORCE_REBUILD=false OCIO_SKIP=false -OPENEXR_VERSION="2.0.0" +OPENEXR_VERSION="2.0.1" OPENEXR_SOURCE="http://download.savannah.nongnu.org/releases/openexr/openexr-$OPENEXR_VERSION.tar.gz" OPENEXR_VERSION_MIN="2.0" -ILMBASE_VERSION="2.0.0" +ILMBASE_VERSION="2.0.1" ILMBASE_SOURCE="http://download.savannah.nongnu.org/releases/openexr/ilmbase-$ILMBASE_VERSION.tar.gz" OPENEXR_FORCE_REBUILD=false OPENEXR_SKIP=false @@ -855,7 +855,7 @@ clean_ILMBASE() { compile_ILMBASE() { # To be changed each time we make edits that would modify the compiled result! - ilmbase_magic=5 + ilmbase_magic=6 _init_ilmbase # Clean install if needed! @@ -958,7 +958,7 @@ clean_OPENEXR() { compile_OPENEXR() { # To be changed each time we make edits that would modify the compiled result! - openexr_magic=10 + openexr_magic=11 # Clean install if needed! magic_compile_check openexr-$OPENEXR_VERSION $openexr_magic @@ -1033,12 +1033,13 @@ compile_OPENEXR() { TARGET_LINK_LIBRARIES ( IlmImfFuzzTest IlmImf Iex Imath Half IlmThread ${PTHREAD_LIB} ${Z_LIB}) --- a/IlmImfTest/CMakeLists.txt +++ b/IlmImfTest/CMakeLists.txt -@@ -19,22 +19,26 @@ +@@ -19,22 +19,28 @@ testCustomAttributes.cpp testDeepScanLineBasic.cpp testDeepScanLineHuge.cpp + testDeepScanLineMultipleRead.cpp testDeepTiledBasic.cpp ++ testBadTypeAttributes.cpp testExistingStreams.cpp + testFutureProofing.cpp testHuf.cpp @@ -1056,6 +1057,7 @@ compile_OPENEXR() { testMultiView.cpp testNativeFormat.cpp + testOptimized.cpp ++ testOptimizedInterleavePatterns.cpp + testPartHelper.cpp testPreviewImage.cpp testRgba.cpp -- cgit v1.2.3 From dee671276dcda464dab6dce6a3904e7f373f8d88 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Oct 2013 10:01:35 +0000 Subject: rename BM_vert_at_index -> BM_vert_at_index_find (since this searches the mempool). needed for other changes - coming. --- source/blender/bmesh/intern/bmesh_mesh.c | 6 +++--- source/blender/bmesh/intern/bmesh_mesh.h | 6 +++--- source/blender/editors/mesh/editmesh_knife.c | 2 +- source/blender/editors/mesh/editmesh_select.c | 12 ++++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index cc2324ba34a..d6d846e44e4 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -829,17 +829,17 @@ void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx) BLI_ghash_free(fptr_map, NULL, NULL); } -BMVert *BM_vert_at_index(BMesh *bm, const int index) +BMVert *BM_vert_at_index_find(BMesh *bm, const int index) { return BLI_mempool_findelem(bm->vpool, index); } -BMEdge *BM_edge_at_index(BMesh *bm, const int index) +BMEdge *BM_edge_at_index_find(BMesh *bm, const int index) { return BLI_mempool_findelem(bm->epool, index); } -BMFace *BM_face_at_index(BMesh *bm, const int index) +BMFace *BM_face_at_index_find(BMesh *bm, const int index) { return BLI_mempool_findelem(bm->fpool, index); } diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h index 583b1589290..23429ec3252 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.h +++ b/source/blender/bmesh/intern/bmesh_mesh.h @@ -49,9 +49,9 @@ int BM_mesh_elem_count(BMesh *bm, const char htype); void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx); -BMVert *BM_vert_at_index(BMesh *bm, const int index); -BMEdge *BM_edge_at_index(BMesh *bm, const int index); -BMFace *BM_face_at_index(BMesh *bm, const int index); +BMVert *BM_vert_at_index_find(BMesh *bm, const int index); +BMEdge *BM_edge_at_index_find(BMesh *bm, const int index); +BMFace *BM_face_at_index_find(BMesh *bm, const int index); typedef struct BMAllocTemplate { int totvert, totedge, totloop, totface; diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index b0dc30d73f7..5d8851640e0 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -400,7 +400,7 @@ static void knife_start_cut(KnifeTool_OpData *kcd) BMVert *v0; knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs); - v0 = BM_vert_at_index(kcd->em->bm, 0); + v0 = BM_vert_at_index_find(kcd->em->bm, 0); if (v0) { closest_to_line_v3(kcd->prev.cage, v0->co, origin_ofs, origin); copy_v3_v3(kcd->prev.co, kcd->prev.cage); /*TODO: do we need this? */ diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index f975d801d10..92bd71e128a 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -392,7 +392,7 @@ static void findnearestvert__doClosest(void *userData, BMVert *eve, const float static bool findnearestvert__backbufIndextest(void *handle, unsigned int index) { BMEditMesh *em = (BMEditMesh *)handle; - BMVert *eve = BM_vert_at_index(em->bm, index - 1); + BMVert *eve = BM_vert_at_index_find(em->bm, index - 1); return !(eve && BM_elem_flag_test(eve, BM_ELEM_SELECT)); } /** @@ -420,7 +420,7 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const bool sel, c 0, NULL, NULL); } - eve = index ? BM_vert_at_index(vc->em->bm, index - 1) : NULL; + eve = index ? BM_vert_at_index_find(vc->em->bm, index - 1) : NULL; if (eve && distance < *r_dist) { *r_dist = distance; @@ -436,7 +436,7 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const bool sel, c static int lastSelectedIndex = 0; static BMVert *lastSelected = NULL; - if (lastSelected && BM_vert_at_index(vc->em->bm, lastSelectedIndex) != lastSelected) { + if (lastSelected && BM_vert_at_index_find(vc->em->bm, lastSelectedIndex) != lastSelected) { lastSelectedIndex = 0; lastSelected = NULL; } @@ -512,7 +512,7 @@ BMEdge *EDBM_edge_find_nearest(ViewContext *vc, float *r_dist) view3d_validate_backbuf(vc); index = view3d_sample_backbuf_rect(vc, vc->mval, 50, bm_solidoffs, bm_wireoffs, &distance, 0, NULL, NULL); - eed = index ? BM_edge_at_index(vc->em->bm, index - 1) : NULL; + eed = index ? BM_edge_at_index_find(vc->em->bm, index - 1) : NULL; if (eed && distance < *r_dist) { *r_dist = distance; @@ -585,7 +585,7 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist) view3d_validate_backbuf(vc); index = view3d_sample_backbuf(vc, vc->mval[0], vc->mval[1]); - efa = index ? BM_face_at_index(vc->em->bm, index - 1) : NULL; + efa = index ? BM_face_at_index_find(vc->em->bm, index - 1) : NULL; if (efa) { struct { float mval_fl[2]; float dist; BMFace *toFace; } data; @@ -612,7 +612,7 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist) static int lastSelectedIndex = 0; static BMFace *lastSelected = NULL; - if (lastSelected && BM_face_at_index(vc->em->bm, lastSelectedIndex) != lastSelected) { + if (lastSelected && BM_face_at_index_find(vc->em->bm, lastSelectedIndex) != lastSelected) { lastSelectedIndex = 0; lastSelected = NULL; } -- cgit v1.2.3 From 7be81ffaf51ce364b441ca6f5e2a8a63a2131aa7 Mon Sep 17 00:00:00 2001 From: Andrew Hale Date: Sun, 27 Oct 2013 12:16:45 +0000 Subject: Expose MVertSkin customdata layer in Python. This allows scripts to change parameters which are used by the skin modifier (such as radius) --- .../python/bmesh/bmesh_py_types_customdata.c | 14 +++ .../blender/python/bmesh/bmesh_py_types_meshdata.c | 110 +++++++++++++++++++++ .../blender/python/bmesh/bmesh_py_types_meshdata.h | 4 + 3 files changed, 128 insertions(+) diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c index 30902c615a1..0ba08f3e8d0 100644 --- a/source/blender/python/bmesh/bmesh_py_types_customdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c @@ -113,6 +113,9 @@ PyDoc_STRVAR(bpy_bmlayeraccess_collection__uv_doc, PyDoc_STRVAR(bpy_bmlayeraccess_collection__color_doc, "Accessor for vertex color layer.\n\ntype: :class:`BMLayerCollection`" ); +PyDoc_STRVAR(bpy_bmlayeraccess_collection__skin_doc, +"Accessor for skin layer.\n\ntype: :class:`BMLayerCollection`" +); #ifdef WITH_FREESTYLE PyDoc_STRVAR(bpy_bmlayeraccess_collection__freestyle_edge_doc, "Accessor for Freestyle edge layer.\n\ntype: :class:`BMLayerCollection`" @@ -192,6 +195,7 @@ static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = { {(char *)"shape", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__shape_doc, (void *)CD_SHAPEKEY}, {(char *)"bevel_weight", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__bevel_weight_doc, (void *)CD_BWEIGHT}, + {(char *)"skin", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)bpy_bmlayeraccess_collection__skin_doc, (void *)CD_MVERT_SKIN}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; @@ -1030,6 +1034,11 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer) ret = PyFloat_FromDouble(*(float *)value); break; } + case CD_MVERT_SKIN: + { + ret = BPy_BMVertSkin_CreatePyObject(value); + break; + } default: { ret = Py_NotImplemented; /* TODO */ @@ -1147,6 +1156,11 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj } break; } + case CD_MVERT_SKIN: + { + ret = BPy_BMVertSkin_AssignPyObject(value, py_value); + break; + } default: { PyErr_SetString(PyExc_AttributeError, "readonly / unsupported type"); diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index 06b11f02b2a..d554f33a77e 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -248,6 +248,115 @@ PyObject *BPy_BMLoopUV_CreatePyObject(struct MLoopUV *mloopuv) /* --- End Mesh Loop UV --- */ +/* Mesh Vert Skin + * ************ */ + +#define BPy_BMVertSkin_Check(v) (Py_TYPE(v) == &BPy_BMVertSkin_Type) + +typedef struct BPy_BMVertSkin { + PyObject_VAR_HEAD + MVertSkin *data; +} BPy_BMVertSkin; + +PyDoc_STRVAR(bpy_bmvertskin_radius_doc, +"Vert skin radii (as a 2D Vector).\n\n:type: :class:`mathutils.Vector`" +); +static PyObject *bpy_bmvertskin_radius_get(BPy_BMVertSkin *self, void *UNUSED(closure)) +{ + return Vector_CreatePyObject(self->data->radius, 2, Py_WRAP, NULL); +} + +static int bpy_bmvertskin_radius_set(BPy_BMVertSkin *self, PyObject *value, void *UNUSED(closure)) +{ + float tvec[2]; + if (mathutils_array_parse(tvec, 2, 2, value, "BMVertSkin.radius") != -1) { + copy_v2_v2(self->data->radius, tvec); + return 0; + } + else { + return -1; + } +} + +PyDoc_STRVAR(bpy_bmvertskin_flag__use_root_doc, +"Use as root vertex.\n\n:type: boolean" +); +PyDoc_STRVAR(bpy_bmvertskin_flag__use_loose_doc, +"Use loose vertex.\n\n:type: boolean" +); + +static PyObject *bpy_bmvertskin_flag_get(BPy_BMVertSkin *self, void *flag_p) +{ + const int flag = GET_INT_FROM_POINTER(flag_p); + return PyBool_FromLong(self->data->flag & flag); +} + +static int bpy_bmvertskin_flag_set(BPy_BMVertSkin *self, PyObject *value, void *flag_p) +{ + const int flag = GET_INT_FROM_POINTER(flag_p); + + switch (PyLong_AsLong(value)) { + case true: + self->data->flag |= flag; + return 0; + case false: + self->data->flag &= ~flag; + return 0; + default: + PyErr_SetString(PyExc_TypeError, + "expected a boolean type 0/1"); + return -1; + } +} + +/* XXX Todo: Make root settable, currently the code to disable all other verts as roots sits within the modifier */ +static PyGetSetDef bpy_bmvertskin_getseters[] = { + /* attributes match rna_mesh_gen */ + {(char *)"radius", (getter)bpy_bmvertskin_radius_get, (setter)bpy_bmvertskin_radius_set, (char *)bpy_bmvertskin_radius_doc, NULL}, + {(char *)"use_root", (getter)bpy_bmvertskin_flag_get, (setter)NULL, (char *)bpy_bmvertskin_flag__use_root_doc, (void *)MVERT_SKIN_ROOT}, + {(char *)"use_loose", (getter)bpy_bmvertskin_flag_get, (setter)bpy_bmvertskin_flag_set, (char *)bpy_bmvertskin_flag__use_loose_doc, (void *)MVERT_SKIN_LOOSE}, + + {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ +}; + +PyTypeObject BPy_BMVertSkin_Type = {{{0}}}; /* bm.loops.layers.uv.active */ + +static void bm_init_types_bmvertskin(void) +{ + BPy_BMVertSkin_Type.tp_basicsize = sizeof(BPy_BMVertSkin); + + BPy_BMVertSkin_Type.tp_name = "BMVertSkin"; + + BPy_BMVertSkin_Type.tp_doc = NULL; // todo + + BPy_BMVertSkin_Type.tp_getset = bpy_bmvertskin_getseters; + + BPy_BMVertSkin_Type.tp_flags = Py_TPFLAGS_DEFAULT; + + PyType_Ready(&BPy_BMVertSkin_Type); +} + +int BPy_BMVertSkin_AssignPyObject(struct MVertSkin *mvertskin, PyObject *value) +{ + if (UNLIKELY(!BPy_BMVertSkin_Check(value))) { + PyErr_Format(PyExc_TypeError, "expected BMVertSkin, not a %.200s", Py_TYPE(value)->tp_name); + return -1; + } + else { + *((MVertSkin *)mvertskin) = *(((BPy_BMVertSkin *)value)->data); + return 0; + } +} + +PyObject *BPy_BMVertSkin_CreatePyObject(struct MVertSkin *mvertskin) +{ + BPy_BMVertSkin *self = PyObject_New(BPy_BMVertSkin, &BPy_BMVertSkin_Type); + self->data = mvertskin; + return (PyObject *)self; +} + +/* --- End Mesh Vert Skin --- */ + /* Mesh Loop Color * *************** */ @@ -692,5 +801,6 @@ void BPy_BM_init_types_meshdata(void) bm_init_types_bmloopuv(); bm_init_types_bmloopcol(); bm_init_types_bmdvert(); + bm_init_types_bmvertskin(); } diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.h b/source/blender/python/bmesh/bmesh_py_types_meshdata.h index 8280e5c3bc5..07d8a46cc65 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.h +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.h @@ -44,6 +44,7 @@ struct MTexPoly; struct MLoopUV; struct MLoopCol; struct MDeformVert; +struct MVertSkin; int BPy_BMTexPoly_AssignPyObject(struct MTexPoly *mloopuv, PyObject *value); PyObject *BPy_BMTexPoly_CreatePyObject(struct MTexPoly *mloopuv); @@ -51,6 +52,9 @@ PyObject *BPy_BMTexPoly_CreatePyObject(struct MTexPoly *mloopuv); int BPy_BMLoopUV_AssignPyObject(struct MLoopUV *data, PyObject *value); PyObject *BPy_BMLoopUV_CreatePyObject(struct MLoopUV *data); +int BPy_BMVertSkin_AssignPyObject(struct MVertSkin *data, PyObject *value); +PyObject *BPy_BMVertSkin_CreatePyObject(struct MVertSkin *data); + int BPy_BMLoopColor_AssignPyObject(struct MLoopCol *data, PyObject *value); PyObject *BPy_BMLoopColor_CreatePyObject(struct MLoopCol *data); -- cgit v1.2.3 From 7d66d3298c9e8fb21745233cdbda35580e67c2e5 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Sun, 27 Oct 2013 13:58:13 +0000 Subject: cmake: bsp needs moto --- intern/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt index 364db3592c7..c45e66cd77b 100644 --- a/intern/CMakeLists.txt +++ b/intern/CMakeLists.txt @@ -61,7 +61,7 @@ if(WITH_IK_ITASC) add_subdirectory(itasc) endif() -if(WITH_IK_SOLVER OR WITH_GAMEENGINE) +if(WITH_IK_SOLVER OR WITH_GAMEENGINE OR WITH_MOD_BOOLEAN) add_subdirectory(moto) endif() -- cgit v1.2.3 From 0773fd7b78a4faf0dff69795842c3f1f82a93b9f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Oct 2013 01:58:05 +0000 Subject: fix for decimator editing the data it loops over in an unsupported way. --- source/blender/bmesh/tools/bmesh_decimate_collapse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c index 4b6835a81fe..99d46559ca5 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c @@ -390,10 +390,10 @@ static void bm_decim_triangulate_end(BMesh *bm) { /* decimation finished, now re-join */ BMIter iter; - BMEdge *e; + BMEdge *e, *e_next; /* boundary edges */ - BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + BM_ITER_MESH_MUTABLE (e, e_next, &iter, bm, BM_EDGES_OF_MESH) { BMLoop *l_a, *l_b; if (BM_edge_loop_pair(e, &l_a, &l_b)) { const int l_a_index = BM_elem_index_get(l_a); -- cgit v1.2.3 From 32644615988277ce60e0447f08d40ef67971bd88 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Oct 2013 02:05:33 +0000 Subject: move bmesh array lookup data and utility functions from editmesh into bmesh, since enough bmesh operations can also take advantage of direct index lookups on verts/edges/faces. developers note: - EDBM_index_arrays_init/ensure/free -> BM_mesh_elem_table_ensure/init/free - EDBM_vert/edge/face_at_index -> BM_vert/edge/face_at_index - EDBM_uv_element_map_create/free -> BM_uv_element_map_create/free - ED_uv_element_get -> BM_uv_element_get --- source/blender/blenkernel/BKE_editmesh.h | 7 - source/blender/blenkernel/intern/editderivedmesh.c | 21 ++- source/blender/blenkernel/intern/editmesh.c | 8 - source/blender/blenkernel/intern/mesh_evaluate.c | 2 +- source/blender/bmesh/bmesh_class.h | 19 ++ source/blender/bmesh/intern/bmesh_core.c | 15 +- source/blender/bmesh/intern/bmesh_mesh.c | 192 ++++++++++++++++++-- source/blender/bmesh/intern/bmesh_mesh.h | 19 +- source/blender/editors/include/ED_mesh.h | 22 +-- source/blender/editors/mesh/editface.c | 6 +- source/blender/editors/mesh/editmesh_loopcut.c | 6 +- source/blender/editors/mesh/editmesh_tools.c | 4 +- source/blender/editors/mesh/editmesh_utils.c | 199 ++++----------------- source/blender/editors/mesh/mesh_navmesh.c | 8 +- source/blender/editors/mesh/meshtools.c | 4 +- source/blender/editors/object/object_vgroup.c | 12 +- source/blender/editors/sculpt_paint/sculpt_uv.c | 14 +- source/blender/editors/space_view3d/drawmesh.c | 4 +- source/blender/editors/space_view3d/drawobject.c | 112 ++++++------ .../editors/space_view3d/view3d_iterators.c | 13 +- source/blender/editors/space_view3d/view3d_snap.c | 4 +- .../editors/transform/transform_conversions.c | 14 +- source/blender/editors/transform/transform_snap.c | 8 +- source/blender/editors/uvedit/uvedit_ops.c | 48 ++--- .../blender/editors/uvedit/uvedit_smart_stitch.c | 38 ++-- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 6 +- source/blender/modifiers/intern/MOD_decimate.c | 10 +- source/blender/python/bmesh/bmesh_py_types.c | 38 +--- 28 files changed, 443 insertions(+), 410 deletions(-) diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h index 738cd87dc39..310807370da 100644 --- a/source/blender/blenkernel/BKE_editmesh.h +++ b/source/blender/blenkernel/BKE_editmesh.h @@ -71,13 +71,6 @@ typedef struct BMEditMesh { unsigned char (*derivedFaceColor)[4]; int derivedFaceColorLen; - /* index tables, to map indices to elements via - * EDBM_index_arrays_init and associated functions. don't - * touch this or read it directly.*/ - struct BMVert **vert_index; - struct BMEdge **edge_index; - struct BMFace **face_index; - /*selection mode*/ short selectmode; short mat_nr; diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 6dd0efc9ab4..453d96a11af 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -1233,7 +1233,8 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *r_vert) return; } - ev = bmdm->em->vert_index[index]; /* should be EDBM_vert_at_index() */ + BLI_assert((bm->elem_table_dirty & BM_VERT) == 0); + ev = bm->vtable[index]; /* should be BM_vert_at_index() */ // ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */ bmvert_to_mvert(bm, ev, r_vert); @@ -1255,7 +1256,10 @@ static void emDM_getVertCo(DerivedMesh *dm, int index, float r_co[3]) copy_v3_v3(r_co, bmdm->vertexCos[index]); } else { - BMVert *ev = bmdm->em->vert_index[index]; /* should be EDBM_vert_at_index() */ + BMVert *ev; + + BLI_assert((bm->elem_table_dirty & BM_VERT) == 0); + ev = bm->vtable[index]; /* should be BM_vert_at_index() */ // ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */ copy_v3_v3(r_co, ev->co); } @@ -1277,7 +1281,10 @@ static void emDM_getVertNo(DerivedMesh *dm, int index, float r_no[3]) copy_v3_v3(r_no, bmdm->vertexNos[index]); } else { - BMVert *ev = bmdm->em->vert_index[index]; /* should be EDBM_vert_at_index() */ + BMVert *ev; + + BLI_assert((bm->elem_table_dirty & BM_VERT) == 0); + ev = bm->vtable[index]; /* should be BM_vert_at_index() */ // ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */ copy_v3_v3(r_no, ev->no); } @@ -1298,7 +1305,10 @@ static void emDM_getPolyNo(DerivedMesh *dm, int index, float r_no[3]) copy_v3_v3(r_no, bmdm->polyNos[index]); } else { - BMFace *efa = bmdm->em->face_index[index]; /* should be EDBM_vert_at_index() */ + BMFace *efa; + + BLI_assert((bm->elem_table_dirty & BM_FACE) == 0); + efa = bm->ftable[index]; /* should be BM_vert_at_index() */ // efa = BM_face_at_index(bm, index); /* warning, does list loop, _not_ ideal */ copy_v3_v3(r_no, efa->no); } @@ -1316,7 +1326,8 @@ static void emDM_getEdge(DerivedMesh *dm, int index, MEdge *r_edge) return; } - e = bmdm->em->edge_index[index]; /* should be EDBM_edge_at_index() */ + BLI_assert((bm->elem_table_dirty & BM_EDGE) == 0); + e = bm->etable[index]; /* should be BM_edge_at_index() */ // e = BM_edge_at_index(bm, index); /* warning, does list loop, _not_ ideal */ r_edge->flag = BM_edge_flag_to_mflag(e); diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c index 6a89d16d7bf..1fc7d024428 100644 --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.c @@ -78,10 +78,6 @@ BMEditMesh *BKE_editmesh_copy(BMEditMesh *em) * used.*/ em_copy->looptris = NULL; - em_copy->vert_index = NULL; - em_copy->edge_index = NULL; - em_copy->face_index = NULL; - return em_copy; } @@ -345,10 +341,6 @@ void BKE_editmesh_free(BMEditMesh *em) if (em->looptris) MEM_freeN(em->looptris); - if (em->vert_index) MEM_freeN(em->vert_index); - if (em->edge_index) MEM_freeN(em->edge_index); - if (em->face_index) MEM_freeN(em->face_index); - if (em->bm) BM_mesh_free(em->bm); } diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index 007a852dee5..1e74ce23c2c 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -946,7 +946,7 @@ bool BKE_mesh_center_centroid(Mesh *me, float cent[3]) * \{ */ -/* ngon version wip, based on EDBM_uv_vert_map_create */ +/* ngon version wip, based on BM_uv_vert_map_create */ /* this replaces the non bmesh function (in trunk) which takes MTFace's, if we ever need it back we could * but for now this replaces it because its unused. */ diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index 90105b0dd81..9c43e5a2ee4 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -183,9 +183,28 @@ typedef struct BMesh { * BM_LOOP isn't handled so far. */ char elem_index_dirty; + /* flag array table as being dirty so we know when its safe to use it, + * or when it needs to be re-created */ + char elem_table_dirty; + + /* element pools */ struct BLI_mempool *vpool, *epool, *lpool, *fpool; + /* mempool lookup tables (optional) + * index tables, to map indices to elements via + * BM_mesh_elem_table_ensure and associated functions. don't + * touch this or read it directly.\ + * Use BM_mesh_elem_table_ensure(), BM_vert/edge/face_at_index() */ + BMVert **vtable; + BMEdge **etable; + BMFace **ftable; + + /* size of allocated tables */ + int vtable_tot; + int etable_tot; + int ftable_tot; + /* operator api stuff (must be all NULL or all alloc'd) */ struct BLI_mempool *vtoolflagpool, *etoolflagpool, *ftoolflagpool; diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 8441a6ec75f..0726af4b641 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -70,7 +70,9 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], /* disallow this flag for verts - its meaningless */ BLI_assert((create_flag & BM_CREATE_NO_DOUBLE) == 0); - bm->elem_index_dirty |= BM_VERT; /* may add to middle of the pool */ + /* may add to middle of the pool */ + bm->elem_index_dirty |= BM_VERT; + bm->elem_table_dirty |= BM_VERT; bm->totvert++; @@ -130,7 +132,9 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, BM_elem_index_set(e, -1); /* set_ok_invalid */ #endif - bm->elem_index_dirty |= BM_EDGE; /* may add to middle of the pool */ + /* may add to middle of the pool */ + bm->elem_index_dirty |= BM_EDGE; + bm->elem_table_dirty |= BM_EDGE; bm->totedge++; @@ -292,7 +296,9 @@ BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm, const eBMCreateFlag creat BM_elem_index_set(f, -1); /* set_ok_invalid */ #endif - bm->elem_index_dirty |= BM_FACE; /* may add to middle of the pool */ + /* may add to middle of the pool */ + bm->elem_index_dirty |= BM_FACE; + bm->elem_table_dirty |= BM_FACE; bm->totface++; @@ -562,6 +568,7 @@ static void bm_kill_only_vert(BMesh *bm, BMVert *v) { bm->totvert--; bm->elem_index_dirty |= BM_VERT; + bm->elem_table_dirty |= BM_VERT; BM_select_history_remove(bm, v); @@ -582,6 +589,7 @@ static void bm_kill_only_edge(BMesh *bm, BMEdge *e) { bm->totedge--; bm->elem_index_dirty |= BM_EDGE; + bm->elem_table_dirty |= BM_EDGE; BM_select_history_remove(bm, (BMElem *)e); @@ -605,6 +613,7 @@ static void bm_kill_only_face(BMesh *bm, BMFace *f) bm->totface--; bm->elem_index_dirty |= BM_FACE; + bm->elem_table_dirty |= BM_FACE; BM_select_history_remove(bm, (BMElem *)f); diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index d6d846e44e4..033a31daae7 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -213,6 +213,10 @@ void BM_mesh_data_free(BMesh *bm) BLI_mempool_destroy(bm->lpool); BLI_mempool_destroy(bm->fpool); + if (bm->vtable) MEM_freeN(bm->vtable); + if (bm->etable) MEM_freeN(bm->etable); + if (bm->ftable) MEM_freeN(bm->ftable); + /* destroy flag pool */ BM_mesh_elem_toolflags_clear(bm); @@ -623,6 +627,179 @@ void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *fu } +/* debug check only - no need to optimize */ +#ifndef NDEBUG +bool BM_mesh_elem_table_check(BMesh *bm) +{ + BMIter iter; + BMElem *ele; + int i; + + if (bm->vtable && ((bm->elem_table_dirty & BM_VERT) == 0)) { + BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) { + if (ele != (BMElem *)bm->vtable[i]) { + return false; + } + } + } + + if (bm->etable && ((bm->elem_table_dirty & BM_EDGE) == 0)) { + BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) { + if (ele != (BMElem *)bm->etable[i]) { + return false; + } + } + } + + if (bm->ftable && ((bm->elem_table_dirty & BM_FACE) == 0)) { + BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) { + if (ele != (BMElem *)bm->ftable[i]) { + return false; + } + } + } + + return true; +} +#endif + + + +void BM_mesh_elem_table_ensure(BMesh *bm, const char htype) +{ + /* assume if the array is non-null then its valid and no need to recalc */ + const char htype_needed = (((bm->vtable && ((bm->elem_table_dirty & BM_VERT) == 0)) ? 0 : BM_VERT) | + ((bm->etable && ((bm->elem_table_dirty & BM_EDGE) == 0)) ? 0 : BM_EDGE) | + ((bm->ftable && ((bm->elem_table_dirty & BM_FACE) == 0)) ? 0 : BM_FACE)) & htype; + + BLI_assert((htype & ~BM_ALL_NOLOOP) == 0); + + /* in debug mode double check we didn't need to recalculate */ + BLI_assert(BM_mesh_elem_table_check(bm) == true); + + if (htype_needed & BM_VERT) { + if (bm->vtable && bm->totvert <= bm->vtable_tot && bm->totvert * 2 >= bm->vtable_tot) { + /* pass (re-use the array) */ + } + else { + if (bm->vtable) + MEM_freeN(bm->vtable); + bm->vtable = MEM_mallocN(sizeof(void **) * bm->totvert, "bm->vtable"); + bm->vtable_tot = bm->totvert; + } + bm->elem_table_dirty &= ~BM_VERT; + } + if (htype_needed & BM_EDGE) { + if (bm->etable && bm->totedge <= bm->etable_tot && bm->totedge * 2 >= bm->etable_tot) { + /* pass (re-use the array) */ + } + else { + if (bm->etable) + MEM_freeN(bm->etable); + bm->etable = MEM_mallocN(sizeof(void **) * bm->totedge, "bm->etable"); + bm->etable_tot = bm->totedge; + } + bm->elem_table_dirty &= ~BM_EDGE; + } + if (htype_needed & BM_FACE) { + if (bm->ftable && bm->totface <= bm->ftable_tot && bm->totface * 2 >= bm->ftable_tot) { + /* pass (re-use the array) */ + } + else { + if (bm->ftable) + MEM_freeN(bm->ftable); + bm->ftable = MEM_mallocN(sizeof(void **) * bm->totface, "bm->ftable"); + bm->ftable_tot = bm->totface; + } + bm->elem_table_dirty &= ~BM_FACE; + } + +#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) + { +#pragma omp section + { + if (htype_needed & BM_VERT) { + BM_iter_as_array(bm, BM_VERTS_OF_MESH, NULL, (void **)bm->vtable, bm->totvert); + } + } +#pragma omp section + { + if (htype_needed & BM_EDGE) { + BM_iter_as_array(bm, BM_EDGES_OF_MESH, NULL, (void **)bm->etable, bm->totedge); + } + } +#pragma omp section + { + if (htype_needed & BM_FACE) { + BM_iter_as_array(bm, BM_FACES_OF_MESH, NULL, (void **)bm->ftable, bm->totface); + } + } + } +} + +/* use BM_mesh_elem_table_ensure where possible to avoid full rebuild */ +void BM_mesh_elem_table_init(BMesh *bm, const char htype) +{ + BLI_assert((htype & ~BM_ALL_NOLOOP) == 0); + + /* force recalc */ + BM_mesh_elem_table_free(bm, BM_ALL_NOLOOP); + BM_mesh_elem_table_ensure(bm, htype); +} + +void BM_mesh_elem_table_free(BMesh *bm, const char htype) +{ + if (htype & BM_VERT) { + MEM_SAFE_FREE(bm->vtable); + } + + if (htype & BM_EDGE) { + MEM_SAFE_FREE(bm->etable); + } + + if (htype & BM_FACE) { + MEM_SAFE_FREE(bm->ftable); + } +} + +BMVert *BM_vert_at_index(BMesh *bm, int index) +{ + BLI_assert((index >= 0) && (index < bm->totvert)); + BLI_assert((bm->elem_table_dirty & BM_VERT) == 0); + return bm->vtable[index]; +} + +BMEdge *BM_edge_at_index(BMesh *bm, int index) +{ + BLI_assert((index >= 0) && (index < bm->totedge)); + BLI_assert((bm->elem_table_dirty & BM_EDGE) == 0); + return bm->etable[index]; +} + +BMFace *BM_face_at_index(BMesh *bm, int index) +{ + BLI_assert((index >= 0) && (index < bm->totface)); + BLI_assert((bm->elem_table_dirty & BM_FACE) == 0); + return bm->ftable[index]; +} + + +BMVert *BM_vert_at_index_find(BMesh *bm, const int index) +{ + return BLI_mempool_findelem(bm->vpool, index); +} + +BMEdge *BM_edge_at_index_find(BMesh *bm, const int index) +{ + return BLI_mempool_findelem(bm->epool, index); +} + +BMFace *BM_face_at_index_find(BMesh *bm, const int index) +{ + return BLI_mempool_findelem(bm->fpool, index); +} + + /** * Return the amount of element of type 'type' in a given bmesh. */ @@ -828,18 +1005,3 @@ void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx) if (fptr_map) BLI_ghash_free(fptr_map, NULL, NULL); } - -BMVert *BM_vert_at_index_find(BMesh *bm, const int index) -{ - return BLI_mempool_findelem(bm->vpool, index); -} - -BMEdge *BM_edge_at_index_find(BMesh *bm, const int index) -{ - return BLI_mempool_findelem(bm->epool, index); -} - -BMFace *BM_face_at_index_find(BMesh *bm, const int index) -{ - return BLI_mempool_findelem(bm->fpool, index); -} diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h index 23429ec3252..33431714660 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.h +++ b/source/blender/bmesh/intern/bmesh_mesh.h @@ -45,14 +45,29 @@ void bmesh_edit_end(BMesh *bm, const BMOpTypeFlag type_flag); void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag); void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *func, const char *msg_a, const char *msg_b); -int BM_mesh_elem_count(BMesh *bm, const char htype); -void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx); +#ifndef NDEBUG +bool BM_mesh_elem_table_check(BMesh *em); +#endif + +void BM_mesh_elem_table_ensure(BMesh *bm, const char htype); +void BM_mesh_elem_table_init(BMesh *bm, const char htype); +void BM_mesh_elem_table_free(BMesh *bm, const char htype); + +BMVert *BM_vert_at_index(BMesh *bm, const int index); +BMEdge *BM_edge_at_index(BMesh *bm, const int index); +BMFace *BM_face_at_index(BMesh *bm, const int index); BMVert *BM_vert_at_index_find(BMesh *bm, const int index); BMEdge *BM_edge_at_index_find(BMesh *bm, const int index); BMFace *BM_face_at_index_find(BMesh *bm, const int index); +// XXX + +int BM_mesh_elem_count(BMesh *bm, const char htype); + +void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx); + typedef struct BMAllocTemplate { int totvert, totedge, totloop, totface; } BMAllocTemplate; diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 5d3d72d0e3d..9d3404aa29b 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -97,16 +97,6 @@ void EDBM_mesh_free(struct BMEditMesh *em); void EDBM_mesh_load(struct Object *ob); struct DerivedMesh *EDBM_mesh_deform_dm_get(struct BMEditMesh *em); -void EDBM_index_arrays_ensure(struct BMEditMesh *em, const char htype); -void EDBM_index_arrays_init(struct BMEditMesh *em, const char htype); -void EDBM_index_arrays_free(struct BMEditMesh *em); -#ifndef NDEBUG -bool EDBM_index_arrays_check(struct BMEditMesh *em); -#endif -struct BMVert *EDBM_vert_at_index(struct BMEditMesh *em, int index); -struct BMEdge *EDBM_edge_at_index(struct BMEditMesh *em, int index); -struct BMFace *EDBM_face_at_index(struct BMEditMesh *em, int index); - /* flushes based on the current select mode. if in vertex select mode, * verts select/deselect edges and faces, if in edge select mode, * edges select/deselect faces and vertices, and in face select mode faces select/deselect @@ -129,16 +119,16 @@ void EDBM_mesh_reveal(struct BMEditMesh *em); void EDBM_update_generic(struct BMEditMesh *em, const bool do_tessface, const bool is_destructive); -struct UvElementMap *EDBM_uv_element_map_create(struct BMEditMesh *em, const bool selected, const bool do_islands); -void EDBM_uv_element_map_free(struct UvElementMap *vmap); -struct UvElement *ED_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l); +struct UvElementMap *BM_uv_element_map_create(struct BMesh *em, const bool selected, const bool do_islands); +void BM_uv_element_map_free(struct UvElementMap *vmap); +struct UvElement *BM_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l); bool EDBM_mtexpoly_check(struct BMEditMesh *em); struct MTexPoly *EDBM_mtexpoly_active_get(struct BMEditMesh *em, struct BMFace **r_act_efa, const bool sloppy, const bool selected); -void EDBM_uv_vert_map_free(struct UvVertMap *vmap); -struct UvMapVert *EDBM_uv_vert_map_at_index(struct UvVertMap *vmap, unsigned int v); -struct UvVertMap *EDBM_uv_vert_map_create(struct BMEditMesh *em, bool use_select, const float limit[2]); +void BM_uv_vert_map_free(struct UvVertMap *vmap); +struct UvMapVert *BM_uv_vert_map_at_index(struct UvVertMap *vmap, unsigned int v); +struct UvVertMap *BM_uv_vert_map_create(struct BMesh *bm, bool use_select, const float limit[2]); void EDBM_flag_enable_all(struct BMEditMesh *em, const char hflag); void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag); diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 7944c2f0cca..9e1785e27d1 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -797,7 +797,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to if (em) { if (skip_em_vert_array_init == false) { - EDBM_index_arrays_ensure(em, BM_VERT); + BM_mesh_elem_table_ensure(em->bm, BM_VERT); } } @@ -822,8 +822,8 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to if ((a == totvert) || (topo_pairs[a - 1].hash != topo_pairs[a].hash)) { if (a - last == 2) { if (em) { - index_lookup[topo_pairs[a - 1].v_index] = (intptr_t)EDBM_vert_at_index(em, topo_pairs[a - 2].v_index); - index_lookup[topo_pairs[a - 2].v_index] = (intptr_t)EDBM_vert_at_index(em, topo_pairs[a - 1].v_index); + index_lookup[topo_pairs[a - 1].v_index] = (intptr_t)BM_vert_at_index(em->bm, topo_pairs[a - 2].v_index); + index_lookup[topo_pairs[a - 2].v_index] = (intptr_t)BM_vert_at_index(em->bm, topo_pairs[a - 1].v_index); } else { index_lookup[topo_pairs[a - 1].v_index] = topo_pairs[a - 2].v_index; diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index ae1007cb98a..3066fb86bf8 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -219,7 +219,7 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, bool select) } if (dm) { - EDBM_index_arrays_ensure(lcd->em, BM_VERT); + BM_mesh_elem_table_ensure(lcd->em->bm, BM_VERT); } BMW_init(&walker, em->bm, BMW_EDGERING, @@ -478,8 +478,8 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event) else { const int e_index = RNA_int_get(op->ptr, "edge_index"); BMEdge *e; - EDBM_index_arrays_ensure(lcd->em, BM_EDGE); - e = EDBM_edge_at_index(lcd->em, e_index); + BM_mesh_elem_table_ensure(lcd->em->bm, BM_EDGE); + e = BM_edge_at_index(lcd->em->bm, e_index); loopcut_update_edge(lcd, e, 0); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 6a0a0694764..e557b07dba2 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4712,7 +4712,7 @@ static int mesh_symmetry_snap_exec(bContext *C, wmOperator *op) EDBM_verts_mirror_cache_begin_ex(em, axis, true, true, use_topology, thresh, index); - EDBM_index_arrays_ensure(em, BM_VERT); + BM_mesh_elem_table_ensure(bm, BM_VERT); BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false); @@ -4724,7 +4724,7 @@ static int mesh_symmetry_snap_exec(bContext *C, wmOperator *op) int i_mirr = index[i]; if (i_mirr != -1) { - BMVert *v_mirr = EDBM_vert_at_index(em, index[i]); + BMVert *v_mirr = BM_vert_at_index(bm, index[i]); if (v != v_mirr) { float co[3], co_mirr[3]; diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index e457f7c45af..ca8853fd3f5 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -410,134 +410,6 @@ void EDBM_mesh_free(BMEditMesh *em) BKE_editmesh_free(em); } - -void EDBM_index_arrays_ensure(BMEditMesh *em, const char htype) -{ - /* assume if the array is non-null then its valid and no need to recalc */ - const char htype_needed = ((em->vert_index ? 0 : BM_VERT) | - (em->edge_index ? 0 : BM_EDGE) | - (em->face_index ? 0 : BM_FACE)) & htype; - - BLI_assert((htype & ~BM_ALL_NOLOOP) == 0); - - /* in debug mode double check we didn't need to recalculate */ - BLI_assert(EDBM_index_arrays_check(em) == true); - - if (htype_needed & BM_VERT) { - em->vert_index = MEM_mallocN(sizeof(void **) * em->bm->totvert, "em->vert_index"); - } - if (htype_needed & BM_EDGE) { - em->edge_index = MEM_mallocN(sizeof(void **) * em->bm->totedge, "em->edge_index"); - } - if (htype_needed & BM_FACE) { - em->face_index = MEM_mallocN(sizeof(void **) * em->bm->totface, "em->face_index"); - } - -#pragma omp parallel sections if (em->bm->totvert + em->bm->totedge + em->bm->totface >= BM_OMP_LIMIT) - { -#pragma omp section - { - if (htype_needed & BM_VERT) { - BM_iter_as_array(em->bm, BM_VERTS_OF_MESH, NULL, (void **)em->vert_index, em->bm->totvert); - } - } -#pragma omp section - { - if (htype_needed & BM_EDGE) { - BM_iter_as_array(em->bm, BM_EDGES_OF_MESH, NULL, (void **)em->edge_index, em->bm->totedge); - } - } -#pragma omp section - { - if (htype_needed & BM_FACE) { - BM_iter_as_array(em->bm, BM_FACES_OF_MESH, NULL, (void **)em->face_index, em->bm->totface); - } - } - } -} - -/* use EDBM_index_arrays_ensure where possible to avoid full rebuild */ -void EDBM_index_arrays_init(BMEditMesh *em, const char htype) -{ - BLI_assert((htype & ~BM_ALL_NOLOOP) == 0); - - /* force recalc */ - EDBM_index_arrays_free(em); - EDBM_index_arrays_ensure(em, htype); -} - -void EDBM_index_arrays_free(BMEditMesh *em) -{ - if (em->vert_index) { - MEM_freeN(em->vert_index); - em->vert_index = NULL; - } - - if (em->edge_index) { - MEM_freeN(em->edge_index); - em->edge_index = NULL; - } - - if (em->face_index) { - MEM_freeN(em->face_index); - em->face_index = NULL; - } -} - -/* debug check only - no need to optimize */ -#ifndef NDEBUG -bool EDBM_index_arrays_check(BMEditMesh *em) -{ - BMIter iter; - BMElem *ele; - int i; - - if (em->vert_index) { - BM_ITER_MESH_INDEX (ele, &iter, em->bm, BM_VERTS_OF_MESH, i) { - if (ele != (BMElem *)em->vert_index[i]) { - return false; - } - } - } - - if (em->edge_index) { - BM_ITER_MESH_INDEX (ele, &iter, em->bm, BM_EDGES_OF_MESH, i) { - if (ele != (BMElem *)em->edge_index[i]) { - return false; - } - } - } - - if (em->face_index) { - BM_ITER_MESH_INDEX (ele, &iter, em->bm, BM_FACES_OF_MESH, i) { - if (ele != (BMElem *)em->face_index[i]) { - return false; - } - } - } - - return true; -} -#endif - -BMVert *EDBM_vert_at_index(BMEditMesh *em, int index) -{ - BLI_assert((index >= 0) && (index < em->bm->totvert)); - return em->vert_index[index]; -} - -BMEdge *EDBM_edge_at_index(BMEditMesh *em, int index) -{ - BLI_assert((index >= 0) && (index < em->bm->totedge)); - return em->edge_index[index]; -} - -BMFace *EDBM_face_at_index(BMEditMesh *em, int index) -{ - BLI_assert((index >= 0) && (index < em->bm->totface)); - return em->face_index[index]; -} - void EDBM_selectmode_flush_ex(BMEditMesh *em, const short selectmode) { BM_mesh_select_mode_flush_ex(em->bm, selectmode); @@ -710,7 +582,7 @@ void undo_push_mesh(bContext *C, const char *name) /** * Return a new UVVertMap from the editmesh */ -UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float limit[2]) +UvVertMap *BM_uv_vert_map_create(BMesh *bm, bool use_select, const float limit[2]) { BMVert *ev; BMFace *efa; @@ -723,15 +595,15 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float MLoopUV *luv; unsigned int a; int totverts, i, totuv; - const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); - BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE); + BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE); - totverts = em->bm->totvert; + totverts = bm->totvert; totuv = 0; /* generate UvMapVert array */ - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if ((use_select == false) || BM_elem_flag_test(efa, BM_ELEM_SELECT)) { totuv += efa->len; } @@ -754,7 +626,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float } a = 0; - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if ((use_select == false) || BM_elem_flag_test(efa, BM_ELEM_SELECT)) { i = 0; BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { @@ -775,7 +647,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float /* sort individual uvs for each vert */ a = 0; - BM_ITER_MESH (ev, &iter, em->bm, BM_VERTS_OF_MESH) { + BM_ITER_MESH (ev, &iter, bm, BM_VERTS_OF_MESH) { UvMapVert *newvlist = NULL, *vlist = vmap->vert[a]; UvMapVert *iterv, *v, *lastv, *next; float *uv, *uv2, uvdiff[2]; @@ -786,10 +658,10 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float v->next = newvlist; newvlist = v; - efa = EDBM_face_at_index(em, v->f); - /* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ + efa = BM_face_at_index(bm, v->f); + /* tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ - l = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa, v->tfindex); + l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, v->tfindex); luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv = luv->uv; @@ -798,10 +670,10 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float while (iterv) { next = iterv->next; - efa = EDBM_face_at_index(em, iterv->f); - /* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ + efa = BM_face_at_index(bm, iterv->f); + /* tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ - l = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa, iterv->tfindex); + l = BM_iter_at_index(bm, BM_LOOPS_OF_FACE, efa, iterv->tfindex); luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv2 = luv->uv; @@ -831,7 +703,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, bool use_select, const float } -UvMapVert *EDBM_uv_vert_map_at_index(UvVertMap *vmap, unsigned int v) +UvMapVert *BM_uv_vert_map_at_index(UvVertMap *vmap, unsigned int v) { return vmap->vert[v]; } @@ -840,7 +712,7 @@ UvMapVert *EDBM_uv_vert_map_at_index(UvVertMap *vmap, unsigned int v) /* A specialized vert map used by stitch operator */ -UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, const bool do_islands) +UvElementMap *BM_uv_element_map_create(BMesh *bm, const bool selected, const bool do_islands) { BMVert *ev; BMFace *efa; @@ -860,20 +732,20 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co BMFace **stack; int stacksize = 0; - const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); - BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE); + BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE); - totverts = em->bm->totvert; + totverts = bm->totvert; totuv = 0; - island_number = MEM_mallocN(sizeof(*stack) * em->bm->totface, "uv_island_number_face"); + island_number = MEM_mallocN(sizeof(*stack) * bm->totface, "uv_island_number_face"); if (!island_number) { return NULL; } /* generate UvElement array */ - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) { totuv += efa->len; } @@ -893,13 +765,13 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co buf = element_map->buf = (UvElement *)MEM_callocN(sizeof(*element_map->buf) * totuv, "UvElement"); if (!element_map->vert || !element_map->buf) { - EDBM_uv_element_map_free(element_map); + BM_uv_element_map_free(element_map); MEM_freeN(island_number); return NULL; } j = 0; - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { island_number[j++] = INVALID_ISLAND; if (!selected || BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { @@ -918,7 +790,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co /* sort individual uvs for each vert */ i = 0; - BM_ITER_MESH (ev, &iter, em->bm, BM_VERTS_OF_MESH) { + BM_ITER_MESH (ev, &iter, bm, BM_VERTS_OF_MESH) { UvElement *newvlist = NULL, *vlist = element_map->vert[i]; UvElement *iterv, *v, *lastv, *next; float *uv, *uv2, uvdiff[2]; @@ -968,7 +840,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co if (do_islands) { /* map holds the map from current vmap->buf to the new, sorted map */ map = MEM_mallocN(sizeof(*map) * totuv, "uvelement_remap"); - stack = MEM_mallocN(sizeof(*stack) * em->bm->totface, "uv_island_face_stack"); + stack = MEM_mallocN(sizeof(*stack) * bm->totface, "uv_island_face_stack"); islandbuf = MEM_callocN(sizeof(*islandbuf) * totuv, "uvelement_island_buffer"); /* at this point, every UvElement in vert points to a UvElement sharing the same vertex. Now we should sort uv's in islands. */ @@ -1019,7 +891,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co } /* remap */ - for (i = 0; i < em->bm->totvert; i++) { + for (i = 0; i < bm->totvert; i++) { /* important since we may do selection only. Some of these may be NULL */ if (element_map->vert[i]) element_map->vert[i] = &islandbuf[map[element_map->vert[i] - element_map->buf]]; @@ -1030,7 +902,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co MEM_freeN(islandbuf); MEM_freeN(stack); MEM_freeN(map); - EDBM_uv_element_map_free(element_map); + BM_uv_element_map_free(element_map); MEM_freeN(island_number); } @@ -1060,7 +932,7 @@ UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, co return element_map; } -void EDBM_uv_vert_map_free(UvVertMap *vmap) +void BM_uv_vert_map_free(UvVertMap *vmap) { if (vmap) { if (vmap->vert) MEM_freeN(vmap->vert); @@ -1069,7 +941,7 @@ void EDBM_uv_vert_map_free(UvVertMap *vmap) } } -void EDBM_uv_element_map_free(UvElementMap *element_map) +void BM_uv_element_map_free(UvElementMap *element_map) { if (element_map) { if (element_map->vert) MEM_freeN(element_map->vert); @@ -1079,7 +951,7 @@ void EDBM_uv_element_map_free(UvElementMap *element_map) } } -UvElement *ED_uv_element_get(UvElementMap *map, BMFace *efa, BMLoop *l) +UvElement *BM_uv_element_get(UvElementMap *map, BMFace *efa, BMLoop *l) { UvElement *element; @@ -1182,7 +1054,7 @@ void EDBM_verts_mirror_cache_begin_ex(BMEditMesh *em, const int axis, const bool struct BMBVHTree *tree = NULL; MirrTopoStore_t mesh_topo_store = {NULL, -1, -1, -1}; - EDBM_index_arrays_ensure(em, BM_VERT); + BM_mesh_elem_table_ensure(bm, BM_VERT); if (r_index == NULL) { const char *layer_id = BM_CD_LAYER_ID; @@ -1270,13 +1142,13 @@ BMVert *EDBM_verts_mirror_get(BMEditMesh *em, BMVert *v) BLI_assert(em->mirror_cdlayer != -1); /* invalid use */ if (mirr && *mirr >= 0 && *mirr < em->bm->totvert) { - if (!em->vert_index) { + if (!em->bm->vtable) { printf("err: should only be called between " "EDBM_verts_mirror_cache_begin and EDBM_verts_mirror_cache_end"); return NULL; } - return em->vert_index[*mirr]; + return em->bm->vtable[*mirr]; } return NULL; @@ -1335,7 +1207,7 @@ void EDBM_verts_mirror_apply(BMEditMesh *em, const int sel_from, const int sel_t BMIter iter; BMVert *v; - BLI_assert(em->vert_index != NULL); + BLI_assert((em->bm->vtable != NULL) && ((em->bm->elem_table_dirty & BM_VERT) == 0)); BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_SELECT) == sel_from) { @@ -1447,11 +1319,12 @@ void EDBM_update_generic(BMEditMesh *em, const bool do_tessface, const bool is_d } if (is_destructive) { - EDBM_index_arrays_free(em); + /* TODO. we may be able to remove this now! - Campbell */ + // BM_mesh_elem_table_free(em->bm, BM_ALL_NOLOOP); } else { /* in debug mode double check we didn't need to recalculate */ - BLI_assert(EDBM_index_arrays_check(em) == true); + BLI_assert(BM_mesh_elem_table_check(em->bm) == true); } } diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index 83feed6756f..433fd176217 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -389,7 +389,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, } /* need to rebuild entirely because array size changes */ - EDBM_index_arrays_init(em, BM_VERT); + BM_mesh_elem_table_init(em->bm, BM_VERT); /* create faces */ for (j = 0; j < trinum; j++) { @@ -404,9 +404,9 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, face[k] = uniquevbase + tri[k] - nv; /* unique vertex */ } newFace = BM_face_create_quad_tri(em->bm, - EDBM_vert_at_index(em, face[0]), - EDBM_vert_at_index(em, face[2]), - EDBM_vert_at_index(em, face[1]), NULL, + BM_vert_at_index(em->bm, face[0]), + BM_vert_at_index(em->bm, face[2]), + BM_vert_at_index(em->bm, face[1]), NULL, NULL, false); /* set navigation polygon idx to the custom layer */ diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 5ee980ef5cb..11f25da529c 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1014,7 +1014,7 @@ BMVert *editbmesh_get_x_mirror_vert(Object *ob, struct BMEditMesh *em, BMVert *e /** * Wrapper for objectmode/editmode. * - * call #EDBM_index_arrays_ensure first for editmesh. + * call #BM_mesh_elem_table_ensure first for editmesh. */ int ED_mesh_mirror_get_vert(Object *ob, int index) { @@ -1025,7 +1025,7 @@ int ED_mesh_mirror_get_vert(Object *ob, int index) if (em) { BMVert *eve, *eve_mirr; - eve = EDBM_vert_at_index(em, index); + eve = BM_vert_at_index(em->bm, index); eve_mirr = editbmesh_get_x_mirror_vert(ob, em, eve, eve->co, index, use_topology); index_mirr = eve_mirr ? BM_elem_index_get(eve_mirr) : -1; } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index d75c50b3f28..a6f7c4d5383 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -348,7 +348,7 @@ void ED_vgroup_parray_mirror_sync(Object *ob, return; } if (em) { - EDBM_index_arrays_ensure(em, BM_VERT); + BM_mesh_elem_table_ensure(em->bm, BM_VERT); } for (i = 0; i < dvert_tot; i++) { @@ -390,7 +390,7 @@ void ED_vgroup_parray_mirror_assign(Object *ob, } BLI_assert(dvert_tot == dvert_tot_all); if (em) { - EDBM_index_arrays_ensure(em, BM_VERT); + BM_mesh_elem_table_ensure(em->bm, BM_VERT); } for (i = 0; i < dvert_tot; i++) { @@ -1283,8 +1283,8 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum) if (cd_dvert_offset != -1) { BMVert *eve; - EDBM_index_arrays_ensure(em, BM_VERT); - eve = EDBM_vert_at_index(em, vertnum); + BM_mesh_elem_table_ensure(em->bm, BM_VERT); + eve = BM_vert_at_index(em->bm, vertnum); dv = BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset); } else { @@ -2179,7 +2179,7 @@ static void vgroup_blend_subset(Object *ob, const bool *vgroup_validmap, const i memset(vgroup_subset_weights, 0, sizeof(*vgroup_subset_weights) * subset_count); if (bm) { - EDBM_index_arrays_ensure(em, BM_VERT); + BM_mesh_elem_table_ensure(bm, BM_VERT); emap = NULL; emap_mem = NULL; @@ -2197,7 +2197,7 @@ static void vgroup_blend_subset(Object *ob, const bool *vgroup_validmap, const i /* in case its not selected */ if (bm) { - BMVert *v = EDBM_vert_at_index(em, i); + BMVert *v = BM_vert_at_index(bm, i); if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { BMIter eiter; BMEdge *e; diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 7a973d8c1ae..626df03a5d4 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -480,7 +480,7 @@ static void uv_sculpt_stroke_exit(bContext *C, wmOperator *op) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), data->timer); } if (data->elementMap) { - EDBM_uv_element_map_free(data->elementMap); + BM_uv_element_map_free(data->elementMap); } if (data->uv) { MEM_freeN(data->uv); @@ -501,7 +501,7 @@ static void uv_sculpt_stroke_exit(bContext *C, wmOperator *op) static int uv_element_offset_from_face_get(UvElementMap *map, BMFace *efa, BMLoop *l, int island_index, int doIslands) { - UvElement *element = ED_uv_element_get(map, efa, l); + UvElement *element = BM_uv_element_get(map, efa, l); if (!element || (doIslands && element->island != island_index)) { return -1; } @@ -566,18 +566,18 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm if (do_island_optimization) { /* We will need island information */ if (ts->uv_flag & UV_SYNC_SELECTION) { - data->elementMap = EDBM_uv_element_map_create(em, 0, 1); + data->elementMap = BM_uv_element_map_create(bm, false, true); } else { - data->elementMap = EDBM_uv_element_map_create(em, 1, 1); + data->elementMap = BM_uv_element_map_create(bm, true, true); } } else { if (ts->uv_flag & UV_SYNC_SELECTION) { - data->elementMap = EDBM_uv_element_map_create(em, 0, 0); + data->elementMap = BM_uv_element_map_create(bm, false, false); } else { - data->elementMap = EDBM_uv_element_map_create(em, 1, 0); + data->elementMap = BM_uv_element_map_create(bm, true, false); } } @@ -596,7 +596,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm Image *ima = CTX_data_edit_image(C); uv_find_nearest_vert(scene, ima, em, co, NULL, &hit); - element = ED_uv_element_get(data->elementMap, hit.efa, hit.l); + element = BM_uv_element_get(data->elementMap, hit.efa, hit.l); island_index = element->island; } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 76fcf70a627..a08a6cc1478 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -574,7 +574,7 @@ static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int index) if (UNLIKELY(index >= em->bm->totface)) return DM_DRAW_OPTION_NORMAL; - efa = EDBM_face_at_index(em, index); + efa = BM_face_at_index(em->bm, index); if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { return DM_DRAW_OPTION_SKIP; @@ -936,7 +936,7 @@ static bool tex_mat_set_face_editmesh_cb(void *userData, int index) if (UNLIKELY(index >= em->bm->totface)) return DM_DRAW_OPTION_NORMAL; - efa = EDBM_face_at_index(em, index); + efa = BM_face_at_index(em->bm, index); return !BM_elem_flag_test(efa, BM_ELEM_HIDDEN); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 03f081476b3..ac1f4406983 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -103,7 +103,7 @@ typedef enum eWireDrawMode { } eWireDrawMode; typedef struct drawDMVerts_userData { - BMEditMesh *em; + BMesh *bm; BMVert *eve_act; char sel; @@ -121,7 +121,7 @@ typedef struct drawDMVerts_userData { } drawDMVerts_userData; typedef struct drawDMEdgesSel_userData { - BMEditMesh *em; + BMesh *bm; unsigned char *baseCol, *selCol, *actCol; BMEdge *eed_act; @@ -135,7 +135,7 @@ typedef struct drawDMFacesSel_userData { #endif DerivedMesh *dm; - BMEditMesh *em; + BMesh *bm; BMFace *efa_act; int *orig_index_mf_to_mpoly; @@ -143,7 +143,7 @@ typedef struct drawDMFacesSel_userData { } drawDMFacesSel_userData; typedef struct drawDMNormal_userData { - BMEditMesh *em; + BMesh *bm; int uniform_scale; float normalsize; float tmat[3][3]; @@ -156,7 +156,7 @@ typedef struct bbsObmodeMeshVerts_userData { } bbsObmodeMeshVerts_userData; typedef struct drawDMLayer_userData { - BMEditMesh *em; + BMesh *bm; int cd_layer_offset; } drawDMLayer_userData; @@ -2038,7 +2038,7 @@ static void calcDrawDMNormalScale(Object *ob, drawDMNormal_userData *data) static void draw_dm_face_normals__mapFunc(void *userData, int index, const float cent[3], const float no[3]) { drawDMNormal_userData *data = userData; - BMFace *efa = EDBM_face_at_index(data->em, index); + BMFace *efa = BM_face_at_index(data->bm, index); float n[3]; if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { @@ -2062,7 +2062,7 @@ static void draw_dm_face_normals(BMEditMesh *em, Scene *scene, Object *ob, Deriv { drawDMNormal_userData data; - data.em = em; + data.bm = em->bm; data.normalsize = scene->toolsettings->normalsize; calcDrawDMNormalScale(ob, &data); @@ -2074,7 +2074,7 @@ static void draw_dm_face_normals(BMEditMesh *em, Scene *scene, Object *ob, Deriv static void draw_dm_face_centers__mapFunc(void *userData, int index, const float cent[3], const float UNUSED(no[3])) { - BMFace *efa = EDBM_face_at_index(((void **)userData)[0], index); + BMFace *efa = BM_face_at_index(((void **)userData)[0], index); const char sel = *(((char **)userData)[1]); if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && @@ -2085,7 +2085,7 @@ static void draw_dm_face_centers__mapFunc(void *userData, int index, const float } static void draw_dm_face_centers(BMEditMesh *em, DerivedMesh *dm, char sel) { - void *ptrs[2] = {em, &sel}; + void *ptrs[2] = {em->bm, &sel}; bglBegin(GL_POINTS); dm->foreachMappedFaceCenter(dm, draw_dm_face_centers__mapFunc, ptrs, DM_FOREACH_NOP); @@ -2095,7 +2095,7 @@ static void draw_dm_face_centers(BMEditMesh *em, DerivedMesh *dm, char sel) static void draw_dm_vert_normals__mapFunc(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]) { drawDMNormal_userData *data = userData; - BMVert *eve = EDBM_vert_at_index(data->em, index); + BMVert *eve = BM_vert_at_index(data->bm, index); if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { float no[3], n[3]; @@ -2127,7 +2127,7 @@ static void draw_dm_vert_normals(BMEditMesh *em, Scene *scene, Object *ob, Deriv { drawDMNormal_userData data; - data.em = em; + data.bm = em->bm; data.normalsize = scene->toolsettings->normalsize; calcDrawDMNormalScale(ob, &data); @@ -2142,7 +2142,7 @@ static void draw_dm_verts__mapFunc(void *userData, int index, const float co[3], const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) { drawDMVerts_userData *data = userData; - BMVert *eve = EDBM_vert_at_index(data->em, index); + BMVert *eve = BM_vert_at_index(data->bm, index); if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT) == data->sel) { /* skin nodes: draw a red circle around the root @@ -2188,7 +2188,7 @@ static void draw_dm_verts(BMEditMesh *em, DerivedMesh *dm, const char sel, BMVer drawDMVerts_userData data; data.sel = sel; data.eve_act = eve_act; - data.em = em; + data.bm = em->bm; /* Cache theme values */ UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, data.th_editmesh_active); @@ -2216,7 +2216,7 @@ static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index) drawDMEdgesSel_userData *data = userData; unsigned char *col; - eed = EDBM_edge_at_index(data->em, index); + eed = BM_edge_at_index(data->bm, index); if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { if (eed == data->eed_act) { @@ -2249,7 +2249,7 @@ static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba data.baseCol = baseCol; data.selCol = selCol; data.actCol = actCol; - data.em = em; + data.bm = em->bm; data.eed_act = eed_act; dm->drawMappedEdges(dm, draw_dm_edges_sel__setDrawOptions, &data); } @@ -2257,7 +2257,7 @@ static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba /* Draw edges */ static DMDrawOption draw_dm_edges__setDrawOptions(void *userData, int index) { - if (BM_elem_flag_test(EDBM_edge_at_index(userData, index), BM_ELEM_HIDDEN)) + if (BM_elem_flag_test(BM_edge_at_index(userData, index), BM_ELEM_HIDDEN)) return DM_DRAW_OPTION_SKIP; else return DM_DRAW_OPTION_NORMAL; @@ -2265,20 +2265,20 @@ static DMDrawOption draw_dm_edges__setDrawOptions(void *userData, int index) static void draw_dm_edges(BMEditMesh *em, DerivedMesh *dm) { - dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, em); + dm->drawMappedEdges(dm, draw_dm_edges__setDrawOptions, em->bm); } /* Draw edges with color interpolated based on selection */ static DMDrawOption draw_dm_edges_sel_interp__setDrawOptions(void *userData, int index) { - if (BM_elem_flag_test(EDBM_edge_at_index(((void **)userData)[0], index), BM_ELEM_HIDDEN)) + if (BM_elem_flag_test(BM_edge_at_index(((void **)userData)[0], index), BM_ELEM_HIDDEN)) return DM_DRAW_OPTION_SKIP; else return DM_DRAW_OPTION_NORMAL; } static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t) { - BMEdge *eed = EDBM_edge_at_index(((void **)userData)[0], index); + BMEdge *eed = BM_edge_at_index(((void **)userData)[0], index); unsigned char **cols = userData; unsigned char *col0 = cols[(BM_elem_flag_test(eed->v1, BM_ELEM_SELECT)) ? 2 : 1]; unsigned char *col1 = cols[(BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) ? 2 : 1]; @@ -2291,7 +2291,7 @@ static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int i static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol) { - void *cols[3] = {em, baseCol, selCol}; + void *cols[3] = {em->bm, baseCol, selCol}; dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, cols); } @@ -2299,7 +2299,7 @@ static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned c /* Draw only seam edges */ static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int index) { - BMEdge *eed = EDBM_edge_at_index(userData, index); + BMEdge *eed = BM_edge_at_index(userData, index); if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SEAM)) return DM_DRAW_OPTION_NORMAL; @@ -2315,7 +2315,7 @@ static void draw_dm_edges_seams(BMEditMesh *em, DerivedMesh *dm) /* Draw only sharp edges */ static DMDrawOption draw_dm_edges_sharp__setDrawOptions(void *userData, int index) { - BMEdge *eed = EDBM_edge_at_index(userData, index); + BMEdge *eed = BM_edge_at_index(userData, index); if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && !BM_elem_flag_test(eed, BM_ELEM_SMOOTH)) return DM_DRAW_OPTION_NORMAL; @@ -2330,9 +2330,9 @@ static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm) #ifdef WITH_FREESTYLE -static int draw_dm_test_freestyle_edge_mark(BMEditMesh *em, BMEdge *eed) +static int draw_dm_test_freestyle_edge_mark(BMesh *bm, BMEdge *eed) { - FreestyleEdge *fed = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_FREESTYLE_EDGE); + FreestyleEdge *fed = CustomData_bmesh_get(&bm->edata, eed->head.data, CD_FREESTYLE_EDGE); if (!fed) return 0; return (fed->flag & FREESTYLE_EDGE_MARK) != 0; @@ -2341,7 +2341,7 @@ static int draw_dm_test_freestyle_edge_mark(BMEditMesh *em, BMEdge *eed) /* Draw only Freestyle feature edges */ static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int index) { - BMEdge *eed = EDBM_edge_at_index(userData, index); + BMEdge *eed = BM_edge_at_index(userData, index); if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && draw_dm_test_freestyle_edge_mark(userData, eed)) return DM_DRAW_OPTION_NORMAL; @@ -2351,12 +2351,12 @@ static DMDrawOption draw_dm_edges_freestyle__setDrawOptions(void *userData, int static void draw_dm_edges_freestyle(BMEditMesh *em, DerivedMesh *dm) { - dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, em); + dm->drawMappedEdges(dm, draw_dm_edges_freestyle__setDrawOptions, em->bm); } -static int draw_dm_test_freestyle_face_mark(BMEditMesh *em, BMFace *efa) +static int draw_dm_test_freestyle_face_mark(BMesh *bm, BMFace *efa) { - FreestyleFace *ffa = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_FREESTYLE_FACE); + FreestyleFace *ffa = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_FREESTYLE_FACE); if (!ffa) return 0; return (ffa->flag & FREESTYLE_FACE_MARK) != 0; @@ -2369,7 +2369,7 @@ static int draw_dm_test_freestyle_face_mark(BMEditMesh *em, BMFace *efa) static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) { drawDMFacesSel_userData *data = userData; - BMFace *efa = EDBM_face_at_index(data->em, index); + BMFace *efa = BM_face_at_index(data->bm, index); unsigned char *col; if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { @@ -2379,7 +2379,7 @@ static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) } else { #ifdef WITH_FREESTYLE - col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->em, efa) ? 3 : 0]; + col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0]; #else col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0]; #endif @@ -2406,9 +2406,9 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int return 0; i = DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, index); - efa = (i != ORIGINDEX_NONE) ? EDBM_face_at_index(data->em, i) : NULL; + efa = (i != ORIGINDEX_NONE) ? BM_face_at_index(data->bm, i) : NULL; i = DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, next_index); - next_efa = (i != ORIGINDEX_NONE) ? EDBM_face_at_index(data->em, i) : NULL; + next_efa = (i != ORIGINDEX_NONE) ? BM_face_at_index(data->bm, i) : NULL; if (ELEM(NULL, efa, next_efa)) return 0; @@ -2420,8 +2420,8 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int return 0; #ifdef WITH_FREESTYLE - col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->em, efa) ? 3 : 0]; - next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->em, efa) ? 3 : 0]; + col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0]; + next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : draw_dm_test_freestyle_face_mark(data->bm, efa) ? 3 : 0]; #else col = data->cols[BM_elem_flag_test(efa, BM_ELEM_SELECT) ? 1 : 0]; next_col = data->cols[BM_elem_flag_test(next_efa, BM_ELEM_SELECT) ? 1 : 0]; @@ -2445,7 +2445,7 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba drawDMFacesSel_userData data; data.dm = dm; data.cols[0] = baseCol; - data.em = em; + data.bm = em->bm; data.cols[1] = selCol; data.cols[2] = actCol; #ifdef WITH_FREESTYLE @@ -2465,8 +2465,8 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba static DMDrawOption draw_dm_creases__setDrawOptions(void *userData, int index) { drawDMLayer_userData *data = userData; - BMEditMesh *em = data->em; - BMEdge *eed = EDBM_edge_at_index(em, index); + BMesh *bm = data->bm; + BMEdge *eed = BM_edge_at_index(bm, index); if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { const float crease = BM_ELEM_CD_GET_FLOAT(eed, data->cd_layer_offset); @@ -2481,7 +2481,7 @@ static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm) { drawDMLayer_userData data; - data.em = em; + data.bm = em->bm; data.cd_layer_offset = CustomData_get_offset(&em->bm->edata, CD_CREASE); if (data.cd_layer_offset != -1) { @@ -2494,8 +2494,8 @@ static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm) static DMDrawOption draw_dm_bweights__setDrawOptions(void *userData, int index) { drawDMLayer_userData *data = userData; - BMEditMesh *em = data->em; - BMEdge *eed = EDBM_edge_at_index(em, index); + BMesh *bm = data->bm; + BMEdge *eed = BM_edge_at_index(bm, index); if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { const float bweight = BM_ELEM_CD_GET_FLOAT(eed, data->cd_layer_offset); @@ -2510,8 +2510,8 @@ static void draw_dm_bweights__mapFunc(void *userData, int index, const float co[ const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) { drawDMLayer_userData *data = userData; - BMEditMesh *em = data->em; - BMVert *eve = EDBM_vert_at_index(em, index); + BMesh *bm = data->bm; + BMVert *eve = BM_vert_at_index(bm, index); if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { const float bweight = BM_ELEM_CD_GET_FLOAT(eve, data->cd_layer_offset); @@ -2528,7 +2528,7 @@ static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm) if (ts->selectmode & SCE_SELECT_VERTEX) { drawDMLayer_userData data; - data.em = em; + data.bm = em->bm; data.cd_layer_offset = CustomData_get_offset(&em->bm->vdata, CD_BWEIGHT); if (data.cd_layer_offset != -1) { @@ -2541,7 +2541,7 @@ static void draw_dm_bweights(BMEditMesh *em, Scene *scene, DerivedMesh *dm) else { drawDMLayer_userData data; - data.em = em; + data.bm = em->bm; data.cd_layer_offset = CustomData_get_offset(&em->bm->edata, CD_BWEIGHT); if (data.cd_layer_offset != -1) { @@ -3060,7 +3060,7 @@ static DMDrawOption draw_em_fancy__setFaceOpts(void *userData, int index) if (UNLIKELY(index >= em->bm->totface)) return DM_DRAW_OPTION_NORMAL; - efa = EDBM_face_at_index(em, index); + efa = BM_face_at_index(em->bm, index); if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { GPU_enable_material(efa->mat_nr + 1, NULL); return DM_DRAW_OPTION_NORMAL; @@ -3078,7 +3078,7 @@ static DMDrawOption draw_em_fancy__setGLSLFaceOpts(void *userData, int index) if (UNLIKELY(index >= em->bm->totface)) return DM_DRAW_OPTION_NORMAL; - efa = EDBM_face_at_index(em, index); + efa = BM_face_at_index(em->bm, index); if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { return DM_DRAW_OPTION_NORMAL; @@ -3116,7 +3116,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d, } } - EDBM_index_arrays_ensure(em, BM_VERT | BM_EDGE | BM_FACE); + BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE); if (check_object_draw_editweight(me, finalDM)) { if (dt > OB_WIRE) { @@ -3128,7 +3128,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d, else { glEnable(GL_DEPTH_TEST); draw_mesh_paint_weight_faces(finalDM, false, draw_em_fancy__setFaceOpts, me->edit_btmesh); - draw_mesh_paint_weight_edges(rv3d, finalDM, true, draw_dm_edges__setDrawOptions, me->edit_btmesh); + draw_mesh_paint_weight_edges(rv3d, finalDM, true, draw_dm_edges__setDrawOptions, me->edit_btmesh->bm); glDisable(GL_DEPTH_TEST); } } @@ -7382,7 +7382,7 @@ static void bbs_mesh_verts__mapFunc(void *userData, int index, const float co[3] { void **ptrs = userData; int offset = (intptr_t) ptrs[0]; - BMVert *eve = EDBM_vert_at_index(ptrs[1], index); + BMVert *eve = BM_vert_at_index(ptrs[1], index); if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { WM_framebuffer_index_set(offset + index); @@ -7391,7 +7391,7 @@ static void bbs_mesh_verts__mapFunc(void *userData, int index, const float co[3] } static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset) { - void *ptrs[2] = {(void *)(intptr_t) offset, em}; + void *ptrs[2] = {(void *)(intptr_t) offset, em->bm}; glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); bglBegin(GL_POINTS); @@ -7404,7 +7404,7 @@ static DMDrawOption bbs_mesh_wire__setDrawOptions(void *userData, int index) { void **ptrs = userData; int offset = (intptr_t) ptrs[0]; - BMEdge *eed = EDBM_edge_at_index(ptrs[1], index); + BMEdge *eed = BM_edge_at_index(ptrs[1], index); if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { WM_framebuffer_index_set(offset + index); @@ -7416,13 +7416,13 @@ static DMDrawOption bbs_mesh_wire__setDrawOptions(void *userData, int index) } static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) { - void *ptrs[2] = {(void *)(intptr_t) offset, em}; + void *ptrs[2] = {(void *)(intptr_t) offset, em->bm}; dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, ptrs); } static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(void *userData, int index) { - BMFace *efa = EDBM_face_at_index(((void **)userData)[0], index); + BMFace *efa = BM_face_at_index(((void **)userData)[0], index); if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { if (((void **)userData)[1]) { @@ -7437,7 +7437,7 @@ static DMDrawOption bbs_mesh_solid__setSolidDrawOptions(void *userData, int inde static void bbs_mesh_solid__drawCenter(void *userData, int index, const float cent[3], const float UNUSED(no[3])) { - BMFace *efa = EDBM_face_at_index(((void **)userData)[0], index); + BMFace *efa = BM_face_at_index(((void **)userData)[0], index); if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { WM_framebuffer_index_set(index + 1); @@ -7450,7 +7450,7 @@ static void bbs_mesh_solid__drawCenter(void *userData, int index, const float ce static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, DerivedMesh *dm, int facecol) { - void *ptrs[2] = {em, NULL}; //second one being null means to draw black + void *ptrs[2] = {em->bm, NULL}; //second one being null means to draw black cpack(0); if (facecol) { @@ -7548,7 +7548,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec DerivedMesh *dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH); - EDBM_index_arrays_ensure(em, BM_VERT | BM_EDGE | BM_FACE); + BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE); bbs_mesh_solid_EM(em, scene, v3d, ob, dm, ts->selectmode & SCE_SELECT_FACE); if (ts->selectmode & SCE_SELECT_FACE) diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c index 2023513ad92..4df8010be9d 100644 --- a/source/blender/editors/space_view3d/view3d_iterators.c +++ b/source/blender/editors/space_view3d/view3d_iterators.c @@ -40,6 +40,7 @@ #include "BKE_curve.h" #include "BKE_DerivedMesh.h" #include "BKE_displist.h" +#include "BKE_editmesh.h" #include "bmesh.h" @@ -133,7 +134,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, const flo const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) { foreachScreenVert_userData *data = userData; - BMVert *eve = EDBM_vert_at_index(data->vc.em, index); + BMVert *eve = BM_vert_at_index(data->vc.em->bm, index); if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { float screen_co[2]; @@ -165,7 +166,7 @@ void mesh_foreachScreenVert( ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ } - EDBM_index_arrays_ensure(vc->em, BM_VERT); + BM_mesh_elem_table_ensure(vc->em->bm, BM_VERT); dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data, DM_FOREACH_NOP); dm->release(dm); @@ -176,7 +177,7 @@ void mesh_foreachScreenVert( static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const float v0co[3], const float v1co[3]) { foreachScreenEdge_userData *data = userData; - BMEdge *eed = EDBM_edge_at_index(data->vc.em, index); + BMEdge *eed = BM_edge_at_index(data->vc.em->bm, index); if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { float screen_co_a[2]; @@ -225,7 +226,7 @@ void mesh_foreachScreenEdge( ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ } - EDBM_index_arrays_ensure(vc->em, BM_EDGE); + BM_mesh_elem_table_ensure(vc->em->bm, BM_EDGE); dm->foreachMappedEdge(dm, mesh_foreachScreenEdge__mapFunc, &data); dm->release(dm); @@ -236,7 +237,7 @@ void mesh_foreachScreenEdge( static void mesh_foreachScreenFace__mapFunc(void *userData, int index, const float cent[3], const float UNUSED(no[3])) { foreachScreenFace_userData *data = userData; - BMFace *efa = EDBM_face_at_index(data->vc.em, index); + BMFace *efa = BM_face_at_index(data->vc.em->bm, index); if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { float screen_co[2]; @@ -261,7 +262,7 @@ void mesh_foreachScreenFace( data.userData = userData; data.clip_flag = clip_flag; - EDBM_index_arrays_ensure(vc->em, BM_FACE); + BM_mesh_elem_table_ensure(vc->em->bm, BM_FACE); dm->foreachMappedFaceCenter(dm, mesh_foreachScreenFace__mapFunc, &data, DM_FOREACH_NOP); dm->release(dm); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 8a099c7198b..34896eb19aa 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -214,7 +214,7 @@ static void set_mapped_co(void *vuserdata, int index, const float co[3], void **userdata = vuserdata; BMEditMesh *em = userdata[0]; TransVert *tv = userdata[1]; - BMVert *eve = EDBM_vert_at_index(em, index); + BMVert *eve = BM_vert_at_index(em->bm, index); if (BM_elem_index_get(eve) != TM_INDEX_SKIP) { tv = &tv[BM_elem_index_get(eve)]; @@ -342,7 +342,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod } if (transvmain && em->derivedCage) { - EDBM_index_arrays_ensure(em, BM_VERT); + BM_mesh_elem_table_ensure(bm, BM_VERT); em->derivedCage->foreachMappedVert(em->derivedCage, set_mapped_co, userdata, DM_FOREACH_NOP); } } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index d3756ea5973..28d31b09ad2 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2008,8 +2008,8 @@ static struct TransIslandData *editmesh_islands_info_calc(BMEditMesh *em, int *r * its possible we have a selected vertex thats not in a face, for now best not crash in that case. */ fill_vn_i(vert_map, bm->totvert, -1); - EDBM_index_arrays_ensure(em, htype); - ele_array = (htype == BM_FACE) ? (void **)em->face_index : (void **)em->edge_index; + BM_mesh_elem_table_ensure(bm, htype); + ele_array = (htype == BM_FACE) ? (void **)bm->ftable : (void **)bm->etable; BM_mesh_elem_index_ensure(bm, BM_VERT); @@ -2576,10 +2576,10 @@ static void createTransUVs(bContext *C, TransInfo *t) if (propconnected) { /* create element map with island information */ if (ts->uv_flag & UV_SYNC_SELECTION) { - elementmap = EDBM_uv_element_map_create(em, false, true); + elementmap = BM_uv_element_map_create(em->bm, false, true); } else { - elementmap = EDBM_uv_element_map_create(em, true, true); + elementmap = BM_uv_element_map_create(em->bm, true, true); } island_enabled = MEM_callocN(sizeof(*island_enabled) * elementmap->totalIslands, "TransIslandData(UV Editing)"); } @@ -2598,7 +2598,7 @@ static void createTransUVs(bContext *C, TransInfo *t) countsel++; if (propconnected) { - UvElement *element = ED_uv_element_get(elementmap, efa, l); + UvElement *element = BM_uv_element_get(elementmap, efa, l); island_enabled[element->island] = TRUE; } @@ -2634,7 +2634,7 @@ static void createTransUVs(bContext *C, TransInfo *t) continue; if (propconnected) { - UvElement *element = ED_uv_element_get(elementmap, efa, l); + UvElement *element = BM_uv_element_get(elementmap, efa, l); if (!island_enabled[element->island]) { count_rejected++; continue; @@ -2648,7 +2648,7 @@ static void createTransUVs(bContext *C, TransInfo *t) if (propconnected) { t->total -= count_rejected; - EDBM_uv_element_map_free(elementmap); + BM_uv_element_map_free(elementmap); MEM_freeN(island_enabled); } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index dfb0217dfa8..48b92dfac7c 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1429,7 +1429,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes if (em != NULL) { index_array = dm->getVertDataArray(dm, CD_ORIGINDEX); - EDBM_index_arrays_ensure(em, BM_VERT); + BM_mesh_elem_table_ensure(em->bm, BM_VERT); } for (i = 0; i < totvert; i++) { @@ -1450,7 +1450,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes test = 0; } else { - eve = EDBM_vert_at_index(em, index); + eve = BM_vert_at_index(em->bm, index); if ((BM_elem_flag_test(eve, BM_ELEM_HIDDEN) || BM_elem_flag_test(eve, BM_ELEM_SELECT))) @@ -1479,7 +1479,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes if (em != NULL) { index_array = dm->getEdgeDataArray(dm, CD_ORIGINDEX); - EDBM_index_arrays_ensure(em, BM_EDGE); + BM_mesh_elem_table_ensure(em->bm, BM_EDGE); } for (i = 0; i < totedge; i++) { @@ -1499,7 +1499,7 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes test = 0; } else { - BMEdge *eed = EDBM_edge_at_index(em, index); + BMEdge *eed = BM_edge_at_index(em->bm, index); if ((BM_elem_flag_test(eed, BM_ELEM_HIDDEN) || BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 8c299cccbc2..474348e84bc 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -924,7 +924,7 @@ static void uv_select_edgeloop_vertex_loop_flag(UvMapVert *first) static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa, BMLoop *l) { UvMapVert *iterv, *first; - first = EDBM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v)); + first = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v)); for (iterv = first; iterv; iterv = iterv->next) { if (iterv->separate) @@ -953,7 +953,7 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, if (iterv1->f == iterv2->f) { /* if face already tagged, don't do this edge */ - efa = EDBM_face_at_index(em, iterv1->f); + efa = BM_face_at_index(em->bm, iterv1->f); if (BM_elem_flag_test(efa, BM_ELEM_TAG)) return false; @@ -978,7 +978,7 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, break; if (iterv1->f == iterv2->f) { - efa = EDBM_face_at_index(em, iterv1->f); + efa = BM_face_at_index(em->bm, iterv1->f); BM_elem_flag_enable(efa, BM_ELEM_TAG); break; } @@ -1005,8 +1005,8 @@ static int uv_select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestH const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); /* setup */ - EDBM_index_arrays_ensure(em, BM_FACE); - vmap = EDBM_uv_vert_map_create(em, 0, limit); + BM_mesh_elem_table_ensure(em->bm, BM_FACE); + vmap = BM_uv_vert_map_create(em->bm, 0, limit); BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE); @@ -1085,7 +1085,7 @@ static int uv_select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestH } /* cleanup */ - EDBM_uv_vert_map_free(vmap); + BM_uv_vert_map_free(vmap); return (select) ? 1 : -1; } @@ -1108,8 +1108,8 @@ static void uv_select_linked(Scene *scene, Image *ima, BMEditMesh *em, const flo const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); - EDBM_index_arrays_ensure(em, BM_FACE); /* we can use this too */ - vmap = EDBM_uv_vert_map_create(em, 1, limit); + BM_mesh_elem_table_ensure(em->bm, BM_FACE); /* we can use this too */ + vmap = BM_uv_vert_map_create(em->bm, 1, limit); if (vmap == NULL) return; @@ -1152,12 +1152,12 @@ static void uv_select_linked(Scene *scene, Image *ima, BMEditMesh *em, const flo stacksize--; a = stack[stacksize]; - efa = EDBM_face_at_index(em, a); + efa = BM_face_at_index(em->bm, a); BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { /* make_uv_vert_map_EM sets verts tmp.l to the indices */ - vlist = EDBM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v)); + vlist = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v)); startv = vlist; @@ -1241,7 +1241,7 @@ static void uv_select_linked(Scene *scene, Image *ima, BMEditMesh *em, const flo MEM_freeN(stack); MEM_freeN(flag); - EDBM_uv_vert_map_free(vmap); + BM_uv_vert_map_free(vmap); } /* WATCH IT: this returns first selected UV, @@ -2567,7 +2567,7 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene, BMEditMes uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset); - vlist_iter = EDBM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v)); + vlist_iter = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v)); while (vlist_iter) { if (vlist_iter->separate) @@ -2587,7 +2587,7 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene, BMEditMes if (efa_index != vlist_iter->f) { BMLoop *l_other; - efa_vlist = EDBM_face_at_index(em, vlist_iter->f); + efa_vlist = BM_face_at_index(em->bm, vlist_iter->f); /* tf_vlist = BM_ELEM_CD_GET_VOID_P(efa_vlist, cd_poly_tex_offset); */ /* UNUSED */ l_other = BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex); @@ -2657,8 +2657,8 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object uvedit_pixel_to_float(sima, limit, 0.05); - EDBM_index_arrays_ensure(em, BM_FACE); - vmap = EDBM_uv_vert_map_create(em, 0, limit); + BM_mesh_elem_table_ensure(em->bm, BM_FACE); + vmap = BM_uv_vert_map_create(em->bm, 0, limit); if (vmap == NULL) { return; } @@ -2673,7 +2673,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object } } } - EDBM_uv_vert_map_free(vmap); + BM_uv_vert_map_free(vmap); } else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */ @@ -2748,8 +2748,8 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object uvedit_pixel_to_float(sima, limit, 0.05); - EDBM_index_arrays_ensure(em, BM_FACE); - vmap = EDBM_uv_vert_map_create(em, 0, limit); + BM_mesh_elem_table_ensure(em->bm, BM_FACE); + vmap = BM_uv_vert_map_create(em->bm, 0, limit); if (vmap == NULL) { return; } @@ -2764,7 +2764,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object } } } - EDBM_uv_vert_map_free(vmap); + BM_uv_vert_map_free(vmap); } else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */ @@ -3963,8 +3963,8 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op) } /* This code sets editvert->tmp.l to the index. This will be useful later on. */ - EDBM_index_arrays_ensure(em, BM_FACE); - vmap = EDBM_uv_vert_map_create(em, 0, limit); + BM_mesh_elem_table_ensure(bm, BM_FACE); + vmap = BM_uv_vert_map_create(bm, 0, limit); BM_ITER_MESH (editedge, &iter, bm, BM_EDGES_OF_MESH) { /* flags to determine if we uv is separated from first editface match */ @@ -3992,14 +3992,14 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op) v1coincident = 0; separated2 = 0; - efa1 = EDBM_face_at_index(em, mv1->f); + efa1 = BM_face_at_index(bm, mv1->f); mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)]; for (mv2 = mvinit2; mv2; mv2 = mv2->next) { if (mv2->separate) mv2sep = mv2; - efa2 = EDBM_face_at_index(em, mv2->f); + efa2 = BM_face_at_index(bm, mv2->f); if (efa1 == efa2) { /* if v1 is not coincident no point in comparing */ if (v1coincident) { @@ -4042,7 +4042,7 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op) me->drawflag |= ME_DRAWSEAMS; - EDBM_uv_vert_map_free(vmap); + BM_uv_vert_map_free(vmap); DAG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index f788c6a772c..4b5d6d55aa0 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -600,7 +600,7 @@ static void state_delete(StitchState *state) { if (state) { if (state->element_map) { - EDBM_uv_element_map_free(state->element_map); + BM_uv_element_map_free(state->element_map); } if (state->uvs) { MEM_freeN(state->uvs); @@ -661,9 +661,9 @@ static void stitch_uv_edge_generate_linked_edges(GHash *edge_hash, StitchState * /* check to see if other vertex of edge belongs to same vertex as */ if (BM_elem_index_get(iter1->l->next->v) == elemindex2) - iter2 = ED_uv_element_get(element_map, iter1->l->f, iter1->l->next); + iter2 = BM_uv_element_get(element_map, iter1->l->f, iter1->l->next); else if (BM_elem_index_get(iter1->l->prev->v) == elemindex2) - iter2 = ED_uv_element_get(element_map, iter1->l->f, iter1->l->prev); + iter2 = BM_uv_element_get(element_map, iter1->l->f, iter1->l->prev); if (iter2) { int index1 = map[iter1 - first_element]; @@ -1017,7 +1017,7 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) /* copy data from MLoopUVs to the preview display buffers */ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { /* just to test if face was added for processing. uvs of inselected vertices will return NULL */ - UvElement *element = ED_uv_element_get(state->element_map, efa, BM_FACE_FIRST_LOOP(efa)); + UvElement *element = BM_uv_element_get(state->element_map, efa, BM_FACE_FIRST_LOOP(efa)); if (element) { int numoftris = efa->len - 2; @@ -1568,8 +1568,8 @@ static UvEdge *uv_edge_get(BMLoop *l, StitchState *state) { UvEdge tmp_edge; - UvElement *element1 = ED_uv_element_get(state->element_map, l->f, l); - UvElement *element2 = ED_uv_element_get(state->element_map, l->f, l->next); + UvElement *element1 = BM_uv_element_get(state->element_map, l->f, l); + UvElement *element2 = BM_uv_element_get(state->element_map, l->f, l->next); int uv1 = state->map[element1 - state->element_map->buf]; int uv2 = state->map[element2 - state->element_map->buf]; @@ -1651,10 +1651,10 @@ static int stitch_init(bContext *C, wmOperator *op) state->draw_handle = ED_region_draw_cb_activate(ar->type, stitch_draw, state, REGION_DRAW_POST_VIEW); /* in uv synch selection, all uv's are visible */ if (ts->uv_flag & UV_SYNC_SELECTION) { - state->element_map = EDBM_uv_element_map_create(state->em, FALSE, TRUE); + state->element_map = BM_uv_element_map_create(state->em->bm, false, true); } else { - state->element_map = EDBM_uv_element_map_create(state->em, TRUE, TRUE); + state->element_map = BM_uv_element_map_create(state->em->bm, true, true); } if (!state->element_map) { state_delete(state); @@ -1715,9 +1715,9 @@ static int stitch_init(bContext *C, wmOperator *op) continue; BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - UvElement *element = ED_uv_element_get(state->element_map, efa, l); + UvElement *element = BM_uv_element_get(state->element_map, efa, l); int offset1, itmp1 = element - state->element_map->buf; - int offset2, itmp2 = ED_uv_element_get(state->element_map, efa, l->next) - state->element_map->buf; + int offset2, itmp2 = BM_uv_element_get(state->element_map, efa, l->next) - state->element_map->buf; UvEdge *edge; offset1 = map[itmp1]; @@ -1814,7 +1814,7 @@ static int stitch_init(bContext *C, wmOperator *op) UvElement *element; enum StitchModes stored_mode = RNA_enum_get(op->ptr, "stored_mode"); - EDBM_index_arrays_ensure(em, BM_FACE); + BM_mesh_elem_table_ensure(em->bm, BM_FACE); if (stored_mode == STITCH_VERT) { state->selection_stack = MEM_mallocN(sizeof(*state->selection_stack) * state->total_separate_uvs, "uv_stitch_selection_stack"); @@ -1823,8 +1823,8 @@ static int stitch_init(bContext *C, wmOperator *op) { faceIndex = RNA_int_get(&itemptr, "face_index"); elementIndex = RNA_int_get(&itemptr, "element_index"); - efa = EDBM_face_at_index(em, faceIndex); - element = ED_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, elementIndex)); + efa = BM_face_at_index(em->bm, faceIndex); + element = BM_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, elementIndex)); stitch_select_uv(element, state, 1); } RNA_END; @@ -1838,11 +1838,11 @@ static int stitch_init(bContext *C, wmOperator *op) int uv1, uv2; faceIndex = RNA_int_get(&itemptr, "face_index"); elementIndex = RNA_int_get(&itemptr, "element_index"); - efa = EDBM_face_at_index(em, faceIndex); - element = ED_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, elementIndex)); + efa = BM_face_at_index(em->bm, faceIndex); + element = BM_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, elementIndex)); uv1 = map[element - state->element_map->buf]; - element = ED_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, (elementIndex + 1) % efa->len)); + element = BM_uv_element_get(state->element_map, efa, BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, (elementIndex + 1) % efa->len)); uv2 = map[element - state->element_map->buf]; if (uv1 < uv2) { @@ -1877,7 +1877,7 @@ static int stitch_init(bContext *C, wmOperator *op) BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { - UvElement *element = ED_uv_element_get(state->element_map, efa, l); + UvElement *element = BM_uv_element_get(state->element_map, efa, l); if (element) { stitch_select_uv(element, state, 1); } @@ -1913,7 +1913,7 @@ static int stitch_init(bContext *C, wmOperator *op) } BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - UvElement *element = ED_uv_element_get(state->element_map, efa, BM_FACE_FIRST_LOOP(efa)); + UvElement *element = BM_uv_element_get(state->element_map, efa, BM_FACE_FIRST_LOOP(efa)); if (element) { state->tris_per_island[element->island] += (efa->len > 2) ? efa->len - 2 : 0; @@ -2039,7 +2039,7 @@ static void stitch_select(bContext *C, Scene *scene, const wmEvent *event, Stitc * you can do stuff like deselect the opposite stitchable vertex and the initial still gets deselected */ /* This works due to setting of tmp in find nearest uv vert */ - UvElement *element = ED_uv_element_get(state->element_map, hit.efa, hit.l); + UvElement *element = BM_uv_element_get(state->element_map, hit.efa, hit.l); stitch_select_uv(element, state, FALSE); } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 0f42808b2d0..06ffdea96bf 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -421,11 +421,11 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B faceMap = MEM_mallocN(numOfFaces * sizeof(BMFace *), "unwrap_edit_face_map"); BM_mesh_elem_index_ensure(em->bm, BM_VERT); - EDBM_index_arrays_ensure(em, BM_EDGE | BM_FACE); + BM_mesh_elem_table_ensure(em->bm, BM_EDGE | BM_FACE); /* map subsurfed faces to original editFaces */ for (i = 0; i < numOfFaces; i++) - faceMap[i] = EDBM_face_at_index(em, DM_origindex_mface_mpoly(origFaceIndices, origPolyIndices, i)); + faceMap[i] = BM_face_at_index(em->bm, DM_origindex_mface_mpoly(origFaceIndices, origPolyIndices, i)); edgeMap = MEM_mallocN(numOfEdges * sizeof(BMEdge *), "unwrap_edit_edge_map"); @@ -433,7 +433,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B for (i = 0; i < numOfEdges; i++) { /* not all edges correspond to an old edge */ edgeMap[i] = (origEdgeIndices[i] != ORIGINDEX_NONE) ? - EDBM_edge_at_index(em, origEdgeIndices[i]) : NULL; + BM_edge_at_index(em->bm, origEdgeIndices[i]) : NULL; } /* Prepare and feed faces to the solver */ diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index a3569cbde68..e4399d1e416 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -196,9 +196,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* update for display only */ dmd->face_count = bm->totface; result = CDDM_from_bmesh(bm, FALSE); - BLI_assert(bm->vtoolflagpool == NULL); /* make sure we never alloc'd this */ - BLI_assert(bm->etoolflagpool == NULL); - BLI_assert(bm->ftoolflagpool == NULL); + BLI_assert(bm->vtoolflagpool == NULL && + bm->etoolflagpool == NULL && + bm->ftoolflagpool == NULL); /* make sure we never alloc'd these */ + BLI_assert(bm->vtable == NULL && + bm->etable == NULL && + bm->ftable == NULL); + BM_mesh_free(bm); #ifdef USE_TIMEIT diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 92fb506497f..448f02a3772 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -3722,47 +3722,11 @@ char *BPy_BMElem_StringFromHType(const char htype) /* -------------------------------------------------------------------- */ /* keep at bottom */ -/* BAD INCLUDES */ - -#include "BKE_global.h" -#include "BKE_main.h" -#include "BKE_editmesh.h" -#include "DNA_scene_types.h" -#include "DNA_object_types.h" -#include "DNA_mesh_types.h" -#include "MEM_guardedalloc.h" - -/* there are cases where this warning isnt needed, otherwise it could be made into an error */ -static void bm_dealloc_warn(const char *mesh_name) -{ - PySys_WriteStdout("Modified BMesh '%.200s' from a wrapped editmesh is freed without a call " - "to bmesh.update_edit_mesh(mesh, destructive=True), this is will likely cause a crash\n", - mesh_name); -} /* this function is called on free, it should stay quite fast */ static void bm_dealloc_editmode_warn(BPy_BMesh *self) { if (self->flag & BPY_BMFLAG_IS_WRAPPED) { - /* likely editmesh */ - BMesh *bm = self->bm; - Scene *scene; - for (scene = G.main->scene.first; scene; scene = scene->id.next) { - Base *base = scene->basact; - if (base && base->object->type == OB_MESH) { - Mesh *me = base->object->data; - BMEditMesh *em = me->edit_btmesh; - if (em && em->bm == bm) { - /* not foolproof, scripter may have added/removed verts */ - if (((em->vert_index && (MEM_allocN_len(em->vert_index) / sizeof(*em->vert_index)) != bm->totvert)) || - ((em->edge_index && (MEM_allocN_len(em->edge_index) / sizeof(*em->edge_index)) != bm->totedge)) || - ((em->face_index && (MEM_allocN_len(em->face_index) / sizeof(*em->face_index)) != bm->totface))) - { - bm_dealloc_warn(me->id.name + 2); - break; - } - } - } - } + /* currently nop - this works without warnings now */ } } -- cgit v1.2.3 From e667f12783c1ab04a1c1ffc224b03234015ceeb7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 28 Oct 2013 12:16:17 +0000 Subject: Fix #37221: Multilayer EXR inputs generate pink frame/last displayed frame when using an image sequence offset generally speaking, if multilayer image fails to load for current frame doesn't mean anything bad. It might be used to make it so image sequence is being alpha-overed somewhere in the middle of scene time. Made it so if the whole file fails to load, image node will deliver black transparent color, the same what happens for regular (non-multilayer images). Also needed to tweak code in load_multilayer_sequwnce to make sure no cached frames are pointing to a freed memory. --- source/blender/blenkernel/intern/image.c | 32 +++++++++++------------ source/blender/compositor/nodes/COM_ImageNode.cpp | 12 ++++++++- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 01b41eb22cd..52f3c90754a 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -191,17 +191,21 @@ void BKE_image_de_interlace(Image *ima, int odd) /* ***************** ALLOC & FREE, DATA MANAGING *************** */ -static void image_free_buffers(Image *ima) +static void image_free_cahced_frames(Image *image) { ImBuf *ibuf; - - while ((ibuf = BLI_pophead(&ima->ibufs))) { + while ((ibuf = BLI_pophead(&image->ibufs))) { if (ibuf->userdata) { MEM_freeN(ibuf->userdata); ibuf->userdata = NULL; } IMB_freeImBuf(ibuf); } +} + +static void image_free_buffers(Image *ima) +{ + image_free_cahced_frames(ima); if (ima->anim) IMB_free_anim(ima->anim); ima->anim = NULL; @@ -2505,26 +2509,22 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f /* check for new RenderResult */ if (ima->rr == NULL || frame != ima->rr->framenr) { - /* copy to survive not found multilayer image */ - RenderResult *oldrr = ima->rr; + if (ima->rr) { + /* Cached image buffers shares pointers with render result, + * need to ensure there's no image buffers are hanging around + * with dead links after freeing the render result. + */ + image_free_cahced_frames(ima); + RE_FreeRenderResult(ima->rr); + ima->rr = NULL; + } - ima->rr = NULL; ibuf = image_load_sequence_file(ima, iuser, frame); if (ibuf) { /* actually an error */ ima->type = IMA_TYPE_IMAGE; printf("error, multi is normal image\n"); } - // printf("loaded new result %p\n", ima->rr); - /* free result if new one found */ - if (ima->rr) { - // if (oldrr) printf("freed previous result %p\n", oldrr); - if (oldrr) RE_FreeRenderResult(oldrr); - } - else { - ima->rr = oldrr; - } - } if (ima->rr) { RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser); diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp index 6e4bff460d1..d595afe6a78 100644 --- a/source/blender/compositor/nodes/COM_ImageNode.cpp +++ b/source/blender/compositor/nodes/COM_ImageNode.cpp @@ -142,7 +142,17 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c /* without this, multilayer that fail to load will crash blender [#32490] */ if (is_multilayer_ok == false) { - convertToOperations_invalid(graph, context); + int index; + vector &outputsockets = this->getOutputSockets(); + for (index = 0; index < outputsockets.size(); index++) { + const float warning_color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + SetColorOperation *operation = new SetColorOperation(); + operation->setChannels(warning_color); + + /* link the operation */ + this->getOutputSocket(index)->relinkConnections(operation->getOutputSocket()); + graph->addOperation(operation); + } } } else { -- cgit v1.2.3 From ecf2f556678ab5dab73a371262aadbf36a5095b3 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 28 Oct 2013 12:54:18 +0000 Subject: Fix #37187: ghost/test/multitest fails to build Commited patch provided by Lawrence D'Oliveiro, thanks. --- intern/ghost/test/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/intern/ghost/test/CMakeLists.txt b/intern/ghost/test/CMakeLists.txt index 455fff74a5c..84b6f663ff2 100644 --- a/intern/ghost/test/CMakeLists.txt +++ b/intern/ghost/test/CMakeLists.txt @@ -122,6 +122,7 @@ add_library(bli_lib "../../../source/blender/blenlib/intern/listbase.c" "../../../source/blender/blenlib/intern/math_color.c" "../../../source/blender/blenlib/intern/storage.c" + "../../../source/blender/blenlib/intern/task.c" "../../../source/blender/blenlib/intern/threads.c" "../../../source/blender/blenlib/intern/time.c" "../../../source/blender/blenlib/intern/path_util.c" -- cgit v1.2.3 From 4ef6f82a10c918dfa69ee3eabe5ab2fca11cf10f Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Mon, 28 Oct 2013 17:08:07 +0000 Subject: OSX/codesigning: add the signing rules used for releases --- build_files/scons/tools/Blender.py | 9 --------- release/darwin/codesigning_rules_blender.plist | 14 ++++++++++++++ release/darwin/codesigning_rules_player.plist | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 release/darwin/codesigning_rules_blender.plist create mode 100644 release/darwin/codesigning_rules_player.plist diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 9bce91ba9a5..f181f290104 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -675,15 +675,6 @@ def AppIt(target=None, source=None, env=None): cmd = 'unzip -q %s/release/%s -d %s/%s.app/Contents/MacOS/%s/python/'%(libdir,python_zip,installdir,binary,VERSION) commands.getoutput(cmd) - if env['XCODE_CUR_VER'] >= 5: - # For OSX 10.9/Xcode5 subcomponents also must be codesigned. To make this work we need a plist in the versioned libdir - # We copy for now the plist from main bundle, note: Blender must be run once before codesigning to have the py caches generated and taken into account - # After this we can run: codesign -s IDENTITY blender.app --deep - cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/Resources/'%(installdir,binary, VERSION) - commands.getoutput(cmd) - cmd = 'cp %s/%s.app/Contents/Info.plist %s/%s.app/Contents/MacOS/%s/Resources'%(installdir,binary,installdir,binary, VERSION) - commands.getoutput(cmd) - cmd = 'chmod +x %s/%s.app/Contents/MacOS/%s'%(installdir,binary, binary) commands.getoutput(cmd) cmd = 'find %s/%s.app -name .svn -prune -exec rm -rf {} \;'%(installdir, binary) diff --git a/release/darwin/codesigning_rules_blender.plist b/release/darwin/codesigning_rules_blender.plist new file mode 100644 index 00000000000..b3baba80bbb --- /dev/null +++ b/release/darwin/codesigning_rules_blender.plist @@ -0,0 +1,14 @@ + + + + + rules + + + ^MacOS/2.69 + + ^Resources/ + + + + diff --git a/release/darwin/codesigning_rules_player.plist b/release/darwin/codesigning_rules_player.plist new file mode 100644 index 00000000000..2a85041f307 --- /dev/null +++ b/release/darwin/codesigning_rules_player.plist @@ -0,0 +1,15 @@ + + + + + rules + + + ^MacOS/2.69 + + + ^Resources/ + + + + -- cgit v1.2.3 From 869031f6be7632bda9202e631bd9349e2161c079 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Mon, 28 Oct 2013 18:13:27 +0000 Subject: OSX/codesigning: Instructions on codesigning in case i get lost :-P --- release/darwin/README_codesigning.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 release/darwin/README_codesigning.txt diff --git a/release/darwin/README_codesigning.txt b/release/darwin/README_codesigning.txt new file mode 100644 index 00000000000..d2ead00da8a --- /dev/null +++ b/release/darwin/README_codesigning.txt @@ -0,0 +1,25 @@ +Tutorial for codesigning Blender releases on OSX ( atm. i do manually when needed ): + +1. You need to obtain the certificates for blender foundation, they can bw pulled at Apple developer account for BF +2. Run the following commands from terminal: + +codesign -s --resource-rules /release/darwin/codesigning_rules_blender.plist --deep + +codesign -s --resource-rules /release/darwin/codesigning_rules_player.plist --deep + + +3. Checking: + +codesign -vv +codesign -vv + +The result should be something like: + +/blender.app: valid on disk +/blender.app: satisfies its Designated Requirement + +/blenderplayer.app: valid on disk +/blenderplayer.app: satisfies its Designated Requirement + +Jens Verwiebe + -- cgit v1.2.3 From d10abe6d4d6792bf0f9d6dbeed75acb9e46f210f Mon Sep 17 00:00:00 2001 From: Keir Mierle Date: Mon, 28 Oct 2013 18:34:19 +0000 Subject: Fix bug where libmv tracking incorrectly succeeds on failure Before this patch, if Ceres returned USER_SUCCESS indicating that Ceres was only changing the tracked quad slightly between iterations (indicating convergence), no final correlation check was done. This leads to incorrectly returning that the tracking was successful, when it actually failed. --- extern/libmv/libmv/tracking/track_region.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/extern/libmv/libmv/tracking/track_region.cc b/extern/libmv/libmv/tracking/track_region.cc index 349d84b3817..786f16bf219 100644 --- a/extern/libmv/libmv/tracking/track_region.cc +++ b/extern/libmv/libmv/tracking/track_region.cc @@ -1450,16 +1450,6 @@ void TemplatedTrackRegion(const FloatImage &image1, return; } - // This happens when the minimum corner shift tolerance is reached. Due to - // how the tolerance is computed this can't be done by Ceres. So return the - // same termination enum as Ceres, even though this is slightly different - // than Ceres's parameter tolerance, which operates on the raw parameter - // values rather than the pixel shifts of the patch corners. - if (summary.termination_type == ceres::USER_SUCCESS) { - result->termination = TrackRegionResult::PARAMETER_TOLERANCE; - return; - } - #define HANDLE_TERMINATION(termination_enum) \ if (summary.termination_type == ceres::termination_enum) { \ result->termination = TrackRegionResult::termination_enum; \ @@ -1481,6 +1471,16 @@ void TemplatedTrackRegion(const FloatImage &image1, } } + // This happens when the minimum corner shift tolerance is reached. Due to + // how the tolerance is computed this can't be done by Ceres. So return the + // same termination enum as Ceres, even though this is slightly different + // than Ceres's parameter tolerance, which operates on the raw parameter + // values rather than the pixel shifts of the patch corners. + if (summary.termination_type == ceres::USER_SUCCESS) { + result->termination = TrackRegionResult::PARAMETER_TOLERANCE; + return; + } + HANDLE_TERMINATION(PARAMETER_TOLERANCE); HANDLE_TERMINATION(FUNCTION_TOLERANCE); HANDLE_TERMINATION(GRADIENT_TOLERANCE); -- cgit v1.2.3 From 70e9191e15825fb7af6d5ed2e71b239ce601922d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 28 Oct 2013 19:01:01 +0000 Subject: Fix #37184: film exposure + transparency not working well in cycles viewport. --- intern/cycles/kernel/kernel_film.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h index 721eceabc37..370c550a515 100644 --- a/intern/cycles/kernel/kernel_film.h +++ b/intern/cycles/kernel/kernel_film.h @@ -72,9 +72,20 @@ __device void kernel_film_convert_to_half_float(KernelGlobals *kg, __global float4 *in = (__global float4*)(buffer + index*kernel_data.film.pass_stride); __global half *out = (__global half*)rgba + index*4; - float scale = kernel_data.film.exposure*sample_scale; - float4_store_half(out, in, scale); + float exposure = kernel_data.film.exposure; + + if(exposure == 1.0f) { + float4_store_half(out, in, sample_scale); + } + else { + float4 rgba = *in; + rgba.x *= exposure; + rgba.y *= exposure; + rgba.z *= exposure; + + float4_store_half(out, &rgba, sample_scale); + } } CCL_NAMESPACE_END -- cgit v1.2.3 From 421346cefeb232495c924e8f635b06ae44d06be8 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Mon, 28 Oct 2013 19:43:53 +0000 Subject: Fix compile error using Visual Studio 2012. --- source/blender/bmesh/intern/bmesh_mesh.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 033a31daae7..701fdf07710 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -762,21 +762,21 @@ void BM_mesh_elem_table_free(BMesh *bm, const char htype) } } -BMVert *BM_vert_at_index(BMesh *bm, int index) +BMVert *BM_vert_at_index(BMesh *bm, const int index) { BLI_assert((index >= 0) && (index < bm->totvert)); BLI_assert((bm->elem_table_dirty & BM_VERT) == 0); return bm->vtable[index]; } -BMEdge *BM_edge_at_index(BMesh *bm, int index) +BMEdge *BM_edge_at_index(BMesh *bm, const int index) { BLI_assert((index >= 0) && (index < bm->totedge)); BLI_assert((bm->elem_table_dirty & BM_EDGE) == 0); return bm->etable[index]; } -BMFace *BM_face_at_index(BMesh *bm, int index) +BMFace *BM_face_at_index(BMesh *bm, const int index) { BLI_assert((index >= 0) && (index < bm->totface)); BLI_assert((bm->elem_table_dirty & BM_FACE) == 0); -- cgit v1.2.3 From 4ab478ffe1a6813b51585c13d3857b9e2d573564 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 28 Oct 2013 21:49:49 +0000 Subject: Make it possible to track specified clip Added a property to track_marker operator to be able to render clip which name was passed to the operator instead of clip from current clip editor context. Very much useful for automatic tests. --- source/blender/editors/space_clip/tracking_ops.c | 86 ++++++++++++++++++------ 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 51d7bc3139a..53eaa2aaf72 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1097,16 +1097,16 @@ static int track_markers_testbreak(void) return G.is_break; } -static int track_count_markers(SpaceClip *sc, MovieClip *clip) +static int track_count_markers(SpaceClip *sc, MovieClip *clip, int framenr) { int tot = 0; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr = ED_space_clip_get_clip_frame_number(sc); track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) { + bool selected = sc ? TRACK_VIEW_SELECTED(sc, track) : TRACK_SELECTED(track); + if (selected && (track->flag & TRACK_LOCKED) == 0) { MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (!marker || (marker->flag & MARKER_DISABLED) == 0) @@ -1142,18 +1142,20 @@ static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip) } } -static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit_r) +static void track_init_markers(SpaceClip *sc, MovieClip *clip, int framenr, int *frames_limit_r) { ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr = ED_space_clip_get_clip_frame_number(sc); int frames_limit = 0; - clear_invisible_track_selection(sc, clip); + if (sc != NULL) { + clear_invisible_track_selection(sc, clip); + } track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track)) { + bool selected = sc ? TRACK_VIEW_SELECTED(sc, track) : TRACK_SELECTED(track); + if (selected) { if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) { BKE_tracking_marker_ensure(track, framenr); @@ -1193,8 +1195,9 @@ static int track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backward Scene *scene = CTX_data_scene(C); MovieTrackingSettings *settings = &clip->tracking.settings; int frames_limit; + int framenr = ED_space_clip_get_clip_frame_number(sc); - track_init_markers(sc, clip, &frames_limit); + track_init_markers(sc, clip, framenr, &frames_limit); tmj->sfra = ED_space_clip_get_clip_frame_number(sc); tmj->clip = clip; @@ -1317,20 +1320,49 @@ static void track_markers_freejob(void *tmv) static int track_markers_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip_get_clip(sc); + SpaceClip *sc; + MovieClip *clip; Scene *scene = CTX_data_scene(C); struct MovieTrackingContext *context; - int framenr = ED_space_clip_get_clip_frame_number(sc); - int sfra = framenr, efra; + MovieClipUser *user, fake_user = {0}; + int framenr, sfra, efra; int backwards = RNA_boolean_get(op->ptr, "backwards"); int sequence = RNA_boolean_get(op->ptr, "sequence"); int frames_limit; - if (track_count_markers(sc, clip) == 0) + if (RNA_struct_property_is_set(op->ptr, "clip")) { + Main *bmain = CTX_data_main(C); + char clip_name[MAX_ID_NAME - 2]; + + RNA_string_get(op->ptr, "clip", clip_name); + clip = (MovieClip *)BLI_findstring(&bmain->movieclip, clip_name, offsetof(ID, name) + 2); + sc = NULL; + + if (clip == NULL) { + return OPERATOR_CANCELLED; + } + framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, CFRA); + fake_user.framenr = framenr; + user = &fake_user; + } + else { + sc = CTX_wm_space_clip(C); + + if (sc == NULL) { + return OPERATOR_CANCELLED; + } + + clip = ED_space_clip_get_clip(sc); + framenr = ED_space_clip_get_clip_frame_number(sc); + user = &sc->user; + } + + sfra = framenr; + + if (track_count_markers(sc, clip, framenr) == 0) return OPERATOR_CANCELLED; - track_init_markers(sc, clip, &frames_limit); + track_init_markers(sc, clip, framenr, &frames_limit); if (backwards) efra = SFRA; @@ -1351,7 +1383,7 @@ static int track_markers_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* do not disable tracks due to threshold when tracking frame-by-frame */ - context = BKE_tracking_context_new(clip, &sc->user, backwards, sequence); + context = BKE_tracking_context_new(clip, user, backwards, sequence); while (framenr != efra) { if (!BKE_tracking_context_step(context)) @@ -1382,10 +1414,21 @@ static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS TrackMarkersJob *tmj; ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip = ED_space_clip_get_clip(sc); + MovieClip *clip; wmJob *wm_job; - int backwards = RNA_boolean_get(op->ptr, "backwards"); - int sequence = RNA_boolean_get(op->ptr, "sequence"); + bool backwards = RNA_boolean_get(op->ptr, "backwards"); + bool sequence = RNA_boolean_get(op->ptr, "sequence"); + int framenr; + + if (sc == NULL) { + /* TODO(sergey): Support clip for invokaction as well. */ + BKE_report(op->reports, RPT_ERROR, + "Invoking this operator only supported from Clip Editor space."); + return OPERATOR_CANCELLED; + } + + clip = ED_space_clip_get_clip(sc); + framenr = ED_space_clip_get_clip_frame_number(sc); if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) { /* only one tracking is allowed at a time */ @@ -1395,7 +1438,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS if (clip->tracking_context) return OPERATOR_CANCELLED; - if (track_count_markers(sc, clip) == 0) + if (track_count_markers(sc, clip, framenr) == 0) return OPERATOR_CANCELLED; if (!sequence) @@ -1453,6 +1496,8 @@ static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), const wmEven void CLIP_OT_track_markers(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Track Markers"; ot->description = "Track selected markers"; @@ -1461,7 +1506,6 @@ void CLIP_OT_track_markers(wmOperatorType *ot) /* api callbacks */ ot->exec = track_markers_exec; ot->invoke = track_markers_invoke; - ot->poll = ED_space_clip_tracking_poll; ot->modal = track_markers_modal; /* flags */ @@ -1470,6 +1514,8 @@ void CLIP_OT_track_markers(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "backwards", 0, "Backwards", "Do backwards tracking"); RNA_def_boolean(ot->srna, "sequence", 0, "Track Sequence", "Track marker during image sequence rather than single image"); + prop = RNA_def_string(ot->srna, "clip", "", MAX_NAME, "Movie Clip", "Movie Clip to be tracked"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /********************** refine track position operator *********************/ -- cgit v1.2.3 From f0780904bcb992529e523ca17d3d4da3eb42cf0b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Oct 2013 23:35:25 +0000 Subject: correct error in recent commit. --- source/blender/editors/space_view3d/drawobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index ac1f4406983..d9dc549f207 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2309,7 +2309,7 @@ static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int inde static void draw_dm_edges_seams(BMEditMesh *em, DerivedMesh *dm) { - dm->drawMappedEdges(dm, draw_dm_edges_seams__setDrawOptions, em); + dm->drawMappedEdges(dm, draw_dm_edges_seams__setDrawOptions, em->bm); } /* Draw only sharp edges */ @@ -2325,7 +2325,7 @@ static DMDrawOption draw_dm_edges_sharp__setDrawOptions(void *userData, int inde static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm) { - dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em); + dm->drawMappedEdges(dm, draw_dm_edges_sharp__setDrawOptions, em->bm); } #ifdef WITH_FREESTYLE -- cgit v1.2.3 From c11afb4a813959dd85d138b0b9e0beffa30878e5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Oct 2013 23:45:36 +0000 Subject: patch [#37231] Bone fill sets bone to connected, even if neither of its points is at the tail point of points it's connecting. from Henrik Aarnio (hjaarnio) --- source/blender/editors/armature/armature_edit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 1c6ba1d3562..2cd8e930860 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -583,8 +583,11 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) else newbone->parent = ebp2->head_owner; } - - newbone->flag |= BONE_CONNECTED; + + /* don't set for bone connecting two head points of bones */ + if (ebp->tail_owner || ebp2->tail_owner) { + newbone->flag |= BONE_CONNECTED; + } } } else { -- cgit v1.2.3 From 0177d555c7ed9ab8bbfb8b1dd811c15adeed7106 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Oct 2013 23:48:53 +0000 Subject: patch [#37229] Save process slot in blender-softwaregl script from Lawrence D'Oliveiro (ldo) --- release/bin/blender-softwaregl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/release/bin/blender-softwaregl b/release/bin/blender-softwaregl index 970a7870760..8628dca2202 100755 --- a/release/bin/blender-softwaregl +++ b/release/bin/blender-softwaregl @@ -1,7 +1,6 @@ #!/bin/sh -BF_DIST_BIN=`dirname "$0"` -BF_PROGRAM="blender" # BF_PROGRAM=`basename "$0"`-bin -exitcode=0 +BF_DIST_BIN=$(dirname "$0") +BF_PROGRAM="blender" # BF_PROGRAM=$(basename "$0")-bin LD_LIBRARY_PATH=${BF_DIST_BIN}/lib:${LD_LIBRARY_PATH} @@ -20,6 +19,4 @@ XLIB_SKIP_ARGB_VISUALS=1 export LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARYN64_PATH LD_LIBRARY_PATH_64 LD_PRELOAD XLIB_SKIP_ARGB_VISUALS -"$BF_DIST_BIN/$BF_PROGRAM" ${1+"$@"} -exitcode=$? -exit $exitcode +exec "$BF_DIST_BIN/$BF_PROGRAM" ${1+"$@"} -- cgit v1.2.3 From 22396540d7c20afcc931ca6e1a88ee4879d42f4e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Oct 2013 23:59:28 +0000 Subject: patch [#37219] RenderParts.partsdone is not a boolean, but a counter from Lawrence D'Oliveiro (ldo) --- source/blender/render/intern/source/initrender.c | 2 +- source/blender/render/intern/source/sss.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 6cac2fa3fa6..2fb723faa12 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -555,7 +555,7 @@ void RE_parts_init(Render *re, int do_crop) /* this is render info for caller, is not reset when parts are freed! */ re->i.totpart = 0; re->i.curpart = 0; - re->i.partsdone = FALSE; + re->i.partsdone = 0; /* just for readable code.. */ xminb = re->disprect.xmin; diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index 732892ed357..3ec487f63dc 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -878,7 +878,7 @@ static void sss_create_tree_mat(Render *re, Material *mat) re->r.mode &= ~R_OSA; re->sss_points= &points; re->sss_mat= mat; - re->i.partsdone = FALSE; + re->i.partsdone = 0; if (!(re->r.scemode & (R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))) re->result= NULL; -- cgit v1.2.3 From 41587de0167ad6be0f512566916a3e56a6f7107c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Oct 2013 00:05:03 +0000 Subject: patch [#37217] Make WM_gesture_lines draw the lasso unfilled. (Adding reroute nodes, cutting node links) by Henrik Aarnio (hjaarnio) --- source/blender/windowmanager/intern/wm_gesture.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 05ee23e2361..4d4d46d063a 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -293,13 +293,15 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt) } -static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt) +static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled) { short *lasso = (short *)gt->customdata; int i; - draw_filled_lasso(win, gt); - + if (filled) { + draw_filled_lasso(win, gt); + } + glEnable(GL_LINE_STIPPLE); glColor3ub(96, 96, 96); glLineStipple(1, 0xAAAA); @@ -365,9 +367,9 @@ void wm_gesture_draw(wmWindow *win) wm_gesture_draw_cross(win, gt); } else if (gt->type == WM_GESTURE_LINES) - wm_gesture_draw_lasso(win, gt); + wm_gesture_draw_lasso(win, gt, false); else if (gt->type == WM_GESTURE_LASSO) - wm_gesture_draw_lasso(win, gt); + wm_gesture_draw_lasso(win, gt, true); else if (gt->type == WM_GESTURE_STRAIGHTLINE) wm_gesture_draw_line(gt); } -- cgit v1.2.3 From 5f05de0c1ee99f0c4ae884f1102862f0d242c64f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Oct 2013 00:10:03 +0000 Subject: patch [#37218] Split operator for armatures from Henrik Aarnio (hjaarnio) --- release/scripts/startup/bl_ui/space_view3d.py | 1 + source/blender/editors/armature/armature_edit.c | 38 +++++++++++++++++++++++ source/blender/editors/armature/armature_intern.h | 1 + source/blender/editors/armature/armature_ops.c | 2 ++ 4 files changed, 42 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 4a36b714c33..6f9af768e38 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2389,6 +2389,7 @@ class VIEW3D_MT_edit_armature(Menu): layout.operator("armature.merge") layout.operator("armature.fill") layout.operator("armature.delete") + layout.operator("armature.split") layout.operator("armature.separate") layout.separator() diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 2cd8e930860..e4d244f9277 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -1066,6 +1066,44 @@ void ARMATURE_OT_align(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/* ********************************* Split ******************************* */ + +static int armature_split_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (bArmature *)ob->data; + EditBone *bone; + + for (bone = arm->edbo->first; bone; bone = bone->next){ + if (bone->parent && (bone->flag & BONE_SELECTED) != (bone->parent->flag & BONE_SELECTED)){ + bone->parent = NULL; + bone->flag &= ~BONE_CONNECTED; + } + } + for (bone = arm->edbo->first; bone; bone = bone->next){ + ED_armature_ebone_select_set(bone, (bone->flag & BONE_SELECTED) != 0); + } + + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); + + return OPERATOR_FINISHED; +} + +void ARMATURE_OT_split(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Split"; + ot->idname = "ARMATURE_OT_split"; + ot->description = "Split off selected bones from connected unselected bones"; + + /* api callbacks */ + ot->exec = armature_split_exec; + ot->poll = ED_operator_editarmature; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + /* ********************************* Delete ******************************* */ /* previously delete_armature */ diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index e58d8fd2380..0f1597cc6f3 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -78,6 +78,7 @@ void ARMATURE_OT_click_extrude(struct wmOperatorType *ot); void ARMATURE_OT_fill(struct wmOperatorType *ot); void ARMATURE_OT_merge(struct wmOperatorType *ot); void ARMATURE_OT_separate(struct wmOperatorType *ot); +void ARMATURE_OT_split(struct wmOperatorType *ot); void ARMATURE_OT_autoside_names(struct wmOperatorType *ot); void ARMATURE_OT_flip_names(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 3c41765034d..496da812610 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -74,6 +74,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(ARMATURE_OT_fill); WM_operatortype_append(ARMATURE_OT_merge); WM_operatortype_append(ARMATURE_OT_separate); + WM_operatortype_append(ARMATURE_OT_split); WM_operatortype_append(ARMATURE_OT_autoside_names); WM_operatortype_append(ARMATURE_OT_flip_names); @@ -269,6 +270,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_click_extrude", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_fill", FKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_merge", MKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_split", YKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); -- cgit v1.2.3 From 427844c28d2083ffcec93066ebee3fcf0fd01e42 Mon Sep 17 00:00:00 2001 From: Keir Mierle Date: Tue, 29 Oct 2013 01:06:50 +0000 Subject: Eagerly attempt to refine a track before doing a brute search Before the refinement phase of tracking, a brute force SAD search is run across the search area. This works well but is slow; especially if the guess for the track's location is accurate. This patch runs a refinement phase before running a brute force search, hoping that the guessed position (in x2, y2) is close to the best answer. If it is, then no brute search is done. If it is not, then a normal brute force search followed by refinement is done. In some cases this may produce worse tracks than before; the regressions will need investigation. The predictive motion model (to be implemented) will reduce the probability of that happening. --- extern/libmv/libmv-capi.cc | 3 ++ extern/libmv/libmv/tracking/track_region.cc | 47 +++++++++++++++++++++++++++-- extern/libmv/libmv/tracking/track_region.h | 12 ++++++-- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/extern/libmv/libmv-capi.cc b/extern/libmv/libmv-capi.cc index 0585bd3e8ac..f02ca0e98e0 100644 --- a/extern/libmv/libmv-capi.cc +++ b/extern/libmv/libmv-capi.cc @@ -306,6 +306,9 @@ int libmv_trackRegion(const libmv_TrackRegionOptions *options, track_region_options.num_extra_points = 1; track_region_options.image1_mask = NULL; track_region_options.use_brute_initialization = options->use_brute; + /* TODO(keir): This will make some cases better, but may be a regression until + * the motion model is in. Since this is on trunk, enable it for now. */ + track_region_options.attempt_refine_before_brute = true; track_region_options.use_normalized_intensities = options->use_normalization; if (options->image1_mask) { diff --git a/extern/libmv/libmv/tracking/track_region.cc b/extern/libmv/libmv/tracking/track_region.cc index 786f16bf219..9e0bf9a77da 100644 --- a/extern/libmv/libmv/tracking/track_region.cc +++ b/extern/libmv/libmv/tracking/track_region.cc @@ -1289,6 +1289,15 @@ bool BruteTranslationOnlyInitialize(const FloatImage &image1, return true; } +void CopyQuad(double *src_x, double *src_y, + double *dst_x, double *dst_y, + int num_extra_points) { + for (int i = 0; i < 4 + num_extra_points; ++i) { + dst_x[i] = src_x[i]; + dst_y[i] = src_y[i]; + } +} + } // namespace template @@ -1298,11 +1307,46 @@ void TemplatedTrackRegion(const FloatImage &image1, const TrackRegionOptions &options, double *x2, double *y2, TrackRegionResult *result) { - for (int i = 0; i < 4; ++i) { + for (int i = 0; i < 4 + options.num_extra_points; ++i) { LG << "P" << i << ": (" << x1[i] << ", " << y1[i] << "); guess (" << x2[i] << ", " << y2[i] << "); (dx, dy): (" << (x2[i] - x1[i]) << ", " << (y2[i] - y1[i]) << ")."; } + + // Since (x2, y2) contains a prediction for where the tracked point should + // go, try a refinement immediately in the hope that the prediction is close + // enough. + if (options.attempt_refine_before_brute) { + TrackRegionOptions modified_options = options; + modified_options.use_brute_initialization = false; + modified_options.attempt_refine_before_brute = false; + + double x2_first_try[5]; + double y2_first_try[5]; + CopyQuad(x2, y2, x2_first_try, y2_first_try, options.num_extra_points); + + TemplatedTrackRegion(image1, image2, + x1, y1, modified_options, + x2_first_try, y2_first_try, result); + + // Of the things that can happen in the first pass, don't try the brute + // pass (and second attempt) if the error is one of the terminations below. + if (result->termination == TrackRegionResult::PARAMETER_TOLERANCE || + result->termination == TrackRegionResult::FUNCTION_TOLERANCE || + result->termination == TrackRegionResult::GRADIENT_TOLERANCE || + result->termination == TrackRegionResult::SOURCE_OUT_OF_BOUNDS || + result->termination == TrackRegionResult::DESTINATION_OUT_OF_BOUNDS || + result->termination == TrackRegionResult::INSUFFICIENT_PATTERN_AREA) { + LG << "Terminated with first try at refinement; no brute needed."; + // TODO(keir): Also check correlation? + CopyQuad(x2_first_try, y2_first_try, x2, y2, options.num_extra_points); + LG << "Early termination correlation: " << result->correlation; + return; + } else { + LG << "Initial eager-refinement failed; retrying normally."; + } + } + if (options.use_normalized_intensities) { LG << "Using normalized intensities."; } @@ -1368,7 +1412,6 @@ void TemplatedTrackRegion(const FloatImage &image1, int num_samples_y; PickSampling(x1, y1, x2, y2, &num_samples_x, &num_samples_y); - // Compute the warp from rectangular coordinates. Mat3 canonical_homography = ComputeCanonicalHomography(x1, y1, num_samples_x, diff --git a/extern/libmv/libmv/tracking/track_region.h b/extern/libmv/libmv/tracking/track_region.h index 6c7218f11d1..58742cab36c 100644 --- a/extern/libmv/libmv/tracking/track_region.h +++ b/extern/libmv/libmv/tracking/track_region.h @@ -55,6 +55,13 @@ struct TrackRegionOptions { // that the nearby minima is correct, or the search area is too small. bool use_brute_initialization; + // If true and brute initialization is enabled, first try refining with the + // initial guess instead of starting with the brute initialization. If the + // initial refinement fails, then a normal brute search followed by + // refinement is attempted. If the initial refinement succeeds, then the + // result is returned as is (skipping a costly brute search). + bool attempt_refine_before_brute; + // If true, normalize the image patches by their mean before doing the sum of // squared error calculation. This is reasonable since the effect of // increasing light intensity is multiplicative on the pixel intensities. @@ -67,8 +74,9 @@ struct TrackRegionOptions { // take the image derivative. double sigma; - // Extra points that should get transformed by the warp. This is useful - // because the actual warp parameters are not exposed. + // Extra points that should get transformed by the warp. These points are + // appended to the x and y arrays. This is useful because the actual warp + // parameters are not exposed. int num_extra_points; // For motion models other than translation, the optimizer sometimes has -- cgit v1.2.3 From a7b44c82e5b90e83a588fabb22fda5ac41891bdf Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 29 Oct 2013 02:42:51 +0000 Subject: Triangulate Modifier: using different ngon and quad methods Quads: Beauty, Fixed, Fixed Alternate, Shortest Diagonal Ngons: Beauty, Scanfill * Shortest Diagonal is the default method in the modifier (popular elsewhere), but beauty is the default in Ctrl+T). * Remove the need for output slot and beauty operator to be called after Clt+T Patch with collaborations and reviewed by Campbell Barton --- .../startup/bl_ui/properties_data_modifier.py | 9 ++- source/blender/blenloader/intern/readfile.c | 20 +++++++ source/blender/bmesh/intern/bmesh_opdefines.c | 3 +- source/blender/bmesh/intern/bmesh_polygon.c | 66 +++++++++++++++++++++- source/blender/bmesh/intern/bmesh_polygon.h | 3 +- source/blender/bmesh/operators/bmo_triangulate.c | 6 +- source/blender/bmesh/tools/bmesh_beautify.c | 27 +++++---- source/blender/bmesh/tools/bmesh_beautify.h | 4 ++ source/blender/bmesh/tools/bmesh_triangulate.c | 12 ++-- source/blender/bmesh/tools/bmesh_triangulate.h | 2 +- source/blender/editors/mesh/editmesh_tools.c | 18 ++---- source/blender/editors/mesh/mesh_ops.c | 7 ++- source/blender/editors/sculpt_paint/sculpt.c | 2 +- source/blender/makesdna/DNA_modifier_types.h | 18 +++++- source/blender/makesrna/RNA_enum_types.h | 3 + source/blender/makesrna/intern/rna_modifier.c | 27 ++++++++- source/blender/modifiers/intern/MOD_triangulate.c | 9 +-- 17 files changed, 188 insertions(+), 48 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 9bfc14f1f28..288330084b9 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -1099,7 +1099,14 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col.prop(md, "use_z_symmetry") def TRIANGULATE(self, layout, ob, md): - layout.prop(md, "use_beauty") + row = layout.row() + + col = row.column() + col.label(text="Quad Method:") + col.prop(md, "quad_method", text="") + col = row.column() + col.label(text="Ngon Method:") + col.prop(md, "ngon_method", text="") def UV_WARP(self, layout, ob, md): split = layout.split() diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 51158fc5321..10c71c79b55 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9758,6 +9758,26 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "quad_method")) { + Object *ob; + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Triangulate) { + TriangulateModifierData *tmd = (TriangulateModifierData *)md; + if ((tmd->flag & MOD_TRIANGULATE_BEAUTY)) { + tmd->quad_method = MOD_TRIANGULATE_QUAD_BEAUTY; + tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY; + } + else { + tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED; + tmd->ngon_method = MOD_TRIANGULATE_NGON_SCANFILL; + } + } + } + } + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */ diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 775cb24b8c9..ea533837b04 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1028,7 +1028,8 @@ static BMOpDefine bmo_triangulate_def = { "triangulate", /* slots_in */ {{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, - {"use_beauty", BMO_OP_SLOT_BOOL}, + {"quad_method", BMO_OP_SLOT_INT}, + {"ngon_method", BMO_OP_SLOT_INT}, {{'\0'}}, }, /* slots_out */ diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 12ec3da9b69..e88fdb8a7e8 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -29,6 +29,7 @@ */ #include "DNA_listBase.h" +#include "DNA_modifier_types.h" #include "BLI_alloca.h" #include "BLI_math.h" @@ -817,7 +818,9 @@ bool BM_face_point_inside_test(BMFace *f, const float co[3]) void BM_face_triangulate(BMesh *bm, BMFace *f, BMFace **r_faces_new, MemArena *sf_arena, - const bool use_beauty, const bool use_tag) + const int quad_method, + const int ngon_method, + const bool use_tag) { BMLoop *l_iter, *l_first, *l_new; BMFace *f_new; @@ -825,6 +828,7 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, int nf_i = 0; BMEdge **edge_array; int edge_array_len; + bool use_beauty = (ngon_method == MOD_TRIANGULATE_NGON_BEAUTY); #define SF_EDGE_IS_BOUNDARY 0xff @@ -832,9 +836,67 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, if (f->len == 4) { + BMVert *v1, *v2; l_first = BM_FACE_FIRST_LOOP(f); - f_new = BM_face_split(bm, f, l_first->v, l_first->next->next->v, &l_new, NULL, false); + switch (quad_method) { + case MOD_TRIANGULATE_QUAD_FIXED: + { + v1 = l_first->v; + v2 = l_first->next->next->v; + break; + } + case MOD_TRIANGULATE_QUAD_ALTERNATE: + { + v1 = l_first->next->v; + v2 = l_first->prev->v; + break; + } + case MOD_TRIANGULATE_QUAD_SHORTEDGE: + { + BMVert *v3, *v4; + float d1, d2; + + v1 = l_first->v; + v2 = l_first->next->next->v; + v3 = l_first->next->v; + v4 = l_first->prev->v; + + d1 = len_squared_v3v3(v1->co, v2->co); + d2 = len_squared_v3v3(v3->co, v4->co); + + if (d2 < d1) { + v1 = v3; + v2 = v4; + } + break; + } + case MOD_TRIANGULATE_QUAD_BEAUTY: + default: + { + BMVert *v3, *v4; + float cost; + + v1 = l_first->next->v; + v2 = l_first->next->next->v; + v3 = l_first->prev->v; + v4 = l_first->v; + + cost = BM_verts_calc_rotate_beauty(v1, v2, v3, v4, 0, 0); + + if (cost < 0.0f) { + v1 = v4; + //v2 = v2; + } + else { + //v1 = v1; + v2 = v3; + } + break; + } + } + + f_new = BM_face_split(bm, f, v1, v2, &l_new, NULL, false); copy_v3_v3(f_new->no, f->no); if (use_tag) { diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h index b7117621273..4759c73cb4d 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.h +++ b/source/blender/bmesh/intern/bmesh_polygon.h @@ -54,7 +54,8 @@ bool BM_face_point_inside_test(BMFace *f, const float co[3]) ATTR_WARN_UNUSED_R void BM_face_triangulate(BMesh *bm, BMFace *f, BMFace **newfaces, struct MemArena *sf_arena, - const bool use_beauty, const bool use_tag) ATTR_NONNULL(1, 2); + const int quad_method, const int ngon_method, + const bool use_tag) ATTR_NONNULL(1, 2); void BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len) ATTR_NONNULL(); diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c index ca45289520b..a1de265bc56 100644 --- a/source/blender/bmesh/operators/bmo_triangulate.c +++ b/source/blender/bmesh/operators/bmo_triangulate.c @@ -42,13 +42,15 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op) { - const bool use_beauty = BMO_slot_bool_get(op->slots_in, "use_beauty"); + const int quad_method = BMO_slot_int_get(op->slots_in, "quad_method"); + const int ngon_method = BMO_slot_int_get(op->slots_in, "ngon_method"); + BMOpSlot *slot_facemap_out = BMO_slot_get(op->slots_out, "face_map.out"); BM_mesh_elem_hflag_disable_all(bm, BM_FACE | BM_EDGE, BM_ELEM_TAG, false); BMO_slot_buffer_hflag_enable(bm, op->slots_in, "faces", BM_FACE, BM_ELEM_TAG, false); - BM_mesh_triangulate(bm, use_beauty, true, op, slot_facemap_out); + BM_mesh_triangulate(bm, quad_method, ngon_method, true, op, slot_facemap_out); BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG); BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG); diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c index af9345b903c..1a1201c015e 100644 --- a/source/blender/bmesh/tools/bmesh_beautify.c +++ b/source/blender/bmesh/tools/bmesh_beautify.c @@ -252,19 +252,13 @@ static float bm_edge_calc_rotate_beauty__angle( return FLT_MAX; } -static float bm_edge_calc_rotate_beauty(const BMEdge *e, const short flag, const short method) +float BM_verts_calc_rotate_beauty( +const BMVert *v1, const BMVert *v2, const BMVert *v3, const BMVert *v4, const short flag, const short method) { /* not a loop (only to be able to break out) */ do { - const float *v1, *v2, *v3, *v4; - - v1 = e->l->prev->v->co; /* first face co */ - v2 = e->l->v->co; /* e->v1 or e->v2*/ - v3 = e->l->radial_next->prev->v->co; /* second face co */ - v4 = e->l->next->v->co; /* e->v1 or e->v2*/ - if (flag & VERT_RESTRICT_TAG) { - BMVert *v_a = e->l->prev->v, *v_b = e->l->radial_next->prev->v; + const BMVert *v_a = v1, *v_b = v3; if (BM_elem_flag_test(v_a, BM_ELEM_TAG) == BM_elem_flag_test(v_b, BM_ELEM_TAG)) { break; } @@ -277,15 +271,26 @@ static float bm_edge_calc_rotate_beauty(const BMEdge *e, const short flag, const switch (method) { case 0: - return bm_edge_calc_rotate_beauty__area(v1, v2, v3, v4); + return bm_edge_calc_rotate_beauty__area(v1->co, v2->co, v3->co, v4->co); default: - return bm_edge_calc_rotate_beauty__angle(v1, v2, v3, v4); + return bm_edge_calc_rotate_beauty__angle(v1->co, v2->co, v3->co, v4->co); } } while (false); return FLT_MAX; } +static float bm_edge_calc_rotate_beauty(const BMEdge *e, const short flag, const short method) +{ + const BMVert *v1, *v2, *v3, *v4; + v1 = e->l->prev->v; /* first vert co */ + v2 = e->l->v; /* e->v1 or e->v2*/ + v3 = e->l->radial_next->prev->v; /* second vert co */ + v4 = e->l->next->v; /* e->v1 or e->v2*/ + + return BM_verts_calc_rotate_beauty(v1, v2, v3, v4, flag, method); +} + /* -------------------------------------------------------------------- */ /* Update the edge cost of rotation in the heap */ diff --git a/source/blender/bmesh/tools/bmesh_beautify.h b/source/blender/bmesh/tools/bmesh_beautify.h index 210e265d706..7cc17008b50 100644 --- a/source/blender/bmesh/tools/bmesh_beautify.h +++ b/source/blender/bmesh/tools/bmesh_beautify.h @@ -35,4 +35,8 @@ void BM_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_ const short flag, const short method, const short oflag_edge, const short oflag_face); +float BM_verts_calc_rotate_beauty(const BMVert *v1, const BMVert *v2, + const BMVert *v3, const BMVert *v4, + const short flag, const short method); + #endif /* __BMESH_BEAUTIFY_H__ */ diff --git a/source/blender/bmesh/tools/bmesh_triangulate.c b/source/blender/bmesh/tools/bmesh_triangulate.c index 34ff493a026..59c2aa4331d 100644 --- a/source/blender/bmesh/tools/bmesh_triangulate.c +++ b/source/blender/bmesh/tools/bmesh_triangulate.c @@ -42,14 +42,16 @@ /** * a version of #BM_face_triangulate that maps to #BMOpSlot */ -static void bm_face_triangulate_mapping(BMesh *bm, BMFace *face, MemArena *sf_arena, const bool use_beauty, const bool use_tag, +static void bm_face_triangulate_mapping(BMesh *bm, BMFace *face, MemArena *sf_arena, + const int quad_method, const int ngon_method, + const bool use_tag, BMOperator *op, BMOpSlot *slot_facemap_out) { const int faces_array_tot = face->len - 3; BMFace **faces_array = BLI_array_alloca(faces_array, faces_array_tot); BLI_assert(face->len > 3); - BM_face_triangulate(bm, face, faces_array, sf_arena, use_beauty, use_tag); + BM_face_triangulate(bm, face, faces_array, sf_arena, quad_method, ngon_method, use_tag); if (faces_array) { int i; @@ -61,7 +63,7 @@ static void bm_face_triangulate_mapping(BMesh *bm, BMFace *face, MemArena *sf_ar } -void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only, +void BM_mesh_triangulate(BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only, BMOperator *op, BMOpSlot *slot_facemap_out) { BMIter iter; @@ -75,7 +77,7 @@ void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only, BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) { if (face->len > 3) { if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) { - bm_face_triangulate_mapping(bm, face, sf_arena, use_beauty, tag_only, + bm_face_triangulate_mapping(bm, face, sf_arena, quad_method, ngon_method, tag_only, op, slot_facemap_out); } } @@ -85,7 +87,7 @@ void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only, BM_ITER_MESH (face, &iter, bm, BM_FACES_OF_MESH) { if (face->len > 3) { if (tag_only == false || BM_elem_flag_test(face, BM_ELEM_TAG)) { - BM_face_triangulate(bm, face, NULL, sf_arena, use_beauty, tag_only); + BM_face_triangulate(bm, face, NULL, sf_arena, quad_method, ngon_method, tag_only); } } } diff --git a/source/blender/bmesh/tools/bmesh_triangulate.h b/source/blender/bmesh/tools/bmesh_triangulate.h index 141aa2f82b4..550109ffef9 100644 --- a/source/blender/bmesh/tools/bmesh_triangulate.h +++ b/source/blender/bmesh/tools/bmesh_triangulate.h @@ -30,7 +30,7 @@ #ifndef __BMESH_TRIANGULATE_H__ #define __BMESH_TRIANGULATE_H__ -void BM_mesh_triangulate(BMesh *bm, const bool use_beauty, const bool tag_only, +void BM_mesh_triangulate(BMesh *bm, const int quad_method, const int ngon_method, const bool tag_only, BMOperator *op, BMOpSlot *slot_facemap_out); #endif /* __BMESH_TRIANGULATE_H__ */ diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index e557b07dba2..b35ed10b157 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3204,21 +3204,12 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); BMOperator bmop; - const bool use_beauty = RNA_boolean_get(op->ptr, "use_beauty"); + const int quad_method = RNA_enum_get(op->ptr, "quad_method"); + const int ngon_method = RNA_enum_get(op->ptr, "ngon_method"); - EDBM_op_init(em, &bmop, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty); + EDBM_op_init(em, &bmop, op, "triangulate faces=%hf quad_method=%i ngon_method=%i", BM_ELEM_SELECT, quad_method, ngon_method); BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true); - - /* now call beauty fill */ - if (use_beauty) { - EDBM_op_call_and_selectf( - em, op, "geom.out", true, - "beautify_fill faces=%S edges=%S", - &bmop, "faces.out", &bmop, "edges.out"); - } - if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } @@ -3243,7 +3234,8 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "use_beauty", 1, "Beauty", "Use best triangulation division"); + RNA_def_enum(ot->srna, "quad_method", modifier_triangulate_quad_method_items, MOD_TRIANGULATE_QUAD_BEAUTY, "Quad Method", "Method for splitting the quads into triangles"); + RNA_def_enum(ot->srna, "ngon_method", modifier_triangulate_ngon_method_items, MOD_TRIANGULATE_NGON_BEAUTY, "Ngon Method", "Method for splitting the ngons into triangles"); } static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 86f69ab8538..3c42beb8b12 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -29,6 +29,7 @@ */ #include "DNA_scene_types.h" +#include "DNA_modifier_types.h" #include "BLI_math.h" @@ -359,9 +360,11 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "use_beauty", true); + RNA_enum_set(kmi->ptr, "quad_method", MOD_TRIANGULATE_QUAD_BEAUTY); + RNA_enum_set(kmi->ptr, "ngon_method", MOD_TRIANGULATE_NGON_BEAUTY); kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "use_beauty", false); + RNA_enum_set(kmi->ptr, "quad_method", MOD_TRIANGULATE_QUAD_FIXED); + RNA_enum_set(kmi->ptr, "ngon_method", MOD_TRIANGULATE_NGON_SCANFILL); WM_keymap_add_item(keymap, "MESH_OT_tris_convert_to_quads", JKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a7a7b6ab84a..7c2c77d9041 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4660,7 +4660,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) static void sculpt_dynamic_topology_triangulate(BMesh *bm) { if (bm->totloop != bm->totface * 3) { - BM_mesh_triangulate(bm, false, false, NULL, NULL); + BM_mesh_triangulate(bm, false, MOD_TRIANGULATE_QUAD_FIXED, MOD_TRIANGULATE_NGON_SCANFILL, NULL, NULL); } } diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 799968335b7..43de7166c4f 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -1177,11 +1177,27 @@ typedef struct TriangulateModifierData { ModifierData modifier; int flag; + int quad_method; + int ngon_method; int pad; } TriangulateModifierData; enum { - MOD_TRIANGULATE_BEAUTY = (1 << 0), + MOD_TRIANGULATE_BEAUTY = (1 << 0), /* deprecated */ +}; + +/* Triangulate methods - NGons */ +enum { + MOD_TRIANGULATE_NGON_BEAUTY = 0, + MOD_TRIANGULATE_NGON_SCANFILL, +}; + +/* Triangulate methods - Quads */ +enum { + MOD_TRIANGULATE_QUAD_BEAUTY = 0, + MOD_TRIANGULATE_QUAD_FIXED, + MOD_TRIANGULATE_QUAD_ALTERNATE, + MOD_TRIANGULATE_QUAD_SHORTEDGE }; typedef struct LaplacianSmoothModifierData { diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index d33d3df8a5e..5a7df0e0080 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -60,6 +60,9 @@ extern EnumPropertyItem constraint_type_items[]; extern EnumPropertyItem boidrule_type_items[]; extern EnumPropertyItem sequence_modifier_type_items[]; +extern EnumPropertyItem modifier_triangulate_quad_method_items[]; +extern EnumPropertyItem modifier_triangulate_ngon_method_items[]; + extern EnumPropertyItem image_type_items[]; extern EnumPropertyItem image_color_mode_items[]; extern EnumPropertyItem image_depth_mode_items[]; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 57eeba61a73..276d8e0a678 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -109,6 +109,20 @@ EnumPropertyItem modifier_type_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem modifier_triangulate_quad_method_items[] = { + {MOD_TRIANGULATE_QUAD_BEAUTY, "BEAUTY", 0, "Beauty ", "Split the quads in nice triangles, slower method"}, + {MOD_TRIANGULATE_QUAD_FIXED, "FIXED", 0, "Fixed", "Split the quads on the first and third vertices"}, + {MOD_TRIANGULATE_QUAD_ALTERNATE, "FIXED_ALTERNATE", 0, "Fixed Alternate", "Split the quads on the 2nd and 4th vertices"}, + {MOD_TRIANGULATE_QUAD_SHORTEDGE, "SHORTEST_DIAGONAL", 0, "Shortest Diagonal", "Split the quads based on the distance between the vertices"}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem modifier_triangulate_ngon_method_items[] = { + {MOD_TRIANGULATE_NGON_SCANFILL, "SCANFILL", 0, "Scanfill", "Split the ngons using a scanfill algorithm "}, + {MOD_TRIANGULATE_NGON_BEAUTY, "BEAUTY", 0, "Beauty", "Arrange the new triangles nicely, slower method"}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "DNA_particle_types.h" @@ -3500,9 +3514,16 @@ static void rna_def_modifier_triangulate(BlenderRNA *brna) RNA_def_struct_sdna(srna, "TriangulateModifierData"); RNA_def_struct_ui_icon(srna, ICON_MOD_TRIANGULATE); - prop = RNA_def_property(srna, "use_beauty", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_TRIANGULATE_BEAUTY); - RNA_def_property_ui_text(prop, "Beauty Subdivide", "Subdivide across shortest diagonal"); + prop = RNA_def_property(srna, "quad_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "quad_method"); + RNA_def_property_enum_items(prop, modifier_triangulate_quad_method_items); + RNA_def_property_ui_text(prop, "Quad Method", "Method for splitting the quads into triangles"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "ngon_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "ngon_method"); + RNA_def_property_enum_items(prop, modifier_triangulate_ngon_method_items); + RNA_def_property_ui_text(prop, "Ngon Method", "Method for splitting the ngons into triangles"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); } diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c index ffc813068b8..d519c981a23 100644 --- a/source/blender/modifiers/intern/MOD_triangulate.c +++ b/source/blender/modifiers/intern/MOD_triangulate.c @@ -36,7 +36,7 @@ #include "bmesh.h" #include "bmesh_tools.h" -static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int flag) +static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int quad_method, const int ngon_method) { DerivedMesh *result; BMesh *bm; @@ -45,7 +45,7 @@ static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int flag) bm = DM_to_bmesh(dm, true); - BM_mesh_triangulate(bm, (flag & MOD_TRIANGULATE_BEAUTY), false, NULL, NULL); + BM_mesh_triangulate(bm, quad_method, ngon_method, false, NULL, NULL); result = CDDM_from_bmesh(bm, FALSE); BM_mesh_free(bm); @@ -69,7 +69,8 @@ static void initData(ModifierData *md) /* Enable in editmode by default */ md->mode |= eModifierMode_Editmode; - tmd->flag = MOD_TRIANGULATE_BEAUTY; + tmd->quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE; + tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY; } @@ -88,7 +89,7 @@ static DerivedMesh *applyModifier(ModifierData *md, { TriangulateModifierData *tmd = (TriangulateModifierData *)md; DerivedMesh *result; - if (!(result = triangulate_dm(dm, tmd->flag))) { + if (!(result = triangulate_dm(dm, tmd->quad_method, tmd->ngon_method))) { return dm; } -- cgit v1.2.3 From 96cd8b94016691f2a874d46c1e2aff84ac8d2f28 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Oct 2013 03:04:46 +0000 Subject: style cleanup --- source/blender/editors/armature/armature_edit.c | 6 +++--- source/blender/editors/metaball/mball_edit.c | 1 + source/blender/editors/space_clip/tracking_ops.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index e4d244f9277..0443afa0954 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -1074,13 +1074,13 @@ static int armature_split_exec(bContext *C, wmOperator *UNUSED(op)) bArmature *arm = (bArmature *)ob->data; EditBone *bone; - for (bone = arm->edbo->first; bone; bone = bone->next){ - if (bone->parent && (bone->flag & BONE_SELECTED) != (bone->parent->flag & BONE_SELECTED)){ + for (bone = arm->edbo->first; bone; bone = bone->next) { + if (bone->parent && (bone->flag & BONE_SELECTED) != (bone->parent->flag & BONE_SELECTED)) { bone->parent = NULL; bone->flag &= ~BONE_CONNECTED; } } - for (bone = arm->edbo->first; bone; bone = bone->next){ + for (bone = arm->edbo->first; bone; bone = bone->next) { ED_armature_ebone_select_set(bone, (bone->flag & BONE_SELECTED) != 0); } diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 7130166ba0e..deae9f17992 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -333,6 +333,7 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op) break; default: BLI_assert(0); + break; } if (change) { diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 53eaa2aaf72..ebb06693995 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1341,7 +1341,7 @@ static int track_markers_exec(bContext *C, wmOperator *op) if (clip == NULL) { return OPERATOR_CANCELLED; } - framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, CFRA); + framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, CFRA); fake_user.framenr = framenr; user = &fake_user; } -- cgit v1.2.3 From f9ab1df5640cfa20ae381dfb75afaf1604e00c0c Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 29 Oct 2013 10:13:49 +0000 Subject: Fix collada compile, too less arguments --- source/blender/collada/collada_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 146aff5ca5b..8a1b391f07b 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -359,7 +359,7 @@ void bc_triangulate_mesh(Mesh *me) BMesh *bm = BM_mesh_create(&bm_mesh_allocsize_default); BM_mesh_bm_from_me(bm, me, true, false, 0); - BM_mesh_triangulate(bm, use_beauty, tag_only, NULL, NULL); + BM_mesh_triangulate(bm, use_beauty, tag_only, NULL, NULL, NULL); BM_mesh_bm_to_me(bm, me, FALSE); BM_mesh_free(bm); } -- cgit v1.2.3 From 055b65d6bad2ce200d3b4315f7754f2cb586e6fe Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Tue, 29 Oct 2013 10:49:44 +0000 Subject: (Due to a change in function call) Added default triangulation method for Collada exporter --- source/blender/collada/collada_utils.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 8a1b391f07b..2e805ce18f1 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -354,12 +354,14 @@ void bc_match_scale(std::vector *objects_done, void bc_triangulate_mesh(Mesh *me) { - bool use_beauty = false; - bool tag_only = false; + bool use_beauty = false; + bool tag_only = false; + int quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE; /* XXX: The triangulation method selection could be offered in the UI */ BMesh *bm = BM_mesh_create(&bm_mesh_allocsize_default); BM_mesh_bm_from_me(bm, me, true, false, 0); - BM_mesh_triangulate(bm, use_beauty, tag_only, NULL, NULL, NULL); + BM_mesh_triangulate(bm, quad_method, use_beauty, tag_only, NULL, NULL); + BM_mesh_bm_to_me(bm, me, FALSE); BM_mesh_free(bm); } -- cgit v1.2.3 From 56cf901f0380d6ae83c7193f2cad64413a683c08 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 29 Oct 2013 11:59:03 +0000 Subject: Fix #37152: Knife tool doesn't work properly with Maya preset (Zooming and Panning) --- release/scripts/presets/keyconfig/maya.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index 21fd757c4e5..c4dea831052 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -697,8 +697,10 @@ km = kc.keymaps.new('Knife Tool Modal Map', space_type='EMPTY', region_type='WIN kmi = km.keymap_items.new_modal('CANCEL', 'ESC', 'ANY', any=True) kmi = km.keymap_items.new_modal('PANNING', 'LEFTMOUSE', 'ANY', alt=True) +kmi = km.keymap_items.new_modal('PANNING', 'MIDDLEMOUSE', 'ANY', alt=True) +kmi = km.keymap_items.new_modal('PANNING', 'RIGHTMOUSE', 'ANY', alt=True) kmi = km.keymap_items.new_modal('ADD_CUT', 'LEFTMOUSE', 'PRESS', any=True) -kmi = km.keymap_items.new_modal('CANCEL', 'RIGHTMOUSE', 'ANY', any=True) +kmi = km.keymap_items.new_modal('CANCEL', 'RIGHTMOUSE', 'ANY') kmi = km.keymap_items.new_modal('CONFIRM', 'RET', 'PRESS', any=True) kmi = km.keymap_items.new_modal('CONFIRM', 'NUMPAD_ENTER', 'PRESS', any=True) kmi = km.keymap_items.new_modal('CONFIRM', 'SPACE', 'PRESS', any=True) -- cgit v1.2.3 From 2cccdd1678c3813a00e319e5f0b82919f7397153 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 29 Oct 2013 14:48:25 +0000 Subject: Fix for particle texture influence bug causing undefined (nan) values: When using a texture with "Particles/Strands" coordinates that in turn has a "Lifetime" influence on the particles, the texture eval accesses the particle lifetime/dietime data before it is actually defined! This is a design flaw, but to avoid corrupted data for now just initialize the lifetime/dietime values for particles in advance before evaluating the texture. --- source/blender/blenkernel/intern/particle_system.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 526d54a97fa..ac32f96d59c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2006,6 +2006,12 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, pa->lifetime = 100.0f; } else { + /* initialize the lifetime, in case the texture coordinates + * are from Particles/Strands, which would cause undefined values + */ + pa->lifetime = part->lifetime * (1.0f - part->randlife * PSYS_FRAND(p + 21)); + pa->dietime = pa->time + pa->lifetime; + /* get possible textural influence */ psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra); -- cgit v1.2.3 From e89b00131836beec5c4edcb2c7081ba28ee958ec Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 29 Oct 2013 15:49:01 +0000 Subject: Project Pampa fix: animplayer will use preview range if preview is enabled --- .../scripts/startup/bl_operators/screen_play_rendered_anim.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py index 6d1f35fe937..04c28500089 100644 --- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py +++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -115,11 +115,17 @@ class PlayRenderedAnim(Operator): cmd = [player_path] # extra options, fps controls etc. + if scene.use_preview_range: + frame_start = scene.frame_preview_start + frame_end = scene.frame_preview_end + else: + frame_start = scene.frame_start + frame_end = scene.frame_end if preset in {'BLENDER24', 'INTERNAL'}: opts = ["-a", "-f", str(rd.fps), str(rd.fps_base), - "-s", str(scene.frame_start), - "-e", str(scene.frame_end), + "-s", str(frame_start), + "-e", str(frame_end), "-j", str(scene.frame_step), file] cmd.extend(opts) -- cgit v1.2.3 From 7bc61927ab81bd95a1bbecb989f3e828738260f5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 29 Oct 2013 16:06:21 +0000 Subject: Fix #37246: Dynamic paint end frame is limited to 9999 Not sure what's actual reason for this, increased it to MAXFRAMRF. --- source/blender/makesrna/intern/rna_dynamicpaint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c index e13ec1f09a4..2a008a44b55 100644 --- a/source/blender/makesrna/intern/rna_dynamicpaint.c +++ b/source/blender/makesrna/intern/rna_dynamicpaint.c @@ -470,7 +470,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "start_frame"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_range(prop, 1.0, 9999.0); + RNA_def_property_range(prop, 1.0, MAXFRAMEF); RNA_def_property_ui_range(prop, 1.0, 9999, 1, -1); RNA_def_property_ui_text(prop, "Start Frame", "Simulation start frame"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames"); @@ -478,7 +478,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "end_frame"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_range(prop, 1.0, 9999.0); + RNA_def_property_range(prop, 1.0, MAXFRAMEF); RNA_def_property_ui_range(prop, 1.0, 9999.0, 1, -1); RNA_def_property_ui_text(prop, "End Frame", "Simulation end frame"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames"); -- cgit v1.2.3 From 781e1f3370d3e1b306132bf9df479d4f9a21960e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 29 Oct 2013 16:43:56 +0000 Subject: Enable multires bake to level 0 Uses trick with crating simple subdivided mesh with level 1 and bakes against it. From quick tests seems to be working correct, more tests are welcome. --- source/blender/editors/object/object_bake.c | 35 ++++++++++------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 060e48f39bc..55564703a87 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -156,12 +156,6 @@ static bool multiresbake_check(bContext *C, wmOperator *op) break; } - if (mmd->lvl == 0) { - BKE_report(op->reports, RPT_ERROR, "Multires data baking is not supported for preview subdivision level 0"); - ok = false; - break; - } - if (!me->mtpoly) { BKE_report(op->reports, RPT_ERROR, "Mesh should be unwrapped before multires data baking"); @@ -214,28 +208,23 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l DerivedMesh *dm; MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0); Mesh *me = (Mesh *)ob->data; + MultiresModifierData tmp_mmd = *mmd; + DerivedMesh *cddm = CDDM_from_mesh(me, ob); - *lvl = mmd->lvl; - - if (*lvl == 0) { - DerivedMesh *tmp_dm = CDDM_from_mesh(me, ob); - - DM_set_only_copy(tmp_dm, CD_MASK_BAREMESH | CD_MASK_MTFACE); - - dm = CDDM_copy(tmp_dm); - tmp_dm->release(tmp_dm); + if (mmd->lvl > 0) { + *lvl = mmd->lvl; } else { - MultiresModifierData tmp_mmd = *mmd; - DerivedMesh *cddm = CDDM_from_mesh(me, ob); + *lvl = 1; + tmp_mmd.simple = true; + } - DM_set_only_copy(cddm, CD_MASK_BAREMESH | CD_MASK_MTFACE); + DM_set_only_copy(cddm, CD_MASK_BAREMESH | CD_MASK_MTFACE); - tmp_mmd.lvl = *lvl; - tmp_mmd.sculptlvl = *lvl; - dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0); - cddm->release(cddm); - } + tmp_mmd.lvl = *lvl; + tmp_mmd.sculptlvl = *lvl; + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0); + cddm->release(cddm); return dm; } -- cgit v1.2.3 From 63b01f6beee8eced14ff013ca93732f5c176ad10 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 29 Oct 2013 16:43:58 +0000 Subject: Code cleanup: remove unused block from multire baker Mapping from grid on ll 0 was not used and was incorrect since bmesh merge anyway. --- .../blender/render/intern/source/multires_bake.c | 35 ++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c index 3ae075b4936..a920306732d 100644 --- a/source/blender/render/intern/source/multires_bake.c +++ b/source/blender/render/intern/source/multires_bake.c @@ -611,6 +611,9 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, float crn_x, crn_y; int grid_size, S, face_side; int *grid_offset, g_index; + int side, grid_index, loc_offs, cell_index, cell_side, row, col; + + BLI_assert(lvl > 0); lodm->getTessFace(lodm, face_index, &mface); @@ -621,25 +624,19 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, face_side = (grid_size << 1) - 1; - if (lvl == 0) { - g_index = grid_offset[face_index]; - S = mdisp_rot_face_to_crn(mface.v4 ? 4 : 3, face_side, u * (face_side - 1), v * (face_side - 1), &crn_x, &crn_y); - } - else { - int side = (1 << (lvl - 1)) + 1; - int grid_index = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, face_index); - int loc_offs = face_index % (1 << (2 * lvl)); - int cell_index = loc_offs % ((side - 1) * (side - 1)); - int cell_side = (grid_size - 1) / (side - 1); - int row = cell_index / (side - 1); - int col = cell_index % (side - 1); - - S = face_index / (1 << (2 * (lvl - 1))) - grid_offset[grid_index]; - g_index = grid_offset[grid_index]; - - crn_y = (row * cell_side) + u * cell_side; - crn_x = (col * cell_side) + v * cell_side; - } + side = (1 << (lvl - 1)) + 1; + grid_index = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, face_index); + loc_offs = face_index % (1 << (2 * lvl)); + cell_index = loc_offs % ((side - 1) * (side - 1)); + cell_side = (grid_size - 1) / (side - 1); + row = cell_index / (side - 1); + col = cell_index % (side - 1); + + S = face_index / (1 << (2 * (lvl - 1))) - grid_offset[grid_index]; + g_index = grid_offset[grid_index]; + + crn_y = (row * cell_side) + u * cell_side; + crn_x = (col * cell_side) + v * cell_side; CLAMP(crn_x, 0.0f, grid_size); CLAMP(crn_y, 0.0f, grid_size); -- cgit v1.2.3 From 8d11abb0ec80a81dbdce1a1a1c163c2e314fb36f Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 29 Oct 2013 17:14:43 +0000 Subject: fix [#37250] dynotopo initial triangulation hmrf arguments order was wrong ... but int/bool casting made it pass through the compiler --- source/blender/editors/sculpt_paint/sculpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7c2c77d9041..488504b71f8 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4660,7 +4660,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) static void sculpt_dynamic_topology_triangulate(BMesh *bm) { if (bm->totloop != bm->totface * 3) { - BM_mesh_triangulate(bm, false, MOD_TRIANGULATE_QUAD_FIXED, MOD_TRIANGULATE_NGON_SCANFILL, NULL, NULL); + BM_mesh_triangulate(bm, MOD_TRIANGULATE_QUAD_FIXED, MOD_TRIANGULATE_NGON_SCANFILL, false, NULL, NULL); } } -- cgit v1.2.3 From 8bdbbca4858ab143661f371cc302092759e29408 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 29 Oct 2013 17:46:01 +0000 Subject: Fix #37192, Rendered preview causes crash when deleting a material node in shader node editor. The 'free' callback for node execution data was accessed from the node->typeinfo, but this pointer can become invalid because the render database is not immediately freed after the job finishes. To avoid access to dangling node pointers, store the function callback in the exec data itself. The node pointer must not be accessed in the free function (wasn't used before either), these functions are purely for the execution data. --- source/blender/blenkernel/BKE_node.h | 2 +- source/blender/nodes/intern/node_exec.c | 6 +++--- source/blender/nodes/intern/node_exec.h | 2 ++ source/blender/nodes/shader/nodes/node_shader_common.c | 2 +- source/blender/nodes/texture/nodes/node_texture_common.c | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 7cc8c7290f7..15c14c7a707 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -132,7 +132,7 @@ typedef struct bNodeSocketType { } bNodeSocketType; typedef void *(*NodeInitExecFunction)(struct bNodeExecContext *context, struct bNode *node, bNodeInstanceKey key); -typedef void (*NodeFreeExecFunction)(struct bNode *node, void *nodedata); +typedef void (*NodeFreeExecFunction)(void *nodedata); typedef void (*NodeExecFunction)(void *data, int thread, struct bNode *, struct bNodeExecData *execdata, struct bNodeStack **in, struct bNodeStack **out); typedef int (*NodeGPUExecFunction)(struct GPUMaterial *mat, struct bNode *node, struct bNodeExecData *execdata, struct GPUNodeStack *in, struct GPUNodeStack *out); diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c index 812fe5b4ae7..37018b3a98d 100644 --- a/source/blender/nodes/intern/node_exec.c +++ b/source/blender/nodes/intern/node_exec.c @@ -207,6 +207,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNo /* prepare all nodes for execution */ for (n = 0, nodeexec = exec->nodeexec; n < totnodes; ++n, ++nodeexec) { node = nodeexec->node = nodelist[n]; + nodeexec->freeexecfunc = node->typeinfo->freeexecfunc; /* tag inputs */ for (sock = node->inputs.first; sock; sock = sock->next) { @@ -245,9 +246,8 @@ void ntree_exec_end(bNodeTreeExec *exec) MEM_freeN(exec->stack); for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { - if (nodeexec->node->typeinfo) - if (nodeexec->node->typeinfo->freeexecfunc) - nodeexec->node->typeinfo->freeexecfunc(nodeexec->node, nodeexec->data.data); + if (nodeexec->freeexecfunc) + nodeexec->freeexecfunc(nodeexec->data.data); } if (exec->nodeexec) diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h index 7d76ef34934..4101c6c4c4d 100644 --- a/source/blender/nodes/intern/node_exec.h +++ b/source/blender/nodes/intern/node_exec.h @@ -51,6 +51,8 @@ struct bNodeStack; typedef struct bNodeExec { struct bNode *node; /* backpointer to node */ bNodeExecData data; + + NodeFreeExecFunction freeexecfunc; /* free function, stored in exec itself to avoid dangling node pointer access */ } bNodeExec; /* Execution Data for each instance of node tree execution */ diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index 72178018de4..e229fc75686 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -85,7 +85,7 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc return exec; } -static void group_freeexec(bNode *UNUSED(node), void *nodedata) +static void group_freeexec(void *nodedata) { bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata; diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c index fec6abbf062..7e65c472eef 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ b/source/blender/nodes/texture/nodes/node_texture_common.c @@ -72,7 +72,7 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc return exec; } -static void group_freeexec(bNode *UNUSED(node), void *nodedata) +static void group_freeexec(void *nodedata) { bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata; -- cgit v1.2.3 From f6e504cee9f85867554f5a0ab89b52a66c0f257e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 29 Oct 2013 18:10:48 +0000 Subject: Make anim system safer for threading Remove usages of ANIM_unit_mapping_apply_fcurve in favor of runtime scale factor apply. There're still calls to ANIM_nla_mapping_apply_fcurve are hanging around, they're the next t be cleaned up! --- source/blender/editors/animation/anim_draw.c | 72 ---------------------- source/blender/editors/include/ED_anim_api.h | 3 - source/blender/editors/space_graph/graph_draw.c | 56 +++++++++-------- source/blender/editors/space_graph/graph_edit.c | 50 +++++++-------- source/blender/editors/space_graph/graph_select.c | 45 ++++++-------- .../editors/transform/transform_conversions.c | 26 ++++---- .../blender/editors/transform/transform_generics.c | 8 --- 7 files changed, 89 insertions(+), 171 deletions(-) diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 9e8800fd91e..4a8557a2b1f 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -389,76 +389,4 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest return 1.0f; } -/* ----------------------- */ - -/* helper function for ANIM_unit_mapping_apply_fcurve -> mapping callback for unit mapping */ -static short bezt_unit_mapping_apply(KeyframeEditData *ked, BezTriple *bezt) -{ - /* mapping factor is stored in f1, flags are stored in i1 */ - const bool only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS) != 0; - const bool sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS) != 0; - const bool skip_knot = (ked->i1 & ANIM_UNITCONV_SKIPKNOTS) != 0; - float fac = ked->f1; - - /* adjust BezTriple handles only if allowed to */ - if (only_keys == false) { - if ((sel_vs == false) || (bezt->f1 & SELECT)) - bezt->vec[0][1] *= fac; - if ((sel_vs == false) || (bezt->f3 & SELECT)) - bezt->vec[2][1] *= fac; - } - - if (skip_knot == false) { - if ((sel_vs == false) || (bezt->f2 & SELECT)) - bezt->vec[1][1] *= fac; - } - - return 0; -} - -/* Apply/Unapply units conversions to keyframes */ -void ANIM_unit_mapping_apply_fcurve(Scene *scene, ID *id, FCurve *fcu, short flag) -{ - KeyframeEditData ked; - KeyframeEditFunc sel_cb; - float fac; - - /* abort if rendering - we may get some race condition issues... */ - if (G.is_rendering) return; - - /* calculate mapping factor, and abort if nothing to change */ - fac = ANIM_unit_mapping_get_factor(scene, id, fcu, (flag & ANIM_UNITCONV_RESTORE)); - if (fac == 1.0f) - return; - - /* init edit data - * - mapping factor is stored in f1 - * - flags are stored in 'i1' - */ - memset(&ked, 0, sizeof(KeyframeEditData)); - ked.f1 = (float)fac; - ked.i1 = (int)flag; - - /* only selected? */ - if (flag & ANIM_UNITCONV_ONLYSEL) - sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); - else - sel_cb = NULL; - - /* apply to F-Curve */ - ANIM_fcurve_keyframes_loop(&ked, fcu, sel_cb, bezt_unit_mapping_apply, NULL); - - // FIXME: loop here for samples should be generalised - // TODO: only sel? - if (fcu->fpt) { - FPoint *fpt; - unsigned int i; - - for (i = 0, fpt = fcu->fpt; i < fcu->totvert; i++, fpt++) { - /* apply unit mapping */ - fpt->vec[1] *= fac; - } - } -} - /* *************************************************** */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 61f9cec15d9..d23c57273ec 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -564,9 +564,6 @@ typedef enum eAnimUnitConv_Flags { /* Get unit conversion factor for given ID + F-Curve */ float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FCurve *fcu, short restore); -/* Apply/Unapply units conversions to keyframes */ -void ANIM_unit_mapping_apply_fcurve(struct Scene *scene, struct ID *id, struct FCurve *fcu, short flag); - /* ------------- Utility macros ----------------------- */ /* provide access to Keyframe Type info in BezTriple diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 23c39a5e99a..ba619fd9c77 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -206,7 +206,7 @@ static void draw_fcurve_handle_control(float x, float y, float xscale, float ysc } /* helper func - draw handle vertices only for an F-Curve (if it is not protected) */ -static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only) +static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only, float units_scale) { BezTriple *bezt = fcu->bezt; BezTriple *prevbezt = NULL; @@ -216,6 +216,9 @@ static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2 /* get view settings */ hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize; UI_view2d_getscale(v2d, &xscale, &yscale); + + /* Compensate OGL scale sued for unit mapping, so circle will be circle, not ellipse */ + yscale *= units_scale; /* set handle color */ if (sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT); @@ -271,7 +274,7 @@ static void set_fcurve_vertex_color(FCurve *fcu, short sel) } -static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only) +static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only, float units_scale) { View2D *v2d = &ar->v2d; @@ -287,10 +290,10 @@ static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short /* draw the two handles first (if they're shown, the curve doesn't have just a single keyframe, and the curve is being edited) */ if (do_handles) { set_fcurve_vertex_color(fcu, 0); - draw_fcurve_vertices_handles(fcu, sipo, v2d, 0, sel_handle_only); + draw_fcurve_vertices_handles(fcu, sipo, v2d, 0, sel_handle_only, units_scale); set_fcurve_vertex_color(fcu, 1); - draw_fcurve_vertices_handles(fcu, sipo, v2d, 1, sel_handle_only); + draw_fcurve_vertices_handles(fcu, sipo, v2d, 1, sel_handle_only, units_scale); } /* draw keyframes over the handles */ @@ -547,11 +550,14 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie FPoint *fpt = prevfpt + 1; float fac, v[2]; int b = fcu->totvert - 1; - - glBegin(GL_LINE_STRIP); - + float unit_scale; + /* apply unit mapping */ - ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, 0); + glPushMatrix(); + unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0); + glScalef(1.0f, unit_scale, 1.0f); + + glBegin(GL_LINE_STRIP); /* extrapolate to left? - left-side of view comes before first keyframe? */ if (prevfpt->vec[0] > v2d->cur.xmin) { @@ -611,10 +617,8 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie glVertex2fv(v); } - /* unapply unit mapping */ - ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, ANIM_UNITCONV_RESTORE); - glEnd(); + glPopMatrix(); } /* helper func - draw one repeat of an F-Curve */ @@ -627,11 +631,14 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 float fac = 0.0f; int b = fcu->totvert - 1; int resol; - - glBegin(GL_LINE_STRIP); - + float unit_scale; + /* apply unit mapping */ - ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, 0); + glPushMatrix(); + unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0); + glScalef(1.0f, unit_scale, 1.0f); + + glBegin(GL_LINE_STRIP); /* extrapolate to left? */ if (prevbezt->vec[1][0] > v2d->cur.xmin) { @@ -766,10 +773,8 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 glVertex2fv(v1); } - /* unapply unit mapping */ - ANIM_unit_mapping_apply_fcurve(ac->scene, id, fcu, ANIM_UNITCONV_RESTORE); - glEnd(); + glPopMatrix(); } /* Debugging -------------------------------- */ @@ -1014,9 +1019,11 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid } } else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) { - /* apply unit mapping */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, fcu, 0); - + float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + + glPushMatrix(); + glScalef(1.0f, unit_scale, 1.0f); + if (fcu->bezt) { int do_handles = draw_fcurve_handles_check(sipo, fcu); @@ -1027,15 +1034,14 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid glDisable(GL_BLEND); } - draw_fcurve_vertices(sipo, ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY)); + draw_fcurve_vertices(sipo, ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY), unit_scale); } else { /* samples: only draw two indicators at either end as indicators */ draw_fcurve_samples(sipo, ar, fcu); } - - /* unapply unit mapping */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, fcu, ANIM_UNITCONV_RESTORE); + + glPopMatrix(); } } diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 274c06bf871..c8e07dbda68 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1787,20 +1787,23 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); - - /* apply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS); - + KeyframeEditData current_ked; + float unit_scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS); + + memset(¤t_ked, 0, sizeof(current_ked)); + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); - ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); + ANIM_fcurve_keyframes_loop(¤t_ked, ale->key_data, NULL, bezt_calc_average, NULL); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else - ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); - - /* unapply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | ANIM_UNITCONV_ONLYKEYS); + ANIM_fcurve_keyframes_loop(¤t_ked, ale->key_data, NULL, bezt_calc_average, NULL); + + ked.f1 += current_ked.f1; + ked.i1 += current_ked.i1; + ked.f2 += current_ked.f2 / unit_scale; + ked.i2 += current_ked.i2; } BLI_freelistN(&anim_data); @@ -1865,6 +1868,7 @@ static void snap_graph_keys(bAnimContext *ac, short mode) KeyframeEditData ked; KeyframeEditFunc edit_cb; + float cursor_value = 0.0f; /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); @@ -1881,16 +1885,16 @@ static void snap_graph_keys(bAnimContext *ac, short mode) } else if (mode == GRAPHKEYS_SNAP_VALUE) { SpaceIpo *sipo = (SpaceIpo *)ac->sl; - ked.f1 = (sipo) ? sipo->cursorVal : 0.0f; + cursor_value = (sipo) ? sipo->cursorVal : 0.0f; } /* snap keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - - /* apply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0); - + float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, 0); + + ked.f1 = cursor_value / unit_scale; + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); @@ -1898,9 +1902,6 @@ static void snap_graph_keys(bAnimContext *ac, short mode) } else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); - - /* apply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE); } BLI_freelistN(&anim_data); @@ -1977,7 +1978,8 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) KeyframeEditData ked; KeyframeEditFunc edit_cb; - + float cursor_value; + /* get beztriple editing callbacks */ edit_cb = ANIM_editkeyframes_mirror(mode); @@ -2000,7 +2002,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) } else if (mode == GRAPHKEYS_MIRROR_VALUE) { SpaceIpo *sipo = (SpaceIpo *)ac->sl; - ked.f1 = (sipo) ? sipo->cursorVal : 0.0f; + cursor_value = (sipo) ? sipo->cursorVal : 0.0f; } /* filter data */ @@ -2010,10 +2012,11 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) /* mirror keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS); + /* apply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS); - + ked.f1 = cursor_value * unit_scale; + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); @@ -2021,9 +2024,6 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) } else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); - - /* unapply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS | ANIM_UNITCONV_RESTORE); } BLI_freelistN(&anim_data); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 4bb5e1b11d4..ce036bec380 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -227,7 +227,7 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor KeyframeEditData ked; KeyframeEditFunc ok_cb, select_cb; View2D *v2d = &ac->ar->v2d; - rctf rectf; + rctf rectf, scaled_rectf; /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); @@ -243,7 +243,7 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); - ked.data = &rectf; + ked.data = &scaled_rectf; /* treat handles separately? */ if (incl_handles) { @@ -252,21 +252,24 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor } else mapping_flag = ANIM_UNITCONV_ONLYKEYS; - + /* loop over data, doing border select */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); FCurve *fcu = (FCurve *)ale->key_data; - - /* apply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, mapping_flag); - + float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + /* apply NLA mapping to all the keyframes, since it's easier than trying to * guess when a callback might use something different */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0); - + + scaled_rectf.xmin = rectf.xmin; + scaled_rectf.xmax = rectf.xmax; + scaled_rectf.ymin = rectf.ymin / unit_scale; + scaled_rectf.ymax = rectf.ymax / unit_scale; + /* set horizontal range (if applicable) * NOTE: these values are only used for x-range and y-range but not region * (which uses ked.data, i.e. rectf) @@ -296,9 +299,6 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor /* un-apply NLA mapping from all the keyframes */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0); - - /* unapply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | mapping_flag); } /* cleanup */ @@ -936,7 +936,7 @@ static int fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt) /* check if the given vertex is within bounds or not */ // TODO: should we return if we hit something? -static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2]) +static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2], float unit_scale) { /* Keyframes or Samples? */ if (bezt) { @@ -947,7 +947,7 @@ static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fc * needed to access the relevant vertex coordinates in the 3x3 * 'vec' matrix */ - UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1], &screen_co[0], &screen_co[1]); + UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale, &screen_co[0], &screen_co[1]); /* check if distance from mouse cursor to vert in screen space is within tolerance */ // XXX: inlined distance calculation, since we cannot do this on ints using the math lib... @@ -996,7 +996,7 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L SpaceIpo *sipo = (SpaceIpo *)ac->sl; View2D *v2d = &ac->ar->v2d; - + /* get curves to search through * - if the option to only show keyframes that belong to selected F-Curves is enabled, * include the 'only selected' flag... @@ -1009,32 +1009,30 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; AnimData *adt = ANIM_nla_mapping_get(ac, ale); - - /* apply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0); - + float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + /* apply NLA mapping to all the keyframes */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); - + if (fcu->bezt) { BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL; int i; for (i = 0; i < fcu->totvert; i++, prevbezt = bezt1, bezt1++) { /* keyframe */ - nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_KEY, mval); + nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_KEY, mval, unit_scale); /* handles - only do them if they're visible */ if (fcurve_handle_sel_check(sipo, bezt1) && (fcu->totvert > 1)) { /* first handle only visible if previous segment had handles */ if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) { - nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_LEFT, mval); + nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_LEFT, mval, unit_scale); } /* second handle only visible if this segment is bezier */ if (bezt1->ipo == BEZT_IPO_BEZ) { - nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_RIGHT, mval); + nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_RIGHT, mval, unit_scale); } } } @@ -1047,9 +1045,6 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L /* un-apply NLA mapping from all the keyframes */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); - - /* unapply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE); } /* free channels */ diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 28d31b09ad2..41d04c85f44 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3835,7 +3835,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) AnimData *adt = ANIM_nla_mapping_get(&ac, ale); FCurve *fcu = (FCurve *)ale->key_data; short intvals = (fcu->flag & FCURVE_INT_VALUES); - + float unit_scale; + float scaled_mtx[3][3], scaled_smtx[3][3]; + /* convert current-frame to action-time (slightly less accurate, especially under * higher scaling ratios, but is faster than converting all points) */ @@ -3848,8 +3850,13 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) if (fcu->bezt == NULL) continue; - ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, anim_map_flag); - + unit_scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, ale->key_data, anim_map_flag); + + copy_m3_m3(scaled_mtx, mtx); + copy_m3_m3(scaled_smtx, smtx); + mul_v3_fl(scaled_mtx[1], 1.0f / unit_scale); + mul_v3_fl(scaled_smtx[1], unit_scale); + /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) { @@ -3866,7 +3873,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) if (!ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE) || !(sel2)) { if (sel1) { hdata = initTransDataCurveHandles(td, bezt); - bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals, mtx, smtx); + bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals, scaled_mtx, scaled_smtx); } else { /* h1 = 0; */ /* UNUSED */ @@ -3875,7 +3882,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) if (sel3) { if (hdata == NULL) hdata = initTransDataCurveHandles(td, bezt); - bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, mtx, smtx); + bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, scaled_mtx, scaled_smtx); } else { /* h2 = 0; */ /* UNUSED */ @@ -3897,7 +3904,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) hdata = initTransDataCurveHandles(td, bezt); } - bezt_to_transdata(td++, td2d++, adt, bezt, 1, 1, 0, intvals, mtx, smtx); + bezt_to_transdata(td++, td2d++, adt, bezt, 1, 1, 0, intvals, scaled_mtx, scaled_smtx); } /* special hack (must be done after initTransDataCurveHandles(), as that stores handle settings to restore...): @@ -3919,13 +3926,6 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* Sets handles based on the selection */ testhandles_fcurve(fcu, use_handle); - - /* even though transform values are written back right after during transform, - * using individual center's with rotation means the center point wont - * be touched again see: [#34303] */ - if (use_local_center) { - ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, anim_map_flag | ANIM_UNITCONV_RESTORE); - } } /* cleanup temp list */ diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 33eca0d6b89..422060c48e6 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -381,9 +381,6 @@ static void recalcData_graphedit(TransInfo *t) bAnimListElem *ale; int dosort = 0; - const bool use_local_center = checkUseLocalCenter_GraphEdit(t); - - /* initialize relevant anim-context 'context' data from TransInfo data */ /* NOTE: sync this with the code in ANIM_animdata_get_context() */ scene = ac.scene = t->scene; @@ -411,11 +408,6 @@ static void recalcData_graphedit(TransInfo *t) if (!fcu_test_selected(fcu)) continue; - ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, - ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS | ANIM_UNITCONV_RESTORE | - (use_local_center ? ANIM_UNITCONV_SKIPKNOTS : 0)); - - /* watch it: if the time is wrong: do not correct handles yet */ if (test_time_fcurve(fcu)) dosort++; -- cgit v1.2.3 From 16d13e0db9d75566735966d81d213958df3ca7e5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 29 Oct 2013 18:10:52 +0000 Subject: Project Pampa request: FCurves normalized display Added two options to a header of FCurve editor: - Normalize which makes it so every individual curve is fit into -1..1 space. - Auto-normalize, which probably is to be called "Lock" which "locks" curve normalization scale. This is useful to prevent curves from jumping around when tweaking it. It's debatable whether it need to be a button to normalize curves n purpose only, and it's fully depends on animator's workflow. Here during Project Pampa we've got Francesco who get used to auto-renormalization and Hjalti who prefers locked behavior. Docs are to be ready soon by Francesco. Thanks Brecht for the review! --- release/scripts/startup/bl_ui/space_graph.py | 5 ++ source/blender/blenkernel/BKE_global.h | 1 + source/blender/editors/animation/anim_draw.c | 64 +++++++++++++++++++++- source/blender/editors/include/ED_anim_api.h | 11 +++- source/blender/editors/space_graph/graph_draw.c | 15 +++-- source/blender/editors/space_graph/graph_edit.c | 23 +++++--- source/blender/editors/space_graph/graph_select.c | 8 ++- .../editors/transform/transform_conversions.c | 13 +++-- source/blender/makesdna/DNA_anim_types.h | 2 + source/blender/makesdna/DNA_space_types.h | 3 + source/blender/makesrna/intern/rna_space.c | 12 ++++ 11 files changed, 136 insertions(+), 21 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py index 2d0b1c93d13..61e2f10a057 100644 --- a/release/scripts/startup/bl_ui/space_graph.py +++ b/release/scripts/startup/bl_ui/space_graph.py @@ -46,6 +46,11 @@ class GRAPH_HT_header(Header): dopesheet_filter(layout, context) + layout.prop(st, "use_normalization", text="Normalize") + row = layout.row() + row.active = st.use_normalization + row.prop(st, "use_auto_normalization", text="Auto") + layout.prop(st, "auto_snap", text="") layout.prop(st, "pivot_point", text="", icon_only=True) diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 9d33af1a0f4..d0341ab8c89 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -192,6 +192,7 @@ enum { #define G_TRANSFORM_OBJ 1 #define G_TRANSFORM_EDIT 2 #define G_TRANSFORM_SEQ 4 +#define G_TRANSFORM_FCURVES 8 /* G.special1 */ diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 4a8557a2b1f..dcf9c8e623b 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -33,6 +33,7 @@ #include "DNA_anim_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_space_types.h" #include "DNA_userdef_types.h" #include "BLI_math.h" @@ -359,9 +360,68 @@ void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, short restore, sh /* *************************************************** */ /* UNITS CONVERSION MAPPING (required for drawing and editing keyframes) */ +/* Get flags used for normalization in ANIM_unit_mapping_get_factor. */ +short ANIM_get_normalization_flags(bAnimContext *ac) +{ + if (ac->sl->spacetype == SPACE_IPO) { + SpaceIpo *sipo = (SpaceIpo *) ac->sl; + bool use_normalization = (sipo->flag & SIPO_NORMALIZE) != 0; + bool freeze_normalization = (sipo->flag & SIPO_NORMALIZE_FREEZE) != 0; + return use_normalization + ? (ANIM_UNITCONV_NORMALIZE | (freeze_normalization ? ANIM_UNITCONV_NORMALIZE_FREEZE : 0)) + : 0; + } + + return 0; +} + +static float normalzation_factor_get(FCurve *fcu, short flag) +{ + float factor; + + if (flag & ANIM_UNITCONV_RESTORE) { + return 1.0f / fcu->prev_norm_factor; + } + + if (flag & ANIM_UNITCONV_NORMALIZE_FREEZE) { + return fcu->prev_norm_factor; + } + + if (G.moving & G_TRANSFORM_FCURVES) { + return fcu->prev_norm_factor; + } + + fcu->prev_norm_factor = 1.0f; + if (fcu->bezt) { + BezTriple *bezt; + int i; + float max_coord = -FLT_MAX; + + if (fcu->totvert < 1) { + return 1.0f; + } + + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { + max_coord = max_ff(max_coord, fabsf(bezt->vec[0][1])); + max_coord = max_ff(max_coord, fabsf(bezt->vec[1][1])); + max_coord = max_ff(max_coord, fabsf(bezt->vec[2][1])); + } + + if (max_coord > FLT_EPSILON) { + factor = 1.0f / max_coord; + } + } + fcu->prev_norm_factor = factor; + return factor; +} + /* Get unit conversion factor for given ID + F-Curve */ -float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short restore) +float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag) { + if (flag & ANIM_UNITCONV_NORMALIZE) { + return normalzation_factor_get(fcu, flag); + } + /* sanity checks */ if (id && fcu && fcu->rna_path) { PointerRNA ptr, id_ptr; @@ -374,7 +434,7 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest if (RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)) == PROP_UNIT_ROTATION) { /* if the radians flag is not set, default to using degrees which need conversions */ if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) { - if (restore) + if (flag & ANIM_UNITCONV_RESTORE) return DEG2RADF(1.0f); /* degrees to radians */ else return RAD2DEGF(1.0f); /* radians to degrees */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index d23c57273ec..d98fa1fc32f 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -559,10 +559,19 @@ typedef enum eAnimUnitConv_Flags { /* only touch selected vertices */ ANIM_UNITCONV_SELVERTS = (1 << 3), ANIM_UNITCONV_SKIPKNOTS = (1 << 4), + /* Scale FCurve i a way it fits to -1..1 space */ + ANIM_UNITCONV_NORMALIZE = (1 << 5), + /* Only whennormalization is used: use scale factor from previous run, + * prevents curves from jumping all over the place when tweaking them. + */ + ANIM_UNITCONV_NORMALIZE_FREEZE = (1 << 6), } eAnimUnitConv_Flags; +/* Normalizatin flags from Space Graph passing to ANIM_unit_mapping_get_factor */ +short ANIM_get_normalization_flags(bAnimContext *ac); + /* Get unit conversion factor for given ID + F-Curve */ -float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FCurve *fcu, short restore); +float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FCurve *fcu, short flag); /* ------------- Utility macros ----------------------- */ diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index ba619fd9c77..e7c98437b9f 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -490,6 +490,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d float stime, etime; float unitFac; float dx, dy; + short mapping_flag = ANIM_get_normalization_flags(ac); /* when opening a blend file on a different sized screen or while dragging the toolbar this can happen * best just bail out in this case */ @@ -503,7 +504,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d fcu->driver = NULL; /* compute unit correction factor */ - unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0); + unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag); /* Note about sampling frequency: * Ideally, this is chosen such that we have 1-2 pixels = 1 segment @@ -551,10 +552,11 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie float fac, v[2]; int b = fcu->totvert - 1; float unit_scale; + short mapping_flag = ANIM_get_normalization_flags(ac); /* apply unit mapping */ glPushMatrix(); - unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0); + unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag); glScalef(1.0f, unit_scale, 1.0f); glBegin(GL_LINE_STRIP); @@ -632,10 +634,11 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 int b = fcu->totvert - 1; int resol; float unit_scale; + short mapping_flag = ANIM_get_normalization_flags(ac); /* apply unit mapping */ glPushMatrix(); - unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0); + unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag); glScalef(1.0f, unit_scale, 1.0f); glBegin(GL_LINE_STRIP); @@ -788,7 +791,8 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) { ChannelDriver *driver = fcu->driver; View2D *v2d = &ac->ar->v2d; - float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, false); + short mapping_flag = ANIM_get_normalization_flags(ac); + float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag); /* for now, only show when debugging driver... */ //if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0) @@ -1019,7 +1023,8 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid } } else if (((fcu->bezt) || (fcu->fpt)) && (fcu->totvert)) { - float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + short mapping_flag = ANIM_get_normalization_flags(ac); + float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag); glPushMatrix(); glScalef(1.0f, unit_scale, 1.0f); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index c8e07dbda68..ebb9266149a 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -116,6 +116,8 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa /* get range */ if (calc_fcurve_bounds(fcu, &txmin, &txmax, &tymin, &tymax, do_sel_only, include_handles)) { + short mapping_flag = ANIM_get_normalization_flags(ac); + /* apply NLA scaling */ if (adt) { txmin = BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP); @@ -123,7 +125,7 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa } /* apply unit corrections */ - unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag); tymin *= unitFac; tymax *= unitFac; @@ -330,12 +332,14 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end) FPoint *fpt; float unitFac; int cfra; - + SpaceIpo *sipo = (SpaceIpo *) ac->sl; + short mapping_flag = ANIM_get_normalization_flags(ac); + /* disable driver so that it don't muck up the sampling process */ fcu->driver = NULL; /* calculate unit-mapping factor */ - unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag); /* create samples, but store them in a new curve * - we cannot use fcurve_store_samples() as that will only overwrite the original curve @@ -578,6 +582,8 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) * keyframes if these will be visible after doing so... */ if (fcurve_is_keyframable(fcu)) { + short mapping_flag = ANIM_get_normalization_flags(&ac); + /* get frame and value from props */ frame = RNA_float_get(op->ptr, "frame"); val = RNA_float_get(op->ptr, "value"); @@ -587,7 +593,7 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) frame = BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP); /* apply inverse unit-mapping to value to get correct value for F-Curves */ - val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, 1); + val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, mapping_flag | ANIM_UNITCONV_RESTORE); /* insert keyframe on the specified frame + value */ insert_vert_fcurve(fcu, frame, val, 0); @@ -1787,8 +1793,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); + short mapping_flag = ANIM_get_normalization_flags(&ac); KeyframeEditData current_ked; - float unit_scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS); + float unit_scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS); memset(¤t_ked, 0, sizeof(current_ked)); @@ -1891,7 +1898,8 @@ static void snap_graph_keys(bAnimContext *ac, short mode) /* snap keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, 0); + short mapping_flag = ANIM_get_normalization_flags(ac); + float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag); ked.f1 = cursor_value / unit_scale; @@ -2012,7 +2020,8 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) /* mirror keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS); + short mapping_flag = ANIM_get_normalization_flags(ac); + float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS); /* apply unit corrections */ ked.f1 = cursor_value * unit_scale; diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index ce036bec380..d0dcaf91e77 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -253,6 +253,8 @@ static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, shor else mapping_flag = ANIM_UNITCONV_ONLYKEYS; + mapping_flag |= ANIM_get_normalization_flags(ac); + /* loop over data, doing border select */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); @@ -996,7 +998,8 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L SpaceIpo *sipo = (SpaceIpo *)ac->sl; View2D *v2d = &ac->ar->v2d; - + short mapping_flag = 0; + /* get curves to search through * - if the option to only show keyframes that belong to selected F-Curves is enabled, * include the 'only selected' flag... @@ -1004,12 +1007,13 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); if (sipo->flag & SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code... filter |= ANIMFILTER_SEL; + mapping_flag |= ANIM_get_normalization_flags(ac); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; AnimData *adt = ANIM_nla_mapping_get(ac, ale); - float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag); /* apply NLA mapping to all the keyframes */ if (adt) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 41d04c85f44..573c4f15657 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3714,12 +3714,14 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) float mtx[3][3], smtx[3][3]; const bool use_handle = !(sipo->flag & SIPO_NOHANDLES); const bool use_local_center = checkUseLocalCenter_GraphEdit(t); - const short anim_map_flag = ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS; + short anim_map_flag = ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS; /* determine what type of data we are operating on */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + + anim_map_flag |= ANIM_get_normalization_flags(&ac); + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); @@ -3854,8 +3856,8 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) copy_m3_m3(scaled_mtx, mtx); copy_m3_m3(scaled_smtx, smtx); - mul_v3_fl(scaled_mtx[1], 1.0f / unit_scale); - mul_v3_fl(scaled_smtx[1], unit_scale); + mul_v3_fl(scaled_mtx[1], unit_scale); + mul_v3_fl(scaled_smtx[1], 1.0f / unit_scale); /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { @@ -5861,6 +5863,9 @@ int special_transform_moving(TransInfo *t) if (t->spacetype == SPACE_SEQ) { return G_TRANSFORM_SEQ; } + else if (t->spacetype == SPACE_IPO) { + return G_TRANSFORM_FCURVES; + } else if (t->obedit || ((t->flag & T_POSE) && (t->poseobj))) { return G_TRANSFORM_EDIT; } diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index fc0dd54a8e7..7a7e08138b0 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -459,6 +459,8 @@ typedef struct FCurve { /* curve coloring (for editor) */ int color_mode; /* coloring method to use (eFCurve_Coloring) */ float color[3]; /* the last-color this curve took */ + + float prev_norm_factor, pad; } FCurve; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index f71516af5e6..faa99aaaad8 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -366,6 +366,9 @@ typedef enum eGraphEdit_Flag { SIPO_BEAUTYDRAW_OFF = (1 << 12), /* draw grouped channels with colors set in group */ SIPO_NODRAWGCOLORS = (1 << 13), + /* normalize curves on display */ + SIPO_NORMALIZE = (1 << 14), + SIPO_NORMALIZE_FREEZE = (1 << 15), } eGraphEdit_Flag; /* SpaceIpo->mode (Graph Editor Mode) */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 5daeb4ae612..a99cdda6ff3 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2880,6 +2880,18 @@ static void rna_def_space_graph(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, "rna_SpaceGraphEditor_has_ghost_curves_get", NULL); RNA_def_property_ui_text(prop, "Has Ghost Curves", "Graph Editor instance has some ghost curves stored"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); + + /* nromalize curves */ + prop = RNA_def_property(srna, "use_normalization", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_NORMALIZE); + RNA_def_property_ui_text(prop, "use Normalization", "Display curves in normalized to -1..1 range, " + "for easier editing of multiple curves with different ranges"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); + + prop = RNA_def_property(srna, "use_auto_normalization", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NORMALIZE_FREEZE); + RNA_def_property_ui_text(prop, "Auto Normalization", "Automatically recalculate curve normalization on every curve edit"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); } static void rna_def_space_nla(BlenderRNA *brna) -- cgit v1.2.3 From 8f747c49230532b9f1d8e51c41561a2d1a2b8b81 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 29 Oct 2013 18:46:45 +0000 Subject: Code cleanup: use bool instead of int in mask module --- source/blender/blenkernel/BKE_mask.h | 11 ++++++----- source/blender/blenkernel/intern/mask.c | 18 +++++++++--------- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 2 +- .../compositor/operations/COM_MaskOperation.cpp | 2 +- source/blender/editors/mask/mask_add.c | 6 +++--- source/blender/editors/mask/mask_shapekey.c | 4 ++-- source/blender/makesrna/intern/rna_mask.c | 2 +- 8 files changed, 24 insertions(+), 23 deletions(-) diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 9e73e0662ce..7f703a0440f 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -123,9 +123,9 @@ void BKE_mask_coord_to_image(struct Image *image, struct ImageUser *iuser, float void BKE_mask_update_display(struct Mask *mask, float ctime); -void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const int do_newframe); -void BKE_mask_evaluate(struct Mask *mask, const float ctime, const int do_newframe); -void BKE_mask_layer_evaluate(struct MaskLayer *masklay, const float ctime, const int do_newframe); +void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const bool do_newframe); +void BKE_mask_evaluate(struct Mask *mask, const float ctime, const bool do_newframe); +void BKE_mask_layer_evaluate(struct MaskLayer *masklay, const float ctime, const bool do_newframe); void BKE_mask_update_scene(struct Main *bmain, struct Scene *scene); void BKE_mask_parent_init(struct MaskParent *parent); void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u); @@ -161,12 +161,13 @@ struct MaskLayerShape *BKE_mask_layer_shape_duplicate(struct MaskLayerShape *mas void BKE_mask_layer_shape_unlink(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape); void BKE_mask_layer_shape_sort(struct MaskLayer *masklay); -int BKE_mask_layer_shape_spline_from_index(struct MaskLayer *masklay, int index, +bool BKE_mask_layer_shape_spline_from_index(struct MaskLayer *masklay, int index, struct MaskSpline **r_masklay_shape, int *r_index); int BKE_mask_layer_shape_spline_to_index(struct MaskLayer *masklay, struct MaskSpline *spline); +/* TODO(sergey): do_init and do_init_interpolate are always true, so let's wipe them later. */ void BKE_mask_layer_shape_changed_add(struct MaskLayer *masklay, int index, - int do_init, int do_init_interpolate); + bool do_init, bool do_init_interpolate); void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, int count); diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index c856d8cfea4..597cfa5d76e 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1443,7 +1443,7 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline) } } -void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const int do_newframe) +void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const bool do_newframe) { /* animation if available */ if (do_newframe) { @@ -1521,7 +1521,7 @@ void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const int do } } -void BKE_mask_evaluate(Mask *mask, const float ctime, const int do_newframe) +void BKE_mask_evaluate(Mask *mask, const float ctime, const bool do_newframe) { MaskLayer *masklay; @@ -1562,10 +1562,10 @@ void BKE_mask_update_display(Mask *mask, float ctime) } #endif - BKE_mask_evaluate(mask, ctime, FALSE); + BKE_mask_evaluate(mask, ctime, false); } -void BKE_mask_evaluate_all_masks(Main *bmain, float ctime, const int do_newframe) +void BKE_mask_evaluate_all_masks(Main *bmain, float ctime, const bool do_newframe) { Mask *mask; @@ -1835,8 +1835,8 @@ void BKE_mask_layer_shape_sort(MaskLayer *masklay) BLI_sortlist(&masklay->splines_shapes, mask_layer_shape_sort_cb); } -int BKE_mask_layer_shape_spline_from_index(MaskLayer *masklay, int index, - MaskSpline **r_masklay_shape, int *r_index) +bool BKE_mask_layer_shape_spline_from_index(MaskLayer *masklay, int index, + MaskSpline **r_masklay_shape, int *r_index) { MaskSpline *spline; @@ -1844,12 +1844,12 @@ int BKE_mask_layer_shape_spline_from_index(MaskLayer *masklay, int index, if (index < spline->tot_point) { *r_masklay_shape = spline; *r_index = index; - return TRUE; + return true; } index -= spline->tot_point; } - return FALSE; + return false; } int BKE_mask_layer_shape_spline_to_index(MaskLayer *masklay, MaskSpline *spline) @@ -1891,7 +1891,7 @@ static void interp_weights_uv_v2_apply(const float uv[2], float r_pt[2], const f /* when a new points added - resize all shapekey array */ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, int index, - int do_init, int do_init_interpolate) + bool do_init, bool do_init_interpolate) { MaskLayerShape *masklay_shape; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index d4618e28191..9356536557a 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1303,7 +1303,7 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) * so don't call within 'scene_update_tagged_recursive' */ DAG_scene_update_flags(bmain, sce, lay, TRUE); // only stuff that moves or needs display still - BKE_mask_evaluate_all_masks(bmain, ctime, TRUE); + BKE_mask_evaluate_all_masks(bmain, ctime, true); /* All 'standard' (i.e. without any dependencies) animation is handled here, * with an 'local' to 'macro' order of evaluation. This should ensure that diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 925355d9383..1235018546e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2341,7 +2341,7 @@ static ImBuf *seq_render_mask(SeqRenderData context, Mask *mask, float nr, short mask_temp = BKE_mask_copy_nolib(mask); - BKE_mask_evaluate(mask_temp, mask->sfra + nr, TRUE); + BKE_mask_evaluate(mask_temp, mask->sfra + nr, true); maskbuf = MEM_mallocN(sizeof(float) * context.rectx * context.recty, __func__); diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index ba1059c4eb5..39f4302dec9 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -84,7 +84,7 @@ void MaskOperation::initExecution() this->m_rasterMaskHandles[i] = BKE_maskrasterize_handle_new(); /* re-eval frame info */ - BKE_mask_evaluate(mask_temp, frame_iter, TRUE); + BKE_mask_evaluate(mask_temp, frame_iter, true); BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[i], mask_temp, this->m_maskWidth, this->m_maskHeight, diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 4cc9d3b59b1..7a78d60e11e 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -385,7 +385,7 @@ static int add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2] setup_vertex_point(mask, spline, new_point, co, tangent, u, NULL, TRUE, 1.0f); /* TODO - we could pass the spline! */ - BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, TRUE, TRUE); + BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, true, true); masklay->act_spline = spline; masklay->act_point = new_point; @@ -486,7 +486,7 @@ static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay, if (masklay->splines_shapes.first) { point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point); - BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, TRUE, TRUE); + BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, true, true); } if (do_recalc_src) { @@ -548,7 +548,7 @@ static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, con { int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point); - BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, TRUE, TRUE); + BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, true, true); } WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c index d5fbdca5b0a..0c9ce5f6c79 100644 --- a/source/blender/editors/mask/mask_shapekey.c +++ b/source/blender/editors/mask/mask_shapekey.c @@ -319,7 +319,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) masklay_shape_tmp; masklay_shape_tmp = masklay_shape_tmp->next) { - BKE_mask_layer_evaluate(masklay, masklay_shape_tmp->frame, TRUE); + BKE_mask_layer_evaluate(masklay, masklay_shape_tmp->frame, true); masklay_shape_tmp_rekey = BKE_mask_layer_shape_varify_frame(masklay, masklay_shape_tmp->frame); BKE_mask_layer_shape_from_mask(masklay, masklay_shape_tmp_rekey); masklay_shape_tmp_rekey->flag = masklay_shape_tmp->flag & MASK_SHAPE_SELECT; @@ -376,7 +376,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) } /* re-evaluate */ - BKE_mask_layer_evaluate(masklay, frame, TRUE); + BKE_mask_layer_evaluate(masklay, frame, true); } } diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 77d593b67b6..670df017038 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -446,7 +446,7 @@ static void rna_MaskSpline_points_add(ID *id, MaskSpline *spline, int count) BKE_mask_parent_init(&new_point->parent); /* Not efficient, but there's no other way for now */ - BKE_mask_layer_shape_changed_add(layer, spline_shape_index + point_index, TRUE, TRUE); + BKE_mask_layer_shape_changed_add(layer, spline_shape_index + point_index, true, true); } WM_main_add_notifier(NC_MASK | ND_DATA, mask); -- cgit v1.2.3 From bc5218a0f4fe4dd72c6df7266f3c45b548fc137e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 29 Oct 2013 18:56:21 +0000 Subject: Code cleanup: more int->bool conversions mask module --- source/blender/blenkernel/BKE_mask.h | 2 +- source/blender/blenkernel/intern/mask.c | 2 +- source/blender/editors/transform/transform_conversions.c | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 7f703a0440f..64eec65f443 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -90,7 +90,7 @@ float BKE_mask_spline_project_co(struct MaskSpline *spline, struct MaskSplinePoi /* point */ int BKE_mask_point_has_handle(struct MaskSplinePoint *point); void BKE_mask_point_handle(struct MaskSplinePoint *point, float handle[2]); -void BKE_mask_point_set_handle(struct MaskSplinePoint *point, float loc[2], int keep_direction, +void BKE_mask_point_set_handle(struct MaskSplinePoint *point, float loc[2], bool keep_direction, float orig_handle[2], float orig_vec[3][3]); void BKE_mask_point_segment_co(struct MaskSpline *spline, struct MaskSplinePoint *point, float u, float co[2]); diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 597cfa5d76e..e8851102fb8 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -462,7 +462,7 @@ void BKE_mask_point_handle(MaskSplinePoint *point, float handle[2]) handle[1] = (point->bezt.vec[1][1] - vec[0]); } -void BKE_mask_point_set_handle(MaskSplinePoint *point, float loc[2], int keep_direction, +void BKE_mask_point_set_handle(MaskSplinePoint *point, float loc[2], bool keep_direction, float orig_handle[2], float orig_vec[3][3]) { BezTriple *bezt = &point->bezt; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 573c4f15657..ce346c7952d 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -6824,8 +6824,11 @@ void flushTransMasking(TransInfo *t) td->loc2d[1] = td->loc[1] * inv[1]; mul_m3_v2(tdm->parent_inverse_matrix, td->loc2d); - if (tdm->is_handle) - BKE_mask_point_set_handle(tdm->point, td->loc2d, t->flag & T_ALT_TRANSFORM, tdm->orig_handle, tdm->vec); + if (tdm->is_handle) { + BKE_mask_point_set_handle(tdm->point, td->loc2d, + (t->flag & T_ALT_TRANSFORM) != 0, + tdm->orig_handle, tdm->vec); + } } } -- cgit v1.2.3 From 96f756d4b377521c118ee3b21dd2087eea79d6a5 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 30 Oct 2013 00:37:13 +0000 Subject: Lasso select tool for masking in sculpting. Initial code, non optimized for now. Used to be ultra terrible but with threading (openmp) there is slightly better performance and is ready for testing. To use press shift-ctrl-lclick. Still no ability to remove mask. Coming soon. Also make box selection threaded (openmp) and comment fix. --- source/blender/editors/sculpt_paint/paint_intern.h | 1 + source/blender/editors/sculpt_paint/paint_mask.c | 131 ++++++++++++++++++++- source/blender/editors/sculpt_paint/paint_ops.c | 3 + 3 files changed, 134 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 86b223ec2a0..f276e6823e2 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -265,5 +265,6 @@ typedef enum { void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot); void PAINT_OT_mask_box_fill(struct wmOperatorType *ot); +void PAINT_OT_mask_lasso_gesture(struct wmOperatorType *ot); #endif /* __PAINT_INTERN_H__ */ diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 13f11c8a816..6a25e31573d 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -41,6 +41,8 @@ #include "BLI_math_matrix.h" #include "BLI_math_geom.h" #include "BLI_utildefines.h" +#include "BLI_lasso.h" + #include "BKE_pbvh.h" #include "BKE_ccg.h" #include "BKE_context.h" @@ -163,6 +165,7 @@ static int is_effected(float planes[4][4], const float co[3]) int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNUSED(extend)) { + Sculpt *sd = vc->scene->toolsettings->sculpt; BoundBox bb; bglMats mats = {{0}}; float clip_planes[4][4]; @@ -180,7 +183,7 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU mode = PAINT_MASK_FLOOD_VALUE; value = select ? 1.0 : 0.0; - /* transform the */ + /* transform the clip planes in object space */ view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, &mats); ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect); mul_m4_fl(clip_planes, -1.0f); @@ -195,6 +198,7 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU sculpt_undo_push_begin("Mask box fill"); + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (i = 0; i < totnode; i++) { PBVHVertexIter vi; @@ -219,3 +223,128 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU return OPERATOR_FINISHED; } + +typedef struct LassoMaskData { + struct ViewContext *vc; + float projviewobjmat[4][4]; + int mcords_tot; + int (*mcords)[2]; +} LassoMaskData; + + +/* Lasso select. This could be defined as part of VIEW3D_OT_select_lasso, still the shortcuts conflict, + * so we will use a separate operator */ + +static bool is_effected_lasso(LassoMaskData *data, float co[3]) +{ + float scr_co_f[2]; + short scr_co_s[2]; + + /* first project point to 2d space */ + ED_view3d_project_float_v2_m4(data->vc->ar, co, scr_co_f, data->projviewobjmat); + + scr_co_s[0] = scr_co_f[0]; + scr_co_s[1] = scr_co_f[1]; + + /* clip against screen, because lasso is limited to screen only */ + if (scr_co_s[0] < 0 || scr_co_s[1] < 0 || scr_co_s[0] > data->vc->ar->winx || scr_co_s[1] > data->vc->ar->winy) + return false; + + if (BLI_lasso_is_point_inside((const int (*)[2])data->mcords, data->mcords_tot, scr_co_s[0], scr_co_s[1], IS_CLIPPED)) + return true; + + return false; +} + +static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) +{ + int mcords_tot; + int (*mcords)[2] = (int (*)[2])WM_gesture_lasso_path_to_array(C, op, &mcords_tot); + + if (mcords) { + bglMats mats = {{0}}; + Object *ob; + ViewContext vc; + LassoMaskData data; + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + + struct MultiresModifierData *mmd; + DerivedMesh *dm; + PBVH *pbvh; + PBVHNode **nodes; + int totnode, i; + PaintMaskFloodMode mode = PAINT_MASK_FLOOD_VALUE; + bool select = true; /* TODO: see how to implement deselection */ + float value = select ? 1.0 : 0.0; + + /* We have two types of calculations here, bounding box lasso inclusion calculation is done in 3D space, to + * correctly account for volume, and individual vertices are done in 2D screen space to diminish the amount of + * calculations done */ + view3d_set_viewcontext(C, &vc); + view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats); + + data.vc = &vc; + data.mcords = mcords; + data.mcords_tot = mcords_tot; + ob = vc.obact; + ED_view3d_ob_project_mat_get(vc.rv3d, ob, data.projviewobjmat); + + mmd = sculpt_multires_active(vc.scene, ob); + ED_sculpt_mask_layers_ensure(ob, mmd); + dm = mesh_get_derived_final(vc.scene, ob, CD_MASK_BAREMESH); + pbvh = dm->getPBVH(ob, dm); + ob->sculpt->pbvh = pbvh; + + /* gather the nodes inside the lasso */ + BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + + sculpt_undo_push_begin("Mask lasso fill"); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (i = 0; i < totnode; i++) { + PBVHVertexIter vi; + + sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + + BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { + if (is_effected_lasso(&data, vi.co)) + mask_flood_fill_set_elem(vi.mask, mode, value); + } BKE_pbvh_vertex_iter_end; + + BKE_pbvh_node_mark_update(nodes[i]); + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + } + + sculpt_undo_push_end(); + + if (nodes) + MEM_freeN(nodes); + + ED_region_tag_redraw(vc.ar); + MEM_freeN((void *)mcords); + + return OPERATOR_FINISHED; + } + return OPERATOR_PASS_THROUGH; +} + +void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot) +{ + PropertyRNA *prop; + + ot->name = "Mask Lasso Gesture"; + ot->idname = "PAINT_OT_mask_lasso_gesture"; + ot->description = "Add mask within the lasso as you move the pointer"; + + ot->invoke = WM_gesture_lasso_invoke; + ot->modal = WM_gesture_lasso_modal; + ot->exec = paint_mask_gesture_lasso_exec; + + ot->poll = sculpt_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); +} diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 8b038973831..03c063692c6 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -987,6 +987,7 @@ void ED_operatortypes_paint(void) /* paint masking */ WM_operatortype_append(PAINT_OT_mask_flood_fill); + WM_operatortype_append(PAINT_OT_mask_lasso_gesture); } @@ -1149,6 +1150,8 @@ void ED_keymap_paint(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_INVERT); + kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_lasso_gesture", LEFTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + /* Toggle dynamic topology */ WM_keymap_add_item(keymap, "SCULPT_OT_dynamic_topology_toggle", DKEY, KM_PRESS, KM_CTRL, 0); -- cgit v1.2.3 From 33a0469630b47d432b5b99582c8e671c70bba3f2 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 30 Oct 2013 00:54:41 +0000 Subject: Some comment fixes, add new sculpt masking operators to menus --- release/scripts/startup/bl_ui/space_view3d.py | 3 +++ source/blender/editors/sculpt_paint/paint_mask.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 6f9af768e38..aa9eda40406 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1445,6 +1445,9 @@ class VIEW3D_MT_hide_mask(Menu): props = layout.operator("paint.mask_flood_fill", text="Clear Mask") props.mode = 'VALUE' props.value = 0 + + props = layout.operator("view3d.select_border", text="Box Mask") + props = layout.operator("paint.mask_lasso_gesture", text="Lasso Mask") # ********** Particle menu ********** diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 6a25e31573d..7a4da0114d3 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -295,7 +295,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) pbvh = dm->getPBVH(ob, dm); ob->sculpt->pbvh = pbvh; - /* gather the nodes inside the lasso */ + /* gather all nodes! (doing bounding box intersection is more work than needed) */ BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); sculpt_undo_push_begin("Mask lasso fill"); -- cgit v1.2.3 From a8aa2c5bb4e87338bbfe45cc3a8ccff52aac0b43 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 30 Oct 2013 01:20:08 +0000 Subject: Optimization of lasso masking using scanfill. Thanks to Campbell for the advice! --- source/blender/editors/sculpt_paint/paint_mask.c | 39 +++++++++++++++++------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 7a4da0114d3..fa63ef2ca86 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -227,8 +227,9 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU typedef struct LassoMaskData { struct ViewContext *vc; float projviewobjmat[4][4]; - int mcords_tot; - int (*mcords)[2]; + bool *px; + int width; + rcti rect; /* bounding box for scanfilling */ } LassoMaskData; @@ -247,13 +248,19 @@ static bool is_effected_lasso(LassoMaskData *data, float co[3]) scr_co_s[1] = scr_co_f[1]; /* clip against screen, because lasso is limited to screen only */ - if (scr_co_s[0] < 0 || scr_co_s[1] < 0 || scr_co_s[0] > data->vc->ar->winx || scr_co_s[1] > data->vc->ar->winy) + if (scr_co_s[0] < data->rect.xmin || scr_co_s[1] < data->rect.ymin || scr_co_s[0] >= data->rect.xmax || scr_co_s[1] >= data->rect.ymax) return false; - if (BLI_lasso_is_point_inside((const int (*)[2])data->mcords, data->mcords_tot, scr_co_s[0], scr_co_s[1], IS_CLIPPED)) - return true; + scr_co_s[0] -= data->rect.xmin; + scr_co_s[1] -= data->rect.ymin; + + return data->px[scr_co_s[1] * data->width + scr_co_s[0]]; +} - return false; +static void mask_lasso_px_cb(int x, int y, void *user_data) +{ + struct LassoMaskData *data = user_data; + data->px[(y * data->width) + x] = true; } static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) @@ -277,18 +284,27 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) bool select = true; /* TODO: see how to implement deselection */ float value = select ? 1.0 : 0.0; - /* We have two types of calculations here, bounding box lasso inclusion calculation is done in 3D space, to - * correctly account for volume, and individual vertices are done in 2D screen space to diminish the amount of - * calculations done */ + /* Calculations of individual vertices are done in 2D screen space to diminish the amount of + * calculations done. Bounding box PBVH collision is not computed because it is quite expensive and + * unnecessary */ view3d_set_viewcontext(C, &vc); view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats); + /* lasso data calculations */ data.vc = &vc; - data.mcords = mcords; - data.mcords_tot = mcords_tot; ob = vc.obact; ED_view3d_ob_project_mat_get(vc.rv3d, ob, data.projviewobjmat); + BLI_lasso_boundbox(&data.rect, (const int (*)[2])mcords, mcords_tot); + data.width = data.rect.xmax - data.rect.xmin; + data.px = MEM_callocN(sizeof(*data.px) * data.width * (data.rect.ymax - data.rect.ymin), "lasso_mask_pixel_buffer"); + + fill_poly_v2i_n( + data.rect.xmin, data.rect.ymin, data.rect.xmax, data.rect.ymax, + (const int (*)[2])mcords, mcords_tot, + mask_lasso_px_cb, &data); + + mmd = sculpt_multires_active(vc.scene, ob); ED_sculpt_mask_layers_ensure(ob, mmd); dm = mesh_get_derived_final(vc.scene, ob, CD_MASK_BAREMESH); @@ -323,6 +339,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) ED_region_tag_redraw(vc.ar); MEM_freeN((void *)mcords); + MEM_freeN(data.px); return OPERATOR_FINISHED; } -- cgit v1.2.3 From 2045c8607035f66758e53a50e31545965df89677 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 30 Oct 2013 01:58:19 +0000 Subject: One more optimization for lasso, clip PBVH against object space planes of lasso enclosing rectangle. --- source/blender/editors/sculpt_paint/paint_mask.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index fa63ef2ca86..2e9efcc02b2 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -269,6 +269,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) int (*mcords)[2] = (int (*)[2])WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { + float clip_planes[4][4]; + BoundBox bb; bglMats mats = {{0}}; Object *ob; ViewContext vc; @@ -285,8 +287,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) float value = select ? 1.0 : 0.0; /* Calculations of individual vertices are done in 2D screen space to diminish the amount of - * calculations done. Bounding box PBVH collision is not computed because it is quite expensive and - * unnecessary */ + * calculations done. Bounding box PBVH collision is not computed against enclosing rectangle + * of lasso */ view3d_set_viewcontext(C, &vc); view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats); @@ -304,6 +306,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) (const int (*)[2])mcords, mcords_tot, mask_lasso_px_cb, &data); + ED_view3d_clipping_calc(&bb, clip_planes, &mats, &data.rect); + mul_m4_fl(clip_planes, -1.0f); mmd = sculpt_multires_active(vc.scene, ob); ED_sculpt_mask_layers_ensure(ob, mmd); @@ -311,8 +315,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) pbvh = dm->getPBVH(ob, dm); ob->sculpt->pbvh = pbvh; - /* gather all nodes! (doing bounding box intersection is more work than needed) */ - BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + /* gather nodes inside lasso's enclosing rectangle (should greatly help with bigger meshes) */ + BKE_pbvh_search_gather(pbvh, BKE_pbvh_node_planes_contain_AABB, clip_planes, &nodes, &totnode); sculpt_undo_push_begin("Mask lasso fill"); -- cgit v1.2.3 From a415d188d288513079ef8a13ca8060bf5eee2639 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 30 Oct 2013 04:56:32 +0000 Subject: Add some update notifiers for a few boolean paint properties (probably a lot more needed) so that they get properly updated in UI when the property is edited through python or a custom key binding to context toggle operator. --- source/blender/makesrna/intern/rna_sculpt_paint.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 89714e49ebf..a9f84f1dcc7 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -340,36 +340,44 @@ static void rna_def_sculpt(BlenderRNA *brna) prop = RNA_def_property(srna, "use_symmetry_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_X); RNA_def_property_ui_text(prop, "Symmetry X", "Mirror brush across the X axis"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_symmetry_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_Y); RNA_def_property_ui_text(prop, "Symmetry Y", "Mirror brush across the Y axis"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_symmetry_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_Z); RNA_def_property_ui_text(prop, "Symmetry Z", "Mirror brush across the Z axis"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "lock_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_X); RNA_def_property_ui_text(prop, "Lock X", "Disallow changes to the X axis of vertices"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "lock_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_Y); RNA_def_property_ui_text(prop, "Lock Y", "Disallow changes to the Y axis of vertices"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "lock_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_LOCK_Z); RNA_def_property_ui_text(prop, "Lock Z", "Disallow changes to the Z axis of vertices"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_symmetry_feather", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMMETRY_FEATHER); RNA_def_property_ui_text(prop, "Symmetry Feathering", "Reduce the strength of the brush where it overlaps symmetrical daubs"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_threaded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_USE_OPENMP); RNA_def_property_ui_text(prop, "Use OpenMP", "Take advantage of multiple CPU cores to improve sculpting performance"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_deform_only", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_ONLY_DEFORM); @@ -400,6 +408,7 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Collapse Short Edges", "In dynamic-topology mode, collapse short edges " "in addition to subdividing long ones"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "symmetrize_direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, symmetrize_direction_items); @@ -432,19 +441,23 @@ static void rna_def_vertex_paint(BlenderRNA *brna) prop = RNA_def_property(srna, "use_all_faces", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_AREA); RNA_def_property_ui_text(prop, "All Faces", "Paint on all faces inside brush"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_NORMALS); RNA_def_property_ui_text(prop, "Normals", "Apply the vertex normal before painting"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_spray", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_SPRAY); RNA_def_property_ui_text(prop, "Spray", "Keep applying paint effect while holding mouse"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* weight paint only */ prop = RNA_def_property(srna, "use_group_restrict", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", VP_ONLYVGROUP); RNA_def_property_ui_text(prop, "Restrict", "Restrict painting to vertices in the group"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); } static void rna_def_image_paint(BlenderRNA *brna) @@ -461,27 +474,33 @@ static void rna_def_image_paint(BlenderRNA *brna) prop = RNA_def_property(srna, "use_occlude", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_XRAY); RNA_def_property_ui_text(prop, "Occlude", "Only paint onto the faces directly under the brush (slower)"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_BACKFACE); RNA_def_property_ui_text(prop, "Cull", "Ignore faces pointing away from the view (faster)"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_normal_falloff", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_FLAT); RNA_def_property_ui_text(prop, "Normal", "Paint most on faces pointing towards the view"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_stencil_layer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_STENCIL); RNA_def_property_ui_text(prop, "Stencil Layer", "Set the mask layer from the UV map buttons"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "invert_stencil", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_STENCIL_INV); RNA_def_property_ui_text(prop, "Invert", "Invert the stencil layer"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_clone_layer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_CLONE); RNA_def_property_ui_text(prop, "Clone Map", "Use another UV map as clone source, otherwise use the 3D cursor as the source"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* integers */ -- cgit v1.2.3 From c241bf30a0ad192821e3844aeb1017551d8edf36 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 30 Oct 2013 09:44:29 +0000 Subject: Fix #37252: Mask modifier doesn't copy settings on object copy --- source/blender/modifiers/intern/MOD_mask.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 0d302fed3e6..2822cf6925b 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -62,6 +62,8 @@ static void copyData(ModifierData *md, ModifierData *target) BLI_strncpy(tmmd->vgroup, mmd->vgroup, sizeof(tmmd->vgroup)); tmmd->flag = mmd->flag; + tmmd->mode = mmd->mode; + tmmd->ob_arm = mmd->ob_arm; } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md)) -- cgit v1.2.3 From 06fb71bc4663eba957f8eca423381403eb98deca Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 30 Oct 2013 11:21:31 +0000 Subject: Fix #37194, OSL script crashes blender. The lookup functions for finding Cycles shader inputs/outputs based on socket names are using a few modifications on the Blender socket names. But these only apply to standard nodes where the Blender socket names can differ from associated Cycles names and may require additional indices to make them unique. Script node sockets are already unique and exact due to being generated from the script function parameters. --- intern/cycles/blender/blender_shader.cpp | 86 +++++++++++++++++++------------- intern/cycles/render/graph.h | 3 +- intern/cycles/render/nodes.cpp | 1 + 3 files changed, 53 insertions(+), 37 deletions(-) diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index b576181d890..a6d2b537bc7 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -673,59 +673,73 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen return node; } +static bool node_use_modified_socket_name(ShaderNode *node) +{ + if (node->special_type == SHADER_SPECIAL_TYPE_SCRIPT) + return false; + + return true; +} + static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::Node b_node, BL::NodeSocket b_socket) { - BL::Node::inputs_iterator b_input; string name = b_socket.name(); - bool found = false; - int counter = 0, total = 0; - for (b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) { - if (b_input->name() == name) { - if (!found) - counter++; - total++; + if (node_use_modified_socket_name(node)) { + BL::Node::inputs_iterator b_input; + bool found = false; + int counter = 0, total = 0; + + for (b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) { + if (b_input->name() == name) { + if (!found) + counter++; + total++; + } + + if(b_input->ptr.data == b_socket.ptr.data) + found = true; } - - if(b_input->ptr.data == b_socket.ptr.data) - found = true; + + /* rename if needed */ + if (name == "Shader") + name = "Closure"; + + if (total > 1) + name = string_printf("%s%d", name.c_str(), counter); } - /* rename if needed */ - if (name == "Shader") - name = "Closure"; - - if (total > 1) - name = string_printf("%s%d", name.c_str(), counter); - return node->input(name.c_str()); } static ShaderOutput *node_find_output_by_name(ShaderNode *node, BL::Node b_node, BL::NodeSocket b_socket) { - BL::Node::outputs_iterator b_output; string name = b_socket.name(); - bool found = false; - int counter = 0, total = 0; - for (b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) { - if (b_output->name() == name) { - if (!found) - counter++; - total++; + if (node_use_modified_socket_name(node)) { + BL::Node::outputs_iterator b_output; + bool found = false; + int counter = 0, total = 0; + + for (b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) { + if (b_output->name() == name) { + if (!found) + counter++; + total++; + } + + if(b_output->ptr.data == b_socket.ptr.data) + found = true; } - - if(b_output->ptr.data == b_socket.ptr.data) - found = true; + + /* rename if needed */ + if (name == "Shader") + name = "Closure"; + + if (total > 1) + name = string_printf("%s%d", name.c_str(), counter); } - /* rename if needed */ - if (name == "Shader") - name = "Closure"; - - if (total > 1) - name = string_printf("%s%d", name.c_str(), counter); - return node->output(name.c_str()); } diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h index 8ebdf3cc220..dfa737115e2 100644 --- a/intern/cycles/render/graph.h +++ b/intern/cycles/render/graph.h @@ -75,7 +75,8 @@ enum ShaderNodeSpecialType { SHADER_SPECIAL_TYPE_PROXY, SHADER_SPECIAL_TYPE_MIX_CLOSURE, SHADER_SPECIAL_TYPE_AUTOCONVERT, - SHADER_SPECIAL_TYPE_GEOMETRY + SHADER_SPECIAL_TYPE_GEOMETRY, + SHADER_SPECIAL_TYPE_SCRIPT }; /* Enum diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 621d52bbbbf..5352840d2cb 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -3719,6 +3719,7 @@ void SetNormalNode::compile(OSLCompiler& compiler) OSLScriptNode::OSLScriptNode() : ShaderNode("osl_script") { + special_type = SHADER_SPECIAL_TYPE_SCRIPT; } void OSLScriptNode::compile(SVMCompiler& compiler) -- cgit v1.2.3 From db8e02bc85c8e5b12e5d5c97cf4aed57204bc813 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Oct 2013 11:32:30 +0000 Subject: revert own commit r60607, caused bug [#37253] --- source/blender/editors/interface/interface_handlers.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 7e9c90d51a1..8a0b3a500b5 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2730,9 +2730,14 @@ static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHa rect.xmin = rect.xmax - (BLI_rcti_size_y(&rect)); if (BLI_rcti_isect_pt(&rect, x, y)) { - ui_set_but_string(C, but, ""); + /* most likely NULL, but let's check, and give it temp zero string */ + if (data->str == NULL) + data->str = MEM_callocN(1, "temp str"); + data->str[0] = 0; + + ui_apply_but_TEX(C, but, data); button_activate_state(C, but, BUTTON_STATE_EXIT); - + return WM_UI_HANDLER_BREAK; } } -- cgit v1.2.3 From cd70a0e73a4568cef5351f406ede0e9f6820b4f2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 30 Oct 2013 11:33:11 +0000 Subject: Code cleanup: typo-fix --- source/blender/editors/space_clip/tracking_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index ebb06693995..61a484c8a2a 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1421,7 +1421,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS int framenr; if (sc == NULL) { - /* TODO(sergey): Support clip for invokaction as well. */ + /* TODO(sergey): Support clip for invoke as well. */ BKE_report(op->reports, RPT_ERROR, "Invoking this operator only supported from Clip Editor space."); return OPERATOR_CANCELLED; -- cgit v1.2.3 From d4cf4efb7791bfb1bff2f39891c6ebd0e2347784 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 30 Oct 2013 11:33:29 +0000 Subject: Bugfix [#37185] Maya Config: Move and Scale Don't Work In Dope Sheet Maya keymap was activating wrong transform modes for translation/scaling - in DopeSheet and NLA, these use the TIME_TRANSLATE/TIME_SCALE modes instead --- release/scripts/presets/keyconfig/maya.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index c4dea831052..e6e0062c112 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -1589,8 +1589,11 @@ kmi = km.keymap_items.new('action.view_all', 'A', 'PRESS') kmi = km.keymap_items.new('action.view_selected', 'F', 'PRESS') kmi = km.keymap_items.new('anim.channels_editable_toggle', 'TAB', 'PRESS') kmi = km.keymap_items.new('transform.transform', 'W', 'PRESS') +kmi.properties.mode = 'TIME_TRANSLATE' kmi = km.keymap_items.new('transform.transform', 'EVT_TWEAK_M', 'ANY') +kmi.properties.mode = 'TIME_TRANSLATE' kmi = km.keymap_items.new('transform.transform', 'S', 'PRESS') +kmi.properties.mode = 'TIME_SCALE' kmi = km.keymap_items.new('transform.transform', 'T', 'PRESS', shift=True) kmi = km.keymap_items.new('marker.add', 'M', 'PRESS') kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True) @@ -1664,6 +1667,7 @@ kmi = km.keymap_items.new('nla.fmodifier_add', 'M', 'PRESS', shift=True, ctrl=Tr kmi = km.keymap_items.new('transform.transform', 'W', 'PRESS') kmi = km.keymap_items.new('transform.transform', 'EVT_TWEAK_M', 'ANY') kmi = km.keymap_items.new('transform.transform', 'R', 'PRESS') +kmi.properties.mode = 'TIME_SCALE' kmi = km.keymap_items.new('marker.add', 'M', 'PRESS') kmi = km.keymap_items.new('marker.rename', 'M', 'PRESS', ctrl=True) kmi = km.keymap_items.new('nla.select_all_toggle', 'LEFTMOUSE', 'DOUBLE_CLICK') -- cgit v1.2.3 From 1a746911d653c7abe6960df4ff5491ebd92e756a Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Wed, 30 Oct 2013 21:16:13 +0000 Subject: Add .webm to the list of extensions recognized as video (Patch by Philipp Oeser, submitted in [#37199], many thanks) --- source/blender/imbuf/intern/util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index ecf6458ac57..89778cdfb50 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -145,6 +145,7 @@ const char *imb_ext_movie[] = { ".divx", ".xvid", ".mxf", + ".webm", NULL }; -- cgit v1.2.3 From bced18155ffc525dc513d097245fe3954acbb900 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Oct 2013 22:13:28 +0000 Subject: fix for uninitialized value use in newly added fcurve normalized view. also quiet warning without openmp. --- source/blender/editors/animation/anim_draw.c | 2 +- source/blender/editors/sculpt_paint/paint_mask.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index dcf9c8e623b..25fcd76b513 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -377,7 +377,7 @@ short ANIM_get_normalization_flags(bAnimContext *ac) static float normalzation_factor_get(FCurve *fcu, short flag) { - float factor; + float factor = 1.0f; if (flag & ANIM_UNITCONV_RESTORE) { return 1.0f / fcu->prev_norm_factor; diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 2e9efcc02b2..87e267b1072 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -165,7 +165,9 @@ static int is_effected(float planes[4][4], const float co[3]) int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNUSED(extend)) { +#ifdef _OPENMP Sculpt *sd = vc->scene->toolsettings->sculpt; +#endif BoundBox bb; bglMats mats = {{0}}; float clip_planes[4][4]; @@ -198,7 +200,7 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU sculpt_undo_push_begin("Mask box fill"); - #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) +#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (i = 0; i < totnode; i++) { PBVHVertexIter vi; -- cgit v1.2.3 From 7267221715d8431bd1aaaaa3ace4f8c0ce151627 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Oct 2013 23:08:53 +0000 Subject: remove return argument from wmOperatorType->cancel, was only ever returning OPERATOR_CANCELLED. --- intern/rigidbody/CMakeLists.txt | 3 +- .../scripts/templates_py/operator_modal_timer.py | 1 - source/blender/editors/animation/anim_markers.c | 4 +- .../blender/editors/armature/editarmature_sketch.c | 10 ++--- source/blender/editors/armature/pose_lib.c | 3 +- source/blender/editors/armature/pose_slide.c | 3 +- source/blender/editors/curve/editfont.c | 3 +- source/blender/editors/gpencil/gpencil_paint.c | 3 +- .../editors/interface/interface_eyedropper.c | 12 +++--- source/blender/editors/interface/view2d_ops.c | 11 ++---- source/blender/editors/mesh/editmesh_bevel.c | 3 +- source/blender/editors/mesh/editmesh_inset.c | 3 +- source/blender/editors/mesh/editmesh_knife.c | 3 +- source/blender/editors/mesh/editmesh_loopcut.c | 9 +++-- source/blender/editors/physics/particle_edit.c | 4 +- source/blender/editors/render/render_internal.c | 4 +- source/blender/editors/render/render_opengl.c | 4 +- source/blender/editors/screen/screen_ops.c | 39 ++++++++------------ source/blender/editors/screen/screendump.c | 3 +- source/blender/editors/sculpt_paint/paint_image.c | 3 +- source/blender/editors/sculpt_paint/paint_intern.h | 2 +- source/blender/editors/sculpt_paint/paint_ops.c | 3 +- source/blender/editors/sculpt_paint/paint_stroke.c | 14 ++++--- source/blender/editors/sculpt_paint/paint_vertex.c | 8 +--- source/blender/editors/sculpt_paint/sculpt.c | 4 +- source/blender/editors/sound/sound_ops.c | 3 +- source/blender/editors/space_buttons/buttons_ops.c | 4 +- source/blender/editors/space_clip/clip_ops.c | 16 +++----- source/blender/editors/space_console/console_ops.c | 3 +- source/blender/editors/space_image/image_ops.c | 30 ++++++--------- source/blender/editors/space_node/node_edit.c | 10 ++--- .../editors/space_node/node_relationships.c | 4 +- source/blender/editors/space_node/node_view.c | 7 +--- .../editors/space_sequencer/sequencer_view.c | 4 +- .../blender/editors/space_text/text_autocomplete.c | 3 +- source/blender/editors/space_text/text_ops.c | 10 ++--- source/blender/editors/space_view3d/view3d_edit.c | 20 +++------- source/blender/editors/space_view3d/view3d_fly.c | 4 +- source/blender/editors/space_view3d/view3d_ruler.c | 4 +- source/blender/editors/transform/transform_ops.c | 4 +- .../blender/editors/uvedit/uvedit_smart_stitch.c | 43 ++++++++++++++-------- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 28 +++++++------- source/blender/makesrna/intern/rna_wm.c | 9 +---- source/blender/makesrna/intern/rna_wm_api.c | 4 -- source/blender/windowmanager/WM_api.h | 10 ++--- source/blender/windowmanager/WM_types.h | 2 +- source/blender/windowmanager/intern/wm_operators.c | 28 ++++---------- 47 files changed, 156 insertions(+), 253 deletions(-) diff --git a/intern/rigidbody/CMakeLists.txt b/intern/rigidbody/CMakeLists.txt index bea3075f6be..3a2edba39bc 100644 --- a/intern/rigidbody/CMakeLists.txt +++ b/intern/rigidbody/CMakeLists.txt @@ -23,11 +23,10 @@ set(INC . - ../../extern/bullet2/src ) set(INC_SYS - + ../../extern/bullet2/src ) set(SRC diff --git a/release/scripts/templates_py/operator_modal_timer.py b/release/scripts/templates_py/operator_modal_timer.py index b8211126daf..4d36860b9e3 100644 --- a/release/scripts/templates_py/operator_modal_timer.py +++ b/release/scripts/templates_py/operator_modal_timer.py @@ -29,7 +29,6 @@ class ModalTimerOperator(bpy.types.Operator): def cancel(self, context): wm = context.window_manager wm.event_timer_remove(self._timer) - return {'CANCELLED'} def register(): diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 1e8f2bfc038..b057ea239f0 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -711,13 +711,11 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op) } /* only for modal */ -static int ed_marker_move_cancel(bContext *C, wmOperator *op) +static void ed_marker_move_cancel(bContext *C, wmOperator *op) { RNA_int_set(op->ptr, "frames", 0); ed_marker_move_apply(C, op); ed_marker_move_exit(C, op); - - return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 8ae1b9557ee..36999c15665 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -2339,7 +2339,7 @@ static int sketch_convert(bContext *C, wmOperator *UNUSED(op), const wmEvent *UN return OPERATOR_FINISHED; } -static int sketch_cancel(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) +static int sketch_cancel_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { SK_Sketch *sketch = contextSketch(C, 0); if (sketch != NULL) { @@ -2374,12 +2374,11 @@ static int sketch_select(bContext *C, wmOperator *UNUSED(op), const wmEvent *eve return OPERATOR_FINISHED; } -static int sketch_draw_stroke_cancel(bContext *C, wmOperator *op) +static void sketch_draw_stroke_cancel(bContext *C, wmOperator *op) { SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */ sk_cancelStroke(sketch); MEM_freeN(op->customdata); - return OPERATOR_CANCELLED; } static int sketch_draw_stroke(bContext *C, wmOperator *op, const wmEvent *event) @@ -2400,12 +2399,11 @@ static int sketch_draw_stroke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int sketch_draw_gesture_cancel(bContext *C, wmOperator *op) +static void sketch_draw_gesture_cancel(bContext *C, wmOperator *op) { SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */ sk_cancelStroke(sketch); MEM_freeN(op->customdata); - return OPERATOR_CANCELLED; } static int sketch_draw_gesture(bContext *C, wmOperator *op, const wmEvent *event) @@ -2622,7 +2620,7 @@ void SKETCH_OT_cancel_stroke(wmOperatorType *ot) ot->description = "Cancel the current sketch stroke"; /* api callbacks */ - ot->invoke = sketch_cancel; + ot->invoke = sketch_cancel_invoke; ot->poll = ED_operator_sketch_mode_active_stroke; diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 182f94b3693..4a40eff204a 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -1532,10 +1532,9 @@ static int poselib_preview_exit(bContext *C, wmOperator *op) } /* Cancel previewing operation (called when exiting Blender) */ -static int poselib_preview_cancel(bContext *C, wmOperator *op) +static void poselib_preview_cancel(bContext *C, wmOperator *op) { poselib_preview_exit(C, op); - return OPERATOR_CANCELLED; } /* main modal status check */ diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index d0e1b15064a..82652702fe7 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -682,11 +682,10 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* common code for cancel() */ -static int pose_slide_cancel(bContext *UNUSED(C), wmOperator *op) +static void pose_slide_cancel(bContext *UNUSED(C), wmOperator *op) { /* cleanup and done */ pose_slide_exit(op); - return OPERATOR_CANCELLED; } /* common code for exec() methods */ diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index ac9c338e431..dc58e84415c 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1613,11 +1613,10 @@ static void font_ui_template_init(bContext *C, wmOperator *op) uiIDContextProperty(C, &pprop->ptr, &pprop->prop); } -static int font_open_cancel(bContext *UNUSED(C), wmOperator *op) +static void font_open_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); op->customdata = NULL; - return OPERATOR_CANCELLED; } static int font_open_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 98fff3d65ce..44917375d43 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1456,11 +1456,10 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op) op->customdata = NULL; } -static int gpencil_draw_cancel(bContext *C, wmOperator *op) +static void gpencil_draw_cancel(bContext *C, wmOperator *op) { /* this is just a wrapper around exit() */ gpencil_draw_exit(C, op); - return OPERATOR_CANCELLED; } /* ------------------------------- */ diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index 783a777a2fe..01e53d5e721 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -122,10 +122,9 @@ static void eyedropper_exit(bContext *C, wmOperator *op) } } -static int eyedropper_cancel(bContext *C, wmOperator *op) +static void eyedropper_cancel(bContext *C, wmOperator *op) { eyedropper_exit(C, op); - return OPERATOR_CANCELLED; } /* *** eyedropper_color_ helper functions *** */ @@ -243,7 +242,8 @@ static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event) switch (event->type) { case ESCKEY: case RIGHTMOUSE: - return eyedropper_cancel(C, op); + eyedropper_cancel(C, op); + return OPERATOR_CANCELLED; case LEFTMOUSE: if (event->val == KM_RELEASE) { if (eye->accum_tot == 0) { @@ -447,10 +447,9 @@ static void datadropper_exit(bContext *C, wmOperator *op) } } -static int datadropper_cancel(bContext *C, wmOperator *op) +static void datadropper_cancel(bContext *C, wmOperator *op) { datadropper_exit(C, op); - return OPERATOR_CANCELLED; } /* *** datadropper id helper functions *** */ @@ -552,7 +551,8 @@ static int datadropper_modal(bContext *C, wmOperator *op, const wmEvent *event) switch (event->type) { case ESCKEY: case RIGHTMOUSE: - return datadropper_cancel(C, op); + datadropper_cancel(C, op); + return OPERATOR_CANCELLED; case LEFTMOUSE: if (event->val == KM_RELEASE) { bool success; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 00113666872..c5c9b1c8ce4 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -284,10 +284,9 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int view_pan_cancel(bContext *UNUSED(C), wmOperator *op) +static void view_pan_cancel(bContext *UNUSED(C), wmOperator *op) { view_pan_exit(op); - return OPERATOR_CANCELLED; } static void VIEW2D_OT_pan(wmOperatorType *ot) @@ -906,11 +905,9 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op) } } -static int view_zoomdrag_cancel(bContext *C, wmOperator *op) +static void view_zoomdrag_cancel(bContext *C, wmOperator *op) { view_zoomdrag_exit(C, op); - - return OPERATOR_CANCELLED; } /* for 'redo' only, with no user input */ @@ -1579,11 +1576,9 @@ static void scroller_activate_exit(bContext *C, wmOperator *op) } } -static int scroller_activate_cancel(bContext *C, wmOperator *op) +static void scroller_activate_cancel(bContext *C, wmOperator *op) { scroller_activate_exit(C, op); - - return OPERATOR_CANCELLED; } /* apply transform to view (i.e. adjust 'cur' rect) */ diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 97da0047793..dd3aacb2d67 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -185,7 +185,7 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op) op->customdata = NULL; } -static int edbm_bevel_cancel(bContext *C, wmOperator *op) +static void edbm_bevel_cancel(bContext *C, wmOperator *op) { BevelData *opdata = op->customdata; if (opdata->is_modal) { @@ -197,7 +197,6 @@ static int edbm_bevel_cancel(bContext *C, wmOperator *op) /* need to force redisplay or we may still view the modified result */ ED_region_tag_redraw(CTX_wm_region(C)); - return OPERATOR_CANCELLED; } /* bevel! yay!!*/ diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index eb66cf50a1e..137554459ce 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -166,7 +166,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op) MEM_freeN(op->customdata); } -static int edbm_inset_cancel(bContext *C, wmOperator *op) +static void edbm_inset_cancel(bContext *C, wmOperator *op) { InsetData *opdata; @@ -180,7 +180,6 @@ static int edbm_inset_cancel(bContext *C, wmOperator *op) /* need to force redisplay or we may still view the modified result */ ED_region_tag_redraw(CTX_wm_region(C)); - return OPERATOR_CANCELLED; } static bool edbm_inset_calc(wmOperator *op) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 5d8851640e0..306aedaa9ec 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -3195,11 +3195,10 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd, } } -static int knifetool_cancel(bContext *C, wmOperator *op) +static void knifetool_cancel(bContext *C, wmOperator *op) { /* this is just a wrapper around exit() */ knifetool_exit(C, op); - return OPERATOR_CANCELLED; } static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event) diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 3066fb86bf8..9223f6d9450 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -418,11 +418,10 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut) return 1; } -static int ringcut_cancel(bContext *C, wmOperator *op) +static void ringcut_cancel(bContext *C, wmOperator *op) { /* this is just a wrapper around exit() */ ringsel_exit(C, op); - return OPERATOR_CANCELLED; } static void loopcut_update_edge(RingSelOpData *lcd, BMEdge *e, const int previewlines) @@ -549,7 +548,8 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) ringsel_exit(C, op); } else { - return ringcut_cancel(C, op); + ringcut_cancel(C, op); + return OPERATOR_CANCELLED; } return OPERATOR_FINISHED; @@ -569,7 +569,8 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_region_tag_redraw(lcd->ar); ED_area_headerprint(CTX_wm_area(C), NULL); - return ringcut_cancel(C, op); + ringcut_cancel(C, op); + return OPERATOR_CANCELLED; } ED_region_tag_redraw(lcd->ar); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index b0e19d04e35..65a3e5b558e 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3880,11 +3880,9 @@ static int brush_edit_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int brush_edit_cancel(bContext *UNUSED(C), wmOperator *op) +static void brush_edit_cancel(bContext *UNUSED(C), wmOperator *op) { brush_edit_exit(op); - - return OPERATOR_CANCELLED; } void PARTICLE_OT_brush_edit(wmOperatorType *ot) diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index df8d5ec4e84..a47235024dd 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -564,15 +564,13 @@ static int screen_render_modal(bContext *C, wmOperator *op, const wmEvent *event return OPERATOR_PASS_THROUGH; } -static int screen_render_cancel(bContext *C, wmOperator *op) +static void screen_render_cancel(bContext *C, wmOperator *op) { wmWindowManager *wm = CTX_wm_manager(C); Scene *scene = (Scene *) op->customdata; /* kill on cancel, because job is using op->reports */ WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_RENDER); - - return OPERATOR_CANCELLED; } /* using context, starts job */ diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 21074bdc47c..107674babdd 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -485,11 +485,9 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) MEM_freeN(oglrender); } -static int screen_opengl_render_cancel(bContext *C, wmOperator *op) +static void screen_opengl_render_cancel(bContext *C, wmOperator *op) { screen_opengl_render_end(C, op->customdata); - - return OPERATOR_CANCELLED; } /* share between invoke and exec */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 3cecbbb767d..b226104a356 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -750,11 +750,9 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int actionzone_cancel(bContext *UNUSED(C), wmOperator *op) +static void actionzone_cancel(bContext *UNUSED(C), wmOperator *op) { actionzone_exit(op); - - return OPERATOR_CANCELLED; } static void SCREEN_OT_actionzone(wmOperatorType *ot) @@ -825,10 +823,9 @@ static void area_swap_exit(bContext *C, wmOperator *op) op->customdata = NULL; } -static int area_swap_cancel(bContext *C, wmOperator *op) +static void area_swap_cancel(bContext *C, wmOperator *op) { area_swap_exit(C, op); - return OPERATOR_CANCELLED; } static int area_swap_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -857,8 +854,8 @@ static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event) case LEFTMOUSE: /* release LMB */ if (event->val == KM_RELEASE) { if (!sad->sa2 || sad->sa1 == sad->sa2) { - - return area_swap_cancel(C, op); + area_swap_cancel(C, op); + return OPERATOR_CANCELLED; } ED_area_tag_redraw(sad->sa1); @@ -875,7 +872,8 @@ static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event) break; case ESCKEY: - return area_swap_cancel(C, op); + area_swap_cancel(C, op); + return OPERATOR_CANCELLED; } return OPERATOR_RUNNING_MODAL; } @@ -1148,14 +1146,12 @@ static int area_move_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int area_move_cancel(bContext *C, wmOperator *op) +static void area_move_cancel(bContext *C, wmOperator *op) { RNA_int_set(op->ptr, "delta", 0); area_move_apply(C, op); area_move_exit(C, op); - - return OPERATOR_CANCELLED; } /* modal callback for while moving edges */ @@ -1186,7 +1182,8 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; case KM_MODAL_CANCEL: - return area_move_cancel(C, op); + area_move_cancel(C, op); + return OPERATOR_CANCELLED; case KM_MODAL_STEP10: md->step = 10; @@ -1530,7 +1527,7 @@ static int area_split_exec(bContext *C, wmOperator *op) } -static int area_split_cancel(bContext *C, wmOperator *op) +static void area_split_cancel(bContext *C, wmOperator *op) { sAreaSplitData *sd = (sAreaSplitData *)op->customdata; @@ -1546,8 +1543,6 @@ static int area_split_cancel(bContext *C, wmOperator *op) } } area_split_exit(C, op); - - return OPERATOR_CANCELLED; } static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) @@ -1640,7 +1635,8 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) case RIGHTMOUSE: /* cancel operation */ case ESCKEY: - return area_split_cancel(C, op); + area_split_cancel(C, op); + return OPERATOR_CANCELLED; } return OPERATOR_RUNNING_MODAL; @@ -1915,12 +1911,10 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int region_scale_cancel(bContext *UNUSED(C), wmOperator *op) +static void region_scale_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); op->customdata = NULL; - - return OPERATOR_CANCELLED; } static void SCREEN_OT_region_scale(wmOperatorType *ot) @@ -2449,7 +2443,7 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int area_join_cancel(bContext *C, wmOperator *op) +static void area_join_cancel(bContext *C, wmOperator *op) { sAreaJoinData *jd = (sAreaJoinData *)op->customdata; @@ -2465,8 +2459,6 @@ static int area_join_cancel(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_WINDOW, NULL); area_join_exit(C, op); - - return OPERATOR_CANCELLED; } /* modal callback while selecting area (space) that will be removed */ @@ -2554,7 +2546,8 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event) case RIGHTMOUSE: case ESCKEY: - return area_join_cancel(C, op); + area_join_cancel(C, op); + return OPERATOR_CANCELLED; } return OPERATOR_RUNNING_MODAL; diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 06581fb3c11..0153d609adb 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -237,10 +237,9 @@ static bool screenshot_check(bContext *UNUSED(C), wmOperator *op) return WM_operator_filesel_ensure_ext_imtype(op, &scd->im_format); } -static int screenshot_cancel(bContext *UNUSED(C), wmOperator *op) +static void screenshot_cancel(bContext *UNUSED(C), wmOperator *op) { screenshot_data_free(op); - return OPERATOR_CANCELLED; } static bool screenshot_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 9e8a8fd3ecc..003db8a9c43 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -898,10 +898,9 @@ static int grab_clone_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int grab_clone_cancel(bContext *UNUSED(C), wmOperator *op) +static void grab_clone_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); - return OPERATOR_CANCELLED; } void PAINT_OT_grab_clone(wmOperatorType *ot) diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index f276e6823e2..5fff02f016b 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -80,7 +80,7 @@ bool paint_supports_jitter(enum PaintMode mode); struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf); int paint_stroke_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int paint_stroke_exec(struct bContext *C, struct wmOperator *op); -int paint_stroke_cancel(struct bContext *C, struct wmOperator *op); +void paint_stroke_cancel(struct bContext *C, struct wmOperator *op); struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke); void *paint_stroke_mode_data(struct PaintStroke *stroke); void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 03c063692c6..55ea0363b7a 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -613,13 +613,12 @@ static void stencil_restore(StencilControlData *scd) *scd->rot_target = scd->init_rot; } -static int stencil_control_cancel(bContext *UNUSED(C), wmOperator *op) +static void stencil_control_cancel(bContext *UNUSED(C), wmOperator *op) { StencilControlData *scd = op->customdata; stencil_restore(scd); MEM_freeN(op->customdata); - return OPERATOR_CANCELLED; } static void stencil_control_calculate(StencilControlData *scd, const int mval[2]) diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index b00b1c3ecff..397baeae4c9 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -718,10 +718,13 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Cancel */ if (event->type == EVT_MODAL_MAP && event->val == PAINT_STROKE_MODAL_CANCEL) { - if (op->type->cancel) - return op->type->cancel(C, op); - else - return paint_stroke_cancel(C, op); + if (op->type->cancel) { + op->type->cancel(C, op); + } + else { + paint_stroke_cancel(C, op); + } + return OPERATOR_CANCELLED; } if (event->type == stroke->event_type && event->val == KM_RELEASE && !first_modal) { @@ -787,10 +790,9 @@ int paint_stroke_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -int paint_stroke_cancel(bContext *C, wmOperator *op) +void paint_stroke_cancel(bContext *C, wmOperator *op) { stroke_done(C, op); - return OPERATOR_CANCELLED; } ViewContext *paint_stroke_view_context(PaintStroke *stroke) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 1c3caf5d8bc..db71ca1a93e 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2593,11 +2593,9 @@ static int wpaint_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int wpaint_cancel(bContext *C, wmOperator *op) +static void wpaint_cancel(bContext *C, wmOperator *op) { paint_stroke_cancel(C, op); - - return OPERATOR_CANCELLED; } void PAINT_OT_weight_paint(wmOperatorType *ot) @@ -3144,11 +3142,9 @@ static int vpaint_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int vpaint_cancel(bContext *C, wmOperator *op) +static void vpaint_cancel(bContext *C, wmOperator *op) { paint_stroke_cancel(C, op); - - return OPERATOR_CANCELLED; } void PAINT_OT_vertex_paint(wmOperatorType *ot) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 488504b71f8..6bd935af436 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4567,7 +4567,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op) +static void sculpt_brush_stroke_cancel(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; @@ -4585,8 +4585,6 @@ static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op) } sculpt_brush_exit_tex(sd); - - return OPERATOR_CANCELLED; } static void SCULPT_OT_brush_stroke(wmOperatorType *ot) diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index a2189f6237c..81b0992c878 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -77,11 +77,10 @@ /******************** open sound operator ********************/ -static int sound_open_cancel(bContext *UNUSED(C), wmOperator *op) +static void sound_open_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); op->customdata = NULL; - return OPERATOR_CANCELLED; } static void sound_open_init(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index cf277957e70..4fbf5aa5fb7 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -158,12 +158,10 @@ static int file_browse_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int file_browse_cancel(bContext *UNUSED(C), wmOperator *op) +static void file_browse_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); op->customdata = NULL; - - return OPERATOR_CANCELLED; } static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index a76f4364492..9aa6eab7fc8 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -159,12 +159,10 @@ static void open_init(bContext *C, wmOperator *op) uiIDContextProperty(C, &pprop->ptr, &pprop->prop); } -static int open_cancel(bContext *UNUSED(C), wmOperator *op) +static void open_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); op->customdata = NULL; - - return OPERATOR_CANCELLED; } static int open_exec(bContext *C, wmOperator *op) @@ -444,11 +442,9 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int view_pan_cancel(bContext *C, wmOperator *op) +static void view_pan_cancel(bContext *C, wmOperator *op) { - view_pan_exit(C, op, 1); - - return OPERATOR_CANCELLED; + view_pan_exit(C, op, true); } void CLIP_OT_view_pan(wmOperatorType *ot) @@ -578,11 +574,9 @@ static int view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int view_zoom_cancel(bContext *C, wmOperator *op) +static void view_zoom_cancel(bContext *C, wmOperator *op) { - view_zoom_exit(C, op, 1); - - return OPERATOR_CANCELLED; + view_zoom_exit(C, op, true); } void CLIP_OT_view_zoom(wmOperatorType *ot) diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 289986d7fba..f24a204912e 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -1123,10 +1123,9 @@ static int console_modal_select(bContext *C, wmOperator *op, const wmEvent *even return OPERATOR_RUNNING_MODAL; } -static int console_modal_select_cancel(bContext *C, wmOperator *op) +static void console_modal_select_cancel(bContext *C, wmOperator *op) { console_cursor_set_exit(C, op); - return OPERATOR_FINISHED; } void CONSOLE_OT_select_set(wmOperatorType *ot) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 710d5c8cd81..ebcc8c2ebee 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -256,7 +256,7 @@ static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *even WM_event_add_modal_handler(C, op); } -static void image_view_pan_exit(bContext *C, wmOperator *op, int cancel) +static void image_view_pan_exit(bContext *C, wmOperator *op, bool cancel) { SpaceImage *sima = CTX_wm_space_image(C); ViewPanData *vpd = op->customdata; @@ -330,7 +330,7 @@ static int image_view_pan_modal(bContext *C, wmOperator *op, const wmEvent *even break; default: if (event->type == vpd->event_type && event->val == KM_RELEASE) { - image_view_pan_exit(C, op, 0); + image_view_pan_exit(C, op, false); return OPERATOR_FINISHED; } break; @@ -339,10 +339,9 @@ static int image_view_pan_modal(bContext *C, wmOperator *op, const wmEvent *even return OPERATOR_RUNNING_MODAL; } -static int image_view_pan_cancel(bContext *C, wmOperator *op) +static void image_view_pan_cancel(bContext *C, wmOperator *op) { - image_view_pan_exit(C, op, 1); - return OPERATOR_CANCELLED; + image_view_pan_exit(C, op, true); } void IMAGE_OT_view_pan(wmOperatorType *ot) @@ -412,7 +411,7 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *eve WM_event_add_modal_handler(C, op); } -static void image_view_zoom_exit(bContext *C, wmOperator *op, int cancel) +static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel) { SpaceImage *sima = CTX_wm_space_image(C); ViewZoomData *vpd = op->customdata; @@ -547,17 +546,16 @@ static int image_view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *eve image_zoom_apply(vpd, op, event->x, event->y, U.viewzoom, (U.uiflag & USER_ZOOM_INVERT) != 0); } else if (event_code == VIEW_CONFIRM) { - image_view_zoom_exit(C, op, 0); + image_view_zoom_exit(C, op, false); return OPERATOR_FINISHED; } return OPERATOR_RUNNING_MODAL; } -static int image_view_zoom_cancel(bContext *C, wmOperator *op) +static void image_view_zoom_cancel(bContext *C, wmOperator *op) { - image_view_zoom_exit(C, op, 1); - return OPERATOR_CANCELLED; + image_view_zoom_exit(C, op, true); } void IMAGE_OT_view_zoom(wmOperatorType *ot) @@ -921,11 +919,10 @@ static void image_open_init(bContext *C, wmOperator *op) uiIDContextProperty(C, &pprop->ptr, &pprop->prop); } -static int image_open_cancel(bContext *UNUSED(C), wmOperator *op) +static void image_open_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); op->customdata = NULL; - return OPERATOR_CANCELLED; } static int image_open_exec(bContext *C, wmOperator *op) @@ -1505,11 +1502,9 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS return OPERATOR_RUNNING_MODAL; } -static int image_save_as_cancel(bContext *UNUSED(C), wmOperator *op) +static void image_save_as_cancel(bContext *UNUSED(C), wmOperator *op) { image_save_as_free(op); - - return OPERATOR_CANCELLED; } static bool image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) @@ -2358,10 +2353,9 @@ static int image_sample_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int image_sample_cancel(bContext *C, wmOperator *op) +static void image_sample_cancel(bContext *C, wmOperator *op) { image_sample_exit(C, op); - return OPERATOR_CANCELLED; } void IMAGE_OT_sample(wmOperatorType *ot) @@ -2625,7 +2619,7 @@ static int image_record_composite_modal(bContext *C, wmOperator *op, const wmEve return OPERATOR_RUNNING_MODAL; } -static int image_record_composite_cancel(bContext *C, wmOperator *op) +static void image_record_composite_cancel(bContext *C, wmOperator *op) { image_record_composite_exit(C, op); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 1d93fe65c09..f58bc83e5d2 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -859,7 +859,7 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED( WM_event_add_modal_handler(C, op); } -static void node_resize_exit(bContext *C, wmOperator *op, int UNUSED(cancel)) +static void node_resize_exit(bContext *C, wmOperator *op, bool UNUSED(cancel)) { WM_cursor_modal_restore(CTX_wm_window(C)); @@ -961,7 +961,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) case MIDDLEMOUSE: case RIGHTMOUSE: - node_resize_exit(C, op, 0); + node_resize_exit(C, op, false); ED_node_post_apply_transform(C, snode->edittree); return OPERATOR_FINISHED; @@ -990,11 +990,9 @@ static int node_resize_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } -static int node_resize_cancel(bContext *C, wmOperator *op) +static void node_resize_cancel(bContext *C, wmOperator *op) { - node_resize_exit(C, op, 1); - - return OPERATOR_CANCELLED; + node_resize_exit(C, op, true); } void NODE_OT_resize(wmOperatorType *ot) diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 4b5cc9e42b6..8c4050766af 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -669,7 +669,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } -static int node_link_cancel(bContext *C, wmOperator *op) +static void node_link_cancel(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); bNodeLinkDrag *nldrag = op->customdata; @@ -678,8 +678,6 @@ static int node_link_cancel(bContext *C, wmOperator *op) BLI_freelistN(&nldrag->links); MEM_freeN(nldrag); - - return OPERATOR_CANCELLED; } void NODE_OT_link(wmOperatorType *ot) diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index f889a8ec97b..5ea6f8b0caf 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -273,12 +273,10 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent * return OPERATOR_RUNNING_MODAL; } -static int snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op) +static void snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); op->customdata = NULL; - - return OPERATOR_CANCELLED; } void NODE_OT_backimage_move(wmOperatorType *ot) @@ -612,10 +610,9 @@ static int sample_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int sample_cancel(bContext *C, wmOperator *op) +static void sample_cancel(bContext *C, wmOperator *op) { sample_exit(C, op); - return OPERATOR_CANCELLED; } void NODE_OT_backimage_sample(wmOperatorType *ot) diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index deb37f8d943..f39b30adf37 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -211,11 +211,9 @@ static int sample_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int sample_cancel(bContext *C, wmOperator *op) +static void sample_cancel(bContext *C, wmOperator *op) { sample_exit(C, op); - - return OPERATOR_CANCELLED; } static int sample_poll(bContext *C) diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index eaba537c0a8..692cefd3ee9 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -529,10 +529,9 @@ static void text_autocomplete_free(bContext *C, wmOperator *op) } } -static int text_autocomplete_cancel(bContext *C, wmOperator *op) +static void text_autocomplete_cancel(bContext *C, wmOperator *op) { text_autocomplete_free(C, op); - return OPERATOR_CANCELLED; } void TEXT_OT_autocomplete(wmOperatorType *ot) diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 4f53d033029..dd5e282587d 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -214,10 +214,9 @@ static void text_open_init(bContext *C, wmOperator *op) uiIDContextProperty(C, &pprop->ptr, &pprop->prop); } -static int text_open_cancel(bContext *UNUSED(C), wmOperator *op) +static void text_open_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); - return OPERATOR_CANCELLED; } static int text_open_exec(bContext *C, wmOperator *op) @@ -2231,11 +2230,9 @@ static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int text_scroll_cancel(bContext *C, wmOperator *op) +static void text_scroll_cancel(bContext *C, wmOperator *op) { scroll_exit(C, op); - - return OPERATOR_CANCELLED; } static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -2706,10 +2703,9 @@ static int text_set_selection_modal(bContext *C, wmOperator *op, const wmEvent * return OPERATOR_RUNNING_MODAL; } -static int text_set_selection_cancel(bContext *C, wmOperator *op) +static void text_set_selection_cancel(bContext *C, wmOperator *op) { text_cursor_set_exit(C, op); - return OPERATOR_FINISHED; } void TEXT_OT_selection_set(wmOperatorType *ot) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index bb41e727d90..80e5d194d45 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1062,11 +1062,9 @@ static int view3d_lock_poll(bContext *C) return false; } -static int viewrotate_cancel(bContext *C, wmOperator *op) +static void viewrotate_cancel(bContext *C, wmOperator *op) { viewops_data_free(C, op); - - return OPERATOR_CANCELLED; } void VIEW3D_OT_rotate(wmOperatorType *ot) @@ -1699,11 +1697,9 @@ static int viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event) } } -static int viewmove_cancel(bContext *C, wmOperator *op) +static void viewmove_cancel(bContext *C, wmOperator *op) { viewops_data_free(C, op); - - return OPERATOR_CANCELLED; } void VIEW3D_OT_move(wmOperatorType *ot) @@ -2091,11 +2087,9 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; } -static int viewzoom_cancel(bContext *C, wmOperator *op) +static void viewzoom_cancel(bContext *C, wmOperator *op) { viewops_data_free(C, op); - - return OPERATOR_CANCELLED; } void VIEW3D_OT_zoom(wmOperatorType *ot) @@ -2332,11 +2326,9 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; } -static int viewdolly_cancel(bContext *C, wmOperator *op) +static void viewdolly_cancel(bContext *C, wmOperator *op) { viewops_data_free(C, op); - - return OPERATOR_CANCELLED; } void VIEW3D_OT_dolly(wmOperatorType *ot) @@ -3772,11 +3764,9 @@ static int viewroll_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; } -static int viewroll_cancel(bContext *C, wmOperator *op) +static void viewroll_cancel(bContext *C, wmOperator *op) { viewops_data_free(C, op); - - return OPERATOR_CANCELLED; } void VIEW3D_OT_view_roll(wmOperatorType *ot) diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 9341ea9d3e6..6d04b9b8826 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -1254,15 +1254,13 @@ static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -static int fly_cancel(bContext *C, wmOperator *op) +static void fly_cancel(bContext *C, wmOperator *op) { FlyInfo *fly = op->customdata; fly->state = FLY_CANCEL; flyEnd(C, fly); op->customdata = NULL; - - return OPERATOR_CANCELLED; } static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event) diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index bca162d156b..288ada3f852 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -809,15 +809,13 @@ static int view3d_ruler_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE return OPERATOR_RUNNING_MODAL; } -static int view3d_ruler_cancel(bContext *C, wmOperator *op) +static void view3d_ruler_cancel(bContext *C, wmOperator *op) { RulerInfo *ruler_info = op->customdata; view3d_ruler_end(C, ruler_info); view3d_ruler_free(ruler_info); op->customdata = NULL; - - return OPERATOR_CANCELLED; } static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event) diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 2904b37c2e5..4b5ae8963d5 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -426,15 +426,13 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event) return exit_code; } -static int transform_cancel(bContext *C, wmOperator *op) +static void transform_cancel(bContext *C, wmOperator *op) { TransInfo *t = op->customdata; t->state = TRANS_CANCEL; transformEnd(C, t); transformops_exit(C, op); - - return OPERATOR_CANCELLED; } static int transform_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 4b5d6d55aa0..c234d1769b3 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1998,10 +1998,9 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished) } -static int stitch_cancel(bContext *C, wmOperator *op) +static void stitch_cancel(bContext *C, wmOperator *op) { stitch_exit(C, op, 0); - return OPERATOR_CANCELLED; } @@ -2016,7 +2015,8 @@ static int stitch_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } else { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } } @@ -2067,8 +2067,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Cancel */ case ESCKEY: - return stitch_cancel(C, op); - + stitch_cancel(C, op); + return OPERATOR_CANCELLED; case LEFTMOUSE: if (event->shift && (U.flag & USER_LMOUSESELECT)) { @@ -2076,7 +2076,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) stitch_select(C, scene, event, state); if (!stitch_process_data(state, scene, FALSE)) { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } } break; @@ -2089,7 +2090,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; } else { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } } else { @@ -2101,7 +2103,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_PRESS && event->alt) { state->limit_dist += 0.01f; if (!stitch_process_data(state, scene, FALSE)) { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } break; } @@ -2115,7 +2118,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) state->limit_dist -= 0.01f; state->limit_dist = MAX2(0.01f, state->limit_dist); if (!stitch_process_data(state, scene, FALSE)) { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } break; } @@ -2128,7 +2132,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_PRESS) { state->use_limit = !state->use_limit; if (!stitch_process_data(state, scene, FALSE)) { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } break; } @@ -2140,7 +2145,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) state->static_island %= state->element_map->totalIslands; if (!stitch_process_data(state, scene, FALSE)) { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } break; } @@ -2150,7 +2156,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_PRESS) { state->midpoints = !state->midpoints; if (!stitch_process_data(state, scene, FALSE)) { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } } break; @@ -2158,13 +2165,15 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Select geometry*/ case RIGHTMOUSE: if (!event->shift) { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } if (event->val == KM_PRESS && !(U.flag & USER_LMOUSESELECT)) { stitch_select(C, scene, event, state); if (!stitch_process_data(state, scene, FALSE)) { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } break; } @@ -2175,7 +2184,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_PRESS) { state->snap_islands = !state->snap_islands; if (!stitch_process_data(state, scene, FALSE)) { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } break; } @@ -2189,7 +2199,8 @@ static int stitch_modal(bContext *C, wmOperator *op, const wmEvent *event) stitch_switch_selection_mode(state); if (!stitch_process_data(state, scene, FALSE)) { - return stitch_cancel(C, op); + stitch_cancel(C, op); + return OPERATOR_CANCELLED; } } break; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 06ffdea96bf..d6bd6f466b9 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -542,7 +542,7 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op) return true; } -static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interactive) +static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interactive) { MinStretch *ms = op->customdata; ScrArea *sa = CTX_wm_area(C); @@ -570,7 +570,7 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interact } } -static void minimize_stretch_exit(bContext *C, wmOperator *op, int cancel) +static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel) { MinStretch *ms = op->customdata; ScrArea *sa = CTX_wm_area(C); @@ -604,8 +604,8 @@ static int minimize_stretch_exec(bContext *C, wmOperator *op) iterations = RNA_int_get(op->ptr, "iterations"); for (i = 0; i < iterations; i++) - minimize_stretch_iteration(C, op, 0); - minimize_stretch_exit(C, op, 0); + minimize_stretch_iteration(C, op, false); + minimize_stretch_exit(C, op, false); return OPERATOR_FINISHED; } @@ -617,7 +617,7 @@ static int minimize_stretch_invoke(bContext *C, wmOperator *op, const wmEvent *U if (!minimize_stretch_init(C, op)) return OPERATOR_CANCELLED; - minimize_stretch_iteration(C, op, 1); + minimize_stretch_iteration(C, op, true); ms = op->customdata; WM_event_add_modal_handler(C, op); @@ -633,12 +633,12 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, const wmEvent *ev switch (event->type) { case ESCKEY: case RIGHTMOUSE: - minimize_stretch_exit(C, op, 1); + minimize_stretch_exit(C, op, true); return OPERATOR_CANCELLED; case RETKEY: case PADENTER: case LEFTMOUSE: - minimize_stretch_exit(C, op, 0); + minimize_stretch_exit(C, op, false); return OPERATOR_FINISHED; case PADPLUSKEY: case WHEELUPMOUSE: @@ -647,7 +647,7 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, const wmEvent *ev ms->blend += 0.1f; ms->lasttime = 0.0f; RNA_float_set(op->ptr, "blend", ms->blend); - minimize_stretch_iteration(C, op, 1); + minimize_stretch_iteration(C, op, true); } } break; @@ -658,7 +658,7 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, const wmEvent *ev ms->blend -= 0.1f; ms->lasttime = 0.0f; RNA_float_set(op->ptr, "blend", ms->blend); - minimize_stretch_iteration(C, op, 1); + minimize_stretch_iteration(C, op, true); } } break; @@ -667,25 +667,23 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, const wmEvent *ev double start = PIL_check_seconds_timer(); do { - minimize_stretch_iteration(C, op, 1); + minimize_stretch_iteration(C, op, true); } while (PIL_check_seconds_timer() - start < 0.01); } break; } if (ms->iterations && ms->i >= ms->iterations) { - minimize_stretch_exit(C, op, 0); + minimize_stretch_exit(C, op, false); return OPERATOR_FINISHED; } return OPERATOR_RUNNING_MODAL; } -static int minimize_stretch_cancel(bContext *C, wmOperator *op) +static void minimize_stretch_cancel(bContext *C, wmOperator *op) { - minimize_stretch_exit(C, op, 1); - - return OPERATOR_CANCELLED; + minimize_stretch_exit(C, op, true); } void UV_OT_minimize_stretch(wmOperatorType *ot) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index dd338713d3e..09451599ce5 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1042,15 +1042,13 @@ static void operator_draw(bContext *C, wmOperator *op) } /* same as exec(), but call cancel */ -static int operator_cancel(bContext *C, wmOperator *op) +static void operator_cancel(bContext *C, wmOperator *op) { extern FunctionRNA rna_Operator_cancel_func; PointerRNA opr; ParameterList list; FunctionRNA *func; - void *ret; - int result; RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); func = &rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */ @@ -1059,12 +1057,7 @@ static int operator_cancel(bContext *C, wmOperator *op) RNA_parameter_set_lookup(&list, "context", &C); op->type->ext.call(C, &opr, func, &list); - RNA_parameter_get_lookup(&list, "result", &ret); - result = *(int *)ret; - RNA_parameter_list_free(&list); - - return result; } void operator_wrapper(wmOperatorType *ot, void *userdata); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index eb84bb61e1f..91cddd28be0 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -539,10 +539,6 @@ void RNA_api_operator(StructRNA *srna) RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE); parm = RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); - - /* better name? */ - parm = RNA_def_enum_flag(func, "result", operator_return_items, OPERATOR_CANCELLED, "result", ""); - RNA_def_function_return(func, parm); } void RNA_api_macro(StructRNA *srna) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index c338d49fe17..9bc12d04b02 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -294,20 +294,20 @@ void WM_menutype_free(void); /* default operator callbacks for border/circle/lasso */ int WM_border_select_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_border_select_modal (struct bContext *C, struct wmOperator *op, const struct wmEvent *event); -int WM_border_select_cancel(struct bContext *C, struct wmOperator *op); +void WM_border_select_cancel(struct bContext *C, struct wmOperator *op); int WM_gesture_circle_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_gesture_circle_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); -int WM_gesture_circle_cancel(struct bContext *C, struct wmOperator *op); +void WM_gesture_circle_cancel(struct bContext *C, struct wmOperator *op); int WM_gesture_lines_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_gesture_lines_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); -int WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op); +void WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op); int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); -int WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op); +void WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op); const int (*WM_gesture_lasso_path_to_array(struct bContext *C, struct wmOperator *op, int *mcords_tot))[2]; int WM_gesture_straightline_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); int WM_gesture_straightline_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event); -int WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op); +void WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op); /* Gesture manager API */ struct wmGesture *WM_gesture_new(struct bContext *C, const struct wmEvent *event, int type); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index ac9af832671..6538272a43c 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -535,7 +535,7 @@ typedef struct wmOperatorType { * canceled due to some external reason, cancel is called * - see defines below for return values */ int (*invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT; - int (*cancel)(struct bContext *, struct wmOperator *); + void (*cancel)(struct bContext *, struct wmOperator *); int (*modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT; /* verify if the operator can be executed in the current context, note diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 6091ec4a371..acc26f6f065 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -341,14 +341,14 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event) return wm_macro_end(op, retval); } -static int wm_macro_cancel(bContext *C, wmOperator *op) +static void wm_macro_cancel(bContext *C, wmOperator *op) { /* call cancel on the current modal operator, if any */ if (op->opm && op->opm->type->cancel) { op->opm->type->cancel(C, op->opm); } - return wm_macro_end(op, OPERATOR_CANCELLED); + wm_macro_end(op, OPERATOR_CANCELLED); } /* Names have to be static for now */ @@ -2844,11 +2844,9 @@ int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -int WM_border_select_cancel(bContext *C, wmOperator *op) +void WM_border_select_cancel(bContext *C, wmOperator *op) { wm_gesture_end(C, op); - - return OPERATOR_CANCELLED; } /* **************** circle gesture *************** */ @@ -2961,11 +2959,9 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } -int WM_gesture_circle_cancel(bContext *C, wmOperator *op) +void WM_gesture_circle_cancel(bContext *C, wmOperator *op) { wm_gesture_end(C, op); - - return OPERATOR_CANCELLED; } #if 0 @@ -3188,18 +3184,14 @@ int WM_gesture_lines_modal(bContext *C, wmOperator *op, const wmEvent *event) return WM_gesture_lasso_modal(C, op, event); } -int WM_gesture_lasso_cancel(bContext *C, wmOperator *op) +void WM_gesture_lasso_cancel(bContext *C, wmOperator *op) { wm_gesture_end(C, op); - - return OPERATOR_CANCELLED; } -int WM_gesture_lines_cancel(bContext *C, wmOperator *op) +void WM_gesture_lines_cancel(bContext *C, wmOperator *op) { wm_gesture_end(C, op); - - return OPERATOR_CANCELLED; } /** @@ -3365,11 +3357,9 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev return OPERATOR_RUNNING_MODAL; } -int WM_gesture_straightline_cancel(bContext *C, wmOperator *op) +void WM_gesture_straightline_cancel(bContext *C, wmOperator *op) { wm_gesture_end(C, op); - - return OPERATOR_CANCELLED; } #if 0 @@ -3803,7 +3793,7 @@ static void radial_control_set_value(RadialControl *rc, float val) } } -static int radial_control_cancel(bContext *C, wmOperator *op) +static void radial_control_cancel(bContext *C, wmOperator *op) { RadialControl *rc = op->customdata; wmWindowManager *wm = CTX_wm_manager(C); @@ -3821,8 +3811,6 @@ static int radial_control_cancel(bContext *C, wmOperator *op) glDeleteTextures(1, &rc->gltex); MEM_freeN(rc); - - return OPERATOR_CANCELLED; } static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *event) -- cgit v1.2.3 From bd17d2371f22ed7a677422297f3ce5a1c3df6f40 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Oct 2013 23:15:27 +0000 Subject: cancelling an operator popup now calls the operators cancel callback. --- source/blender/windowmanager/intern/wm_operators.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index acc26f6f065..7748a2cb4b8 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1396,12 +1396,19 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) return block; } -static void wm_operator_ui_popup_cancel(struct bContext *UNUSED(C), void *userData) +static void wm_operator_ui_popup_cancel(struct bContext *C, void *userData) { wmOpPopUp *data = userData; - if (data->free_op && data->op) { - wmOperator *op = data->op; - WM_operator_free(op); + wmOperator *op = data->op; + + if (op) { + if (op->type->cancel) { + op->type->cancel(C, op); + } + + if (data->free_op) { + WM_operator_free(op); + } } MEM_freeN(data); -- cgit v1.2.3 From 1cf1984d1c4913024f58cc54cbe1db06eb47738a Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 31 Oct 2013 03:21:20 +0000 Subject: Python ui: increase interface float precision limit from 6 to 7 --- source/blender/editors/interface/interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 16e92f2bc18..54fb0fc5c20 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -78,7 +78,7 @@ #include "interface_intern.h" -#define PRECISION_FLOAT_MAX 6 +#define PRECISION_FLOAT_MAX 7 #define PRECISION_FLOAT_MAX_POW 1000000 /* pow(10, PRECISION_FLOAT_MAX) */ /* avoid unneeded calls to ui_get_but_val */ @@ -443,7 +443,7 @@ void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int max static int ui_but_float_precision(uiBut *but, double value) { int prec; - const double pow10_neg[PRECISION_FLOAT_MAX + 1] = {1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001}; + const double pow10_neg[PRECISION_FLOAT_MAX + 1] = {1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 0.0000001}; /* first check if prec is 0 and fallback to a simple default */ if ((prec = (int)but->a2) == -1) { -- cgit v1.2.3 From 712c8f3caeafb982b0c589895c81874b97b3b902 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Oct 2013 03:30:20 +0000 Subject: code cleanup: warnings --- source/blender/makesrna/RNA_enum_types.h | 1 - source/blender/makesrna/intern/rna_curve.c | 1 + source/blender/nodes/composite/nodes/node_composite_switch.c | 2 -- source/blender/python/bmesh/bmesh_py_types_meshdata.c | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 5a7df0e0080..f1881c8beba 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -71,7 +71,6 @@ extern EnumPropertyItem image_generated_type_items[]; extern EnumPropertyItem color_sets_items[]; extern EnumPropertyItem beztriple_keyframe_type_items[]; -extern EnumPropertyItem beztriple_handle_type_items[]; extern EnumPropertyItem beztriple_interpolation_mode_items[]; extern EnumPropertyItem keyframe_handle_type_items[]; diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index bd4b8dd76b1..74fe3c145f1 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -38,6 +38,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "rna_internal.h" diff --git a/source/blender/nodes/composite/nodes/node_composite_switch.c b/source/blender/nodes/composite/nodes/node_composite_switch.c index 3384f31bfd1..d7de26730d0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_switch.c +++ b/source/blender/nodes/composite/nodes/node_composite_switch.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.c b/source/blender/python/bmesh/bmesh_py_types_meshdata.c index d554f33a77e..80b07a926f4 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.c @@ -319,7 +319,7 @@ static PyGetSetDef bpy_bmvertskin_getseters[] = { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; -PyTypeObject BPy_BMVertSkin_Type = {{{0}}}; /* bm.loops.layers.uv.active */ +static PyTypeObject BPy_BMVertSkin_Type = {{{0}}}; /* bm.loops.layers.uv.active */ static void bm_init_types_bmvertskin(void) { -- cgit v1.2.3 From 7eff2285a380e421a2bab8127bf769821491c918 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Thu, 31 Oct 2013 07:41:40 +0000 Subject: Fix for Freestyle rendering errors with color blend modes SOFT_LIGHT and LINEAR_LIGHT. --- source/blender/freestyle/intern/python/BPy_Freestyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp index 680f399cc77..c28f6ef6762 100644 --- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -101,8 +101,8 @@ static int ramp_blend_type(const char *type) if (!strcmp(type, "SATURATION")) return MA_RAMP_SAT; if (!strcmp(type, "VALUE")) return MA_RAMP_VAL; if (!strcmp(type, "COLOR")) return MA_RAMP_COLOR; - if (!strcmp(type, "SOFT LIGHT")) return MA_RAMP_SOFT; - if (!strcmp(type, "LINEAR LIGHT")) return MA_RAMP_LINEAR; + if (!strcmp(type, "SOFT_LIGHT")) return MA_RAMP_SOFT; + if (!strcmp(type, "LINEAR_LIGHT")) return MA_RAMP_LINEAR; return -1; } -- cgit v1.2.3 From bdc3e1e5de4f729b7fd878962f0cc745ef4987ed Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 31 Oct 2013 13:11:01 +0000 Subject: Minor update to r60953. --- build_files/build_environment/install_deps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 6daa3831c08..4ca7400fe44 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -1091,11 +1091,12 @@ compile_OPENEXR() { DESTINATION \${CMAKE_INSTALL_PREFIX}/lib ) -@@ -168,6 +167,7 @@ +@@ -168,6 +167,8 @@ INSTALL ( FILES ${CMAKE_SOURCE_DIR}/config/OpenEXRConfig.h ImfForward.h + ImfNamespace.h ++ ImfPartHelper.h ImfExport.h ImfAttribute.h ImfBoxAttribute.h -- cgit v1.2.3 From 50d1129a57cb1eab3f87ffa1149d4b0ad76a012f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Oct 2013 14:09:01 +0000 Subject: add atomic_ops.h to cmake's source code listing. --- intern/guardedalloc/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt index b7a59da7813..1d041ba5380 100644 --- a/intern/guardedalloc/CMakeLists.txt +++ b/intern/guardedalloc/CMakeLists.txt @@ -39,6 +39,9 @@ set(SRC MEM_guardedalloc.h ./intern/mallocn_intern.h + + # only so the header is known by cmake + ../atomic/atomic_ops.h ) if(WIN32 AND NOT UNIX) -- cgit v1.2.3 From beae4f498da5a730889e9deb17455263a6e2f054 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Oct 2013 14:10:01 +0000 Subject: code cleanup: spelling --- intern/ffmpeg/ffmpeg_compat.h | 2 +- intern/ghost/intern/GHOST_SystemCocoa.mm | 2 +- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/brush.c | 2 +- source/blender/blenkernel/intern/bvhutils.c | 2 +- source/blender/blenkernel/intern/cloth.c | 4 ++-- source/blender/blenkernel/intern/editderivedmesh.c | 2 +- source/blender/blenkernel/intern/image.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 4 ++-- source/blender/blenkernel/intern/rigidbody.c | 2 +- source/blender/blenlib/BLI_voronoi.h | 2 +- source/blender/blenlib/intern/voronoi.c | 10 +++++----- source/blender/collada/ArmatureImporter.cpp | 2 +- source/blender/compositor/nodes/COM_DespeckleNode.cpp | 2 +- .../blender/compositor/operations/COM_DespeckleOperation.cpp | 2 +- source/blender/compositor/operations/COM_DespeckleOperation.h | 4 ++-- source/blender/editors/animation/drivers.c | 4 ++-- source/blender/editors/armature/armature_edit.c | 2 +- source/blender/editors/armature/armature_utils.c | 2 +- source/blender/editors/gpencil/gpencil_paint.c | 2 +- source/blender/editors/object/object_lattice.c | 2 +- source/blender/editors/space_node/drawnode.c | 2 +- source/blender/editors/space_sequencer/sequencer_edit.c | 2 +- source/blender/freestyle/intern/geometry/Grid.h | 2 +- .../freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp | 2 +- .../blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp | 2 +- source/blender/freestyle/intern/stroke/Curve.h | 2 +- source/blender/freestyle/intern/stroke/Stroke.h | 4 ++-- source/blender/freestyle/intern/system/Id.h | 4 ++-- source/blender/freestyle/intern/system/TimeUtils.h | 2 +- source/blender/freestyle/intern/view_map/SteerableViewMap.h | 2 +- source/blender/freestyle/intern/view_map/ViewMap.h | 4 ++-- source/blender/makesrna/intern/rna_nodetree.c | 2 +- source/blender/makesrna/intern/rna_scene.c | 2 +- source/blender/python/intern/bpy_app_handlers.c | 2 +- source/blender/render/intern/source/pipeline.c | 2 +- 36 files changed, 47 insertions(+), 47 deletions(-) diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index 3b0180fd71a..459bee48e0e 100644 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -2,7 +2,7 @@ * compatibility macros to make every ffmpeg installation appear * like the most current installation (wrapping some functionality sometimes) * it also includes all ffmpeg header files at once, no need to do it - * seperately. + * separately. * * Copyright (c) 2011 Peter Schlaile * diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 84b4bb35768..ab1d547ea5e 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -525,7 +525,7 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op) return NSTerminateCancel; } -// To avoid cancelling a log off process, we must use Cocoa termination process +// To avoid canceling a log off process, we must use Cocoa termination process // And this function is the only chance to perform clean up // So WM_exit needs to be called directly, as the event loop will never run before termination - (void)applicationWillTerminate:(NSNotification *)aNotification diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 225be335c6d..9226538910c 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -285,7 +285,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets) /* ........ */ /* Note on evaluation optimizations: - * Optimisations currently used here play tricks with the depsgraph in order to try and + * Optimization's currently used here play tricks with the depsgraph in order to try and * evaluate as few objects as strictly necessary to get nicer performance under standard * production conditions. For those people who really need the accurate version, * disable the ifdef (i.e. 1 -> 0) and comment out the call to motionpaths_calc_optimise_depsgraph() diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 790c1f09ff0..33c6f3eb7c0 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -762,7 +762,7 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br, * radius become inconsistent. * the biggest problem is that it isn't possible to change * unprojected radius because a view context is not - * available. my ussual solution to this is to use the + * available. my usual solution to this is to use the * ratio of change of the size to change the unprojected * radius. Not completely convinced that is correct. * In any case, a better solution is needed to prevent diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 370dbc62ef8..dba7a291a46 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -557,7 +557,7 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *dm, float e 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 */ + * remember the min distance to point is the same as the min distance to BV of point */ data->nearest_callback = NULL; data->raycast_callback = NULL; diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index e4c6f7790d7..cab4adf46bf 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -1114,8 +1114,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) if ( numedges==0 ) return 0; - /* NOTE: handling ownership of sptings and edgehash is quite sloppy - * currenlty they are never initialized but assert just to be sure */ + /* NOTE: handling ownership of springs and edgehash is quite sloppy + * currently they are never initialized but assert just to be sure */ BLI_assert(cloth->springs == NULL); BLI_assert(cloth->edgehash == NULL); diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 453d96a11af..6fb5dd56ce5 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -34,7 +34,7 @@ * to three loops per triangle. the derivedmesh stores a cache of tessellations * for each face. this cache will smartly update as needed (though at first * it'll simply be more brute force). keeping track of face/edge counts may - * be a small problbm. + * be a small problem. * * this won't be the most efficient thing, considering that internal edges and * faces of tessellations are exposed. looking up an edge by index in particular diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 52f3c90754a..6a411f8c308 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2241,7 +2241,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) #else /* image buffers for non-sequence multilayer will share buffers with RenderResult, * however sequence multilayer will own buffers. Such logic makes switching from - * single multilayer file to sequence completely instable + * single multilayer file to sequence completely unstable * since changes in nodes seems this workaround isn't needed anymore, all sockets * are nicely detecting anyway, but freeing buffers always here makes multilayer * sequences behave stable diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index ac32f96d59c..41217110cd8 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2850,10 +2850,10 @@ static void sphclassical_force_cb(void *sphdata_v, ParticleKey *state, float *fo continue; } - /* Find vector to neighbour. Exclude particles that are more than 2h + /* Find vector to neighbor. Exclude particles that are more than 2h * away. Can't use current state here because it may have changed on * another thread - so do own mini integration. Unlike basic_integrate, - * SPH integration depends on neighbouring particles. - z0r */ + * SPH integration depends on neighboring particles. - z0r */ madd_v3_v3v3fl(co, npa->prev_state.co, npa->prev_state.vel, state->time); sub_v3_v3v3(vec, co, state->co); rij = normalize_v3(vec); diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 42147be33e4..600805e71ce 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1211,7 +1211,7 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime) } } -/* Used when cancelling transforms - return rigidbody and object to initial states */ +/* Used when canceling transforms - return rigidbody and object to initial states */ void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle) { RigidBodyOb *rbo = ob->rigidbody_object; diff --git a/source/blender/blenlib/BLI_voronoi.h b/source/blender/blenlib/BLI_voronoi.h index 68d7398d89b..9d32061bf97 100644 --- a/source/blender/blenlib/BLI_voronoi.h +++ b/source/blender/blenlib/BLI_voronoi.h @@ -52,7 +52,7 @@ typedef struct VoronoiEdge { float f, g; /* directional coeffitients satisfying equation y = f * x + g (edge lies on this line) */ /* some edges consist of two parts, so we add the pointer to another part to connect them at the end of an algorithm */ - struct VoronoiEdge *neighbour; + struct VoronoiEdge *neighbor; } VoronoiEdge; typedef struct VoronoiTriangulationPoint { diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index 3f6adff1eda..731536ff0df 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -99,7 +99,7 @@ static VoronoiEdge *voronoiEdge_new(float start[2], float left[2], float right[2 copy_v2_v2(edge->left, left); copy_v2_v2(edge->right, right); - edge->neighbour = NULL; + edge->neighbor = NULL; edge->end[0] = 0; edge->end[1] = 0; @@ -395,7 +395,7 @@ static void voronoi_addParabola(VoronoiProcess *process, float site[2]) el = voronoiEdge_new(start, par->site, site); er = voronoiEdge_new(start, site, par->site); - el->neighbour = er; + el->neighbor = er; BLI_addtail(&process->edges, el); par->edge = er; @@ -682,9 +682,9 @@ void BLI_voronoi_compute(const VoronoiSite *sites, int sites_total, int width, i edge = process.edges.first; while (edge) { - if (edge->neighbour) { - copy_v2_v2(edge->start, edge->neighbour->end); - MEM_freeN(edge->neighbour); + if (edge->neighbor) { + copy_v2_v2(edge->start, edge->neighbor->end); + MEM_freeN(edge->neighbor); } edge = edge->next; diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 5d47ce155c8..74db2082a00 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -701,7 +701,7 @@ void ArmatureImporter::make_shape_keys() //insert other shape keys for (int i = 0 ; i < morphTargetIds.getCount() ; i++ ) { - //better to have a seperate map of morph objects, + //better to have a separate map of morph objects, //This'll do for now since only mesh morphing is imported Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]); diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.cpp b/source/blender/compositor/nodes/COM_DespeckleNode.cpp index a97714c870e..9894dc7b9ac 100644 --- a/source/blender/compositor/nodes/COM_DespeckleNode.cpp +++ b/source/blender/compositor/nodes/COM_DespeckleNode.cpp @@ -39,7 +39,7 @@ void DespeckleNode::convertToOperations(ExecutionSystem *graph, CompositorContex operation->setbNode(editorNode); operation->setThreshold(editorNode->custom3); - operation->setThresholdNeighbour(editorNode->custom4); + operation->setThresholdNeighbor(editorNode->custom4); inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph); inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph); diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp index 599f54720f2..186c17845f3 100644 --- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp +++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp @@ -114,7 +114,7 @@ void DespeckleOperation::executePixel(float output[4], int x, int y, void *data) //mul_v4_fl(color_mid, 1.0f / w); if ((w != 0.0f) && - ((w / WTOT) > (this->m_threshold_neighbour)) && + ((w / WTOT) > (this->m_threshold_neighbor)) && color_diff(color_mid, color_org, this->m_threshold)) { mul_v4_fl(color_mid_ok, 1.0f / w); diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.h b/source/blender/compositor/operations/COM_DespeckleOperation.h index 99635e61544..00c5463c17a 100644 --- a/source/blender/compositor/operations/COM_DespeckleOperation.h +++ b/source/blender/compositor/operations/COM_DespeckleOperation.h @@ -25,7 +25,7 @@ class DespeckleOperation : public NodeOperation { private: float m_threshold; - float m_threshold_neighbour; + float m_threshold_neighbor; // int m_filterWidth; // int m_filterHeight; @@ -40,7 +40,7 @@ public: void executePixel(float output[4], int x, int y, void *data); void setThreshold(float threshold) { this->m_threshold = threshold; } - void setThresholdNeighbour(float threshold) { this->m_threshold_neighbour = threshold; } + void setThresholdNeighbor(float threshold) { this->m_threshold_neighbor = threshold; } void initExecution(); void deinitExecution(); diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 826e204d981..bbfa981c0c7 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -76,7 +76,7 @@ void free_anim_drivers_copybuf(void); * * - add: 0 - don't add anything if not found, * 1 - add new Driver FCurve (with keyframes for visual tweaking), - * 2 - add new Driver FCurve (with generator, for script backwards compatability) + * 2 - add new Driver FCurve (with generator, for script backwards compatibility) * -1 - add new Driver FCurve without driver stuff (for pasting) */ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_index, short add) @@ -125,7 +125,7 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde /* F-Modifier or Keyframes? */ // FIXME: replace these magic numbers with defines if (add == 2) { - /* Python API Backwards compatability hack: + /* Python API Backwards compatibility hack: * Create FModifier so that old scripts won't break * for now before 2.7 series -- (September 4, 2013) */ diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 0443afa0954..4c90a37e720 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -843,7 +843,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) armature_tag_select_mirrored(arm); /* clear BONE_TRANSFORM flags - * - used to prevent duplicate/cancelling operations from occurring [#34123] + * - used to prevent duplicate/canceling operations from occurring [#34123] * - BONE_DONE cannot be used here as that's already used for mirroring */ armature_clear_swap_done_flags(arm); diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 76cd12f12f8..f2f51dc1bd5 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -454,7 +454,7 @@ void ED_armature_from_edit(Object *obedit) /* armature bones */ BKE_armature_bonelist_free(&arm->bonebase); - /* remove zero sized bones, this gives instable restposes */ + /* remove zero sized bones, this gives unstable restposes */ for (eBone = arm->edbo->first; eBone; eBone = neBone) { float len = len_v3v3(eBone->head, eBone->tail); neBone = eBone->next; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 44917375d43..2cf8d9c27af 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1874,7 +1874,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) //printf("\tGP - handle modal event...\n"); /* exit painting mode (and/or end current stroke) - * NOTE: cannot do RIGHTMOUSE (as is standard for cancelling) as that would break polyline [#32647] + * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647] */ if (ELEM4(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY)) { /* exit() ends the current stroke before cleaning up */ diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index a79b0607421..3425aa08955 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -528,7 +528,7 @@ typedef enum eLattice_FlipAxes { LATTICE_FLIP_W = 2 } eLattice_FlipAxes; -/* Flip midpoint value so that relative distances between midpoint and neighbour-pair is maintained +/* Flip midpoint value so that relative distances between midpoint and neighbor-pair is maintained * ! Assumes that uvw <=> xyz (i.e. axis-aligned index-axes with coordinate-axes) * - Helper for lattice_flip_exec() */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index ba28f502349..1af800ebf24 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1444,7 +1444,7 @@ static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C), col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "threshold_neighbour", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "threshold_neighbor", 0, NULL, ICON_NONE); } static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 8b2e7067eb9..63aa92517a7 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -821,7 +821,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe) /* like duplicate, but only duplicate and cut overlapping strips, * strips to the left of the cutframe are ignored and strips to the right * are moved to the end of slist - * we have to work on the same slist (not using a seperate list), since + * we have to work on the same slist (not using a separate list), since * otherwise dupli_seq can't check for duplicate names properly and * may generate strips with the same name (which will mess up animdata) */ diff --git a/source/blender/freestyle/intern/geometry/Grid.h b/source/blender/freestyle/intern/geometry/Grid.h index a1368f1ea21..070bee047a9 100644 --- a/source/blender/freestyle/intern/geometry/Grid.h +++ b/source/blender/freestyle/intern/geometry/Grid.h @@ -261,7 +261,7 @@ public: /*! inserts a convex polygon occluder * This method is quite coarse insofar as it adds all cells intersecting the polygon bounding box * convex_poly - * The list of 3D points constituing a convex polygon + * The list of 3D points constituting a convex polygon */ void insertOccluder(Polygon3r *convex_poly); diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp index 50d54df2ead..9bbb0405e49 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp @@ -167,7 +167,7 @@ static PyObject *FrsCurve_is_empty_get(BPy_FrsCurve *self, void *UNUSED(closure) } PyDoc_STRVAR(FrsCurve_segments_size_doc, -"The number of segments in the polyline constituing the Curve.\n" +"The number of segments in the polyline constituting the Curve.\n" "\n" ":type: int"); diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp index 3e4e7e3aef3..80765e794fb 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp @@ -283,7 +283,7 @@ static PyObject *Stroke_stroke_vertices_end(BPy_Stroke *self) PyDoc_STRVAR(Stroke_stroke_vertices_size_doc, ".. method:: stroke_vertices_size()\n" "\n" -" Returns the number of StrokeVertex constituing the Stroke.\n" +" Returns the number of StrokeVertex constituting the Stroke.\n" "\n" " :return: The number of stroke vertices.\n" " :rtype: int"); diff --git a/source/blender/freestyle/intern/stroke/Curve.h b/source/blender/freestyle/intern/stroke/Curve.h index 68da744d7b3..7e3b6732bff 100644 --- a/source/blender/freestyle/intern/stroke/Curve.h +++ b/source/blender/freestyle/intern/stroke/Curve.h @@ -491,7 +491,7 @@ public: return _Id; } - /*! Returns the number of segments in the polyline constituing the Curve. */ + /*! Returns the number of segments in the polyline constituting the Curve. */ inline unsigned int nSegments() const { return _nSegments; diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h index e7a75728985..d116edc6ace 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.h +++ b/source/blender/freestyle/intern/stroke/Stroke.h @@ -774,7 +774,7 @@ public: const_vertex_iterator vertices_end() const; vertex_iterator vertices_end(); - /*! Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can specifly a sampling + /*! Returns a StrokeVertexIterator pointing on the first StrokeVertex of the Stroke. One can specify a sampling * value to resample the Stroke on the fly if needed. * \param t * The resampling value with which we want our Stroke to be resampled. @@ -785,7 +785,7 @@ public: /*! Returns a StrokeVertexIterator pointing after the last StrokeVertex of the Stroke. */ StrokeInternal::StrokeVertexIterator strokeVerticesEnd(); - /*! Returns the number of StrokeVertex constituing the Stroke. */ + /*! Returns the number of StrokeVertex constituting the Stroke. */ inline unsigned int strokeVerticesSize() const { return _Vertices.size(); diff --git a/source/blender/freestyle/intern/system/Id.h b/source/blender/freestyle/intern/system/Id.h index 9cd45646f1c..8b028cdb3da 100644 --- a/source/blender/freestyle/intern/system/Id.h +++ b/source/blender/freestyle/intern/system/Id.h @@ -92,13 +92,13 @@ public: return _second; } - /*! Sets the first number constituing the Id */ + /*! Sets the first number constituting the Id */ void setFirst(id_type first) { _first = first; } - /*! Sets the second number constituing the Id */ + /*! Sets the second number constituting the Id */ void setSecond(id_type second) { _second = second; diff --git a/source/blender/freestyle/intern/system/TimeUtils.h b/source/blender/freestyle/intern/system/TimeUtils.h index bbf4c5a1edb..6fe8b0e7431 100644 --- a/source/blender/freestyle/intern/system/TimeUtils.h +++ b/source/blender/freestyle/intern/system/TimeUtils.h @@ -23,7 +23,7 @@ /** \file blender/freestyle/intern/system/TimeUtils.h * \ingroup freestyle - * \brief Class to measure ellapsed time + * \brief Class to measure elapsed time * \author Stephane Grabli * \date 10/04/2002 */ diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.h b/source/blender/freestyle/intern/view_map/SteerableViewMap.h index 581155fa6e8..d6af7384fb8 100644 --- a/source/blender/freestyle/intern/view_map/SteerableViewMap.h +++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.h @@ -95,7 +95,7 @@ public: /*! Builds _nbOrientations+1 pyramids of images from the _nbOrientations+1 base images of the steerable viewmap. * \param steerableBases - * The _nbOrientations+1 images constituing the basis for the steerable pyramid. + * The _nbOrientations+1 images constituting the basis for the steerable pyramid. * \param copy * If false, the data is not duplicated, and Canvas deals with the memory management of these * _nbOrientations+1 images. If true, data is copied, and it's up to the caller to delete the images. diff --git a/source/blender/freestyle/intern/view_map/ViewMap.h b/source/blender/freestyle/intern/view_map/ViewMap.h index 0ab089b7d7a..2c9672be53b 100644 --- a/source/blender/freestyle/intern/view_map/ViewMap.h +++ b/source/blender/freestyle/intern/view_map/ViewMap.h @@ -1352,12 +1352,12 @@ public: vertex_iterator vertices_end(); // Iterator access (Interface1D) - /*! Returns an Interface0DIterator to iterate over the SVertex constituing the embedding of this ViewEdge. + /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this ViewEdge. * The returned Interface0DIterator points to the first SVertex of the ViewEdge. */ virtual Interface0DIterator verticesBegin(); - /*! Returns an Interface0DIterator to iterate over the SVertex constituing the embedding of this ViewEdge. + /*! Returns an Interface0DIterator to iterate over the SVertex constituting the embedding of this ViewEdge. * The returned Interface0DIterator points after the last SVertex of the ViewEdge. */ virtual Interface0DIterator verticesEnd(); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 7fc53395e61..1f154460ef0 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4346,7 +4346,7 @@ static void def_cmp_despeckle(StructRNA *srna) RNA_def_property_ui_text(prop, "Threshold", "Threshold for detecting pixels to despeckle"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "threshold_neighbour", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "threshold_neighbor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "custom4"); RNA_def_property_range(prop, 0.0, 1.0f); RNA_def_property_ui_text(prop, "Neighbor", "Threshold for the number of neighbor pixels that must match"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 476f92b77da..7e726c9b16b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -159,7 +159,7 @@ EnumPropertyItem snap_uv_element_items[] = { }; /* workaround for duplicate enums, - * have each enum line as a defne then conditionally set it or not + * have each enum line as a define then conditionally set it or not */ #define R_IMF_ENUM_BMP {R_IMF_IMTYPE_BMP, "BMP", ICON_FILE_IMAGE, "BMP", "Output image in bitmap format"}, diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 959e4a788dd..f8725d61167 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -50,7 +50,7 @@ static PyStructSequence_Field app_cb_info_fields[] = { {(char *)"render_post", (char *)"Callback list - on render (after)"}, {(char *)"render_stats", (char *)"Callback list - on printing render statistics"}, {(char *)"render_complete", (char *)"Callback list - on completion of render job"}, - {(char *)"render_cancel", (char *)"Callback list - on cancelling a render job"}, + {(char *)"render_cancel", (char *)"Callback list - on canceling a render job"}, {(char *)"load_pre", (char *)"Callback list - on loading a new blend file (before)"}, {(char *)"load_post", (char *)"Callback list - on loading a new blend file (after)"}, {(char *)"save_pre", (char *)"Callback list - on saving a blend file (before)"}, diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 9930a8f7f61..8128dd25fdc 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1684,7 +1684,7 @@ static void add_freestyle(Render *re, int render) * real bmain uses. This is needed because freestyle's * bmain could be used to tag scenes for update, which * implies call of ED_render_scene_update in some cases - * and that function requires proper windoew manager + * and that function requires proper window manager * to present (sergey) */ re->freestyle_bmain.wm = re->main->wm; -- cgit v1.2.3 From c9fdec14f5114c2ea34fc8e0c301ba83be0630ac Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 31 Oct 2013 17:20:31 +0000 Subject: Fix #37261 Rendering a Render Layer from another scene doesn't update. The scene pointer used for looking up the appropriate source of render result images in the image editor was always taken from context. This means that render results for a different scene would never be displayed in the image editor. To give feedback on running renders, try to get the running render job's scene pointer in the image editor for render result type images. This only happens during rendering, apart from that the regular context scene result is displayed. --- source/blender/editors/include/ED_render.h | 1 + source/blender/editors/render/render_internal.c | 10 +++++++ source/blender/editors/space_image/space_image.c | 12 ++++++++- source/blender/windowmanager/WM_api.h | 1 + source/blender/windowmanager/intern/wm_jobs.c | 34 +++++++++++++++++------- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index 518bee665ae..8f39502b2fe 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -55,6 +55,7 @@ void ED_render_scene_update(struct Main *bmain, struct Scene *scene, int updated void ED_render_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa); void ED_viewport_render_kill_jobs(const struct bContext *C, bool free_database); +struct Scene *ED_render_job_get_scene(const struct bContext *C); /* render_preview.c */ diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index a47235024dd..71bf67220fe 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -1237,3 +1237,13 @@ void ED_viewport_render_kill_jobs(const bContext *C, bool free_database) } } +Scene *ED_render_job_get_scene(const bContext *C) +{ + wmWindowManager *wm = CTX_wm_manager(C); + RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(wm, WM_JOB_TYPE_RENDER); + + if (rj) + return rj->scene; + + return NULL; +} diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 7b20af340ae..2ba9123b30b 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -56,6 +56,7 @@ #include "ED_mask.h" #include "ED_mesh.h" #include "ED_node.h" +#include "ED_render.h" #include "ED_space_api.h" #include "ED_screen.h" #include "ED_uvedit.h" @@ -653,7 +654,16 @@ static void image_main_area_draw(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); /* put scene context variable in iuser */ - sima->iuser.scene = scene; + if (sima->image && sima->image->type == IMA_TYPE_R_RESULT) { + /* for render result, try to use the currently rendering scene */ + Scene *render_scene = ED_render_job_get_scene(C); + if (render_scene) + sima->iuser.scene = render_scene; + else + sima->iuser.scene = scene; + } + else + sima->iuser.scene = scene; /* we set view2d from own zoom and offset each time */ image_main_area_set_view2d(sima, ar); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 9bc12d04b02..75a6e4465bf 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -378,6 +378,7 @@ int WM_jobs_test(struct wmWindowManager *wm, void *owner, int job_type); float WM_jobs_progress(struct wmWindowManager *wm, void *owner); char *WM_jobs_name(struct wmWindowManager *wm, void *owner); void *WM_jobs_customdata(struct wmWindowManager *wm, void *owner); +void *WM_jobs_customdata_from_type(struct wmWindowManager *wm, int job_type); int WM_jobs_is_running(struct wmJob *); void *WM_jobs_customdata_get(struct wmJob *); diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index c9c3d2df788..6908588ebd7 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -166,22 +166,27 @@ static void wm_job_main_thread_yield(wmJob *wm_job, bool ending) } /* finds: - * if type, compare for it, otherwise any matching job + * if type or owner, compare for it, otherwise any matching job */ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type) { wmJob *wm_job; - for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) - if (wm_job->owner == owner) { - - if (job_type) { - if ( wm_job->job_type == job_type) - return wm_job; - } - else + if (owner && job_type) { + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) + if (wm_job->owner == owner && wm_job->job_type == job_type) return wm_job; - } + } + else if (owner) { + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) + if (wm_job->owner == owner) + return wm_job; + } + else if (job_type) { + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) + if (wm_job->job_type == job_type) + return wm_job; + } return NULL; } @@ -263,7 +268,16 @@ void *WM_jobs_customdata(wmWindowManager *wm, void *owner) return WM_jobs_customdata_get(wm_job); return NULL; +} +void *WM_jobs_customdata_from_type(wmWindowManager *wm, int job_type) +{ + wmJob *wm_job = wm_job_find(wm, NULL, job_type); + + if (wm_job) + return WM_jobs_customdata_get(wm_job); + + return NULL; } int WM_jobs_is_running(wmJob *wm_job) -- cgit v1.2.3 From fc0e225a77ab75df778315c08c743197d9e773b3 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Thu, 31 Oct 2013 21:00:55 +0000 Subject: FIX: [#37199] .ogg file is not recognized as a movie in File Browser CHANGE: writing an animation in the ogg movie format now defaults to .ogv (ogg/video) which is recommended by Xiph.org for video CHANGE: for .ogg files a check is added whether Blender can read it as a movie (is avi or ffmpeg movie), otherwise assume audio CHANGE: the anim player now filters for the same extensions as the file browser --- source/blender/blenkernel/intern/writeffmpeg.c | 2 +- source/blender/editors/space_file/filelist.c | 59 ++++++++++++++++---------- source/blender/imbuf/intern/util.c | 28 ++++++------ 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index ebd6bc01bea..5507baecd76 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -295,7 +295,7 @@ static const char **get_file_extensions(int format) } case FFMPEG_OGG: { - static const char *rv[] = { ".ogg", ".ogv", NULL }; + static const char *rv[] = { ".ogv", ".ogg", NULL }; return rv; } case FFMPEG_MP3: diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 19a6296993d..acba9934dd2 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -764,56 +764,69 @@ static int file_is_blend_backup(const char *str) return (retval); } - -static int file_extension_type(const char *relname) +static int path_extension_type(const char *path) { - if (BLO_has_bfile_extension(relname)) { + if (BLO_has_bfile_extension(path)) { return BLENDERFILE; } - else if (file_is_blend_backup(relname)) { + else if (file_is_blend_backup(path)) { return BLENDERFILE_BACKUP; } - else if (BLI_testextensie(relname, ".py")) { + else if (BLI_testextensie(path, ".py")) { return PYSCRIPTFILE; } - else if (BLI_testextensie(relname, ".txt") || - BLI_testextensie(relname, ".glsl") || - BLI_testextensie(relname, ".osl") || - BLI_testextensie(relname, ".data")) + else if (BLI_testextensie(path, ".txt") || + BLI_testextensie(path, ".glsl") || + BLI_testextensie(path, ".osl") || + BLI_testextensie(path, ".data")) { return TEXTFILE; } - else if (BLI_testextensie(relname, ".ttf") || - BLI_testextensie(relname, ".ttc") || - BLI_testextensie(relname, ".pfb") || - BLI_testextensie(relname, ".otf") || - BLI_testextensie(relname, ".otc")) + else if (BLI_testextensie(path, ".ttf") || + BLI_testextensie(path, ".ttc") || + BLI_testextensie(path, ".pfb") || + BLI_testextensie(path, ".otf") || + BLI_testextensie(path, ".otc")) { return FTFONTFILE; } - else if (BLI_testextensie(relname, ".btx")) { + else if (BLI_testextensie(path, ".btx")) { return BTXFILE; } - else if (BLI_testextensie(relname, ".dae")) { + else if (BLI_testextensie(path, ".dae")) { return COLLADAFILE; } - else if (BLI_testextensie_array(relname, imb_ext_image) || - (G.have_quicktime && BLI_testextensie_array(relname, imb_ext_image_qt))) + else if (BLI_testextensie_array(path, imb_ext_image) || + (G.have_quicktime && BLI_testextensie_array(path, imb_ext_image_qt))) { return IMAGEFILE; } - else if (BLI_testextensie_array(relname, imb_ext_movie)) { + else if (BLI_testextensie(path, ".ogg")) { + if (IMB_isanim(path)) { + return MOVIEFILE; + } else { + return SOUNDFILE; + } + } + else if (BLI_testextensie_array(path, imb_ext_movie)) { return MOVIEFILE; } - else if (BLI_testextensie_array(relname, imb_ext_audio)) { + else if (BLI_testextensie_array(path, imb_ext_audio)) { return SOUNDFILE; } return 0; } -int ED_file_extension_icon(const char *relname) +static int file_extension_type(const char *dir, const char *relname) +{ + char path[FILE_MAX]; + BLI_join_dirfile(path, sizeof(path), dir, relname); + return path_extension_type(path); +} + +int ED_file_extension_icon(const char *path) { - int type = file_extension_type(relname); + int type = path_extension_type(path); if (type == BLENDERFILE) return ICON_FILE_BLEND; @@ -853,7 +866,7 @@ static void filelist_setfiletypes(struct FileList *filelist) if (file->type & S_IFDIR) { continue; } - file->flags = file_extension_type(file->relname); + file->flags = file_extension_type(filelist->dir, file->relname); if (filelist->filter_glob[0] && BLI_testextensie_glob(file->relname, filelist->filter_glob)) diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 89778cdfb50..2ab22085088 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -120,6 +120,17 @@ const char *imb_ext_image_qt[] = { NULL }; +const char *imb_ext_movie_qt[] = { + ".avi", + ".flc", + ".dv", + ".r3d", + ".mov", + ".movie", + ".mv", + NULL +}; + const char *imb_ext_movie[] = { ".avi", ".flc", @@ -135,6 +146,8 @@ const char *imb_ext_movie[] = { ".avs", ".wmv", ".ogv", + ".ogg", + ".r3d", ".dv", ".mpeg", ".mpg", @@ -449,14 +462,7 @@ int IMB_isanim(const char *filename) if (U.uiflag & USER_FILTERFILEEXTS) { if (G.have_quicktime) { - if (BLI_testextensie(filename, ".avi") || - BLI_testextensie(filename, ".flc") || - BLI_testextensie(filename, ".dv") || - BLI_testextensie(filename, ".r3d") || - BLI_testextensie(filename, ".mov") || - BLI_testextensie(filename, ".movie") || - BLI_testextensie(filename, ".mv")) - { + if (BLI_testextensie_array(filename, imb_ext_movie_qt)) { type = imb_get_anim_type(filename); } else { @@ -464,11 +470,7 @@ int IMB_isanim(const char *filename) } } else { /* no quicktime */ - if (BLI_testextensie(filename, ".avi") || - BLI_testextensie(filename, ".dv") || - BLI_testextensie(filename, ".r3d") || - BLI_testextensie(filename, ".mv")) - { + if (BLI_testextensie_array(filename, imb_ext_movie)) { type = imb_get_anim_type(filename); } else { -- cgit v1.2.3 From f9d5bccb06505d0e36a8b7076189ab961a616a96 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Oct 2013 23:52:44 +0000 Subject: code cleanup: spelling --- intern/cycles/render/sky_model.h | 2 +- source/blender/blenkernel/BKE_rigidbody.h | 2 +- source/blender/blenlib/intern/BLI_ghash.c | 2 +- source/blender/blenlib/intern/edgehash.c | 2 +- source/blender/blenlib/intern/threads.c | 2 +- source/blender/editors/animation/anim_markers.c | 1 - source/blender/editors/space_file/filelist.c | 3 ++- source/creator/creator.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/intern/cycles/render/sky_model.h b/intern/cycles/render/sky_model.h index 4f0833aef5a..3814543c8b6 100644 --- a/intern/cycles/render/sky_model.h +++ b/intern/cycles/render/sky_model.h @@ -136,7 +136,7 @@ and solar radii: 'arhosekskymodelstate_alienworld_alloc_init()'. See the notes about the "Alien World" functionality provided further down for a discussion of the usefulness and limits of that second initalisation function. -Sky model states that have been initialised with either function behave in a +Sky model states that have been initialized with either function behave in a completely identical fashion during use and cleanup. Using the model to generate skydome samples diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h index ef5b8349d60..34ed4f2c8b1 100644 --- a/source/blender/blenkernel/BKE_rigidbody.h +++ b/source/blender/blenkernel/BKE_rigidbody.h @@ -57,7 +57,7 @@ void BKE_rigidbody_relink_constraint(struct RigidBodyCon *rbc); /* -------------- */ /* Setup */ -/* create Blender-side settings data - physics objects not initialised yet */ +/* create Blender-side settings data - physics objects not initialized yet */ struct RigidBodyWorld *BKE_rigidbody_create_world(struct Scene *scene); struct RigidBodyOb *BKE_rigidbody_create_object(struct Scene *scene, struct Object *ob, short type); struct RigidBodyCon *BKE_rigidbody_create_constraint(struct Scene *scene, struct Object *ob, short type); diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index fcca6cd59ba..f3ebddddc8c 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -136,7 +136,7 @@ BLI_INLINE void ghash_resize_buckets(GHash *gh, const unsigned int nbuckets) } /** - * Increase initial bucket size to match a reserved ammount. + * Increase initial bucket size to match a reserved amount. */ BLI_INLINE void ghash_buckets_reserve(GHash *gh, const unsigned int nentries_reserve) { diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c index b26e007b3e6..50dcd01207d 100644 --- a/source/blender/blenlib/intern/edgehash.c +++ b/source/blender/blenlib/intern/edgehash.c @@ -137,7 +137,7 @@ BLI_INLINE void edgehash_resize_buckets(EdgeHash *eh, const unsigned int nbucket } /** - * Increase initial bucket size to match a reserved ammount. + * Increase initial bucket size to match a reserved amount. */ BLI_INLINE void edgehash_buckets_reserve(EdgeHash *eh, const unsigned int nentries_reserve) { diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 4361583dafc..0b8f5dfdde5 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -166,7 +166,7 @@ TaskScheduler *BLI_task_scheduler_get(void) if (task_scheduler == NULL) { int tot_thread = BLI_system_thread_count(); - /* Do a lazy initialization, so it happes after + /* Do a lazy initialization, so it happens after * command line arguments parsing */ task_scheduler = BLI_task_scheduler_create(tot_thread); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index b057ea239f0..cab072675b2 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -732,7 +732,6 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even case ESCKEY: ed_marker_move_cancel(C, op); return OPERATOR_CANCELLED; - case RIGHTMOUSE: /* press = user manually demands transform to be canceled */ if (event->val == KM_PRESS) { diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index acba9934dd2..822d1ba8bca 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -804,7 +804,8 @@ static int path_extension_type(const char *path) else if (BLI_testextensie(path, ".ogg")) { if (IMB_isanim(path)) { return MOVIEFILE; - } else { + } + else { return SOUNDFILE; } } diff --git a/source/creator/creator.c b/source/creator/creator.c index 1596fe5359c..54fc80984f3 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1470,7 +1470,7 @@ int main(int argc, const char **argv) #endif #ifdef WIN32 /* Win32 Unicode Args */ - /* NOTE: cannot use guardedalloc malloc here, as it's not yet initialised + /* NOTE: cannot use guardedalloc malloc here, as it's not yet initialized * (it depends on the args passed in, which is what we're getting here!) */ wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc); -- cgit v1.2.3 From 7371aaab08388ab195dab59ba4334d6c55832f40 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Nov 2013 01:14:36 +0000 Subject: fix for weight-paint crash picking the weight with the mask modifier (or any modifier which removes geometry). was incorrectly mixing indices from the DerivedMesh and the original mesh. --- source/blender/editors/mesh/meshtools.c | 101 +++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 28 deletions(-) diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 11f25da529c..1d47d4c49df 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1231,6 +1231,29 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int return true; } +static void ed_mesh_pick_face_vert__mpoly_find( + /* context */ + struct ARegion *ar, const float mval[2], + /* mesh data */ + DerivedMesh *dm, MPoly *mp, MLoop *mloop, + /* return values */ + float *r_len_best, int *r_v_idx_best) +{ + const MLoop *ml; + int j = mp->totloop; + for (ml = &mloop[mp->loopstart]; j--; ml++) { + float co[3], sco[2], len; + const int v_idx = ml->v; + dm->getVertCo(dm, v_idx, co); + if (ED_view3d_project_float_object(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + len = len_manhattan_v2v2(mval, sco); + if (len < *r_len_best) { + *r_len_best = len; + *r_v_idx_best = v_idx; + } + } + } +} /** * Use when the back buffer stores face index values. but we want a vert. * This gets the face then finds the closest vertex to mval. @@ -1247,39 +1270,61 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned struct ARegion *ar = CTX_wm_region(C); /* derived mesh to find deformed locations */ - DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - int v_idx_best = -1; - - if (dm->getVertCo) { - RegionView3D *rv3d = ar->regiondata; - - /* find the vert closest to 'mval' */ - const float mval_f[2] = {(float)mval[0], - (float)mval[1]}; - MPoly *mp = &me->mpoly[poly_index]; - int fidx; - float len_best = FLT_MAX; - - ED_view3d_init_mats_rv3d(ob, rv3d); - - fidx = mp->totloop - 1; - do { - float co[3], sco[2], len; - const int v_idx = me->mloop[mp->loopstart + fidx].v; - dm->getVertCo(dm, v_idx, co); - if (ED_view3d_project_float_object(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { - len = len_manhattan_v2v2(mval_f, sco); - if (len < len_best) { - len_best = len; - v_idx_best = v_idx; - } + DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); + + int v_idx_best = ORIGINDEX_NONE; + + /* find the vert closest to 'mval' */ + const float mval_f[2] = {UNPACK2(mval)}; + float len_best = FLT_MAX; + + MPoly *dm_mpoly; + MLoop *dm_mloop; + unsigned int dm_mpoly_tot; + const int *index_mp_to_orig; + + dm_mpoly = dm->getPolyArray(dm); + dm_mloop = dm->getLoopArray(dm); + + dm_mpoly_tot = dm->getNumPolys(dm); + + index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); + + /* tag all verts using this face */ + if (index_mp_to_orig) { + unsigned int i; + + for (i = 0; i < dm_mpoly_tot; i++) { + if (index_mp_to_orig[i] == poly_index) { + ed_mesh_pick_face_vert__mpoly_find( + ar, mval_f, + dm, &dm_mpoly[i], dm_mloop, + &len_best, &v_idx_best); } - } while (fidx--); + } + } + else { + if (poly_index < dm_mpoly_tot) { + ed_mesh_pick_face_vert__mpoly_find( + ar, mval_f, + dm, &dm_mpoly[poly_index], dm_mloop, + &len_best, &v_idx_best); + } + } + + /* map 'dm -> me' index if possible */ + if (v_idx_best != ORIGINDEX_NONE) { + const int *index_mv_to_orig; + + index_mv_to_orig = dm->getVertDataArray(dm, CD_ORIGINDEX); + if (index_mv_to_orig) { + v_idx_best = index_mv_to_orig[v_idx_best]; + } } dm->release(dm); - if (v_idx_best != -1) { + if ((v_idx_best != ORIGINDEX_NONE) && (v_idx_best < me->totvert)) { *index = v_idx_best; return true; } -- cgit v1.2.3 From 21fe81bc135670446b33e8255d40706c9ab1b970 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 1 Nov 2013 04:06:01 +0000 Subject: Expose is_keyframed flag for tracking marker So now it's possible to know from python whether marker is a keyframe or tracked one. --- source/blender/makesrna/intern/rna_tracking.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index f62778a5c1e..83d9bca4780 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1089,6 +1089,12 @@ static void rna_def_trackingMarker(BlenderRNA *brna) "Right-bottom corner of search area in normalized coordinates relative " "to marker position"); RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_markerSearch_update"); + + /* is marker keyframed */ + prop = RNA_def_property(srna, "is_keyframed", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MARKER_TRACKED); + RNA_def_property_ui_text(prop, "Keyframed", "Indicates whether position of marker is keyframed, not tracked"); } static void rna_def_trackingMarkers(BlenderRNA *brna, PropertyRNA *cprop) -- cgit v1.2.3 From 57f72623e3078af32b6a06b9cd63c254618f7307 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 1 Nov 2013 04:24:29 +0000 Subject: Fix #37270: Blender crashes in several situations Issue was caused by cloth modifier used for particle system dynamic have an invalid error field pointer. Seems at some point cloth failed to apply and set an error, This commit only fixes crash with existing file, will look further into why exactly such situation happened, --- source/blender/blenloader/intern/readfile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 10c71c79b55..c3727c0f688 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3815,6 +3815,7 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase psys->clmd->point_cache = psys->pointcache; psys->clmd->ptcaches.first = psys->clmd->ptcaches.last= NULL; psys->clmd->coll_parms->group = newlibadr(fd, id->lib, psys->clmd->coll_parms->group); + psys->clmd->modifier.error = NULL; } } else { -- cgit v1.2.3 From 1512cda61d0c2a2b946e8c5a73cf9bab45bd1bc7 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 1 Nov 2013 08:03:25 +0000 Subject: Fix [#37224] Icons: tiny interface issue with certain DPI settings. For some reason (consistant margin?), the whole icon stuff is shifted by two vertically in the svg file - but the bottom row of numbers was not, comming in touch with the icon area, and at some DPI values it showed in icons... --- release/datafiles/blender_icons.svg | 445 +++++++++++++++++----------------- release/datafiles/blender_icons16.png | Bin 240983 -> 240844 bytes release/datafiles/blender_icons32.png | Bin 605580 -> 605416 bytes 3 files changed, 224 insertions(+), 221 deletions(-) diff --git a/release/datafiles/blender_icons.svg b/release/datafiles/blender_icons.svg index fef2b047474..27b93f6b10f 100644 --- a/release/datafiles/blender_icons.svg +++ b/release/datafiles/blender_icons.svg @@ -27061,11 +27061,11 @@ objecttolerance="10000" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="8" - inkscape:cx="336.81018" - inkscape:cy="34.425847" + inkscape:zoom="11.313708" + inkscape:cx="256.37124" + inkscape:cy="2.0121538" inkscape:document-units="px" - inkscape:current-layer="g24559-2" + inkscape:current-layer="layer1" showgrid="false" inkscape:window-width="1366" inkscape:window-height="695" @@ -33313,222 +33313,225 @@ inkscape:connector-curvature="0" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + transform="translate(0,636)"> Date: Fri, 1 Nov 2013 08:31:36 +0000 Subject: Fix [#37266] Skin modifier can't be copied. Patch by Martin Felke, many thanks. When copying that modifier across objects, we also have to ensure that a skin CDLayer is present in dest objects (just as when adding it). --- source/blender/blenkernel/BKE_modifier.h | 1 + source/blender/blenkernel/intern/object.c | 7 ++++++- source/blender/editors/object/object_modifier.c | 3 +-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 6bf42a3e885..65038c7f09c 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -357,6 +357,7 @@ bool modifiers_usesArmature(struct Object *ob, struct bArmature *arm); bool modifiers_isCorrectableDeformed(struct Scene *scene, struct Object *ob); void modifier_freeTemporaryData(struct ModifierData *md); bool modifiers_isPreview(struct Object *ob); +void modifier_skin_customdata_ensure(struct Object *ob); typedef struct CDMaskLink { struct CDMaskLink *next; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index bef0263b2f5..45d9d144f55 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include "MEM_guardedalloc.h" @@ -256,6 +256,11 @@ void BKE_object_link_modifiers(struct Object *ob_dst, struct Object *ob_src) if (!BKE_object_support_modifier_type_check(ob_dst, md->type)) continue; + + if (md->type == eModifierType_Skin) { + /* ensure skin-node customdata exists */ + modifier_skin_customdata_ensure(ob_dst); + } nmd = modifier_new(md->type); BLI_strncpy(nmd->name, md->name, sizeof(nmd->name)); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 0ba84e27420..ec0423d7480 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -87,7 +87,6 @@ #include "object_intern.h" -static void modifier_skin_customdata_ensure(struct Object *ob); static void modifier_skin_customdata_delete(struct Object *ob); /******************************** API ****************************/ @@ -1434,7 +1433,7 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot) /************************** skin modifier ***********************/ -static void modifier_skin_customdata_ensure(Object *ob) +void modifier_skin_customdata_ensure(Object *ob) { Mesh *me = ob->data; BMesh *bm = me->edit_btmesh ? me->edit_btmesh->bm : NULL; -- cgit v1.2.3 From 2c57e4f57773f469697bfd788c37decb239af620 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 1 Nov 2013 09:37:42 +0000 Subject: Cycles: * Change the default Light Path settings. * Diffuse/Glossy bounces are now set to 4, to give a bit faster renders in default scenes. More bounces are often not needed (especially in animation). * Transmission bounces have been increased to 12, to not run into problems with dark glass too quickly. * Max/Min bounces are now 12/3. --- intern/cycles/blender/addon/properties.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 367f021ee34..ac15acee0c5 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -253,26 +253,26 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): name="Max Bounces", description="Total maximum number of bounces", min=0, max=1024, - default=8, + default=12, ) cls.diffuse_bounces = IntProperty( name="Diffuse Bounces", description="Maximum number of diffuse reflection bounces, bounded by total maximum", min=0, max=1024, - default=128, + default=4, ) cls.glossy_bounces = IntProperty( name="Glossy Bounces", description="Maximum number of glossy reflection bounces, bounded by total maximum", min=0, max=1024, - default=128, + default=4, ) cls.transmission_bounces = IntProperty( name="Transmission Bounces", description="Maximum number of transmission bounces, bounded by total maximum", min=0, max=1024, - default=128, + default=12, ) cls.transparent_min_bounces = IntProperty( -- cgit v1.2.3 From e8c54b682a2ab658a0e87b45f442220c1caaadcd Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Fri, 1 Nov 2013 11:42:11 +0000 Subject: Add 'cut-through' option for Knife Project operator. If enabled, it makes knife project act as the cut-through (Shift-K) version of knife. This option will soon be more useful when a better cut-though Knife change is submitted, allowing this to work for cuts within faces in addition to cuts across them. --- source/blender/editors/mesh/editmesh_knife.c | 3 +-- source/blender/editors/mesh/editmesh_knife_project.c | 9 ++++++++- source/blender/editors/mesh/mesh_intern.h | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 306aedaa9ec..adb03ab837b 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -3539,7 +3539,7 @@ static bool edbm_mesh_knife_face_isect(ARegion *ar, LinkNode *polys, BMFace *f, /** * \param use_tag When set, tag all faces inside the polylines. */ -void EDBM_mesh_knife(bContext *C, LinkNode *polys, bool use_tag) +void EDBM_mesh_knife(bContext *C, LinkNode *polys, bool use_tag, bool cut_through) { KnifeTool_OpData *kcd; @@ -3548,7 +3548,6 @@ void EDBM_mesh_knife(bContext *C, LinkNode *polys, bool use_tag) /* init */ { const bool only_select = false; - const bool cut_through = false; const bool is_interactive = false; /* can enable for testing */ kcd = MEM_callocN(sizeof(KnifeTool_OpData), __func__); diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c index f473939d0aa..57a85f1162d 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.c +++ b/source/blender/editors/mesh/editmesh_knife_project.c @@ -42,6 +42,9 @@ #include "BKE_editmesh.h" #include "BKE_report.h" +#include "RNA_define.h" +#include "RNA_access.h" + #include "MEM_guardedalloc.h" #include "WM_types.h" @@ -117,6 +120,7 @@ static int knifeproject_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); + const bool cut_through = RNA_boolean_get(op->ptr, "cut_through"); LinkNode *polys = NULL; @@ -129,7 +133,7 @@ static int knifeproject_exec(bContext *C, wmOperator *op) CTX_DATA_END; if (polys) { - EDBM_mesh_knife(C, polys, true); + EDBM_mesh_knife(C, polys, true, cut_through); /* select only tagged faces */ BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false); @@ -166,4 +170,7 @@ void MESH_OT_knife_project(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; + + /* parameters */ + RNA_def_boolean(ot->srna, "cut_through", false, "Cut through", "Cut through all faces, not just visible ones"); } diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index ed026258e4b..98c145c9ce7 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -116,7 +116,8 @@ void MESH_OT_inset(struct wmOperatorType *ot); /* *** editmesh_knife.c *** */ void MESH_OT_knife_tool(struct wmOperatorType *ot); void MESH_OT_knife_project(struct wmOperatorType *ot); -void EDBM_mesh_knife(struct bContext *C, struct LinkNode *polys, bool use_tag); +void EDBM_mesh_knife(struct bContext *C, struct LinkNode *polys, + bool use_tag, bool cut_through); struct wmKeyMap *knifetool_modal_keymap(struct wmKeyConfig *keyconf); -- cgit v1.2.3 From 1eb90abf2b380207e5e69888c51a312e77ea1826 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 1 Nov 2013 13:14:17 +0000 Subject: * Extrude options where available in object mode (search menu), resulting in error msg. Added polls now, patch by Gottfried Hofmann (gottfried). --- release/scripts/startup/bl_operators/view3d.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py index 27d2a2361a1..bf51dc5672a 100644 --- a/release/scripts/startup/bl_operators/view3d.py +++ b/release/scripts/startup/bl_operators/view3d.py @@ -29,6 +29,11 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator): bl_label = "Extrude Individual and Move" bl_idname = "view3d.edit_mesh_extrude_individual_move" + @classmethod + def poll(cls, context): + obj = context.active_object + return obj.mode == 'EDIT' + def execute(self, context): mesh = context.object.data select_mode = context.tool_settings.mesh_select_mode @@ -62,6 +67,11 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator): bl_label = "Extrude and Move on Normals" bl_idname = "view3d.edit_mesh_extrude_move_normal" + @classmethod + def poll(cls, context): + obj = context.active_object + return obj.mode == 'EDIT' + @staticmethod def extrude_region(context, use_vert_normals): mesh = context.object.data @@ -107,6 +117,11 @@ class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator): bl_label = "Extrude and Move on Individual Normals" bl_idname = "view3d.edit_mesh_extrude_move_shrink_fatten" + @classmethod + def poll(cls, context): + obj = context.active_object + return obj.mode == 'EDIT' + def execute(self, context): return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True) -- cgit v1.2.3 From d2cd8715f41d1f7e6aa4a4a9be65f52d3f2482a0 Mon Sep 17 00:00:00 2001 From: Thomas Beck Date: Fri, 1 Nov 2013 16:39:11 +0000 Subject: Fix blenderplayer build, stub for modifier_skin_customdata_ensure(...) --- source/blenderplayer/bad_level_call_stubs/stubs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 2af65c763b5..2916dddc68f 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -167,6 +167,9 @@ void RE_free_sample_material(struct Material *mat) {STUB_ASSERT(0);} void RE_sample_material_color(struct Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3], int face_index, short hit_quad, struct DerivedMesh *orcoDm, struct Object *ob) {STUB_ASSERT(0);} +/* skin modifier*/ +void modifier_skin_customdata_ensure(struct Object *ob) {STUB_ASSERT(0);} + /* nodes */ struct RenderResult *RE_GetResult(struct Render *re) {STUB_ASSERT(0); return (struct RenderResult *) NULL;} struct Render *RE_GetRender(const char *name) {STUB_ASSERT(0); return (struct Render *) NULL;} -- cgit v1.2.3 From 614b15a70dea7a4d66d90c908d132534198bef6b Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 1 Nov 2013 18:11:54 +0000 Subject: missing bit from last float precision update (patch by 'unknow' via irc) --- source/blender/editors/interface/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 54fb0fc5c20..96638f77b10 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -79,7 +79,7 @@ #include "interface_intern.h" #define PRECISION_FLOAT_MAX 7 -#define PRECISION_FLOAT_MAX_POW 1000000 /* pow(10, PRECISION_FLOAT_MAX) */ +#define PRECISION_FLOAT_MAX_POW 10000000 /* pow(10, PRECISION_FLOAT_MAX) */ /* avoid unneeded calls to ui_get_but_val */ #define UI_BUT_VALUE_UNSET DBL_MAX -- cgit v1.2.3 From 2742cb6000443b67705e4c9bcff2d2250f7d8eb5 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 1 Nov 2013 18:20:21 +0000 Subject: Fix [#37290] Movie files filtering does not show *.ts files. --- source/blender/imbuf/intern/util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 2ab22085088..9d1ff79960c 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -142,6 +142,7 @@ const char *imb_ext_movie[] = { ".m2t", ".m2ts", ".mts", + ".ts", ".mv", ".avs", ".wmv", -- cgit v1.2.3 From df1f21d678dbfcefd9d0be1e6f62b979e0a8d294 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Nov 2013 04:04:30 +0000 Subject: code cleanup: warnings --- source/blender/blenkernel/intern/smoke.c | 8 ++++---- source/blender/editors/sculpt_paint/paint_ops.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index b7251a5e795..23f7dd6ccfb 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -276,21 +276,21 @@ static void smoke_set_domain_from_derivedmesh(SmokeDomainSettings *sds, Object * /* define grid resolutions from longest domain side */ if (size[0] >= MAX2(size[1], size[2])) { scale = res / size[0]; - sds->scale = size[0] / fabs(ob->size[0]); + sds->scale = size[0] / fabsf(ob->size[0]); sds->base_res[0] = res; sds->base_res[1] = (int)(size[1] * scale + 0.5f); sds->base_res[2] = (int)(size[2] * scale + 0.5f); } else if (size[1] >= MAX2(size[0], size[2])) { scale = res / size[1]; - sds->scale = size[1] / fabs(ob->size[1]); + sds->scale = size[1] / fabsf(ob->size[1]); sds->base_res[0] = (int)(size[0] * scale + 0.5f); sds->base_res[1] = res; sds->base_res[2] = (int)(size[2] * scale + 0.5f); } else { scale = res / size[2]; - sds->scale = size[2] / fabs(ob->size[2]); + sds->scale = size[2] / fabsf(ob->size[2]); sds->base_res[0] = (int)(size[0] * scale + 0.5f); sds->base_res[1] = (int)(size[1] * scale + 0.5f); sds->base_res[2] = res; @@ -1338,7 +1338,7 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke float hr = 1.0f / ((float)hires_multiplier); /* slightly adjust high res antialias smoothness based on number of divisions * to allow smaller details but yet not differing too much from the low res size */ - float hr_smooth = smooth * pow(hr, 1.0f/3.0f); + const float hr_smooth = smooth * powf(hr, 1.0f / 3.0f); /* setup loop bounds */ for (i = 0; i < 3; i++) { diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 55ea0363b7a..809e9911e09 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -1149,7 +1149,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_INVERT); - kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_lasso_gesture", LEFTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + WM_keymap_add_item(keymap, "PAINT_OT_mask_lasso_gesture", LEFTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); /* Toggle dynamic topology */ WM_keymap_add_item(keymap, "SCULPT_OT_dynamic_topology_toggle", DKEY, KM_PRESS, KM_CTRL, 0); -- cgit v1.2.3 From 59cdb0d65de1015b4fb111154ad05c2e7e72f915 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Nov 2013 04:22:08 +0000 Subject: fix memory leak with navmesh --- source/gameengine/Ketsji/KX_NavMeshObject.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index e45346db9c7..c8e2370ab7f 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -126,7 +126,7 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts, MEM_SAFE_FREE(dtrisToTrisMap); MEM_SAFE_FREE(trisToFacesMap); - unsigned short *verticesMap = new unsigned short[nAllVerts]; + unsigned short *verticesMap = (unsigned short *)MEM_mallocN(sizeof(*verticesMap) * nAllVerts, __func__); memset(verticesMap, 0xff, sizeof(*verticesMap) * nAllVerts); int curIdx = 0; //vertices - mesh verts @@ -215,6 +215,8 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts, } MEM_SAFE_FREE(allVerts); + + MEM_freeN(verticesMap); } else { -- cgit v1.2.3 From fc618bbcbffaa6f029c80a5d541728a4c4c9c608 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Nov 2013 05:18:31 +0000 Subject: fix for possible leak in the expression controller find identifier. --- source/gameengine/GameLogic/SCA_ExpressionController.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.cpp b/source/gameengine/GameLogic/SCA_ExpressionController.cpp index 41a0fa7d095..d1c7b58a52c 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.cpp +++ b/source/gameengine/GameLogic/SCA_ExpressionController.cpp @@ -141,6 +141,7 @@ CValue* SCA_ExpressionController::FindIdentifier(const STR_String& identifiernam { identifierval = new CBoolValue(sensor->GetState()); //identifierval = sensor->AddRef(); + break; } //if (!sensor->IsPositiveTrigger()) -- cgit v1.2.3 From 4cf57c02fab189239620432ff681d3b6d4f78599 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sat, 2 Nov 2013 10:37:42 +0000 Subject: Fix: error message when removing an 'Excluded path' for python execution, small leftover from copy/paste --- source/blender/makesrna/intern/rna_userdef.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 2a12194dfa1..3b5d669ffdb 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -367,7 +367,7 @@ static void rna_userdef_pathcompare_remove(ReportList *reports, PointerRNA *path { bPathCompare *path_cmp = path_cmp_ptr->data; if (BLI_findindex(&U.autoexec_paths, path_cmp) == -1) { - BKE_report(reports, RPT_ERROR, "Addon is no longer valid"); + BKE_report(reports, RPT_ERROR, "Excluded path is no longer valid"); return; } -- cgit v1.2.3 From 08838e0d18045a904fa0b376fe0b407e77a45db2 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sat, 2 Nov 2013 10:48:34 +0000 Subject: Fix: tooltip when adding a new 'Excluded path' for python execution --- source/blender/makesrna/intern/rna_userdef.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 3b5d669ffdb..5221e8de7ce 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -4091,7 +4091,7 @@ static void rna_def_userdef_autoexec_path_collection(BlenderRNA *brna, PropertyR func = RNA_def_function(srna, "new", "rna_userdef_pathcompare_new"); RNA_def_function_flag(func, FUNC_NO_SELF); - RNA_def_function_ui_description(func, "Add a new addon"); + RNA_def_function_ui_description(func, "Add a new path"); /* return type */ parm = RNA_def_pointer(func, "pathcmp", "PathCompare", "", ""); RNA_def_function_return(func, parm); -- cgit v1.2.3 From 5c0a8ca73f65deedd4fb119a697349a532fae824 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 2 Nov 2013 13:08:48 +0000 Subject: Quick test commit - fixing what looks like a typo in a comment --- source/blender/blenkernel/intern/anim_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index d2189468f53..e52aaefd416 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -2124,7 +2124,7 @@ static void nlastrip_evaluate_meta(PointerRNA *ptr, ListBase *channels, ListBase */ nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, tmp_nes); - /* assumulate temp-buffer and full-buffer, using the 'real' strip */ + /* accumulate temp-buffer and full-buffer, using the 'real' strip */ nlaevalchan_buffers_accumulate(channels, &tmp_channels, nes); /* free temp eval-strip */ -- cgit v1.2.3 From a8a4431fcfbe9504742bf465d137bcd977288222 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 2 Nov 2013 13:11:06 +0000 Subject: Bugfix [#36687] Animation channels can't be grouped in action editor Internal filtering flags used to obtain AnimData blocks as result were not working correctly in Action and ShapeKey modes. Instead, in these modes, they were often returning F-Curves instead, which lead to the grouping operating failing (and perhaps other unidentified bugs) --- source/blender/editors/animation/anim_filter.c | 44 ++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index b7a1614146a..ad745155286 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -2624,24 +2624,50 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo /* firstly filter the data */ switch (datatype) { + /* Action-Editing Modes */ case ANIMCONT_ACTION: /* 'Action Editor' */ { Object *obact = ac->obact; SpaceAction *saction = (SpaceAction *)ac->sl; bDopeSheet *ads = (saction) ? &saction->ads : NULL; - /* the check for the DopeSheet summary is included here since the summary works here too */ - if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) - items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact); + /* specially check for AnimData filter... [#36687] */ + if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) { + /* all channels here are within the same AnimData block, hence this special case */ + if (LIKELY(obact->adt)) { + ANIMCHANNEL_NEW_CHANNEL(obact->adt, ANIMTYPE_ANIMDATA, (ID *)obact); + } + } + else { + /* the check for the DopeSheet summary is included here since the summary works here too */ + if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) + items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact); + } + break; } case ANIMCONT_SHAPEKEY: /* 'ShapeKey Editor' */ { - /* the check for the DopeSheet summary is included here since the summary works here too */ - if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) - items = animdata_filter_shapekey(ac, anim_data, data, filter_mode); + Key *key = (Key *)data; + + /* specially check for AnimData filter... [#36687] */ + if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) { + /* all channels here are within the same AnimData block, hence this special case */ + if (LIKELY(key->adt)) { + ANIMCHANNEL_NEW_CHANNEL(key->adt, ANIMTYPE_ANIMDATA, (ID *)key); + } + } + else { + /* the check for the DopeSheet summary is included here since the summary works here too */ + if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) + items = animdata_filter_shapekey(ac, anim_data, key, filter_mode); + } + break; } + + + /* Modes for Specialty Data Types (i.e. not keyframes) */ case ANIMCONT_GPENCIL: { if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) @@ -2654,6 +2680,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo items = animdata_filter_mask(anim_data, data, filter_mode); break; } + + + /* DopeSheet Based Modes */ case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */ { /* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */ @@ -2669,6 +2698,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode); break; } + + + /* Special/Internal Use */ case ANIMCONT_CHANNEL: /* animation channel */ { bDopeSheet *ads = ac->ads; -- cgit v1.2.3 From 348addd7d2dff6bb2d898a1db014332311fa0dcc Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sat, 2 Nov 2013 17:58:53 +0000 Subject: OSX: give application bundles an own icon to better differentiate vs. folders --- source/blender/editors/space_file/file_draw.c | 3 +++ source/blender/editors/space_file/filelist.c | 7 +++++-- source/blender/makesdna/DNA_space_types.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 43df3be45ac..c4e6ca97418 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -251,6 +251,9 @@ static int get_file_icon(struct direntry *file) if (strcmp(file->relname, "..") == 0) { return ICON_FILE_PARENT; } + if (file->flags & APPLICATIONBUNDLE) { + return ICON_UGLYPACKAGE; + } if (file->flags & BLENDERFILE) { return ICON_FILE_BLEND; } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 822d1ba8bca..6ee1afea5e9 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -772,6 +772,9 @@ static int path_extension_type(const char *path) else if (file_is_blend_backup(path)) { return BLENDERFILE_BACKUP; } + else if (BLI_testextensie(path, ".app")) { + return APPLICATIONBUNDLE; + } else if (BLI_testextensie(path, ".py")) { return PYSCRIPTFILE; } @@ -863,8 +866,8 @@ static void filelist_setfiletypes(struct FileList *filelist) for (num = 0; num < filelist->numfiles; num++, file++) { file->type = file->s.st_mode; /* restore the mess below */ - /* Don't check extensions for directories */ - if (file->type & S_IFDIR) { + /* Don't check extensions for directories, allow in OSX application bundles */ + if ((file->type & S_IFDIR) && (!APPLICATIONBUNDLE)) { continue; } file->flags = file_extension_type(filelist->dir, file->relname); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index faa99aaaad8..4ebfe349a9f 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -693,6 +693,7 @@ typedef enum eFileSel_File_Types { BTXFILE = (1 << 12), COLLADAFILE = (1 << 13), OPERATORFILE = (1 << 14), /* from filter_glob operator property */ + APPLICATIONBUNDLE = (1 << 15), } eFileSel_File_Types; /* Selection Flags in filesel: struct direntry, unsigned char selflag */ -- cgit v1.2.3 From ec32964194966927f24a02ba4a0c63437e99bd5e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 3 Nov 2013 05:19:55 +0000 Subject: code cleanup: warnings --- source/blender/bmesh/operators/bmo_wireframe.c | 6 +++--- source/blender/editors/transform/transform.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c index 2e5db5210c4..7f1008813ad 100644 --- a/source/blender/bmesh/operators/bmo_wireframe.c +++ b/source/blender/bmesh/operators/bmo_wireframe.c @@ -172,9 +172,9 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) BMIter itersub; /* filled only with boundary verts */ - BMVert **verts_src = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__); - BMVert **verts_neg = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__); - BMVert **verts_pos = MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__); + BMVert **verts_src = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__); + BMVert **verts_neg = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__); + BMVert **verts_pos = MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__); /* will over-alloc, but makes for easy lookups by index to keep aligned */ BMVert **verts_boundary = use_boundary ? diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 9909f438734..ab2732d4e8c 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4262,7 +4262,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) } } BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Even Thickness %s"), - WM_bool_as_string(t->flag & T_ALT_TRANSFORM)); + WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0)); /* done with header string */ @@ -6946,7 +6946,7 @@ static void headerSeqSlide(TransInfo *t, float val[2], char str[MAX_INFO_LEN]) } } ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Expand to fit %s"), - WM_bool_as_string(t->flag & T_ALT_TRANSFORM)); + WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0)); } static void applySeqSlideValue(TransInfo *t, const float val[2]) -- cgit v1.2.3 From e5572a3f553409a6960baba769c0a0ee0ee48853 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 3 Nov 2013 09:33:17 +0000 Subject: Motion tracking: use is_keyed to match naming in other areas of RNA --- source/blender/makesrna/intern/rna_tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 83d9bca4780..662673adf77 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1091,7 +1091,7 @@ static void rna_def_trackingMarker(BlenderRNA *brna) RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_tracking_markerSearch_update"); /* is marker keyframed */ - prop = RNA_def_property(srna, "is_keyframed", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "is_keyed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MARKER_TRACKED); RNA_def_property_ui_text(prop, "Keyframed", "Indicates whether position of marker is keyframed, not tracked"); -- cgit v1.2.3 From bb9cbedf72961a45642e3f398ccb828d9b6d73a8 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sun, 3 Nov 2013 13:10:18 +0000 Subject: OSX: Fix an error in own 61065 --- source/blender/editors/space_file/filelist.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 6ee1afea5e9..a2f81498dd3 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -865,11 +865,12 @@ static void filelist_setfiletypes(struct FileList *filelist) for (num = 0; num < filelist->numfiles; num++, file++) { file->type = file->s.st_mode; /* restore the mess below */ - - /* Don't check extensions for directories, allow in OSX application bundles */ - if ((file->type & S_IFDIR) && (!APPLICATIONBUNDLE)) { +#ifndef __APPLE__ + /* Don't check extensions for directories, allow in OSX cause bundles have extensions*/ + if (file->type & S_IFDIR) { continue; } +#endif file->flags = file_extension_type(filelist->dir, file->relname); if (filelist->filter_glob[0] && -- cgit v1.2.3 From 2190e6de0e971b5267925e609b73f0ce4931b02b Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 3 Nov 2013 14:24:02 +0000 Subject: Fix for missing calls of BaseMath_ReadCallback() when accessing vector/color elements. This bug was causing wrong color blending results in Freestyle color modifiers. Problem report from Light BWK through personal communications, thanks! --- .../blender/freestyle/intern/python/BPy_Convert.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index 3b1232c51af..bb907ec572c 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -556,6 +556,8 @@ Vec2f *Vec2f_ptr_from_Vector(PyObject *obj) { if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 2) return NULL; + if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) + return NULL; float x = ((VectorObject *)obj)->vec[0]; float y = ((VectorObject *)obj)->vec[1]; return new Vec2f(x, y); @@ -565,6 +567,8 @@ Vec3f *Vec3f_ptr_from_Vector(PyObject *obj) { if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3) return NULL; + if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) + return NULL; float x = ((VectorObject *)obj)->vec[0]; float y = ((VectorObject *)obj)->vec[1]; float z = ((VectorObject *)obj)->vec[2]; @@ -575,6 +579,8 @@ Vec3r *Vec3r_ptr_from_Vector(PyObject *obj) { if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3) return NULL; + if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) + return NULL; real x = ((VectorObject *)obj)->vec[0]; real y = ((VectorObject *)obj)->vec[1]; real z = ((VectorObject *)obj)->vec[2]; @@ -585,6 +591,8 @@ Vec3f *Vec3f_ptr_from_Color(PyObject *obj) { if (!ColorObject_Check(obj)) return NULL; + if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) + return NULL; float r = ((ColorObject *)obj)->col[0]; float g = ((ColorObject *)obj)->col[1]; float b = ((ColorObject *)obj)->col[2]; @@ -595,6 +603,8 @@ Vec3r *Vec3r_ptr_from_Color(PyObject *obj) { if (!ColorObject_Check(obj)) return NULL; + if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) + return NULL; real r = ((ColorObject *)obj)->col[0]; real g = ((ColorObject *)obj)->col[1]; real b = ((ColorObject *)obj)->col[2]; @@ -696,10 +706,19 @@ Vec3r *Vec3r_ptr_from_PyTuple(PyObject *obj) int float_array_from_PyObject(PyObject *obj, float *v, int n) { if (VectorObject_Check(obj) && ((VectorObject *)obj)->size == n) { + if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) + return 0; for (int i = 0; i < n; i++) v[i] = ((VectorObject *)obj)->vec[i]; return 1; } + else if (ColorObject_Check(obj) && n == 3) { + if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) + return 0; + for (int i = 0; i < n; i++) + v[i] = ((ColorObject *)obj)->col[i]; + return 1; + } else if (PyList_Check(obj) && PyList_Size(obj) == n) { return float_array_from_PyList(obj, v, n); } -- cgit v1.2.3 From 95755218128956d8bd874d3e30eb53f10b2cd9ce Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 3 Nov 2013 14:25:37 +0000 Subject: Minor code improvements: avoid unnecessary Python object allocations in Freestyle color blending. --- .../freestyle/intern/python/BPy_Freestyle.cpp | 23 +++++----------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp index c28f6ef6762..fb678d7ea66 100644 --- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -129,7 +129,6 @@ static PyObject *Freestyle_blendRamp(PyObject *self, PyObject *args) PyObject *obj1, *obj2; char *s; int type; - Vec3f *v1 = NULL, *v2 = NULL; float a[3], fac, b[3]; if (!PyArg_ParseTuple(args, "sOfO", &s, &obj1, &fac, &obj2)) @@ -137,32 +136,20 @@ static PyObject *Freestyle_blendRamp(PyObject *self, PyObject *args) type = ramp_blend_type(s); if (type < 0) { PyErr_SetString(PyExc_TypeError, "argument 1 is an unknown ramp blend type"); - goto error; + return NULL; } - v1 = Vec3f_ptr_from_PyObject(obj1); - if (!v1) { + if (!float_array_from_PyObject(obj1, a, 3)) { PyErr_SetString(PyExc_TypeError, "argument 2 must be a 3D vector (either a tuple/list of 3 elements or Vector)"); - goto error; + return NULL; } - v2 = Vec3f_ptr_from_PyObject(obj2); - if (!v2) { + if (!float_array_from_PyObject(obj2, b, 3)) { PyErr_SetString(PyExc_TypeError, "argument 4 must be a 3D vector (either a tuple/list of 3 elements or Vector)"); - goto error; + return NULL; } - a[0] = v1->x(); b[0] = v2->x(); - a[1] = v1->y(); b[1] = v2->y(); - a[2] = v1->z(); b[2] = v2->z(); ramp_blend(type, a, fac, b); - delete v1; - delete v2; return Vector_CreatePyObject(a, 3, Py_NEW, NULL); - -error: - if (v1) delete v1; - if (v2) delete v2; - return NULL; } #include "BKE_texture.h" /* do_colorband() */ -- cgit v1.2.3 From ddcb1166def10f5b180de9c6191f24801a5d6698 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 3 Nov 2013 18:04:45 +0000 Subject: Fix [#37275] can't import 2.68a keymap Now exported keymaps will still be usable accross versions, even if some operator properties disappear (write a warning in console in this case, instead of "crashing"). Also factorized a bit of code here! --- .../scripts/modules/bpy_extras/keyconfig_utils.py | 107 +++++++++------------ 1 file changed, 47 insertions(+), 60 deletions(-) diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py index 1baab5654c6..4b673b2e0de 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py @@ -151,7 +151,7 @@ def keyconfig_merge(kc1, kc2): return merged_keymaps -def _export_properties(prefix, properties, lines=None): +def _export_properties(prefix, properties, kmi_id, lines=None): from bpy.types import OperatorProperties if lines is None: @@ -171,20 +171,58 @@ def _export_properties(prefix, properties, lines=None): if pname != "rna_type": value = getattr(properties, pname) if isinstance(value, OperatorProperties): - _export_properties(prefix + "." + pname, value, lines) + _export_properties(prefix + "." + pname, value, kmi_id, lines) elif properties.is_property_set(pname): value = string_value(value) if value != "": - lines.append("%s.%s = %s\n" % (prefix, pname, value)) + lines.append("set_kmi_prop(%s, '%s', %s, '%s')\n" % (prefix, pname, value, kmi_id)) return lines +def _kmistr(kmi, is_modal): + if is_modal: + kmi_id = kmi.propvalue + kmi_newfunc = 'new_modal' + else: + kmi_id = kmi.idname + kmi_newfunc = 'new' + s = ["kmi = km.keymap_items.%s(\'%s\', \'%s\', \'%s\'" % (kmi_newfunc, kmi_id, kmi.type, kmi.value)] + + if kmi.any: + s.append(", any=True") + else: + if kmi.shift: + s.append(", shift=True") + if kmi.ctrl: + s.append(", ctrl=True") + if kmi.alt: + s.append(", alt=True") + if kmi.oskey: + s.append(", oskey=True") + if kmi.key_modifier and kmi.key_modifier != 'NONE': + s.append(", key_modifier=\'%s\'" % kmi.key_modifier) + + s.append(")\n") + + props = kmi.properties + + if props is not None: + _export_properties("kmi.properties", props, kmi_id, s) + + return "".join(s) + + def keyconfig_export(wm, kc, filepath): f = open(filepath, "w") f.write("import bpy\n") f.write("import os\n\n") + f.write("def set_kmi_prop(kmiprops, prop, value, kmiid):\n" + " if hasattr(kmiprops, prop):\n" + " setattr(kmiprops, prop, value)\n" + " else:\n" + " print(\"Warning: property '%s' not found in keymap item '%s'\" % (prop, kmiid))\n\n") f.write("wm = bpy.context.window_manager\n") f.write("kc = wm.keyconfigs.new(os.path.splitext(os.path.basename(__file__))[0])\n\n") # keymap must be created by caller @@ -216,30 +254,7 @@ def keyconfig_export(wm, kc, filepath): f.write("# Map %s\n" % km.name) f.write("km = kc.keymaps.new('%s', space_type='%s', region_type='%s', modal=%s)\n\n" % (km.name, km.space_type, km.region_type, km.is_modal)) for kmi in km.keymap_items: - if km.is_modal: - f.write("kmi = km.keymap_items.new_modal('%s', '%s', '%s'" % (kmi.propvalue, kmi.type, kmi.value)) - else: - f.write("kmi = km.keymap_items.new('%s', '%s', '%s'" % (kmi.idname, kmi.type, kmi.value)) - if kmi.any: - f.write(", any=True") - else: - if kmi.shift: - f.write(", shift=True") - if kmi.ctrl: - f.write(", ctrl=True") - if kmi.alt: - f.write(", alt=True") - if kmi.oskey: - f.write(", oskey=True") - if kmi.key_modifier and kmi.key_modifier != 'NONE': - f.write(", key_modifier='%s'" % kmi.key_modifier) - f.write(")\n") - - props = kmi.properties - - if props is not None: - f.write("".join(_export_properties("kmi.properties", props))) - + f.write(_kmistr(kmi, km.is_modal)) f.write("\n") f.close() @@ -250,50 +265,22 @@ def keyconfig_test(kc): def testEntry(kc, entry, src=None, parent=None): result = False - def kmistr(kmi): - if km.is_modal: - s = ["kmi = km.keymap_items.new_modal(\'%s\', \'%s\', \'%s\'" % (kmi.propvalue, kmi.type, kmi.value)] - else: - s = ["kmi = km.keymap_items.new(\'%s\', \'%s\', \'%s\'" % (kmi.idname, kmi.type, kmi.value)] - - if kmi.any: - s.append(", any=True") - else: - if kmi.shift: - s.append(", shift=True") - if kmi.ctrl: - s.append(", ctrl=True") - if kmi.alt: - s.append(", alt=True") - if kmi.oskey: - s.append(", oskey=True") - if kmi.key_modifier and kmi.key_modifier != 'NONE': - s.append(", key_modifier=\'%s\'" % kmi.key_modifier) - - s.append(")\n") - - props = kmi.properties - - if props is not None: - _export_properties("kmi.properties", props, s) - - return "".join(s).strip() - idname, spaceid, regionid, children = entry km = kc.keymaps.find(idname, space_type=spaceid, region_type=regionid) if km: km = km.active() + is_modal = km.is_modal if src: for item in km.keymap_items: if src.compare(item): print("===========") print(parent.name) - print(kmistr(src)) + print(_kmistr(src, is_modal).strip()) print(km.name) - print(kmistr(item)) + print(_kmistr(item, is_modal).strip()) result = True for child in children: @@ -312,8 +299,8 @@ def keyconfig_test(kc): if src.compare(item): print("===========") print(km.name) - print(kmistr(src)) - print(kmistr(item)) + print(_kmistr(src, is_modal).strip()) + print(_kmistr(item, is_modal).strip()) result = True for child in children: -- cgit v1.2.3 From c366f08b6f681ce84b75f402505873a313a80ca7 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 3 Nov 2013 21:11:27 +0000 Subject: Fix [#37297] Crash when Adding and Removing Fluid Particlesystem. Using freed mem... --- source/blender/makesrna/intern/rna_fluidsim.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index b18c21d53f1..9007baa9dad 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -122,7 +122,7 @@ static void rna_FluidSettings_update_type(Main *bmain, Scene *scene, PointerRNA Object *ob = (Object *)ptr->id.data; FluidsimModifierData *fluidmd; ParticleSystemModifierData *psmd; - ParticleSystem *psys; + ParticleSystem *psys, *next_psys; ParticleSettings *part; fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); @@ -155,7 +155,8 @@ static void rna_FluidSettings_update_type(Main *bmain, Scene *scene, PointerRNA } } else { - for (psys = ob->particlesystem.first; psys; psys = psys->next) { + for (psys = ob->particlesystem.first; psys; psys = next_psys) { + next_psys = psys->next; if (psys->part->type == PART_FLUID) { /* clear modifier */ psmd = psys_get_modifier(ob, psys); -- cgit v1.2.3 From 65633d7be25b81dc6837098909e1662dc03939e2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Nov 2013 00:55:00 +0000 Subject: code cleanup: remove unused operator (select all handles this case now) --- source/blender/editors/armature/armature_intern.h | 1 - source/blender/editors/armature/armature_ops.c | 1 - source/blender/editors/armature/armature_select.c | 33 ----------------------- 3 files changed, 35 deletions(-) diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 0f1597cc6f3..3080ab33538 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -62,7 +62,6 @@ void ARMATURE_OT_parent_set(struct wmOperatorType *ot); void ARMATURE_OT_parent_clear(struct wmOperatorType *ot); void ARMATURE_OT_select_all(struct wmOperatorType *ot); -void ARMATURE_OT_select_inverse(struct wmOperatorType *ot); void ARMATURE_OT_select_more(struct wmOperatorType *ot); void ARMATURE_OT_select_less(struct wmOperatorType *ot); void ARMATURE_OT_select_hierarchy(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 496da812610..3322b115da9 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -58,7 +58,6 @@ void ED_operatortypes_armature(void) WM_operatortype_append(ARMATURE_OT_parent_clear); WM_operatortype_append(ARMATURE_OT_select_all); - WM_operatortype_append(ARMATURE_OT_select_inverse); WM_operatortype_append(ARMATURE_OT_select_more); WM_operatortype_append(ARMATURE_OT_select_less); WM_operatortype_append(ARMATURE_OT_select_hierarchy); diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index fe1d2fa3765..69a42b84624 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -559,39 +559,6 @@ bool mouse_armature(bContext *C, const int mval[2], bool extend, bool deselect, /* **************** Selections ******************/ -static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) -{ - /* Set the flags */ - CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones) - { - /* ignore bone if selection can't change */ - if ((ebone->flag & BONE_UNSELECTABLE) == 0) { - /* select bone */ - ebone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - } - } - CTX_DATA_END; - - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); - - return OPERATOR_FINISHED; -} - -void ARMATURE_OT_select_inverse(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Select Inverse"; - ot->idname = "ARMATURE_OT_select_inverse"; - ot->description = "Flip the selection status of bones (selected -> unselected, unselected -> selected)"; - - /* api callbacks */ - ot->exec = armature_select_inverse_exec; - ot->poll = ED_operator_editarmature; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - -} static int armature_de_select_all_exec(bContext *C, wmOperator *op) { int action = RNA_enum_get(op->ptr, "action"); -- cgit v1.2.3 From 0b2d9ffaebc04214a65977b2c6f189aae262439b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 4 Nov 2013 01:18:33 +0000 Subject: Fix for uninitialised var --- source/blender/editors/space_graph/graph_edit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index ebb9266149a..db13e2a4024 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1986,7 +1986,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) KeyframeEditData ked; KeyframeEditFunc edit_cb; - float cursor_value; + float cursor_value = 0.0f; /* get beztriple editing callbacks */ edit_cb = ANIM_editkeyframes_mirror(mode); -- cgit v1.2.3 From a1d553a8f388f1e4064b5c80dd9a9621d8172eb3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 4 Nov 2013 04:18:28 +0000 Subject: Bugfix [#36950] Restrict Frame Range not being obeyed on Driver F-Curves By default, drivers (used to) automatically map the driver result (i.e. "evaltime" or the x-coordinates in the driver graphs) to results. This evaltime => cvalue mapping is necessary when there are absolutely no keyframes or modifiers on a driver F-Curve, or else nothing would happen. However, when there are modifiers on these driver F-Curves, and these modifiers only work within certain ranges, there would be confusing and unwanted situations where even if you clamped the modifiers to only generating a curve within certain frame ranges, the final driver output would still ignore the results of the curve due to the underlying 1-1 mapping. This commit introduces a check to ensure that this automatic mapping won't happen during such invalid ranges. --- source/blender/blenkernel/intern/fcurve.c | 32 +++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index dbdf30ea63d..a40d7401566 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -2139,11 +2139,39 @@ float evaluate_fcurve(FCurve *fcu, float evaltime) /* if there is a driver (only if this F-Curve is acting as 'driver'), evaluate it to find value to use as "evaltime" * since drivers essentially act as alternative input (i.e. in place of 'time') for F-Curves - * - this value will also be returned as the value of the 'curve', if there are no keyframes */ if (fcu->driver) { /* evaltime now serves as input for the curve */ - evaltime = cvalue = evaluate_driver(fcu->driver, evaltime); + evaltime = evaluate_driver(fcu->driver, evaltime); + + /* only do a default 1-1 mapping if it's unlikely that anything else will set a value... */ + if (fcu->totvert == 0) { + FModifier *fcm; + bool do_linear = true; + + /* out-of-range F-Modifiers will block, as will those which just plain overwrite the values + * XXX: additive is a bit more dicey; it really depends then if things are in range or not... + */ + for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { + /* if there are range-restrictions, we must definitely block [#36950] */ + if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 || + ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) ) + { + /* within range: here it probably doesn't matter, though we'd want to check on additive... */ + } + else { + /* outside range: modifier shouldn't contribute to the curve here, though it does in other areas, + * so neither should the driver! + */ + do_linear = false; + } + } + + /* only copy over results if none of the modifiers disagreed with this */ + if (do_linear) { + cvalue = evaltime; + } + } } /* evaluate modifiers which modify time to evaluate the base curve at */ -- cgit v1.2.3 From 3b91a77c7de1e93ce14ab5c8ea45729102985a98 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Nov 2013 11:27:11 +0000 Subject: code cleanup: typo in function name --- source/blender/blenkernel/BKE_mask.h | 2 +- source/blender/blenkernel/intern/mask.c | 2 +- source/blender/compositor/operations/COM_MaskOperation.cpp | 2 +- source/blender/editors/mask/mask_shapekey.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 64eec65f443..d73249041e8 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -156,7 +156,7 @@ int BKE_mask_layer_shape_find_frame_range(struct MaskLayer *masklay, const float struct MaskLayerShape **r_masklay_shape_b); struct MaskLayerShape *BKE_mask_layer_shape_alloc(struct MaskLayer *masklay, const int frame); void BKE_mask_layer_shape_free(struct MaskLayerShape *masklay_shape); -struct MaskLayerShape *BKE_mask_layer_shape_varify_frame(struct MaskLayer *masklay, const int frame); +struct MaskLayerShape *BKE_mask_layer_shape_verify_frame(struct MaskLayer *masklay, const int frame); struct MaskLayerShape *BKE_mask_layer_shape_duplicate(struct MaskLayerShape *masklay_shape); void BKE_mask_layer_shape_unlink(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape); void BKE_mask_layer_shape_sort(struct MaskLayer *masklay); diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index e8851102fb8..b20b4294f84 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1772,7 +1772,7 @@ int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay, const float frame, } } -MaskLayerShape *BKE_mask_layer_shape_varify_frame(MaskLayer *masklay, const int frame) +MaskLayerShape *BKE_mask_layer_shape_verify_frame(MaskLayer *masklay, const int frame) { MaskLayerShape *masklay_shape; diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index 39f4302dec9..85df691ee29 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -75,7 +75,7 @@ void MaskOperation::initExecution() masklay; masklay = masklay->next) { - masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_frame_number); + masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, this->m_frame_number); BKE_mask_layer_shape_from_mask(masklay, masklay_shape); } } diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c index 0c9ce5f6c79..78dba382520 100644 --- a/source/blender/editors/mask/mask_shapekey.c +++ b/source/blender/editors/mask/mask_shapekey.c @@ -69,7 +69,7 @@ static int mask_shape_key_insert_exec(bContext *C, wmOperator *UNUSED(op)) continue; } - masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, frame); + masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, frame); BKE_mask_layer_shape_from_mask(masklay, masklay_shape); change = TRUE; } @@ -320,7 +320,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) masklay_shape_tmp = masklay_shape_tmp->next) { BKE_mask_layer_evaluate(masklay, masklay_shape_tmp->frame, true); - masklay_shape_tmp_rekey = BKE_mask_layer_shape_varify_frame(masklay, masklay_shape_tmp->frame); + masklay_shape_tmp_rekey = BKE_mask_layer_shape_verify_frame(masklay, masklay_shape_tmp->frame); BKE_mask_layer_shape_from_mask(masklay, masklay_shape_tmp_rekey); masklay_shape_tmp_rekey->flag = masklay_shape_tmp->flag & MASK_SHAPE_SELECT; } @@ -417,7 +417,7 @@ void ED_mask_layer_shape_auto_key(MaskLayer *masklay, const int frame) { MaskLayerShape *masklay_shape; - masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, frame); + masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, frame); BKE_mask_layer_shape_from_mask(masklay, masklay_shape); } -- cgit v1.2.3 From d07f3f793b8c7596e36249d589aafcf63611cc1d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Nov 2013 12:01:46 +0000 Subject: add CDDM_lower_num_loops(), for completeness (currently unused). --- source/blender/blenkernel/BKE_cdderivedmesh.h | 1 + source/blender/blenkernel/intern/cdderivedmesh.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h index ddb36df74ca..560617db474 100644 --- a/source/blender/blenkernel/BKE_cdderivedmesh.h +++ b/source/blender/blenkernel/BKE_cdderivedmesh.h @@ -122,6 +122,7 @@ void CDDM_recalc_tessellation_ex(struct DerivedMesh *dm, const int do_face_nor_c */ void CDDM_lower_num_verts(struct DerivedMesh *dm, int numVerts); void CDDM_lower_num_edges(struct DerivedMesh *dm, int numEdges); +void CDDM_lower_num_loops(struct DerivedMesh *dm, int numLoops); void CDDM_lower_num_polys(struct DerivedMesh *dm, int numPolys); void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces); diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 4846199b9d9..d57d9180697 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -2786,6 +2786,7 @@ void CDDM_calc_edges(DerivedMesh *dm) void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts) { + BLI_assert(numVerts >= 0); if (numVerts < dm->numVertData) CustomData_free_elem(&dm->vertData, numVerts, dm->numVertData - numVerts); @@ -2794,6 +2795,7 @@ void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts) void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges) { + BLI_assert(numEdges >= 0); if (numEdges < dm->numEdgeData) CustomData_free_elem(&dm->edgeData, numEdges, dm->numEdgeData - numEdges); @@ -2802,14 +2804,25 @@ void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges) void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces) { + BLI_assert(numTessFaces >= 0); if (numTessFaces < dm->numTessFaceData) CustomData_free_elem(&dm->faceData, numTessFaces, dm->numTessFaceData - numTessFaces); dm->numTessFaceData = numTessFaces; } +void CDDM_lower_num_loops(DerivedMesh *dm, int numLoops) +{ + BLI_assert(numLoops >= 0); + if (numLoops < dm->numLoopData) + CustomData_free_elem(&dm->loopData, numLoops, dm->numLoopData - numLoops); + + dm->numLoopData = numLoops; +} + void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys) { + BLI_assert(numPolys >= 0); if (numPolys < dm->numPolyData) CustomData_free_elem(&dm->polyData, numPolys, dm->numPolyData - numPolys); -- cgit v1.2.3 From 2010c6ad6cae41b5f13b36339404ff60c98ae915 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 4 Nov 2013 13:21:39 +0000 Subject: Made buildinfo aware of builds from GIT - Use commit number since last annotated tag as a revision number replacement. It'll eb followed by 'M' symbol if there're local modification in the source tree. - Commit short SHA1 is included. Helps getting information about commit used to build blender with much faster. - If build is not done from master branch, this also will be noticed in the splash screen. This commit also replaces revision stored in the files with git-specific fields (change and hash). This is kind of breaks compatibility, meaning files which were saved before this change wouldn't display any information about which revision they were saved with. When we'll finally switch to git, we'll see proper hash and change number since previous release in the files, for until then svn version will be used as a change number and hash will be empty. Not a huge deal, since this field was only used by developers to help torubleshooting things and isn't needed for blender itself. Some additional tweaks are probably needed :) --- build_files/cmake/buildinfo.cmake | 84 +++++++++++++++++++--- build_files/scons/tools/Blender.py | 25 +++++-- release/scripts/modules/sys_info.py | 14 +++- source/blender/blenkernel/BKE_main.h | 2 +- source/blender/blenloader/intern/readfile.c | 10 ++- source/blender/blenloader/intern/writefile.c | 11 +-- source/blender/collada/AnimationExporter.h | 4 -- source/blender/collada/DocumentExporter.cpp | 12 +++- source/blender/makesdna/DNA_fileglobal_types.h | 3 +- source/blender/python/intern/bpy_app.c | 14 +++- source/blender/windowmanager/intern/wm_operators.c | 47 ++++++++---- .../bad_level_call_stubs/CMakeLists.txt | 5 +- source/creator/CMakeLists.txt | 4 +- source/creator/buildinfo.c | 4 +- source/creator/creator.c | 27 +++++-- 15 files changed, 211 insertions(+), 55 deletions(-) diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake index e68015e36d3..ae2f87b49be 100644 --- a/build_files/cmake/buildinfo.cmake +++ b/build_files/cmake/buildinfo.cmake @@ -1,16 +1,82 @@ # This is called by cmake as an extermal process from # ./source/creator/CMakeLists.txt to write ./source/creator/buildinfo.h -# The FindSubversion.cmake module is part of the standard distribution -include(FindSubversion) - # Extract working copy information for SOURCE_DIR into MY_XXX variables # with a default in case anything fails, for examble when using git-svn -set(MY_WC_REVISION "unknown") +set(MY_WC_HASH "") +set(MY_WC_BRANCH "") +set(MY_WC_CHANGE "unknown") + # Guess if this is a SVN working copy and then look up the revision -if(EXISTS ${SOURCE_DIR}/.svn/) - if(Subversion_FOUND) - Subversion_WC_INFO(${SOURCE_DIR} MY) +if(EXISTS ${SOURCE_DIR}/.git/) + if(EXISTS ${SOURCE_DIR}/.git/) + # The FindSubversion.cmake module is part of the standard distribution + include(FindGit) + if(GIT_FOUND) + execute_process(COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE) + + # Get latest version tag + execute_process(COMMAND git describe --match "v[0-9]*" --abbrev=0 + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE _git_latest_version_tag + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT _git_latest_version_tag STREQUAL "") + execute_process(COMMAND git rev-list HEAD ^${_git_latest_version_tag} --count + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_CHANGE + OUTPUT_STRIP_TRAILING_WHITESPACE) + else() + # For the time being we don't have annotated release tags, + # count all the revisions in branch. + execute_process(COMMAND git rev-list HEAD --count + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_CHANGE + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + + # Update GIT index before getting dirty files + execute_process(COMMAND git update-index -q --refresh + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND git diff-index --name-only HEAD -- + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE _git_changed_files + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT _git_changed_files STREQUAL "") + set(MY_WC_CHANGE "${MY_WC_CHANGE}M") + endif() + + unset(_git_changed_files) + unset(_git_latest_version_tag) + endif() + endif() +else() + # Some crazy folks like me could have hacked git-svn chekout in a way + # so svnversion gives proper svn revision for themm which required having + # empty .svn folder. + # + # For such a crazy blokes put svn check into an else branch. + # + # (sergey) + if(EXISTS ${SOURCE_DIR}/.svn/) + # The FindSubversion.cmake module is part of the standard distribution + include(FindSubversion) + + if(Subversion_FOUND) + Subversion_WC_INFO(${SOURCE_DIR} MY) + set(MY_WC_CHANGE "${MY_WC_REVISION}") + endif() endif() endif() @@ -27,7 +93,9 @@ endif() # Write a file with the SVNVERSION define file(WRITE buildinfo.h.txt - "#define BUILD_REV \"${MY_WC_REVISION}\"\n" + "#define BUILD_HASH \"${MY_WC_HASH}\"\n" + "#define BUILD_CHANGE \"${MY_WC_CHANGE}\"\n" + "#define BUILD_BRANCH \"${MY_WC_BRANCH}\"\n" "#define BUILD_DATE \"${BUILD_DATE}\"\n" "#define BUILD_TIME \"${BUILD_TIME}\"\n" ) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index f181f290104..b79ba991b9a 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -410,9 +410,24 @@ def buildinfo(lenv, build_type): """ build_date = time.strftime ("%Y-%m-%d") build_time = time.strftime ("%H:%M:%S") - build_rev = os.popen('svnversion').read()[:-1] # remove \n - if build_rev == '': - build_rev = '-UNKNOWN-' + if os.path.isdir(os.path.abspath('.git')): + latest_version_tag = os.popen('git describe --match "v[0-9]*" --abbrev=0').read().strip() + if latest_version_tag: + build_change = os.popen('git rev-list HEAD ' + latest_version_tag + ' --count').read().strip() + else: + build_change = os.popen('git rev-list HEAD --count').read().strip() + + build_hash = os.popen('git rev-parse --short HEAD').read().strip() + build_branch = os.popen('git rev-parse --abbrev-ref HEAD').read().strip() + elif os.path.isdir(os.path.abspath('.svn')): + build_hash = '' + build_change = os.popen('svnversion').read()[:-1] # remove \n + build_branch = '' + else: + build_hash = '' + build_change = 'unknown' + build_branch = '' + if lenv['BF_DEBUG']: build_type = "Debug" build_cflags = ' '.join(lenv['CFLAGS'] + lenv['CCFLAGS'] + lenv['BF_DEBUG_CCFLAGS'] + lenv['CPPFLAGS']) @@ -429,7 +444,9 @@ def buildinfo(lenv, build_type): lenv.Append (CPPDEFINES = ['BUILD_TIME=\\"%s\\"'%(build_time), 'BUILD_DATE=\\"%s\\"'%(build_date), 'BUILD_TYPE=\\"%s\\"'%(build_type), - 'BUILD_REV=\\"%s\\"'%(build_rev), + 'BUILD_HASH=\\"%s\\"'%(build_hash), + 'BUILD_CHANGE=\\"%s\\"'%(build_change), + 'BUILD_BRANCH=\\"%s\\"'%(build_branch), 'WITH_BUILDINFO', 'BUILD_PLATFORM=\\"%s:%s\\"'%(platform.system(), platform.architecture()[0]), 'BUILD_CFLAGS=\\"%s\\"'%(build_cflags), diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py index ea75bfde809..3fd4a60d0b1 100644 --- a/release/scripts/modules/sys_info.py +++ b/release/scripts/modules/sys_info.py @@ -67,7 +67,19 @@ def write_sysinfo(op): # build info output.write("\nBlender:\n") output.write(lilies) - output.write("version %s, revision %r. %r\n" % (bpy.app.version_string, bpy.app.build_revision, bpy.app.build_type)) + if bpy.app.build_branch and bpy.app.build_branch != "Unknown": + output.write("version %s, branch %r, chage %r, hash %r, %r\n" % + (bpy.app.version_string, + bpy.app.build_branch, + bpy.app.build_change, + bpy.app.build_hash, + bpy.app.build_type)) + else: + output.write("version %s, revision %r. %r\n" % + (bpy.app.version_string, + bpy.app.build_change, + bpy.app.build_type)) + output.write("build date: %r, %r\n" % (bpy.app.build_date, bpy.app.build_time)) output.write("platform: %r\n" % (bpy.app.build_platform)) output.write("binary path: %r\n" % (bpy.app.binary_path)) diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 264a7421e91..36c1f5dcf1f 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -53,7 +53,7 @@ typedef struct Main { char name[1024]; /* 1024 = FILE_MAX */ short versionfile, subversionfile; /* see BLENDER_VERSION, BLENDER_SUBVERSION */ short minversionfile, minsubversionfile; - int revision; /* svn revision of binary that saved file */ + char build_change[16], build_hash[16]; /* change number and hash from buildinfo */ short recovered; /* indicate the main->name (file) is the recovered one */ struct Library *curlib; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c3727c0f688..bc7cd2d9143 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7292,7 +7292,8 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) bfd->main->subversionfile = fg->subversion; bfd->main->minversionfile = fg->minversion; bfd->main->minsubversionfile = fg->minsubversion; - bfd->main->revision = fg->revision; + BLI_strncpy(bfd->main->build_change, fg->build_change, sizeof(bfd->main->build_change)); + BLI_strncpy(bfd->main->build_hash, fg->build_hash, sizeof(bfd->main->build_hash)); bfd->winpos = fg->winpos; bfd->fileflags = fg->fileflags; @@ -7926,8 +7927,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ - if (G.debug & G_DEBUG) - printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision); + if (G.debug & G_DEBUG) { + printf("read file %s\n Version %d sub %d change %s hash %s\n", + fd->relabase, main->versionfile, main->subversionfile, + main->build_change, main->build_hash); + } blo_do_versions_pre250(fd, lib, main); blo_do_versions_250(fd, lib, main); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 83122e24b34..cf7a5329a35 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3261,7 +3261,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) char subvstr[8]; /* prevent mem checkers from complaining */ - fg.pads= fg.pad= 0; + fg.pads= 0; memset(fg.filename, 0, sizeof(fg.filename)); current_screen_compat(mainvar, &screen); @@ -3285,11 +3285,14 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) fg.minsubversion= BLENDER_MINSUBVERSION; #ifdef WITH_BUILDINFO { - extern char build_rev[]; - fg.revision= atoi(build_rev); + extern char build_change[], build_hash[]; + /* TODO(sergey): Add branch name to file as well? */ + BLI_strncpy(fg.build_change, build_change, sizeof(fg.build_change)); + BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash)); } #else - fg.revision= 0; + BLI_strncpy(fg.build_change, "unknown", sizeof(fg.build_change)); + BLI_strncpy(fg.build_hash, "unknown", sizeof(fg.build_hash)); #endif writestruct(wd, GLOB, "FileGlobal", 1, &fg); } diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index ea5fd203bea..60224151308 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -53,10 +53,6 @@ extern "C" #include "BIK_api.h" #include "BKE_global.h" #include "ED_object.h" - -#ifdef NAN_BUILDINFO -extern char build_rev[]; -#endif } #include "MEM_guardedalloc.h" diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index c03316e1fe5..9aa0f6e2831 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -101,7 +101,8 @@ extern "C" #include "ED_keyframing.h" #ifdef WITH_BUILDINFO -extern char build_rev[]; +extern char build_change[]; +extern char build_hash[]; #endif #include "MEM_guardedalloc.h" @@ -226,7 +227,14 @@ void DocumentExporter::exportCurrentScene(Scene *sce) } char version_buf[128]; #ifdef WITH_BUILDINFO - sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, build_rev); + /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ + if (build_hash[0] != '\0') { + sprintf(version_buf, "Blender %d.%02d.%d change:%s, hash:", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, + build_change, build_hash); + } + else { + sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, build_change); + } #else sprintf(version_buf, "Blender %d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); #endif diff --git a/source/blender/makesdna/DNA_fileglobal_types.h b/source/blender/makesdna/DNA_fileglobal_types.h index 7e81041fe4a..734741fa687 100644 --- a/source/blender/makesdna/DNA_fileglobal_types.h +++ b/source/blender/makesdna/DNA_fileglobal_types.h @@ -48,8 +48,7 @@ typedef struct FileGlobal { struct Scene *curscene; int fileflags; int globalf; - int revision; /* svn revision from buildinfo */ - int pad; + char build_change[16], build_hash[16]; /* change number and hash from buildinfo */ /* file path where this was saved, for recover */ char filename[1024]; /* 1024 = FILE_MAX */ } FileGlobal; diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 2edb0aee783..3a529496f02 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -53,7 +53,9 @@ #ifdef BUILD_DATE extern char build_date[]; extern char build_time[]; -extern char build_rev[]; +extern char build_change[]; +extern char build_hash[]; +extern char build_branch[]; extern char build_platform[]; extern char build_type[]; extern char build_cflags[]; @@ -75,7 +77,9 @@ static PyStructSequence_Field app_info_fields[] = { /* buildinfo */ {(char *)"build_date", (char *)"The date this blender instance was built"}, {(char *)"build_time", (char *)"The time this blender instance was built"}, - {(char *)"build_revision", (char *)"The subversion revision this blender instance was built with"}, + {(char *)"build_change", (char *)"The change number this blender instance was built with"}, + {(char *)"build_hash", (char *)"The commit hash this blender instance was built with"}, + {(char *)"build_branch", (char *)"The branch this blender instance was built from"}, {(char *)"build_platform", (char *)"The platform this blender instance was built for"}, {(char *)"build_type", (char *)"The type of build (Release, Debug)"}, {(char *)"build_cflags", (char *)"C compiler flags"}, @@ -133,7 +137,9 @@ static PyObject *make_app_info(void) #ifdef BUILD_DATE SetBytesItem(build_date); SetBytesItem(build_time); - SetBytesItem(build_rev); + SetBytesItem(build_change); + SetBytesItem(build_hash); + SetBytesItem(build_branch); SetBytesItem(build_platform); SetBytesItem(build_type); SetBytesItem(build_cflags); @@ -150,6 +156,8 @@ static PyObject *make_app_info(void) SetBytesItem("Unknown"); SetBytesItem("Unknown"); SetBytesItem("Unknown"); + SetBytesItem("Unknown"); + SetBytesItem("Unknown"); #endif SetObjItem(BPY_app_ffmpeg_struct()); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 7748a2cb4b8..2cd5190cdaf 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1641,18 +1641,25 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar #ifdef WITH_BUILDINFO - int ver_width, rev_width; - char version_buf[128]; - char revision_buf[128]; - extern char build_rev[]; - - BLI_snprintf(version_buf, sizeof(version_buf), - "%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); - BLI_snprintf(revision_buf, sizeof(revision_buf), "r%s", build_rev); + int label_delta = 0; + int hash_width, change_width; + char change_buf[128] = "\0"; + char hash_buf[128] = "\0"; + extern char build_hash[], build_change[], build_branch[]; + + /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ + if (build_hash[0] != '\0') { + /* Builds made from tag only shows tag sha */ + BLI_snprintf(hash_buf, sizeof(hash_buf), "Hash: %s", build_hash); + BLI_snprintf(change_buf, sizeof(change_buf), "Change: %s", build_change); + } + else { + BLI_snprintf(change_buf, sizeof(change_buf), "r%s", build_change); + } BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi); - ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_buf) + 0.5f * U.widget_unit; - rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_buf) + 0.5f * U.widget_unit; + hash_width = (int)BLF_width(style->widgetlabel.uifont_id, hash_buf) + 0.5f * U.widget_unit; + change_width = (int)BLF_width(style->widgetlabel.uifont_id, change_buf) + 0.5f * U.widget_unit; #endif /* WITH_BUILDINFO */ block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); @@ -1667,9 +1674,23 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiButSetFunc(but, wm_block_splash_close, block, NULL); uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, NULL); -#ifdef WITH_BUILDINFO - uiDefBut(block, LABEL, 0, version_buf, U.pixelsize * 494 - ver_width, U.pixelsize * 258, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); - uiDefBut(block, LABEL, 0, revision_buf, U.pixelsize * 494 - rev_width, U.pixelsize * 246, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); +#ifdef WITH_BUILDINFO + if (!STREQ(build_change, "0")) { + uiDefBut(block, LABEL, 0, change_buf, U.pixelsize * 494 - change_width, U.pixelsize * 270, change_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + label_delta = 12; + } + uiDefBut(block, LABEL, 0, hash_buf, U.pixelsize * 494 - hash_width, U.pixelsize * (270 - label_delta), hash_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + + /* TODO(sergey): As soon as we fully switched to GIT, no need to check + * whether branch is empty or not. + */ + if (build_branch[0] != '\0' && !STREQ(build_branch, "master")) { + char branch_buf[128] = "\0"; + int branch_width; + BLI_snprintf(branch_buf, sizeof(branch_buf), "Branch: %s", build_branch); + branch_width = (int)BLF_width(style->widgetlabel.uifont_id, branch_buf) + 0.5f * U.widget_unit; + uiDefBut(block, LABEL, 0, branch_buf, U.pixelsize * 494 - branch_width, U.pixelsize * (258 - label_delta), branch_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + } #endif /* WITH_BUILDINFO */ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, U.pixelsize * 480, U.pixelsize * 110, style); diff --git a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt index e8e7ee6ea0a..f8fe401cb1c 100644 --- a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt +++ b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt @@ -1,3 +1,4 @@ + # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or @@ -51,8 +52,10 @@ if(WITH_BUILDINFO) ) add_definitions(-DBUILD_DATE="\"\"" -DBUILD_TIME="\"\"" - -DBUILD_REV="\"\"" + -DBUILD_CHANGE="\"\"" + -DBUILD_HASH="\"\"" -DBUILD_PLATFORM="\"\"" + -DBUILD_BRANCH="\"\"" -DBUILD_TYPE="\"\"" ) endif() diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 8e0ba6684ab..33d5c7dc90b 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -131,7 +131,9 @@ if(WITH_BUILDINFO) # # define in header now, else these get out of date on rebuilds. # -DBUILD_DATE="${BUILD_DATE}" # -DBUILD_TIME="${BUILD_TIME}" - # -DBUILD_REV="${BUILD_REV}" + # -DBUILD_CHANGE="${BUILD_CHANGE}" + # -DBUILD_HASH="${BUILD_HASH}" + # -DBUILD_BRANCH="${BUILD_BRANCH}" -DWITH_BUILDINFO_HEADER # alternative to lines above -DBUILD_PLATFORM="${CMAKE_SYSTEM_NAME}" -DBUILD_TYPE="${CMAKE_BUILD_TYPE}" diff --git a/source/creator/buildinfo.c b/source/creator/buildinfo.c index d747fe8e1ff..d51249980a8 100644 --- a/source/creator/buildinfo.c +++ b/source/creator/buildinfo.c @@ -39,7 +39,9 @@ /* currently only these are defined in the header */ char build_date[] = BUILD_DATE; char build_time[] = BUILD_TIME; -char build_rev[] = BUILD_REV; +char build_hash[] = BUILD_HASH; +char build_change[] = BUILD_CHANGE; +char build_branch[] = BUILD_BRANCH; char build_platform[] = BUILD_PLATFORM; char build_type[] = BUILD_TYPE; diff --git a/source/creator/creator.c b/source/creator/creator.c index 54fc80984f3..8221552a1d7 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -153,7 +153,9 @@ #ifdef BUILD_DATE extern char build_date[]; extern char build_time[]; -extern char build_rev[]; +extern char build_hash[]; +extern char build_change[]; +extern char build_branch[]; extern char build_platform[]; extern char build_type[]; extern char build_cflags[]; @@ -219,7 +221,14 @@ static int print_version(int UNUSED(argc), const char **UNUSED(argv), void *UNUS #ifdef BUILD_DATE printf("\tbuild date: %s\n", build_date); printf("\tbuild time: %s\n", build_time); - printf("\tbuild revision: %s\n", build_rev); + /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ + if (build_hash[0] != '\0') { + printf("\tbuild revision: %s\n", build_change); + } + else { + printf("\tbuild change: %s\n", build_change); + printf("\tbuild hash: %s\n", build_hash); + } printf("\tbuild platform: %s\n", build_platform); printf("\tbuild type: %s\n", build_type); printf("\tbuild c flags: %s\n", build_cflags); @@ -590,13 +599,17 @@ static void blender_crash_handler(int signum) printf("Writing: %s\n", fname); fflush(stdout); - BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Revision: %s\n", BLEND_VERSION_ARG, -#ifdef BUILD_DATE - build_rev +#ifndef BUILD_DATE + BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Unknown revision\n", BLEND_VERSION_ARG); #else - "Unknown" + /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ + if (build_hash[0] != '\0') { + BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Change: %s, Hash %s\n", BLEND_VERSION_ARG, build_change, build_hash); + } + else { + BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Revision: %s\n", BLEND_VERSION_ARG, build_change); + } #endif - ); /* open the crash log */ errno = 0; -- cgit v1.2.3 From 13caf5cc14a6ecb38653a8b254c8f36bb2355a4c Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Mon, 4 Nov 2013 17:02:01 +0000 Subject: bullet: Remove patch applied upstream --- extern/bullet2/patches/ghost_softbody.patch | 42 ----------------------------- extern/bullet2/readme.txt | 3 --- 2 files changed, 45 deletions(-) delete mode 100644 extern/bullet2/patches/ghost_softbody.patch diff --git a/extern/bullet2/patches/ghost_softbody.patch b/extern/bullet2/patches/ghost_softbody.patch deleted file mode 100644 index b150d57040d..00000000000 --- a/extern/bullet2/patches/ghost_softbody.patch +++ /dev/null @@ -1,42 +0,0 @@ -Index: extern/bullet2/src/BulletSoftBody/btSoftBody.cpp -=================================================================== ---- extern/bullet2/src/BulletSoftBody/btSoftBody.cpp (Revision 43904) -+++ extern/bullet2/src/BulletSoftBody/btSoftBody.cpp (Revision 43905) -@@ -2780,21 +2780,23 @@ - { - const RContact& c = psb->m_rcontacts[i]; - const sCti& cti = c.m_cti; -- btRigidBody* tmpRigid = btRigidBody::upcast(cti.m_colObj); - -- const btVector3 va = tmpRigid ? tmpRigid->getVelocityInLocalPoint(c.m_c1)*dt : btVector3(0,0,0); -- const btVector3 vb = c.m_node->m_x-c.m_node->m_q; -- const btVector3 vr = vb-va; -- const btScalar dn = btDot(vr, cti.m_normal); -- if(dn<=SIMD_EPSILON) -- { -- const btScalar dp = btMin( (btDot(c.m_node->m_x, cti.m_normal) + cti.m_offset), mrg ); -- const btVector3 fv = vr - (cti.m_normal * dn); -- // c0 is the impulse matrix, c3 is 1 - the friction coefficient or 0, c4 is the contact hardness coefficient -- const btVector3 impulse = c.m_c0 * ( (vr - (fv * c.m_c3) + (cti.m_normal * (dp * c.m_c4))) * kst ); -- c.m_node->m_x -= impulse * c.m_c2; -- if (tmpRigid) -- tmpRigid->applyImpulse(impulse,c.m_c1); -+ if (cti.m_colObj->hasContactResponse()) { -+ btRigidBody* tmpRigid = btRigidBody::upcast(cti.m_colObj); -+ const btVector3 va = tmpRigid ? tmpRigid->getVelocityInLocalPoint(c.m_c1)*dt : btVector3(0,0,0); -+ const btVector3 vb = c.m_node->m_x-c.m_node->m_q; -+ const btVector3 vr = vb-va; -+ const btScalar dn = btDot(vr, cti.m_normal); -+ if(dn<=SIMD_EPSILON) -+ { -+ const btScalar dp = btMin( (btDot(c.m_node->m_x, cti.m_normal) + cti.m_offset), mrg ); -+ const btVector3 fv = vr - (cti.m_normal * dn); -+ // c0 is the impulse matrix, c3 is 1 - the friction coefficient or 0, c4 is the contact hardness coefficient -+ const btVector3 impulse = c.m_c0 * ( (vr - (fv * c.m_c3) + (cti.m_normal * (dp * c.m_c4))) * kst ); -+ c.m_node->m_x -= impulse * c.m_c2; -+ if (tmpRigid) -+ tmpRigid->applyImpulse(impulse,c.m_c1); -+ } - } - } - } diff --git a/extern/bullet2/readme.txt b/extern/bullet2/readme.txt index 33430fc8ee3..3c09dad1fbf 100644 --- a/extern/bullet2/readme.txt +++ b/extern/bullet2/readme.txt @@ -4,8 +4,5 @@ Questions? mail blender at erwincoumans.com, or check the bf-blender mailing lis Thanks, Erwin -Apply patches/ghost_softbody.patch to prevent softbodies being hit by ghost objects. -Originally committed in blender svn revision: 43905. - Apply patches/convex_hull.patch to add access to the convex hull operation, used in the BMesh convex hull operator. -- cgit v1.2.3 From 84daa5718856ed293fd38d138765d07b203c623c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 4 Nov 2013 18:26:56 +0000 Subject: Update i18n tools for new build_hash... --- release/scripts/modules/bl_i18n_utils/bl_extract_messages.py | 4 ++-- release/scripts/modules/bl_i18n_utils/settings.py | 2 +- release/scripts/modules/bl_i18n_utils/utils.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py index e9ed9a8de5b..429fea60d7a 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -791,10 +791,10 @@ def dump_src_messages(msgs, reports, settings): ##### Main functions! ##### def dump_messages(do_messages, do_checks, settings): bl_ver = "Blender " + bpy.app.version_string - bl_rev = bpy.app.build_revision + bl_hash = bpy.app.build_hash or b'0000000000000000000000000000000000000000' bl_date = datetime.datetime.strptime(bpy.app.build_date.decode() + "T" + bpy.app.build_time.decode(), "%Y-%m-%dT%H:%M:%S") - pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, bl_ver, bl_rev, bl_date, bl_date.year, + pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, bl_ver, bl_hash, bl_date, bl_date.year, settings=settings) msgs = pot.msgs diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index dba5099607c..300cd7ae955 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -146,7 +146,7 @@ PO_MSGSTR = "msgstr " PO_HEADER_KEY = (DEFAULT_CONTEXT, "") PO_HEADER_MSGSTR = ( - "Project-Id-Version: {blender_ver} (r{blender_rev})\\n\n" + "Project-Id-Version: {blender_ver} ({blender_hash})\\n\n" "Report-Msgid-Bugs-To: \\n\n" "POT-Creation-Date: {time}\\n\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\n" diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index feefd14fd28..53146fd0287 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -408,10 +408,10 @@ class I18nMessages: return getattr(collections, 'OrderedDict', dict)() @classmethod - def gen_empty_messages(cls, uid, blender_ver, blender_rev, time, year, default_copyright=True, settings=settings): + def gen_empty_messages(cls, uid, blender_ver, blender_hash, time, year, default_copyright=True, settings=settings): """Generate an empty I18nMessages object (only header is present!).""" fmt = settings.PO_HEADER_MSGSTR - msgstr = fmt.format(blender_ver=str(blender_ver), blender_rev=int(blender_rev), time=str(time), uid=str(uid)) + msgstr = fmt.format(blender_ver=str(blender_ver), blender_hash=blender_hash, time=str(time), uid=str(uid)) comment = "" if default_copyright: comment = settings.PO_HEADER_COMMENT_COPYRIGHT.format(year=str(year)) -- cgit v1.2.3 From 3ccaa9b57328cf6725ba83bab715a734f17c0d78 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Mon, 4 Nov 2013 18:40:45 +0000 Subject: Missing convert button on particle modifier panel. Cache pathcache check should be only on path display mode. --- source/blender/editors/interface/interface_templates.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index c343115be30..11990a5d052 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -967,11 +967,11 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (md->type == eModifierType_ParticleSystem) { ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys; - if (!(ob->mode & OB_MODE_PARTICLE_EDIT) && psys->pathcache) { + if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) { if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB)) uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE, "OBJECT_OT_duplicates_make_real"); - else if (psys->part->ren_as == PART_DRAW_PATH) + else if (psys->part->ren_as == PART_DRAW_PATH && psys->pathcache) uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE, "OBJECT_OT_modifier_convert"); } -- cgit v1.2.3 From f4762eb12ba5474fd883aa29d09bc23f0db5d076 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 4 Nov 2013 18:58:22 +0000 Subject: UI messages fixes... --- source/blender/editors/mesh/editmesh_tools.c | 6 ++++-- source/blender/editors/space_clip/tracking_ops.c | 2 +- source/blender/makesrna/intern/rna_modifier.c | 10 ++++++---- source/blender/makesrna/intern/rna_space.c | 23 ++++++++++++++--------- source/blender/makesrna/intern/rna_tracking.c | 13 ++++++++----- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index b35ed10b157..203907226e3 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3234,8 +3234,10 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_enum(ot->srna, "quad_method", modifier_triangulate_quad_method_items, MOD_TRIANGULATE_QUAD_BEAUTY, "Quad Method", "Method for splitting the quads into triangles"); - RNA_def_enum(ot->srna, "ngon_method", modifier_triangulate_ngon_method_items, MOD_TRIANGULATE_NGON_BEAUTY, "Ngon Method", "Method for splitting the ngons into triangles"); + RNA_def_enum(ot->srna, "quad_method", modifier_triangulate_quad_method_items, MOD_TRIANGULATE_QUAD_BEAUTY, + "Quad Method", "Method for splitting the quads into triangles"); + RNA_def_enum(ot->srna, "ngon_method", modifier_triangulate_ngon_method_items, MOD_TRIANGULATE_NGON_BEAUTY, + "Polygon Method", "Method for splitting the polygons into triangles"); } static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 61a484c8a2a..5607d7dc635 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1423,7 +1423,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS if (sc == NULL) { /* TODO(sergey): Support clip for invoke as well. */ BKE_report(op->reports, RPT_ERROR, - "Invoking this operator only supported from Clip Editor space."); + "Invoking this operator only supported from Clip Editor space"); return OPERATOR_CANCELLED; } diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 276d8e0a678..eee7692e2ed 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -112,13 +112,15 @@ EnumPropertyItem modifier_type_items[] = { EnumPropertyItem modifier_triangulate_quad_method_items[] = { {MOD_TRIANGULATE_QUAD_BEAUTY, "BEAUTY", 0, "Beauty ", "Split the quads in nice triangles, slower method"}, {MOD_TRIANGULATE_QUAD_FIXED, "FIXED", 0, "Fixed", "Split the quads on the first and third vertices"}, - {MOD_TRIANGULATE_QUAD_ALTERNATE, "FIXED_ALTERNATE", 0, "Fixed Alternate", "Split the quads on the 2nd and 4th vertices"}, - {MOD_TRIANGULATE_QUAD_SHORTEDGE, "SHORTEST_DIAGONAL", 0, "Shortest Diagonal", "Split the quads based on the distance between the vertices"}, + {MOD_TRIANGULATE_QUAD_ALTERNATE, "FIXED_ALTERNATE", 0, "Fixed Alternate", + "Split the quads on the 2nd and 4th vertices"}, + {MOD_TRIANGULATE_QUAD_SHORTEDGE, "SHORTEST_DIAGONAL", 0, "Shortest Diagonal", + "Split the quads based on the distance between the vertices"}, {0, NULL, 0, NULL, NULL} }; EnumPropertyItem modifier_triangulate_ngon_method_items[] = { - {MOD_TRIANGULATE_NGON_SCANFILL, "SCANFILL", 0, "Scanfill", "Split the ngons using a scanfill algorithm "}, + {MOD_TRIANGULATE_NGON_SCANFILL, "SCANFILL", 0, "Scanfill", "Split the polygons using a scanfill algorithm"}, {MOD_TRIANGULATE_NGON_BEAUTY, "BEAUTY", 0, "Beauty", "Arrange the new triangles nicely, slower method"}, {0, NULL, 0, NULL, NULL} }; @@ -3523,7 +3525,7 @@ static void rna_def_modifier_triangulate(BlenderRNA *brna) prop = RNA_def_property(srna, "ngon_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ngon_method"); RNA_def_property_enum_items(prop, modifier_triangulate_ngon_method_items); - RNA_def_property_ui_text(prop, "Ngon Method", "Method for splitting the ngons into triangles"); + RNA_def_property_ui_text(prop, "Polygon Method", "Method for splitting the polygons into triangles"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index a99cdda6ff3..07723b34837 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1212,7 +1212,8 @@ static int rna_SpaceNodeEditor_tree_type_poll(void *Cv, bNodeTreeType *type) else return TRUE; } -static EnumPropertyItem *rna_SpaceNodeEditor_tree_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) +static EnumPropertyItem *rna_SpaceNodeEditor_tree_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), int *free) { return rna_node_tree_type_itemf(C, rna_SpaceNodeEditor_tree_type_poll, free); } @@ -1785,8 +1786,8 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "use_render_border", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_RENDER_BORDER); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Render Border", - "Use a region within the frame size for rendered viewport (when not viewing through the camera)"); + RNA_def_property_ui_text(prop, "Render Border", "Use a region within the frame size for rendered viewport " + "(when not viewing through the camera)"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "render_border_min_x", PROP_FLOAT, PROP_NONE); @@ -1832,7 +1833,8 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "viewport_shade", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "drawtype"); RNA_def_property_enum_items(prop, viewport_shade_items); - RNA_def_property_enum_funcs(prop, "rna_SpaceView3D_viewport_shade_get", NULL, "rna_SpaceView3D_viewport_shade_itemf"); + RNA_def_property_enum_funcs(prop, "rna_SpaceView3D_viewport_shade_get", NULL, + "rna_SpaceView3D_viewport_shade_itemf"); RNA_def_property_ui_text(prop, "Viewport Shading", "Method to display/shade objects in the 3D View"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update"); @@ -2884,13 +2886,14 @@ static void rna_def_space_graph(BlenderRNA *brna) /* nromalize curves */ prop = RNA_def_property(srna, "use_normalization", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_NORMALIZE); - RNA_def_property_ui_text(prop, "use Normalization", "Display curves in normalized to -1..1 range, " - "for easier editing of multiple curves with different ranges"); + RNA_def_property_ui_text(prop, "Use Normalization", "Display curves in normalized to -1..1 range, " + "for easier editing of multiple curves with different ranges"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); prop = RNA_def_property(srna, "use_auto_normalization", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NORMALIZE_FREEZE); - RNA_def_property_ui_text(prop, "Auto Normalization", "Automatically recalculate curve normalization on every curve edit"); + RNA_def_property_ui_text(prop, "Auto Normalization", + "Automatically recalculate curve normalization on every curve edit"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); } @@ -3385,7 +3388,8 @@ static void rna_def_space_node(BlenderRNA *brna) prop = RNA_def_property(srna, "tree_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, dummy_items); - RNA_def_property_enum_funcs(prop, "rna_SpaceNodeEditor_tree_type_get", "rna_SpaceNodeEditor_tree_type_set", "rna_SpaceNodeEditor_tree_type_itemf"); + RNA_def_property_enum_funcs(prop, "rna_SpaceNodeEditor_tree_type_get", "rna_SpaceNodeEditor_tree_type_set", + "rna_SpaceNodeEditor_tree_type_itemf"); RNA_def_property_ui_text(prop, "Tree Type", "Node tree type to display and edit"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, NULL); @@ -3417,7 +3421,8 @@ static void rna_def_space_node(BlenderRNA *brna) rna_def_space_node_path_api(brna, prop); prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceNodeEditor_node_tree_set", NULL, "rna_SpaceNodeEditor_node_tree_poll"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceNodeEditor_node_tree_set", NULL, + "rna_SpaceNodeEditor_node_tree_poll"); RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Node Tree", "Base node tree from context"); diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 662673adf77..92d12a3a92c 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -570,7 +570,8 @@ static MovieTrackingTrack *rna_trackingTracks_new(ID *id, MovieTracking *trackin return track; } -static MovieTrackingTrack *rna_trackingObject_tracks_new(ID *id, MovieTrackingObject *object, const char *name, int frame) +static MovieTrackingTrack *rna_trackingObject_tracks_new(ID *id, MovieTrackingObject *object, const char *name, + int frame) { MovieClip *clip = (MovieClip *) id; ListBase *tracksbase = &object->tracks; @@ -649,7 +650,8 @@ static void rna_trackingMarkers_delete_frame(MovieTrackingTrack *track, int fram WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, NULL); } -static MovieTrackingPlaneMarker *rna_trackingPlaneMarkers_find_frame(MovieTrackingPlaneTrack *plane_track, int framenr, int exact) +static MovieTrackingPlaneMarker *rna_trackingPlaneMarkers_find_frame(MovieTrackingPlaneTrack *plane_track, + int framenr, int exact) { if (exact) return BKE_tracking_plane_marker_get_exact(plane_track, framenr); @@ -657,7 +659,8 @@ static MovieTrackingPlaneMarker *rna_trackingPlaneMarkers_find_frame(MovieTracki return BKE_tracking_plane_marker_get(plane_track, framenr); } -static MovieTrackingPlaneMarker *rna_trackingPlaneMarkers_insert_frame(MovieTrackingPlaneTrack *plane_track, int framenr) +static MovieTrackingPlaneMarker *rna_trackingPlaneMarkers_insert_frame(MovieTrackingPlaneTrack *plane_track, + int framenr) { MovieTrackingPlaneMarker plane_marker, *new_plane_marker; @@ -1094,7 +1097,7 @@ static void rna_def_trackingMarker(BlenderRNA *brna) prop = RNA_def_property(srna, "is_keyed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MARKER_TRACKED); - RNA_def_property_ui_text(prop, "Keyframed", "Indicates whether position of marker is keyframed, not tracked"); + RNA_def_property_ui_text(prop, "Keyframed", "Whether the position of the marker is keyframed or tracked"); } static void rna_def_trackingMarkers(BlenderRNA *brna, PropertyRNA *cprop) @@ -1350,7 +1353,7 @@ static void rna_def_trackingTrack(BlenderRNA *brna) prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "weight"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Weight", "How much this track affects on a final solution"); + RNA_def_property_ui_text(prop, "Weight", "Influence of this track on a final solution"); } static void rna_def_trackingPlaneMarker(BlenderRNA *brna) -- cgit v1.2.3 From cf9fe8f329cee363439c90a3b86dc99e25377088 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:21:07 +0000 Subject: BGE Rasterizer Cleanup: Removing RAS_IRenderTools and moving the functionality to RAS_IRasterizer. RAS_OpenGLRasterizer is a bit of a mess now with references to Ketsji and other modules it shouldn't be accessing. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 12 +- source/gameengine/BlenderRoutines/CMakeLists.txt | 2 - source/gameengine/BlenderRoutines/KX_BlenderGL.cpp | 163 ------ source/gameengine/BlenderRoutines/KX_BlenderGL.h | 5 - .../BlenderRoutines/KX_BlenderRenderTools.cpp | 410 --------------- .../BlenderRoutines/KX_BlenderRenderTools.h | 122 ----- .../Converter/BL_BlenderDataConversion.cpp | 9 +- .../Converter/BL_BlenderDataConversion.h | 2 +- .../Converter/KX_BlenderSceneConverter.cpp | 2 +- .../Converter/KX_BlenderSceneConverter.h | 2 +- source/gameengine/GamePlayer/common/CMakeLists.txt | 2 - .../GamePlayer/common/GPC_RenderTools.cpp | 577 --------------------- .../gameengine/GamePlayer/common/GPC_RenderTools.h | 115 ---- .../GamePlayer/ghost/GPG_Application.cpp | 18 +- .../gameengine/GamePlayer/ghost/GPG_Application.h | 3 - source/gameengine/Ketsji/KX_Dome.cpp | 5 +- source/gameengine/Ketsji/KX_Dome.h | 3 - source/gameengine/Ketsji/KX_FontObject.cpp | 8 +- source/gameengine/Ketsji/KX_FontObject.h | 6 +- source/gameengine/Ketsji/KX_ISceneConverter.h | 2 +- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 59 +-- source/gameengine/Ketsji/KX_KetsjiEngine.h | 3 - source/gameengine/Ketsji/KX_Light.cpp | 11 +- source/gameengine/Ketsji/KX_Light.h | 10 +- source/gameengine/Ketsji/KX_Scene.cpp | 5 +- source/gameengine/Ketsji/KX_Scene.h | 3 +- source/gameengine/Rasterizer/CMakeLists.txt | 2 - source/gameengine/Rasterizer/RAS_BucketManager.cpp | 38 +- source/gameengine/Rasterizer/RAS_BucketManager.h | 11 +- source/gameengine/Rasterizer/RAS_IRasterizer.h | 93 +++- source/gameengine/Rasterizer/RAS_IRenderTools.cpp | 59 --- source/gameengine/Rasterizer/RAS_IRenderTools.h | 227 -------- .../gameengine/Rasterizer/RAS_MaterialBucket.cpp | 17 +- source/gameengine/Rasterizer/RAS_MaterialBucket.h | 6 +- .../Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt | 6 + .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 506 +++++++++++++++++- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 74 ++- source/gameengine/VideoTexture/ImageRender.cpp | 7 +- source/gameengine/VideoTexture/ImageRender.h | 3 - 39 files changed, 756 insertions(+), 1852 deletions(-) delete mode 100644 source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp delete mode 100644 source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h delete mode 100644 source/gameengine/GamePlayer/common/GPC_RenderTools.cpp delete mode 100644 source/gameengine/GamePlayer/common/GPC_RenderTools.h delete mode 100644 source/gameengine/Rasterizer/RAS_IRenderTools.cpp delete mode 100644 source/gameengine/Rasterizer/RAS_IRenderTools.h diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 484e51c4ed1..5479a5e7a6e 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -46,7 +46,6 @@ #include "KX_BlenderCanvas.h" #include "KX_BlenderKeyboardDevice.h" #include "KX_BlenderMouseDevice.h" -#include "KX_BlenderRenderTools.h" #include "KX_BlenderSystem.h" #include "BL_Material.h" @@ -276,7 +275,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c if (animation_record) usefixed= false; /* override since you don't want to run full-speed for sim recording */ - // create the canvas, rasterizer and rendertools + // create the canvas and rasterizer RAS_ICanvas* canvas = new KX_BlenderCanvas(wm, win, area_rect, ar); // default mouse state set on render panel @@ -292,7 +291,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c else canvas->SetSwapInterval((startscene->gm.vsync == VSYNC_ON) ? 1 : 0); - RAS_IRenderTools* rendertools = new KX_BlenderRenderTools(); RAS_IRasterizer* rasterizer = NULL; //Don't use displaylists with VBOs //If auto starts using VBOs, make sure to check for that here @@ -324,7 +322,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c ketsjiengine->SetMouseDevice(mousedevice); ketsjiengine->SetNetworkDevice(networkdevice); ketsjiengine->SetCanvas(canvas); - ketsjiengine->SetRenderTools(rendertools); ketsjiengine->SetRasterizer(rasterizer); ketsjiengine->SetUseFixedTime(usefixed); ketsjiengine->SetTimingDisplay(frameRate, profile, properties); @@ -518,7 +515,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c // convert and add scene sceneconverter->ConvertScene( startscene, - rendertools, + rasterizer, canvas); ketsjiengine->AddScene(startscene); @@ -664,11 +661,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c delete rasterizer; rasterizer = NULL; } - if (rendertools) - { - delete rendertools; - rendertools = NULL; - } if (canvas) { canvas->SetSwapInterval(previous_vsync); // Set the swap interval back diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index 67739706e3c..1f323a798ce 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -43,7 +43,6 @@ set(SRC KX_BlenderInputDevice.cpp KX_BlenderKeyboardDevice.cpp KX_BlenderMouseDevice.cpp - KX_BlenderRenderTools.cpp KX_BlenderSystem.cpp BL_System.h @@ -52,7 +51,6 @@ set(SRC KX_BlenderInputDevice.h KX_BlenderKeyboardDevice.h KX_BlenderMouseDevice.h - KX_BlenderRenderTools.h KX_BlenderSystem.h ) diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index 6ed4866579c..3770d81f4d5 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -108,169 +108,6 @@ int BL_GetSwapInterval(struct wmWindow *win) return wm_window_get_swap_interval(win); } -static void DisableForText() -{ - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */ - - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - - glDisable(GL_LIGHTING); - glDisable(GL_COLOR_MATERIAL); - - if (GLEW_ARB_multitexture) { - for (int i=0; i(m_clientobject)->GetLayer(); - } - - /* avoid state switching */ - if (m_lastlightlayer == layer && m_lastauxinfo == m_auxilaryClientInfo) - return; - - m_lastlightlayer = layer; - m_lastauxinfo = m_auxilaryClientInfo; - - /* enable/disable lights as needed */ - if (layer >= 0) - enable = applyLights(layer, viewmat); - - if (enable) - EnableOpenGLLights(rasty); - else - DisableOpenGLLights(); -} - -void KX_BlenderRenderTools::EnableOpenGLLights(RAS_IRasterizer *rasty) -{ - if (m_lastlighting == true) - return; - - glEnable(GL_LIGHTING); - glEnable(GL_COLOR_MATERIAL); - - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); - glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (rasty->GetCameraOrtho())? GL_FALSE: GL_TRUE); - if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); - - m_lastlighting = true; -} - -void KX_BlenderRenderTools::DisableOpenGLLights() -{ - if (m_lastlighting == false) - return; - - glDisable(GL_LIGHTING); - glDisable(GL_COLOR_MATERIAL); - - m_lastlighting = false; -} - - -void KX_BlenderRenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj) -{ - if (m_clientobject != obj) - { - bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling()); - rasty->SetFrontFace(ccw); - - m_clientobject = obj; - } -} - -bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void * const data) -{ - double* const oglmatrix = (double* const) data; - - RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon); - if (!poly->IsVisible()) - return false; - - MT_Point3 resultpoint(result->m_hitPoint); - MT_Vector3 resultnormal(result->m_hitNormal); - MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]); - MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized(); - left = (dir.cross(resultnormal)).safe_normalized(); - // for the up vector, we take the 'resultnormal' returned by the physics - - double maat[16] = {left[0], left[1], left[2], 0, - dir[0], dir[1], dir[2], 0, - resultnormal[0], resultnormal[1], resultnormal[2], 0, - 0, 0, 0, 1}; - - glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]); - //glMultMatrixd(oglmatrix); - glMultMatrixd(maat); - return true; -} - -void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode ) -{ - /* FIXME: - blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const - MT_Vector3&, double): Assertion `!MT_fuzzyZero(s)' failed. - - Program received signal SIGABRT, Aborted. - [Switching to Thread 16384 (LWP 1519)] - 0x40477571 in kill () from /lib/libc.so.6 - (gdb) bt - #7 0x08334368 in MT_Vector3::normalized() const () - #8 0x0833e6ec in KX_BlenderRenderTools::applyTransform(RAS_IRasterizer*, double*, int) () - */ - - if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED || - objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED) - { - // rotate the billboard/halo - //page 360/361 3D Game Engine Design, David Eberly for a discussion - // on screen aligned and axis aligned billboards - // assumed is that the preprocessor transformed all billboard polygons - // so that their normal points into the positive x direction (1.0, 0.0, 0.0) - // when new parenting for objects is done, this rotation - // will be moved into the object - - MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]); - MT_Point3 campos = rasty->GetCameraPosition(); - MT_Vector3 dir = (campos - objpos).safe_normalized(); - MT_Vector3 up(0,0,1.0); - - KX_GameObject* gameobj = (KX_GameObject *)this->m_clientobject; - // get scaling of halo object - MT_Vector3 size = gameobj->GetSGNode()->GetWorldScaling(); - - bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned - if (screenaligned) - { - up = (up - up.dot(dir) * dir).safe_normalized(); - } else - { - dir = (dir - up.dot(dir)*up).safe_normalized(); - } - - MT_Vector3 left = dir.normalized(); - dir = (left.cross(up)).normalized(); - - // we have calculated the row vectors, now we keep - // local scaling into account: - - left *= size[0]; - dir *= size[1]; - up *= size[2]; - - double maat[16] = {left[0], left[1], left[2], 0, - dir[0], dir[1], dir[2], 0, - up[0], up[1], up[2], 0, - 0, 0, 0, 1}; - - glTranslated(objpos[0],objpos[1],objpos[2]); - glMultMatrixd(maat); - } - else { - if (objectdrawmode & RAS_IPolyMaterial::SHADOW) - { - // shadow must be cast to the ground, physics system needed here! - MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]); - KX_GameObject *gameobj = (KX_GameObject *)this->m_clientobject; - MT_Vector3 direction = MT_Vector3(0,0,-1); - - direction.normalize(); - direction *= 100000; - - MT_Point3 topoint = frompoint + direction; - - KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo; - PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment(); - KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController(); - - KX_GameObject *parent = gameobj->GetParent(); - if (!physics_controller && parent) - physics_controller = parent->GetPhysicsController(); - if (parent) - parent->Release(); - - KX_RayCast::Callback callback(this, physics_controller, oglmatrix); - if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback)) - { - // couldn't find something to cast the shadow on... - glMultMatrixd(oglmatrix); - } - else - { // we found the "ground", but the cast matrix doesn't take - // scaling in consideration, so we must apply the object scale - MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale(); - glScalef(size[0], size[1], size[2]); - } - } else - { - - // 'normal' object - glMultMatrixd(oglmatrix); - } - } -} - -void KX_BlenderRenderTools::RenderBox2D(int xco, - int yco, - int width, - int height, - float percentage) -{ - BL_draw_gamedebug_box(xco, yco, width, height, percentage); -} - -void KX_BlenderRenderTools::RenderText3D(int fontid, - const char* text, - int size, - int dpi, - float* color, - double* mat, - float aspect) -{ - BL_print_game_line(fontid, text, size, dpi, color, mat, aspect); -} - -void KX_BlenderRenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, - const char* text, - int xco, - int yco, - int width, - int height) -{ - if (mode == RAS_IRenderTools::RAS_TEXT_PADDED) - BL_print_gamedebug_line_padded(text, xco, yco, width, height); - else - BL_print_gamedebug_line(text, xco, yco, width, height); -} - -/* Render Text renders text into a (series of) polygon, using a texture font, - * Each character consists of one polygon (one quad or two triangles) */ - -void KX_BlenderRenderTools::RenderText( - int mode, - RAS_IPolyMaterial* polymat, - float v1[3], float v2[3], float v3[3], float v4[3], int glattrib) -{ - const STR_String &mytext = ((CValue *)m_clientobject)->GetPropertyText("Text"); - - const unsigned int flag = polymat->GetFlag(); - struct MTFace* tface = 0; - unsigned int *col = 0; - - if (flag & RAS_BLENDERMAT) { - KX_BlenderMaterial *bl_mat = static_cast(polymat); - tface = bl_mat->GetMTFace(); - col = bl_mat->GetMCol(); - } else { - KX_PolygonMaterial* blenderpoly = static_cast(polymat); - tface = blenderpoly->GetMTFace(); - col = blenderpoly->GetMCol(); - } - - GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib); -} - - -void KX_BlenderRenderTools::PushMatrix() -{ - glPushMatrix(); -} - -void KX_BlenderRenderTools::PopMatrix() -{ - glPopMatrix(); -} - - -int KX_BlenderRenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) -{ - // taken from blender source, incompatibility between Blender Object / GameObject - KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; - float glviewmat[16]; - unsigned int count; - std::vector::iterator lit = m_lights.begin(); - - for (count=0; countm_light; - - if (kxlight->ApplyLight(kxscene, objectlayer, count)) - count++; - } - glPopMatrix(); - - return count; -} - -void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer) -{ - int state = rasterizer->GetMotionBlurState(); - float motionblurvalue; - if (state) - { - motionblurvalue = rasterizer->GetMotionBlurValue(); - if (state==1) - { - //bugfix:load color buffer into accum buffer for the first time(state=1) - glAccum(GL_LOAD, 1.0); - rasterizer->SetMotionBlurState(2); - } - else if (motionblurvalue >= 0.0f && motionblurvalue <= 1.0f) { - glAccum(GL_MULT, motionblurvalue); - glAccum(GL_ACCUM, 1-motionblurvalue); - glAccum(GL_RETURN, 1.0); - glFlush(); - } - } -} - diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h deleted file mode 100644 index 228763e7d2d..00000000000 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file KX_BlenderRenderTools.h - * \ingroup blroutines - */ - -#ifndef __KX_BLENDERRENDERTOOLS_H__ -#define __KX_BLENDERRENDERTOOLS_H__ - -#ifdef _MSC_VER - /* don't show stl-warnings */ -# pragma warning (disable:4786) -#endif - -#include "RAS_IRenderTools.h" - -#ifdef WITH_CXX_GUARDEDALLOC -#include "MEM_guardedalloc.h" -#endif - -struct KX_ClientObjectInfo; -class KX_RayCast; - -/* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which - * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon) - * text, lighting. - * - * Most of this code is duplicated in GPC_RenderTools, so this should be - * moved to some common location to avoid duplication. */ - -class KX_BlenderRenderTools : public RAS_IRenderTools -{ - int m_lastlightlayer; - bool m_lastlighting; - void *m_lastauxinfo; - static unsigned int m_numgllights; - -public: - KX_BlenderRenderTools(); - virtual ~KX_BlenderRenderTools(); - - void EndFrame(RAS_IRasterizer* rasty); - void BeginFrame(RAS_IRasterizer* rasty); - - void EnableOpenGLLights(RAS_IRasterizer *rasty); - void DisableOpenGLLights(); - void ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat); - - void RenderBox2D(int xco, - int yco, - int width, - int height, - float percentage); - - - void RenderText3D(int fontid, - const char* text, - int size, - int dpi, - float* color, - double* mat, - float aspect); - - void RenderText2D(RAS_TEXT_RENDER_MODE mode, - const char* text, - int xco, - int yco, - int width, - int height); - void RenderText(int mode, - class RAS_IPolyMaterial* polymat, - float v1[3], - float v2[3], - float v3[3], - float v4[3], - int glattrib); - - void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode); - int applyLights(int objectlayer, const MT_Transform& viewmat); - - void PushMatrix(); - void PopMatrix(); - - bool RayHit(KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data); - bool NeedRayCast(KX_ClientObjectInfo*) { return true; } - - virtual void MotionBlur(RAS_IRasterizer* rasterizer); - - virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj); - - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderRenderTools") -#endif -}; - -#endif /* __KX_BLENDERRENDERTOOLS_H__ */ diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index b0555abbea4..7456670fcdb 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -80,7 +80,6 @@ #include "RAS_Polygon.h" #include "RAS_TexVert.h" #include "RAS_BucketManager.h" -#include "RAS_IRenderTools.h" #include "BL_Material.h" #include "KX_BlenderMaterial.h" #include "BL_Texture.h" @@ -1874,7 +1873,7 @@ static void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, -static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRenderTools *rendertools, KX_BlenderSceneConverter *converter) +static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRasterizer *rasterizer, KX_BlenderSceneConverter *converter) { RAS_LightObject lightobj; KX_LightObject *gamelight; @@ -1913,7 +1912,7 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l lightobj.m_type = RAS_LightObject::LIGHT_NORMAL; } - gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, + gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rasterizer, lightobj, glslmat); return gamelight; @@ -1934,7 +1933,7 @@ static KX_Camera *gamecamera_from_bcamera(Object *ob, KX_Scene *kxscene, KX_Blen static KX_GameObject *gameobject_from_blenderobject( Object *ob, KX_Scene *kxscene, - RAS_IRenderTools *rendertools, + RAS_IRasterizer *rendertools, KX_BlenderSceneConverter *converter, bool libloading) { @@ -2359,7 +2358,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, KX_Scene* kxscene, KX_KetsjiEngine* ketsjiEngine, e_PhysicsEngine physics_engine, - RAS_IRenderTools* rendertools, + RAS_IRasterizer* rendertools, RAS_ICanvas* canvas, KX_BlenderSceneConverter* converter, bool alwaysUseExpandFraming, diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.h b/source/gameengine/Converter/BL_BlenderDataConversion.h index f3a680929fb..6bd77954b88 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.h +++ b/source/gameengine/Converter/BL_BlenderDataConversion.h @@ -44,7 +44,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, class KX_Scene* kxscene, class KX_KetsjiEngine* ketsjiEngine, e_PhysicsEngine physics_engine, - class RAS_IRenderTools* rendertools, + class RAS_IRasterizer* rendertools, class RAS_ICanvas* canvas, class KX_BlenderSceneConverter* sceneconverter, bool alwaysUseExpandFraming, diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 98af99825e1..05a2c344c1a 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -313,7 +313,7 @@ struct BlenderDebugDraw : public btIDebugDraw #endif void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene, - class RAS_IRenderTools* rendertools, + class RAS_IRasterizer* rendertools, class RAS_ICanvas* canvas, bool libloading) { diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index 7ed75ad7614..3ae90301553 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -111,7 +111,7 @@ public: */ virtual void ConvertScene( class KX_Scene* destinationscene, - class RAS_IRenderTools* rendertools, + class RAS_IRasterizer* rendertools, class RAS_ICanvas* canvas, bool libloading=false ); diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt index 4f2531cec2a..2fc4df86332 100644 --- a/source/gameengine/GamePlayer/common/CMakeLists.txt +++ b/source/gameengine/GamePlayer/common/CMakeLists.txt @@ -63,12 +63,10 @@ set(SRC GPC_Canvas.cpp GPC_KeyboardDevice.cpp GPC_MouseDevice.cpp - GPC_RenderTools.cpp GPC_Canvas.h GPC_KeyboardDevice.h GPC_MouseDevice.h - GPC_RenderTools.h ) add_definitions(-DGLEW_STATIC) diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp deleted file mode 100644 index 0d851c4f10d..00000000000 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ /dev/null @@ -1,577 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file gameengine/GamePlayer/common/GPC_RenderTools.cpp - * \ingroup player - */ - - -#include "GL/glew.h" - -#include "RAS_IRenderTools.h" -#include "RAS_IRasterizer.h" -#include "RAS_LightObject.h" -#include "RAS_ICanvas.h" -#include "RAS_GLExtensionManager.h" -#include "RAS_MeshObject.h" - -#include "KX_GameObject.h" -#include "KX_PolygonMaterial.h" -#include "KX_BlenderMaterial.h" -#include "KX_RayCast.h" -#include "KX_IPhysicsController.h" -#include "KX_Light.h" - -#include "PHY_IPhysicsEnvironment.h" - -#include "STR_String.h" - -#include "GPU_draw.h" - -#include "BKE_bmfont.h" // for text printing -#include "BKE_bmfont_types.h" - -#include "GPC_RenderTools.h" - -extern "C" { -#include "BLF_api.h" -} - - -unsigned int GPC_RenderTools::m_numgllights; - -GPC_RenderTools::GPC_RenderTools() -{ - glGetIntegerv(GL_MAX_LIGHTS, (GLint *) &m_numgllights); - if (m_numgllights < 8) - m_numgllights = 8; -} - -GPC_RenderTools::~GPC_RenderTools() -{ -} - -void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty) -{ - m_clientobject = NULL; - m_lastlightlayer = -1; - m_lastauxinfo = NULL; - m_lastlighting = true; /* force disable in DisableOpenGLLights() */ - DisableOpenGLLights(); -} - -void GPC_RenderTools::EndFrame(RAS_IRasterizer* rasty) -{ -} - -/* ProcessLighting performs lighting on objects. the layer is a bitfield that - * contains layer information. There are 20 'official' layers in blender. A - * light is applied on an object only when they are in the same layer. OpenGL - * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in - * a scene. */ - -void GPC_RenderTools::ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat) -{ - bool enable = false; - int layer= -1; - - /* find the layer */ - if (uselights) { - if (m_clientobject) - layer = static_cast(m_clientobject)->GetLayer(); - } - - /* avoid state switching */ - if (m_lastlightlayer == layer && m_lastauxinfo == m_auxilaryClientInfo) - return; - - m_lastlightlayer = layer; - m_lastauxinfo = m_auxilaryClientInfo; - - /* enable/disable lights as needed */ - if (layer >= 0) - enable = applyLights(layer, viewmat); - - if (enable) - EnableOpenGLLights(rasty); - else - DisableOpenGLLights(); -} - -void GPC_RenderTools::EnableOpenGLLights(RAS_IRasterizer *rasty) -{ - if (m_lastlighting == true) - return; - - glEnable(GL_LIGHTING); - glEnable(GL_COLOR_MATERIAL); - - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); - glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (rasty->GetCameraOrtho())? GL_FALSE: GL_TRUE); - if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); - - m_lastlighting = true; -} - -void GPC_RenderTools::DisableOpenGLLights() -{ - if (m_lastlighting == false) - return; - - glDisable(GL_LIGHTING); - glDisable(GL_COLOR_MATERIAL); - - m_lastlighting = false; -} - - -void GPC_RenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj) -{ - if (m_clientobject != obj) - { - bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling()); - rasty->SetFrontFace(ccw); - - m_clientobject = obj; - } -} - -bool GPC_RenderTools::RayHit(KX_ClientObjectInfo *client, KX_RayCast *result, void * const data) -{ - double* const oglmatrix = (double* const) data; - - RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon); - if (!poly->IsVisible()) - return false; - - MT_Point3 resultpoint(result->m_hitPoint); - MT_Vector3 resultnormal(result->m_hitNormal); - MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]); - MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized(); - left = (dir.cross(resultnormal)).safe_normalized(); - // for the up vector, we take the 'resultnormal' returned by the physics - - double maat[16] = {left[0], left[1], left[2], 0, - dir[0], dir[1], dir[2], 0, - resultnormal[0], resultnormal[1], resultnormal[2], 0, - 0, 0, 0, 1}; - - glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]); - //glMultMatrixd(oglmatrix); - glMultMatrixd(maat); - return true; -} - -void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode ) -{ - /* FIXME: - blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const - MT_Vector3&, double): Assertion `!MT_fuzzyZero(s)' failed. - - Program received signal SIGABRT, Aborted. - [Switching to Thread 16384 (LWP 1519)] - 0x40477571 in kill () from /lib/libc.so.6 - (gdb) bt - #7 0x08334368 in MT_Vector3::normalized() const () - #8 0x0833e6ec in GPC_RenderTools::applyTransform(RAS_IRasterizer*, double*, int) () - */ - - if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED || - objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED) - { - // rotate the billboard/halo - //page 360/361 3D Game Engine Design, David Eberly for a discussion - // on screen aligned and axis aligned billboards - // assumed is that the preprocessor transformed all billboard polygons - // so that their normal points into the positive x direction (1.0, 0.0, 0.0) - // when new parenting for objects is done, this rotation - // will be moved into the object - - MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]); - MT_Point3 campos = rasty->GetCameraPosition(); - MT_Vector3 dir = (campos - objpos).safe_normalized(); - MT_Vector3 up(0,0,1.0); - - KX_GameObject* gameobj = (KX_GameObject *)this->m_clientobject; - // get scaling of halo object - MT_Vector3 size = gameobj->GetSGNode()->GetWorldScaling(); - - bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned - if (screenaligned) - { - up = (up - up.dot(dir) * dir).safe_normalized(); - } else - { - dir = (dir - up.dot(dir)*up).safe_normalized(); - } - - MT_Vector3 left = dir.normalized(); - dir = (left.cross(up)).normalized(); - - // we have calculated the row vectors, now we keep - // local scaling into account: - - left *= size[0]; - dir *= size[1]; - up *= size[2]; - - double maat[16] = {left[0], left[1], left[2], 0, - dir[0], dir[1], dir[2], 0, - up[0], up[1], up[2], 0, - 0, 0, 0, 1}; - - glTranslated(objpos[0],objpos[1],objpos[2]); - glMultMatrixd(maat); - } - else { - if (objectdrawmode & RAS_IPolyMaterial::SHADOW) - { - // shadow must be cast to the ground, physics system needed here! - MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]); - KX_GameObject *gameobj = (KX_GameObject *)this->m_clientobject; - MT_Vector3 direction = MT_Vector3(0,0,-1); - - direction.normalize(); - direction *= 100000; - - MT_Point3 topoint = frompoint + direction; - - KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo; - PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment(); - KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController(); - - KX_GameObject *parent = gameobj->GetParent(); - if (!physics_controller && parent) - physics_controller = parent->GetPhysicsController(); - if (parent) - parent->Release(); - - KX_RayCast::Callback callback(this, physics_controller, oglmatrix); - if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback)) - { - // couldn't find something to cast the shadow on... - glMultMatrixd(oglmatrix); - } - else - { // we found the "ground", but the cast matrix doesn't take - // scaling in consideration, so we must apply the object scale - MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale(); - glScalef(size[0], size[1], size[2]); - } - } else - { - - // 'normal' object - glMultMatrixd(oglmatrix); - } - } -} - -void GPC_RenderTools::RenderBox2D(int xco, - int yco, - int width, - int height, - float percentage) -{ - // Save and change OpenGL settings - int texture2D; - glGetIntegerv(GL_TEXTURE_2D, (GLint*)&texture2D); - glDisable(GL_TEXTURE_2D); - int fog; - glGetIntegerv(GL_FOG, (GLint*)&fog); - glDisable(GL_FOG); - - int light; - glGetIntegerv(GL_LIGHTING, (GLint*)&light); - glDisable(GL_LIGHTING); - - glDisable(GL_DEPTH_TEST); - - // Set up viewing settings - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(0, width, 0, height, -1, 1); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - yco = height - yco; - int barsize = 50; - - // draw in black first - glColor3ub(0, 0, 0); - glBegin(GL_QUADS); - glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1 + 10); - glVertex2f(xco + 1, yco - 1 + 10); - glVertex2f(xco + 1, yco - 1); - glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1); - glEnd(); - - glColor3ub(255, 255, 255); - glBegin(GL_QUADS); - glVertex2f(xco + 1 + barsize * percentage, yco + 10); - glVertex2f(xco, yco + 10); - glVertex2f(xco, yco); - glVertex2f(xco + 1 + barsize * percentage, yco); - glEnd(); - - // Restore view settings - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - // Restore OpenGL Settings - if (fog) - glEnable(GL_FOG); - else - glDisable(GL_FOG); - - if (texture2D) - glEnable(GL_TEXTURE_2D); - else - glDisable(GL_TEXTURE_2D); - if (light) - glEnable(GL_LIGHTING); - else - glDisable(GL_LIGHTING); -} - - -void GPC_RenderTools::RenderText3D( int fontid, - const char* text, - int size, - int dpi, - float* color, - double* mat, - float aspect) -{ - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */ - - if (GLEW_ARB_multitexture) { - for (int i=0; iGetPropertyText("Text"); - - const unsigned int flag = polymat->GetFlag(); - struct MTFace* tface = 0; - unsigned int *col = 0; - - if (flag & RAS_BLENDERMAT) { - KX_BlenderMaterial *bl_mat = static_cast(polymat); - tface = bl_mat->GetMTFace(); - col = bl_mat->GetMCol(); - } else { - KX_PolygonMaterial* blenderpoly = static_cast(polymat); - tface = blenderpoly->GetMTFace(); - col = blenderpoly->GetMCol(); - } - - GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib); -} - - -void GPC_RenderTools::PushMatrix() -{ - glPushMatrix(); -} - -void GPC_RenderTools::PopMatrix() -{ - glPopMatrix(); -} - - -int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) -{ - // taken from blender source, incompatibility between Blender Object / GameObject - KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; - float glviewmat[16]; - unsigned int count; - std::vector::iterator lit = m_lights.begin(); - - for (count=0; countm_light; - - if (kxlight->ApplyLight(kxscene, objectlayer, count)) - count++; - } - glPopMatrix(); - - return count; -} - -void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer) -{ - int state = rasterizer->GetMotionBlurState(); - float motionblurvalue; - if (state) - { - motionblurvalue = rasterizer->GetMotionBlurValue(); - if (state==1) - { - //bugfix:load color buffer into accum buffer for the first time(state=1) - glAccum(GL_LOAD, 1.0); - rasterizer->SetMotionBlurState(2); - } - else if (motionblurvalue >= 0.0f && motionblurvalue <= 1.0f) { - glAccum(GL_MULT, motionblurvalue); - glAccum(GL_ACCUM, 1-motionblurvalue); - glAccum(GL_RETURN, 1.0); - glFlush(); - } - } -} - diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h deleted file mode 100644 index f4dcddd3250..00000000000 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file GPC_RenderTools.h - * \ingroup player - */ - -#ifndef __GPC_RENDERTOOLS_H__ -#define __GPC_RENDERTOOLS_H__ - -#ifdef WIN32 -// don't show stl-warnings -#pragma warning (disable:4786) -#include -#endif /* WIN32 */ - -#include "RAS_IRenderTools.h" - -struct KX_ClientObjectInfo; -class KX_RayCast; - -/* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which - * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon) - * text, lighting. - * - * Most of this code is duplicated in KX_BlenderRenderTools, so this should be - * moved to some common location to avoid duplication. */ - -class GPC_RenderTools : public RAS_IRenderTools -{ - int m_lastlightlayer; - bool m_lastlighting; - void *m_lastauxinfo; - static unsigned int m_numgllights; - -// XXX BMF_Font* m_font; - -public: - GPC_RenderTools(); - virtual ~GPC_RenderTools(); - - void EndFrame(RAS_IRasterizer* rasty); - void BeginFrame(RAS_IRasterizer* rasty); - - void EnableOpenGLLights(RAS_IRasterizer *rasty); - void DisableOpenGLLights(); - void ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat); - - void RenderBox2D(int xco, - int yco, - int width, - int height, - float percentage); - - void RenderText3D(int fontid, - const char* text, - int size, - int dpi, - float* color, - double* mat, - float aspect); - /* \attention mode is ignored here */ - void RenderText2D(RAS_TEXT_RENDER_MODE mode, - const char* text, - int xco, - int yco, - int width, - int height); - void RenderText(int mode, - class RAS_IPolyMaterial* polymat, - float v1[3], - float v2[3], - float v3[3], - float v4[3], - int glattrib); - - void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode); - int applyLights(int objectlayer, const MT_Transform& viewmat); - - void PushMatrix(); - void PopMatrix(); - - bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); - bool NeedRayCast(KX_ClientObjectInfo* client) { return true; } - - virtual void MotionBlur(RAS_IRasterizer* rasterizer); - - virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj); -}; - -#endif /* __GPC_RENDERTOOLS_H__ */ diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index c74e3daf7b2..d8eb224d5f7 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -86,7 +86,6 @@ extern "C" #include "NG_LoopBackNetworkDeviceInterface.h" #include "GPC_MouseDevice.h" -#include "GPC_RenderTools.h" #include "GPG_Canvas.h" #include "GPG_KeyboardDevice.h" #include "GPG_System.h" @@ -126,8 +125,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) m_kxsystem(0), m_keyboard(0), m_mouse(0), - m_canvas(0), - m_rendertools(0), + m_canvas(0), m_rasterizer(0), m_sceneconverter(0), m_networkdevice(0), @@ -591,10 +589,6 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) m_canvas->Init(); if (gm->flag & GAME_SHOW_MOUSE) m_canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); - - m_rendertools = new GPC_RenderTools(); - if (!m_rendertools) - goto initFailed; //Don't use displaylists with VBOs //If auto starts using VBOs, make sure to check for that here @@ -639,7 +633,6 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) m_ketsjiengine->SetMouseDevice(m_mouse); m_ketsjiengine->SetNetworkDevice(m_networkdevice); m_ketsjiengine->SetCanvas(m_canvas); - m_ketsjiengine->SetRenderTools(m_rendertools); m_ketsjiengine->SetRasterizer(m_rasterizer); KX_KetsjiEngine::SetExitKey(ConvertKeyCode(gm->exitkey)); @@ -667,10 +660,8 @@ initFailed: delete m_mouse; delete m_keyboard; delete m_rasterizer; - delete m_rendertools; delete m_canvas; m_canvas = NULL; - m_rendertools = NULL; m_rasterizer = NULL; m_keyboard = NULL; m_mouse = NULL; @@ -752,7 +743,7 @@ bool GPG_Application::startEngine(void) #endif m_sceneconverter->ConvertScene( startscene, - m_rendertools, + m_rasterizer, m_canvas); m_ketsjiengine->AddScene(startscene); @@ -870,11 +861,6 @@ void GPG_Application::exitEngine() delete m_rasterizer; m_rasterizer = 0; } - if (m_rendertools) - { - delete m_rendertools; - m_rendertools = 0; - } if (m_canvas) { delete m_canvas; diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index f141443e738..2d21b50e664 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -48,7 +48,6 @@ class GHOST_ISystem; class GHOST_ITimerTask; class GHOST_IWindow; class GPC_MouseDevice; -class GPC_RenderTools; class GPG_Canvas; class GPG_KeyboardDevice; class GPG_System; @@ -151,8 +150,6 @@ protected: GPC_MouseDevice* m_mouse; /** The game engine's canvas abstraction. */ GPG_Canvas* m_canvas; - /** The game engine's platform dependent render tools. */ - GPC_RenderTools* m_rendertools; /** the rasterizer */ RAS_IRasterizer* m_rasterizer; /** Converts Blender data files. */ diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 85fa0b2b3ce..f87d4799abc 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -48,8 +48,6 @@ KX_Dome::KX_Dome ( RAS_ICanvas* canvas, /// rasterizer RAS_IRasterizer* rasterizer, - /// render tools - RAS_IRenderTools* rendertools, /// engine KX_KetsjiEngine* engine, @@ -71,7 +69,6 @@ KX_Dome::KX_Dome ( m_tilt(tilt), m_canvas(canvas), m_rasterizer(rasterizer), - m_rendertools(rendertools), m_engine(engine) { warp.usemesh = false; @@ -2047,6 +2044,6 @@ void KX_Dome::RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i) cam->NodeUpdateGS(0.f); scene->CalculateVisibleMeshes(m_rasterizer,cam); - scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools); + scene->RenderBuckets(camtrans, m_rasterizer); } diff --git a/source/gameengine/Ketsji/KX_Dome.h b/source/gameengine/Ketsji/KX_Dome.h index 3bc90bf6c35..a7e798a3944 100644 --- a/source/gameengine/Ketsji/KX_Dome.h +++ b/source/gameengine/Ketsji/KX_Dome.h @@ -36,7 +36,6 @@ #include "DNA_screen_types.h" #include "RAS_ICanvas.h" #include "RAS_IRasterizer.h" -#include "RAS_IRenderTools.h" #include "KX_KetsjiEngine.h" #include "GL/glew.h" @@ -62,8 +61,6 @@ public: KX_Dome (RAS_ICanvas* m_canvas, /// rasterizer RAS_IRasterizer* m_rasterizer, - /// render tools - RAS_IRenderTools* m_rendertools, /// engine KX_KetsjiEngine* m_engine, diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index c6d1041a12a..a0266a54411 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -31,10 +31,12 @@ #include "KX_FontObject.h" #include "DNA_curve_types.h" +#include "DNA_vfont_types.h" #include "KX_Scene.h" #include "KX_PythonInit.h" #include "BLI_math.h" #include "StringValue.h" +#include "RAS_IRasterizer.h" /* paths needed for font load */ #include "BLI_blenlib.h" @@ -75,14 +77,14 @@ static std::vector split_string(STR_String str) KX_FontObject::KX_FontObject(void* sgReplicationInfo, SG_Callbacks callbacks, - RAS_IRenderTools* rendertools, + RAS_IRasterizer* rasterizer, Object *ob, bool do_color_management): KX_GameObject(sgReplicationInfo, callbacks), m_object(ob), m_dpi(72), m_resolution(1.f), - m_rendertools(rendertools), + m_rasterizer(rasterizer), m_do_color_management(do_color_management) { Curve *text = static_cast (ob->data); @@ -212,7 +214,7 @@ void KX_FontObject::DrawText() mat[13] -= spacing[1]; mat[14] -= spacing[2]; } - m_rendertools->RenderText3D(m_fontid, m_text[i], int(size), m_dpi, color, mat, aspect); + m_rasterizer->RenderText3D(m_fontid, m_text[i], int(size), m_dpi, color, mat, aspect); } } diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h index 3d8c1d99dcc..8b66accb797 100644 --- a/source/gameengine/Ketsji/KX_FontObject.h +++ b/source/gameengine/Ketsji/KX_FontObject.h @@ -32,8 +32,6 @@ #ifndef __KX_FONTOBJECT_H__ #define __KX_FONTOBJECT_H__ #include "KX_GameObject.h" -#include "DNA_vfont_types.h" -#include "RAS_IRenderTools.h" class KX_FontObject : public KX_GameObject { @@ -41,7 +39,7 @@ public: Py_Header KX_FontObject(void* sgReplicationInfo, SG_Callbacks callbacks, - RAS_IRenderTools* rendertools, + RAS_IRasterizer* rasterizer, Object *ob, bool do_color_management); @@ -68,7 +66,7 @@ protected: float m_line_spacing; MT_Vector3 m_offset; - class RAS_IRenderTools* m_rendertools; //needed for drawing routine + class RAS_IRasterizer* m_rasterizer; //needed for drawing routine bool m_do_color_management; diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h index 616895a8269..a07d4b2195c 100644 --- a/source/gameengine/Ketsji/KX_ISceneConverter.h +++ b/source/gameengine/Ketsji/KX_ISceneConverter.h @@ -56,7 +56,7 @@ public: */ virtual void ConvertScene( class KX_Scene* destinationscene, - class RAS_IRenderTools* rendertools, + class RAS_IRasterizer* rendertools, class RAS_ICanvas* canvas, bool libloading=false)=0; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index c685dcfe068..48ef8cdd50d 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -48,7 +48,6 @@ #include "RAS_BucketManager.h" #include "RAS_Rect.h" #include "RAS_IRasterizer.h" -#include "RAS_IRenderTools.h" #include "RAS_ICanvas.h" #include "MT_Vector3.h" #include "MT_Transform.h" @@ -121,7 +120,6 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) : m_canvas(NULL), m_rasterizer(NULL), m_kxsystem(system), - m_rendertools(NULL), m_sceneconverter(NULL), m_networkdevice(NULL), #ifdef WITH_PYTHON @@ -237,14 +235,6 @@ void KX_KetsjiEngine::SetCanvas(RAS_ICanvas* canvas) -void KX_KetsjiEngine::SetRenderTools(RAS_IRenderTools* rendertools) -{ - MT_assert(rendertools); - m_rendertools = rendertools; -} - - - void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer) { MT_assert(rasterizer); @@ -278,7 +268,7 @@ void KX_KetsjiEngine::SetSceneConverter(KX_ISceneConverter* sceneconverter) void KX_KetsjiEngine::InitDome(short res, short mode, short angle, float resbuf, short tilt, struct Text* text) { - m_dome = new KX_Dome(m_canvas, m_rasterizer, m_rendertools,this, res, mode, angle, resbuf, tilt, text); + m_dome = new KX_Dome(m_canvas, m_rasterizer,this, res, mode, angle, resbuf, tilt, text); m_usedome = true; } @@ -319,7 +309,6 @@ void KX_KetsjiEngine::RenderDome() scene = *sceneit; KX_Camera* cam = scene->GetActiveCamera(); - m_rendertools->BeginFrame(m_rasterizer); // pass the scene's worldsettings to the rasterizer SetWorldSettings(scene->GetWorldInfo()); @@ -333,7 +322,7 @@ void KX_KetsjiEngine::RenderDome() if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); - m_rendertools->SetAuxilaryClientInfo(scene); + m_rasterizer->SetAuxilaryClientInfo(scene); // do the rendering m_dome->RenderDomeFrame(scene,cam, i); @@ -351,7 +340,7 @@ void KX_KetsjiEngine::RenderDome() if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); - m_rendertools->SetAuxilaryClientInfo(scene); + m_rasterizer->SetAuxilaryClientInfo(scene); // do the rendering m_dome->RenderDomeFrame(scene, (*it),i); @@ -362,7 +351,7 @@ void KX_KetsjiEngine::RenderDome() it++; } // Part of PostRenderScene() - m_rendertools->MotionBlur(m_rasterizer); + m_rasterizer->MotionBlur(); scene->Render2DFilters(m_canvas); // no RunDrawingCallBacks // no FlushDebugLines @@ -499,7 +488,6 @@ bool KX_KetsjiEngine::BeginFrame() ClearFrame(); m_rasterizer->BeginFrame(m_drawingmode , m_kxsystem->GetTimeInSeconds()); - m_rendertools->BeginFrame(m_rasterizer); return true; } @@ -510,7 +498,7 @@ bool KX_KetsjiEngine::BeginFrame() void KX_KetsjiEngine::EndFrame() { - m_rendertools->MotionBlur(m_rasterizer); + m_rasterizer->MotionBlur(); // Show profiling info m_logger->StartLog(tc_overhead, m_kxsystem->GetTimeInSeconds(), true); @@ -546,9 +534,6 @@ void KX_KetsjiEngine::EndFrame() m_logger->StartLog(tc_latency, m_kxsystem->GetTimeInSeconds(), true); m_rasterizer->SwapBuffers(); m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true); - - m_rendertools->EndFrame(m_rasterizer); - m_canvas->EndDraw(); } @@ -905,7 +890,7 @@ void KX_KetsjiEngine::Render() if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); - m_rendertools->SetAuxilaryClientInfo(scene); + m_rasterizer->SetAuxilaryClientInfo(scene); // do the rendering RenderFrame(scene, cam); @@ -921,7 +906,7 @@ void KX_KetsjiEngine::Render() if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); - m_rendertools->SetAuxilaryClientInfo(scene); + m_rasterizer->SetAuxilaryClientInfo(scene); // do the rendering RenderFrame(scene, (*it)); @@ -954,7 +939,7 @@ void KX_KetsjiEngine::Render() m_rasterizer->ClearDepthBuffer(); //pass the scene, for picking and raycasting (shadows) - m_rendertools->SetAuxilaryClientInfo(scene); + m_rasterizer->SetAuxilaryClientInfo(scene); // do the rendering //RenderFrame(scene); @@ -970,7 +955,7 @@ void KX_KetsjiEngine::Render() if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); - m_rendertools->SetAuxilaryClientInfo(scene); + m_rasterizer->SetAuxilaryClientInfo(scene); // do the rendering RenderFrame(scene, (*it)); @@ -1172,7 +1157,7 @@ void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene) CListValue *lightlist = scene->GetLightList(); int i, drawmode; - m_rendertools->SetAuxilaryClientInfo(scene); + m_rasterizer->SetAuxilaryClientInfo(scene); for (i=0; iGetCount(); i++) { KX_GameObject *gameobj = (KX_GameObject*)lightlist->GetValue(i); @@ -1202,7 +1187,7 @@ void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene) /* render */ m_rasterizer->ClearDepthBuffer(); m_rasterizer->ClearColorBuffer(); - scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools); + scene->RenderBuckets(camtrans, m_rasterizer); /* unbind framebuffer object, restore drawmode, free camera */ light->UnbindShadowBuffer(m_rasterizer); @@ -1338,7 +1323,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) scene->RunDrawingCallbacks(scene->GetPreDrawCB()); #endif - scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools); + scene->RenderBuckets(camtrans, m_rasterizer); //render all the font objects for this scene scene->RenderFonts(); @@ -1475,7 +1460,7 @@ void KX_KetsjiEngine::RenderDebugProperties() if (m_show_framerate || m_show_profile) { /* Title for profiling("Profile") */ - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, "Profile", xcoord + const_xindent + title_xmargin, // Adds the constant x indent (0 for now) to the title x margin ycoord, @@ -1490,7 +1475,7 @@ void KX_KetsjiEngine::RenderDebugProperties() /* Framerate display */ if (m_show_framerate) { - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, "Frametime :", xcoord + const_xindent, ycoord, @@ -1498,7 +1483,7 @@ void KX_KetsjiEngine::RenderDebugProperties() m_canvas->GetHeight() /* RdV, TODO ?? */); debugtxt.Format("%5.1fms (%.1ffps)", tottime * 1000.f, 1.0/tottime); - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, debugtxt.ReadPtr(), xcoord + const_xindent + profile_indent, ycoord, @@ -1511,7 +1496,7 @@ void KX_KetsjiEngine::RenderDebugProperties() /* Profile display */ if (m_show_profile) { for (int j = tc_first; j < tc_numCategories; j++) { - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, m_profileLabels[j], xcoord + const_xindent, ycoord, @@ -1521,13 +1506,13 @@ void KX_KetsjiEngine::RenderDebugProperties() double time = m_logger->GetAverage((KX_TimeCategory)j); debugtxt.Format("%5.2fms | %d%%", time*1000.f, (int)(time/tottime * 100.f)); - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, debugtxt.ReadPtr(), xcoord + const_xindent + profile_indent, ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); - m_rendertools->RenderBox2D(xcoord + (int)(2.2 * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), time/tottime); + m_rasterizer->RenderBox2D(xcoord + (int)(2.2 * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), time/tottime); ycoord += const_ysize; } } @@ -1538,7 +1523,7 @@ void KX_KetsjiEngine::RenderDebugProperties() if (m_show_debug_properties) { /* Title for debugging("Debug properties") */ - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, "Debug Properties", xcoord + const_xindent + title_xmargin, // Adds the constant x indent (0 for now) to the title x margin ycoord, @@ -1584,7 +1569,7 @@ void KX_KetsjiEngine::RenderDebugProperties() first = false; } } - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, debugtxt.ReadPtr(), xcoord + const_xindent, ycoord, @@ -1597,7 +1582,7 @@ void KX_KetsjiEngine::RenderDebugProperties() if (propval) { STR_String text = propval->GetText(); debugtxt = objname + ": '" + propname + "' = " + text; - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + m_rasterizer->RenderText2D(RAS_IRasterizer::RAS_TEXT_PADDED, debugtxt.ReadPtr(), xcoord + const_xindent, ycoord, @@ -1704,7 +1689,7 @@ KX_Scene* KX_KetsjiEngine::CreateScene(Scene *scene, bool libloading) m_canvas); m_sceneconverter->ConvertScene(tmpscene, - m_rendertools, + m_rasterizer, m_canvas, libloading); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index d5d7262a418..e7fb250c2d9 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -74,7 +74,6 @@ private: class RAS_ICanvas* m_canvas; // 2D Canvas (2D Rendering Device Context) class RAS_IRasterizer* m_rasterizer; // 3D Rasterizer (3D Rendering) class KX_ISystem* m_kxsystem; - class RAS_IRenderTools* m_rendertools; class KX_ISceneConverter* m_sceneconverter; class NG_NetworkDeviceInterface* m_networkdevice; #ifdef WITH_PYTHON @@ -217,7 +216,6 @@ public: void SetMouseDevice(SCA_IInputDevice* mousedevice); void SetNetworkDevice(NG_NetworkDeviceInterface* networkdevice); void SetCanvas(RAS_ICanvas* canvas); - void SetRenderTools(RAS_IRenderTools* rendertools); void SetRasterizer(RAS_IRasterizer* rasterizer); #ifdef WITH_PYTHON void SetPyNamespace(PyObject *pythondictionary); @@ -229,7 +227,6 @@ public: RAS_IRasterizer* GetRasterizer() { return m_rasterizer; } RAS_ICanvas* GetCanvas() { return m_canvas; } - RAS_IRenderTools* GetRenderTools() { return m_rendertools; } SCA_IInputDevice* GetKeyboardDevice() { return m_keyboarddevice; } SCA_IInputDevice* GetMouseDevice() { return m_mousedevice; } diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 0e4db0d351e..1d314c577ca 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -40,7 +40,6 @@ #include "KX_Light.h" #include "KX_Camera.h" #include "RAS_IRasterizer.h" -#include "RAS_IRenderTools.h" #include "KX_PyMath.h" @@ -53,16 +52,16 @@ #include "MEM_guardedalloc.h" KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, - class RAS_IRenderTools* rendertools, + RAS_IRasterizer* rasterizer, const RAS_LightObject& lightobj, bool glsl) : KX_GameObject(sgReplicationInfo,callbacks), - m_rendertools(rendertools) + m_rasterizer(rasterizer) { m_lightobj = lightobj; m_lightobj.m_scene = sgReplicationInfo; m_lightobj.m_light = this; - m_rendertools->AddLight(&m_lightobj); + m_rasterizer->AddLight(&m_lightobj); m_glsl = glsl; m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene(); m_base = NULL; @@ -81,7 +80,7 @@ KX_LightObject::~KX_LightObject() GPU_lamp_update_spot(lamp, la->spotsize, la->spotblend); } - m_rendertools->RemoveLight(&m_lightobj); + m_rasterizer->RemoveLight(&m_lightobj); if (m_base) { BKE_scene_base_unlink(m_blenderscene, m_base); @@ -98,7 +97,7 @@ CValue* KX_LightObject::GetReplica() replica->ProcessReplica(); replica->m_lightobj.m_light = replica; - m_rendertools->AddLight(&replica->m_lightobj); + m_rasterizer->AddLight(&replica->m_lightobj); return replica; } diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index 43421a3faf3..9a81388d43b 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -38,9 +38,9 @@ struct GPULamp; struct Scene; struct Base; +struct RAS_LightObject; class KX_Camera; class RAS_IRasterizer; -class RAS_IRenderTools; class MT_Transform; class KX_LightObject : public KX_GameObject @@ -48,13 +48,13 @@ class KX_LightObject : public KX_GameObject Py_Header protected: RAS_LightObject m_lightobj; - class RAS_IRenderTools* m_rendertools; //needed for registering and replication of lightobj + class RAS_IRasterizer* m_rasterizer; //needed for registering and replication of lightobj bool m_glsl; Scene* m_blenderscene; Base* m_base; public: - KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, bool glsl); + KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,RAS_IRasterizer* rasterizer,const RAS_LightObject& lightobj, bool glsl); virtual ~KX_LightObject(); virtual CValue* GetReplica(); RAS_LightObject* GetLightData() { return &m_lightobj;} @@ -66,8 +66,8 @@ public: struct GPULamp *GetGPULamp(); bool HasShadowBuffer(); int GetShadowLayer(); - void BindShadowBuffer(class RAS_IRasterizer *ras, class RAS_ICanvas *canvas, class KX_Camera *cam, class MT_Transform& camtrans); - void UnbindShadowBuffer(class RAS_IRasterizer *ras); + void BindShadowBuffer(RAS_IRasterizer *ras, class RAS_ICanvas *canvas, class KX_Camera *cam, class MT_Transform& camtrans); + void UnbindShadowBuffer(RAS_IRasterizer *ras); struct Image *GetTextureImage(short texslot); void Update(); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 4fa51b48ab8..dba26d4e3a7 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1678,10 +1678,9 @@ RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat, bool void KX_Scene::RenderBuckets(const MT_Transform & cameratransform, - class RAS_IRasterizer* rasty, - class RAS_IRenderTools* rendertools) + class RAS_IRasterizer* rasty) { - m_bucketmanager->Renderbuckets(cameratransform,rasty,rendertools); + m_bucketmanager->Renderbuckets(cameratransform,rasty); KX_BlenderMaterial::EndFrame(); } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index edaa0663b22..ee2a994d53c 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -309,8 +309,7 @@ public: RAS_BucketManager* GetBucketManager(); RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial* polymat, bool &bucketCreated); void RenderBuckets(const MT_Transform& cameratransform, - RAS_IRasterizer* rasty, - RAS_IRenderTools* rendertools); + RAS_IRasterizer* rasty); /** * Update all transforms according to the scenegraph. diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index 9061532ba5d..879115add47 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -47,7 +47,6 @@ set(SRC RAS_BucketManager.cpp RAS_FramingManager.cpp RAS_IPolygonMaterial.cpp - RAS_IRenderTools.cpp RAS_MaterialBucket.cpp RAS_MeshObject.cpp RAS_Polygon.cpp @@ -62,7 +61,6 @@ set(SRC RAS_ICanvas.h RAS_IPolygonMaterial.h RAS_IRasterizer.h - RAS_IRenderTools.h RAS_LightObject.h RAS_MaterialBucket.h RAS_MeshObject.h diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 713d324bf17..02c50df3dd3 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -38,7 +38,6 @@ #include "STR_HashedString.h" #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" -#include "RAS_IRenderTools.h" #include "RAS_BucketManager.h" @@ -139,8 +138,7 @@ void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList sort(slots.begin(), slots.end(), fronttoback()); } -void RAS_BucketManager::RenderAlphaBuckets( - const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools) +void RAS_BucketManager::RenderAlphaBuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty) { vector slots; vector::iterator sit; @@ -154,10 +152,10 @@ void RAS_BucketManager::RenderAlphaBuckets( OrderBuckets(cameratrans, m_AlphaBuckets, slots, true); for (sit=slots.begin(); sit!=slots.end(); ++sit) { - rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj); + rasty->SetClientObject(sit->m_ms->m_clientObj); - while (sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools)) - sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms)); + while (sit->m_bucket->ActivateMaterial(cameratrans, rasty)) + sit->m_bucket->RenderMeshSlot(cameratrans, rasty, *(sit->m_ms)); // make this mesh slot culled automatically for next frame // it will be culled out by frustrum culling @@ -167,8 +165,7 @@ void RAS_BucketManager::RenderAlphaBuckets( rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED); } -void RAS_BucketManager::RenderSolidBuckets( - const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools) +void RAS_BucketManager::RenderSolidBuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty) { BucketList::iterator bit; @@ -180,9 +177,9 @@ void RAS_BucketManager::RenderSolidBuckets( RAS_MeshSlot* ms; // remove the mesh slot form the list, it culls them automatically for next frame while ((ms = bucket->GetNextActiveMeshSlot())) { - rendertools->SetClientObject(rasty, ms->m_clientObj); - while (bucket->ActivateMaterial(cameratrans, rasty, rendertools)) - bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *ms); + rasty->SetClientObject(ms->m_clientObj); + while (bucket->ActivateMaterial(cameratrans, rasty)) + bucket->RenderMeshSlot(cameratrans, rasty, *ms); // make this mesh slot culled automatically for next frame // it will be culled out by frustrum culling @@ -194,10 +191,10 @@ void RAS_BucketManager::RenderSolidBuckets( if (mit->IsCulled()) continue; - rendertools->SetClientObject(rasty, mit->m_clientObj); + rasty->SetClientObject(rasty, mit->m_clientObj); - while ((*bit)->ActivateMaterial(cameratrans, rasty, rendertools)) - (*bit)->RenderMeshSlot(cameratrans, rasty, rendertools, *mit); + while ((*bit)->ActivateMaterial(cameratrans, rasty)) + (*bit)->RenderMeshSlot(cameratrans, rasty, *mit); // make this mesh slot culled automatically for next frame // it will be culled out by frustrum culling @@ -218,20 +215,19 @@ void RAS_BucketManager::RenderSolidBuckets( for (sit=slots.begin(); sit!=slots.end(); ++sit) { rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj); - while (sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools)) - sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms)); + while (sit->m_bucket->ActivateMaterial(cameratrans, rasty)) + sit->m_bucket->RenderMeshSlot(cameratrans, rasty, *(sit->m_ms)); } #endif } -void RAS_BucketManager::Renderbuckets( - const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools) +void RAS_BucketManager::Renderbuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty) { /* beginning each frame, clear (texture/material) caching information */ rasty->ClearCachingInfo(); - RenderSolidBuckets(cameratrans, rasty, rendertools); - RenderAlphaBuckets(cameratrans, rasty, rendertools); + RenderSolidBuckets(cameratrans, rasty); + RenderAlphaBuckets(cameratrans, rasty); /* All meshes should be up to date now */ /* Don't do this while processing buckets because some meshes are split between buckets */ @@ -259,7 +255,7 @@ void RAS_BucketManager::Renderbuckets( } - rendertools->SetClientObject(rasty, NULL); + rasty->SetClientObject(NULL); } RAS_MaterialBucket *RAS_BucketManager::FindBucket(RAS_IPolyMaterial *material, bool &bucketCreated) diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index bf88da6f1ba..f8c6375d474 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -51,8 +51,7 @@ public: RAS_BucketManager(); virtual ~RAS_BucketManager(); - void Renderbuckets(const MT_Transform & cameratrans, - RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); + void Renderbuckets(const MT_Transform & cameratrans, RAS_IRasterizer* rasty); RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial *material, bool &bucketCreated); void OptimizeBuckets(MT_Scalar distance); @@ -78,10 +77,10 @@ public: private: void OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector& slots, bool alpha); - void RenderSolidBuckets(const MT_Transform& cameratrans, - RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); - void RenderAlphaBuckets(const MT_Transform& cameratrans, - RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); + void RenderSolidBuckets(const MT_Transform& cameratrans, + RAS_IRasterizer* rasty); + void RenderAlphaBuckets(const MT_Transform& cameratrans, + RAS_IRasterizer* rasty); #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index ace91f6dd51..8291b9a2d5b 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -65,6 +65,13 @@ typedef vector< KX_IndexArray* > vecIndexArrays; class RAS_IRasterizer { public: + enum RAS_TEXT_RENDER_MODE { + RAS_TEXT_RENDER_NODEF = 0, + RAS_TEXT_NORMAL, + RAS_TEXT_PADDED, + RAS_TEXT_MAX + }; + RAS_IRasterizer(RAS_ICanvas* canv) {}; virtual ~RAS_IRasterizer() {}; @@ -247,11 +254,9 @@ public: /** * IndexPrimitives_3DText will render text into the polygons. - * The text to be rendered is from \param rendertools client object's text property. */ virtual void IndexPrimitives_3DText(class RAS_MeshSlot& ms, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools)=0; + class RAS_IPolyMaterial* polymat)=0; virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat)=0; /* This one should become our final version, methinks. */ @@ -434,6 +439,88 @@ public: virtual void SetUsingOverrideShader(bool val)=0; virtual bool GetUsingOverrideShader()=0; + /** + * Render Tools + */ + virtual void applyTransform(double* oglmatrix, int drawingmode)=0; + + /** + * Renders 2D boxes. + * \param xco Position on the screen (origin in lower left corner). + * \param yco Position on the screen (origin in lower left corner). + * \param width Width of the canvas to draw to. + * \param height Height of the canvas to draw to. + * \param percentage Percentage of bar. + */ + virtual void RenderBox2D(int xco, + int yco, + int width, + int height, + float percentage) = 0; + + /** + * Renders 3D text string using BFL. + * \param fontid The id of the font. + * \param text The string to render. + * \param size The size of the text. + * \param dpi The resolution of the text. + * \param color The color of the object. + * \param mat The Matrix of the text object. + * \param aspect A scaling factor to compensate for the size. + */ + virtual void RenderText3D(int fontid, + const char* text, + int size, + int dpi, + float* color, + double* mat, + float aspect + ) = 0; + + + /** + * Renders 2D text string. + * \param mode The type of text + * \param text The string to render. + * \param xco Position on the screen (origin in lower left corner). + * \param yco Position on the screen (origin in lower left corner). + * \param width Width of the canvas to draw to. + * \param height Height of the canvas to draw to. + */ + virtual void RenderText2D(RAS_TEXT_RENDER_MODE mode, + const char* text, + int xco, + int yco, + int width, + int height + ) = 0; + + // 3d text, mapped on polygon + virtual void RenderText(int mode, + RAS_IPolyMaterial* polymat, + float v1[3], + float v2[3], + float v3[3], + float v4[3], + int glattrib + )=0; + + virtual void ProcessLighting(bool uselights, const MT_Transform& trans)=0; + + virtual void PushMatrix()=0; + + virtual void PopMatrix()=0; + + virtual void AddLight(struct RAS_LightObject* lightobject)=0; + + virtual void RemoveLight(struct RAS_LightObject* lightobject)=0; + + virtual void MotionBlur()=0; + + virtual void SetClientObject(void* obj)=0; + + virtual void SetAuxilaryClientInfo(void* inf)=0; + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRasterizer") #endif diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.cpp b/source/gameengine/Rasterizer/RAS_IRenderTools.cpp deleted file mode 100644 index 045373eff85..00000000000 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file gameengine/Rasterizer/RAS_IRenderTools.cpp - * \ingroup bgerast - */ - - -#include "RAS_IRenderTools.h" - -void RAS_IRenderTools::SetClientObject(RAS_IRasterizer* rasty, void *obj) -{ - if (m_clientobject != obj) - m_clientobject = obj; -} - -void RAS_IRenderTools::SetAuxilaryClientInfo(void* inf) -{ - m_auxilaryClientInfo = inf; -} - -void RAS_IRenderTools::AddLight(struct RAS_LightObject* lightobject) -{ - m_lights.push_back(lightobject); -} - -void RAS_IRenderTools::RemoveLight(struct RAS_LightObject* lightobject) -{ - std::vector::iterator lit = - std::find(m_lights.begin(),m_lights.end(),lightobject); - - if (!(lit==m_lights.end())) - m_lights.erase(lit); -} - diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h deleted file mode 100644 index 6131abc0650..00000000000 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ /dev/null @@ -1,227 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file RAS_IRenderTools.h - * \ingroup bgerast - */ - -#ifndef __RAS_IRENDERTOOLS_H__ -#define __RAS_IRENDERTOOLS_H__ - -#include "MT_Transform.h" -#include "RAS_IRasterizer.h" -#include "RAS_2DFilterManager.h" - -#include -#include - -#ifdef WITH_CXX_GUARDEDALLOC -#include "MEM_guardedalloc.h" -#endif - -class RAS_IPolyMaterial; -struct RAS_LightObject; - - -class RAS_IRenderTools -{ - -protected: - void* m_clientobject; - void* m_auxilaryClientInfo; - - std::vector m_lights; - - RAS_2DFilterManager m_filtermanager; - -public: - enum RAS_TEXT_RENDER_MODE { - RAS_TEXT_RENDER_NODEF = 0, - RAS_TEXT_NORMAL, - RAS_TEXT_PADDED, - RAS_TEXT_MAX - }; - - RAS_IRenderTools( - ) : - m_clientobject(NULL) - { - }; - - virtual - ~RAS_IRenderTools( - ) {}; - - virtual - void - BeginFrame( - RAS_IRasterizer* rasty - )=0; - - virtual - void - EndFrame( - RAS_IRasterizer* rasty - )=0; - - // the following function was formerly called 'Render' - // by it doesn't render anymore - // It only sets the transform for the rasterizer - // so must be renamed to 'applyTransform' or something - - virtual - void - applyTransform( - class RAS_IRasterizer* rasty, - double* oglmatrix, - int drawingmode - )=0; - - /** - * Renders 2D boxes. - * \param xco Position on the screen (origin in lower left corner). - * \param yco Position on the screen (origin in lower left corner). - * \param width Width of the canvas to draw to. - * \param height Height of the canvas to draw to. - * \param percentage Percentage of bar. - */ - virtual - void - RenderBox2D(int xco, - int yco, - int width, - int height, - float percentage) = 0; - - /** - * Renders 3D text string using BFL. - * \param fontid The id of the font. - * \param text The string to render. - * \param size The size of the text. - * \param dpi The resolution of the text. - * \param color The color of the object. - * \param mat The Matrix of the text object. - * \param aspect A scaling factor to compensate for the size. - */ - virtual - void - RenderText3D(int fontid, - const char* text, - int size, - int dpi, - float* color, - double* mat, - float aspect - ) = 0; - - - /** - * Renders 2D text string. - * \param mode The type of text - * \param text The string to render. - * \param xco Position on the screen (origin in lower left corner). - * \param yco Position on the screen (origin in lower left corner). - * \param width Width of the canvas to draw to. - * \param height Height of the canvas to draw to. - */ - virtual - void - RenderText2D( - RAS_TEXT_RENDER_MODE mode, - const char* text, - int xco, - int yco, - int width, - int height - ) = 0; - - // 3d text, mapped on polygon - virtual - void - RenderText( - int mode, - RAS_IPolyMaterial* polymat, - float v1[3], - float v2[3], - float v3[3], - float v4[3], - int glattrib - )=0; - - virtual - void - ProcessLighting( - RAS_IRasterizer *rasty, - bool uselights, - const MT_Transform& trans - )=0; - - virtual - void - SetClientObject( - RAS_IRasterizer* rasty, - void* obj - ); - - void - SetAuxilaryClientInfo( - void* inf - ); - - virtual - void - PushMatrix( - )=0; - - virtual - void - PopMatrix( - )=0; - - virtual - void - AddLight( - struct RAS_LightObject* lightobject - ); - - virtual - void - RemoveLight( - struct RAS_LightObject* lightobject - ); - - virtual - void - MotionBlur(RAS_IRasterizer* rasterizer)=0; - - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRenderTools") -#endif -}; - -#endif /* __RAS_IRENDERTOOLS_H__ */ diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 8ea09029a35..726b9106340 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -43,7 +43,6 @@ #include "RAS_Polygon.h" #include "RAS_TexVert.h" #include "RAS_IRasterizer.h" -#include "RAS_IRenderTools.h" #include "RAS_MeshObject.h" #include "RAS_Deformer.h" // __NLA @@ -581,8 +580,7 @@ list::iterator RAS_MaterialBucket::msEnd() return m_meshSlots.end(); } -bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools *rendertools) +bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty) { bool uselights; @@ -593,13 +591,12 @@ bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_I return false; uselights= m_material->UsesLighting(rasty); - rendertools->ProcessLighting(rasty, uselights, cameratrans); + rasty->ProcessLighting(uselights, cameratrans); return true; } -void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools* rendertools, RAS_MeshSlot &ms) +void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_MeshSlot &ms) { m_material->ActivateMeshSlot(ms, rasty); @@ -613,10 +610,10 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa if (IsZSort() && rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) ms.m_mesh->SortPolygons(ms, cameratrans*MT_Transform(ms.m_OpenGLMatrix)); - rendertools->PushMatrix(); + rasty->PushMatrix(); if (!ms.m_pDeformer || !ms.m_pDeformer->SkipVertexTransform()) { - rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode()); + rasty->applyTransform(ms.m_OpenGLMatrix,m_material->GetDrawingMode()); } if (rasty->QueryLists()) @@ -641,7 +638,7 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa // for text drawing using faces if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) - rasty->IndexPrimitives_3DText(ms, m_material, rendertools); + rasty->IndexPrimitives_3DText(ms, m_material); // for multitexturing else if ((m_material->GetFlag() & (RAS_MULTITEX|RAS_BLENDERGLSL))) rasty->IndexPrimitivesMulti(ms); @@ -649,7 +646,7 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa else rasty->IndexPrimitives(ms); - rendertools->PopMatrix(); + rasty->PopMatrix(); } void RAS_MaterialBucket::Optimize(MT_Scalar distance) diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index 4c72f128817..c112d44f774 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -219,10 +219,8 @@ public: bool IsZSort() const; /* Rendering */ - bool ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools *rendertools); - void RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools* rendertools, RAS_MeshSlot &ms); + bool ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty); + void RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_MeshSlot &ms); /* Mesh Slot Access */ list::iterator msBegin(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index 6b53990770f..76ac6316e38 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -25,9 +25,15 @@ set(INC .. + # XXX Remove these <<< ../../BlenderRoutines + ../../Expressions + ../../GameLogic ../../Ketsji + ../../Physics/common + # >>> ../../SceneGraph + ../../../blender/blenfont ../../../blender/blenkernel ../../../blender/blenlib ../../../blender/gpu diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index bfc74e0c6dc..9d1fb3ba63c 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -40,8 +40,8 @@ #include "RAS_Rect.h" #include "RAS_TexVert.h" #include "RAS_MeshObject.h" +#include "RAS_LightObject.h" #include "MT_CmMatrix4x4.h" -#include "RAS_IRenderTools.h" // rendering text #include "RAS_StorageIM.h" #include "RAS_StorageVA.h" @@ -59,8 +59,21 @@ extern "C"{ #include "BLI_utildefines.h" #include "BKE_DerivedMesh.h" + #include "BLF_api.h" } + +// XXX Clean these up <<< +#include "BL_Material.h" // MAXTEX +#include "Value.h" +#include "KX_BlenderMaterial.h" +#include "KX_PolygonMaterial.h" +#include "KX_Light.h" +#include "KX_Scene.h" +#include "KX_RayCast.h" +#include "KX_GameObject.h" +// >>> + #ifndef M_PI #define M_PI 3.14159265358979323846 #endif @@ -94,6 +107,8 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, int storage) m_motionblur(0), m_motionblurvalue(-1.0), m_usingoverrideshader(false), + m_clientobject(NULL), + m_auxilaryClientInfo(NULL), m_texco_num(0), m_attrib_num(0), //m_last_alphablend(GPU_BLEND_SOLID), @@ -131,6 +146,10 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas, int storage) m_storage = m_failsafe_storage = new RAS_StorageIM(&m_texco_num, m_texco, &m_attrib_num, m_attrib, m_attrib_layer); m_storage_type = RAS_IMMEDIATE; } + + glGetIntegerv(GL_MAX_LIGHTS, (GLint *) &m_numgllights); + if (m_numgllights < 8) + m_numgllights = 8; } @@ -350,6 +369,13 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time) glEnable(GL_MULTISAMPLE_ARB); m_2DCanvas->BeginFrame(); + + // Render Tools + m_clientobject = NULL; + m_lastlightlayer = -1; + m_lastauxinfo = NULL; + m_lastlighting = true; /* force disable in DisableOpenGLLights() */ + DisableOpenGLLights(); return true; } @@ -650,8 +676,7 @@ const MT_Matrix4x4& RAS_OpenGLRasterizer::GetViewInvMatrix() const } void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools) + class RAS_IPolyMaterial* polymat) { bool obcolor = ms.m_bObjectColor; MT_Vector4& rgba = ms.m_RGBAcolor; @@ -708,7 +733,7 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms, if (m_attrib[unit] == RAS_TEXCO_UV) glattrib = unit; - rendertools->RenderText(polymat->GetDrawingMode(), polymat, + RenderText(polymat->GetDrawingMode(), polymat, v[0], v[1], v[2], (numvert == 4)? v[3]: NULL, glattrib); ClearCachingInfo(); @@ -1107,3 +1132,476 @@ bool RAS_OpenGLRasterizer::GetUsingOverrideShader() return m_usingoverrideshader; } +/** + * Render Tools + */ + +/* ProcessLighting performs lighting on objects. the layer is a bitfield that + * contains layer information. There are 20 'official' layers in blender. A + * light is applied on an object only when they are in the same layer. OpenGL + * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in + * a scene. */ + +void RAS_OpenGLRasterizer::ProcessLighting(bool uselights, const MT_Transform& viewmat) +{ + bool enable = false; + int layer= -1; + + /* find the layer */ + if (uselights) { + if (m_clientobject) + layer = static_cast(m_clientobject)->GetLayer(); + } + + /* avoid state switching */ + if (m_lastlightlayer == layer && m_lastauxinfo == m_auxilaryClientInfo) + return; + + m_lastlightlayer = layer; + m_lastauxinfo = m_auxilaryClientInfo; + + /* enable/disable lights as needed */ + if (layer >= 0) + enable = ApplyLights(layer, viewmat); + + if (enable) + EnableOpenGLLights(); + else + DisableOpenGLLights(); +} + +void RAS_OpenGLRasterizer::EnableOpenGLLights() +{ + if (m_lastlighting == true) + return; + + glEnable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); + + glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (GetCameraOrtho())? GL_FALSE: GL_TRUE); + if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); + + m_lastlighting = true; +} + +void RAS_OpenGLRasterizer::DisableOpenGLLights() +{ + if (m_lastlighting == false) + return; + + glDisable(GL_LIGHTING); + glDisable(GL_COLOR_MATERIAL); + + m_lastlighting = false; +} + +void RAS_OpenGLRasterizer::AddLight(struct RAS_LightObject* lightobject) +{ + m_lights.push_back(lightobject); +} + +void RAS_OpenGLRasterizer::RemoveLight(struct RAS_LightObject* lightobject) +{ + std::vector::iterator lit = + std::find(m_lights.begin(),m_lights.end(),lightobject); + + if (!(lit==m_lights.end())) + m_lights.erase(lit); +} + +bool RAS_OpenGLRasterizer::RayHit(class KX_ClientObjectInfo *client, KX_RayCast *result, void * const data) +{ + double* const oglmatrix = (double* const) data; + + RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon); + if (!poly->IsVisible()) + return false; + + MT_Point3 resultpoint(result->m_hitPoint); + MT_Vector3 resultnormal(result->m_hitNormal); + MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]); + MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized(); + left = (dir.cross(resultnormal)).safe_normalized(); + // for the up vector, we take the 'resultnormal' returned by the physics + + double maat[16] = {left[0], left[1], left[2], 0, + dir[0], dir[1], dir[2], 0, + resultnormal[0], resultnormal[1], resultnormal[2], 0, + 0, 0, 0, 1}; + + glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]); + //glMultMatrixd(oglmatrix); + glMultMatrixd(maat); + return true; +} + +void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode ) +{ + /* FIXME: + blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const + MT_Vector3&, double): Assertion `!MT_fuzzyZero(s)' failed. + + Program received signal SIGABRT, Aborted. + [Switching to Thread 16384 (LWP 1519)] + 0x40477571 in kill () from /lib/libc.so.6 + (gdb) bt + #7 0x08334368 in MT_Vector3::normalized() const () + #8 0x0833e6ec in RAS_OpenGLRasterizer::applyTransform(RAS_IRasterizer*, double*, int) () + */ + + if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED || + objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED) + { + // rotate the billboard/halo + //page 360/361 3D Game Engine Design, David Eberly for a discussion + // on screen aligned and axis aligned billboards + // assumed is that the preprocessor transformed all billboard polygons + // so that their normal points into the positive x direction (1.0, 0.0, 0.0) + // when new parenting for objects is done, this rotation + // will be moved into the object + + MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]); + MT_Point3 campos = GetCameraPosition(); + MT_Vector3 dir = (campos - objpos).safe_normalized(); + MT_Vector3 up(0,0,1.0); + + KX_GameObject* gameobj = (KX_GameObject*)m_clientobject; + // get scaling of halo object + MT_Vector3 size = gameobj->GetSGNode()->GetWorldScaling(); + + bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned + if (screenaligned) + { + up = (up - up.dot(dir) * dir).safe_normalized(); + } else + { + dir = (dir - up.dot(dir)*up).safe_normalized(); + } + + MT_Vector3 left = dir.normalized(); + dir = (up.cross(left)).normalized(); + + // we have calculated the row vectors, now we keep + // local scaling into account: + + left *= size[0]; + dir *= size[1]; + up *= size[2]; + + double maat[16] = {left[0], left[1], left[2], 0, + dir[0], dir[1], dir[2], 0, + up[0], up[1], up[2], 0, + 0, 0, 0, 1}; + + glTranslated(objpos[0],objpos[1],objpos[2]); + glMultMatrixd(maat); + + } + else { + if (objectdrawmode & RAS_IPolyMaterial::SHADOW) + { + // shadow must be cast to the ground, physics system needed here! + MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]); + KX_GameObject *gameobj = (KX_GameObject*)m_clientobject; + MT_Vector3 direction = MT_Vector3(0,0,-1); + + direction.normalize(); + direction *= 100000; + + MT_Point3 topoint = frompoint + direction; + + KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo; + PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment(); + KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController(); + + KX_GameObject *parent = gameobj->GetParent(); + if (!physics_controller && parent) + physics_controller = parent->GetPhysicsController(); + if (parent) + parent->Release(); + + KX_RayCast::Callback callback(this, physics_controller, oglmatrix); + if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback)) + { + // couldn't find something to cast the shadow on... + glMultMatrixd(oglmatrix); + } + else + { // we found the "ground", but the cast matrix doesn't take + // scaling in consideration, so we must apply the object scale + MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale(); + glScalef(size[0], size[1], size[2]); + } + } else + { + + // 'normal' object + glMultMatrixd(oglmatrix); + } + } +} + +static void DisableForText() +{ + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); /* needed for texture fonts otherwise they render as wireframe */ + + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + + glDisable(GL_LIGHTING); + glDisable(GL_COLOR_MATERIAL); + + if (GLEW_ARB_multitexture) { + for (int i=0; iGetPropertyText("Text"); + + const unsigned int flag = polymat->GetFlag(); + struct MTFace* tface = 0; + unsigned int *col = 0; + + if (flag & RAS_BLENDERMAT) { + KX_BlenderMaterial *bl_mat = static_cast(polymat); + tface = bl_mat->GetMTFace(); + col = bl_mat->GetMCol(); + } else { + KX_PolygonMaterial* blenderpoly = static_cast(polymat); + tface = blenderpoly->GetMTFace(); + col = blenderpoly->GetMCol(); + } + + GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib); +} + + +void RAS_OpenGLRasterizer::PushMatrix() +{ + glPushMatrix(); +} + +void RAS_OpenGLRasterizer::PopMatrix() +{ + glPopMatrix(); +} + + +int RAS_OpenGLRasterizer::ApplyLights(int objectlayer, const MT_Transform& viewmat) +{ + // taken from blender source, incompatibility between Blender Object / GameObject + KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; + float glviewmat[16]; + unsigned int count; + std::vector::iterator lit = m_lights.begin(); + + for (count=0; countm_light; + + if (kxlight->ApplyLight(kxscene, objectlayer, count)) + count++; + } + glPopMatrix(); + + return count; +} + +void RAS_OpenGLRasterizer::MotionBlur() +{ + int state = GetMotionBlurState(); + float motionblurvalue; + if (state) + { + motionblurvalue = GetMotionBlurValue(); + if (state==1) + { + //bugfix:load color buffer into accum buffer for the first time(state=1) + glAccum(GL_LOAD, 1.0); + SetMotionBlurState(2); + } + else if (motionblurvalue >= 0.0f && motionblurvalue <= 1.0f) { + glAccum(GL_MULT, motionblurvalue); + glAccum(GL_ACCUM, 1-motionblurvalue); + glAccum(GL_RETURN, 1.0); + glFlush(); + } + } +} + +void RAS_OpenGLRasterizer::SetClientObject(void* obj) +{ + if (m_clientobject != obj) + { + bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling()); + SetFrontFace(ccw); + + m_clientobject = obj; + } +} + +void RAS_OpenGLRasterizer::SetAuxilaryClientInfo(void* inf) +{ + m_auxilaryClientInfo = inf; +} + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index c638c40d34b..bd9e479464a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -105,6 +105,15 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer bool m_usingoverrideshader; + // Render tools + void* m_clientobject; + void* m_auxilaryClientInfo; + std::vector m_lights; + int m_lastlightlayer; + bool m_lastlighting; + void *m_lastauxinfo; + unsigned int m_numgllights; + protected: int m_drawingmode; TexCoGen m_texco[RAS_MAX_TEXCO]; @@ -171,10 +180,8 @@ public: virtual void IndexPrimitives(class RAS_MeshSlot& ms); virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms); - virtual void IndexPrimitives_3DText( - class RAS_MeshSlot& ms, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools); + virtual void IndexPrimitives_3DText(class RAS_MeshSlot& ms, + class RAS_IPolyMaterial* polymat); virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat); virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat); @@ -330,6 +337,65 @@ public: virtual void SetUsingOverrideShader(bool val); virtual bool GetUsingOverrideShader(); + /** + * Render Tools + */ + void EnableOpenGLLights(); + void DisableOpenGLLights(); + void ProcessLighting(bool uselights, const MT_Transform& viewmat); + + void RenderBox2D(int xco, + int yco, + int width, + int height, + float percentage); + + + void RenderText3D(int fontid, + const char* text, + int size, + int dpi, + float* color, + double* mat, + float aspect); + + void RenderText2D(RAS_TEXT_RENDER_MODE mode, + const char* text, + int xco, + int yco, + int width, + int height); + + void RenderText(int mode, + class RAS_IPolyMaterial* polymat, + float v1[3], + float v2[3], + float v3[3], + float v4[3], + int glattrib); + + void applyTransform(double* oglmatrix, int objectdrawmode); + int applyLights(int objectlayer, const MT_Transform& viewmat); + + void PushMatrix(); + void PopMatrix(); + + bool RayHit(class KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data); + bool NeedRayCast(class KX_ClientObjectInfo*) { return true; } + + + void AddLight(struct RAS_LightObject* lightobject); + + void RemoveLight(struct RAS_LightObject* lightobject); + int ApplyLights(int objectlayer, const MT_Transform& viewmat); + + void MotionBlur(); + + void SetClientObject(void* obj); + + void SetAuxilaryClientInfo(void* inf); + + #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_OpenGLRasterizer") #endif diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index d83cd2dc6fd..68adb07b1f8 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -80,7 +80,6 @@ ImageRender::ImageRender (KX_Scene *scene, KX_Camera * camera) : m_engine = KX_GetActiveEngine(); m_rasterizer = m_engine->GetRasterizer(); m_canvas = m_engine->GetCanvas(); - m_rendertools = m_engine->GetRenderTools(); } // destructor @@ -200,9 +199,8 @@ void ImageRender::Render() m_canvas->ClearColor(m_background[0], m_background[1], m_background[2], m_background[3]); m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER); m_rasterizer->BeginFrame(RAS_IRasterizer::KX_TEXTURED,m_engine->GetClockTime()); - m_rendertools->BeginFrame(m_rasterizer); m_engine->SetWorldSettings(m_scene->GetWorldInfo()); - m_rendertools->SetAuxilaryClientInfo(m_scene); + m_rasterizer->SetAuxilaryClientInfo(m_scene); m_rasterizer->DisplayFog(); // matrix calculation, don't apply any of the stereo mode m_rasterizer->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO); @@ -275,7 +273,7 @@ void ImageRender::Render() m_scene->CalculateVisibleMeshes(m_rasterizer,m_camera); - m_scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools); + m_scene->RenderBuckets(camtrans, m_rasterizer); m_scene->RenderFonts(); @@ -595,7 +593,6 @@ ImageRender::ImageRender (KX_Scene *scene, KX_GameObject *observer, KX_GameObjec m_engine = KX_GetActiveEngine(); m_rasterizer = m_engine->GetRasterizer(); m_canvas = m_engine->GetCanvas(); - m_rendertools = m_engine->GetRenderTools(); // locate the vertex assigned to mat and do following calculation in mesh coordinates for (int meshIndex = 0; meshIndex < mirror->GetMeshCount(); meshIndex++) { diff --git a/source/gameengine/VideoTexture/ImageRender.h b/source/gameengine/VideoTexture/ImageRender.h index 680e1cc1d89..98dceeaafe1 100644 --- a/source/gameengine/VideoTexture/ImageRender.h +++ b/source/gameengine/VideoTexture/ImageRender.h @@ -39,7 +39,6 @@ #include "DNA_screen_types.h" #include "RAS_ICanvas.h" #include "RAS_IRasterizer.h" -#include "RAS_IRenderTools.h" #include "ImageViewport.h" @@ -88,8 +87,6 @@ protected: RAS_ICanvas* m_canvas; /// rasterizer RAS_IRasterizer* m_rasterizer; - /// render tools - RAS_IRenderTools* m_rendertools; /// engine KX_KetsjiEngine* m_engine; -- cgit v1.2.3 From a565e34c39880557ca09ec02d8bfb05e4bcccbae Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:21:16 +0000 Subject: BGE Rasterizer Cleanup: Removing KX_BlenderGL since it was mostly one-line functions used by KX_BlenderCanvas. KX_BlenderCanvas now just calls those functions directly. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 1 - source/gameengine/BlenderRoutines/CMakeLists.txt | 2 - .../BlenderRoutines/KX_BlenderCanvas.cpp | 93 +++++++++-- .../gameengine/BlenderRoutines/KX_BlenderCanvas.h | 8 +- source/gameengine/BlenderRoutines/KX_BlenderGL.cpp | 185 --------------------- source/gameengine/BlenderRoutines/KX_BlenderGL.h | 65 -------- .../Converter/BL_BlenderDataConversion.cpp | 1 - source/gameengine/Converter/BlenderWorldInfo.cpp | 1 - source/gameengine/Converter/BlenderWorldInfo.h | 1 - source/gameengine/Converter/KX_ConvertSensors.cpp | 1 - 10 files changed, 85 insertions(+), 273 deletions(-) delete mode 100644 source/gameengine/BlenderRoutines/KX_BlenderGL.cpp delete mode 100644 source/gameengine/BlenderRoutines/KX_BlenderGL.h diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 5479a5e7a6e..0c259f1ad79 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -42,7 +42,6 @@ #include "GL/glew.h" -#include "KX_BlenderGL.h" #include "KX_BlenderCanvas.h" #include "KX_BlenderKeyboardDevice.h" #include "KX_BlenderMouseDevice.h" diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index 1f323a798ce..73dbe005518 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -39,7 +39,6 @@ set(SRC BL_KetsjiEmbedStart.cpp BL_System.cpp KX_BlenderCanvas.cpp - KX_BlenderGL.cpp KX_BlenderInputDevice.cpp KX_BlenderKeyboardDevice.cpp KX_BlenderMouseDevice.cpp @@ -47,7 +46,6 @@ set(SRC BL_System.h KX_BlenderCanvas.h - KX_BlenderGL.h KX_BlenderInputDevice.h KX_BlenderKeyboardDevice.h KX_BlenderMouseDevice.h diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index 3089b3fd44d..b3e0b4c3ea6 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -29,13 +29,33 @@ * \ingroup blroutines */ +#include + +#include "MEM_guardedalloc.h" #include "KX_BlenderCanvas.h" + +#include "DNA_image_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" -#include + +#include "BKE_image.h" +#include "BKE_global.h" +#include "BKE_main.h" + +#include "BLI_path_util.h" +#include "BLI_string.h" + #include +extern "C" { +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "WM_api.h" +#include "wm_cursors.h" +#include "wm_window.h" +} KX_BlenderCanvas::KX_BlenderCanvas(wmWindowManager *wm, wmWindow *win, RAS_Rect &rect, struct ARegion *ar) : m_wm(wm), @@ -63,17 +83,17 @@ void KX_BlenderCanvas::Init() void KX_BlenderCanvas::SwapBuffers() { - BL_SwapBuffers(m_win); + wm_window_swap_buffers(m_win); } void KX_BlenderCanvas::SetSwapInterval(int interval) { - BL_SetSwapInterval(m_win, interval); + wm_window_set_swap_interval(m_win, interval); } int KX_BlenderCanvas::GetSwapInterval() { - return BL_GetSwapInterval(m_win); + return wm_window_get_swap_interval(m_win); } void KX_BlenderCanvas::ResizeWindow(int width, int height) @@ -96,7 +116,7 @@ bool KX_BlenderCanvas::BeginDraw() { // in case of multi-window we need to ensure we are drawing to the correct // window always, because it may change in window event handling - BL_MakeDrawable(m_wm, m_win); + wm_window_make_drawable(m_wm, m_win); return true; } @@ -247,17 +267,17 @@ void KX_BlenderCanvas::SetMouseState(RAS_MouseState mousestate) { case MOUSE_INVISIBLE: { - BL_HideMouse(m_win); + WM_cursor_set(m_win, CURSOR_NONE); break; } case MOUSE_WAIT: { - BL_WaitMouse(m_win); + WM_cursor_set(m_win, CURSOR_WAIT); break; } case MOUSE_NORMAL: { - BL_NormalMouse(m_win); + WM_cursor_set(m_win, CURSOR_STD); break; } default: @@ -275,18 +295,71 @@ void KX_BlenderCanvas::SetMousePosition(int x,int y) int winY = m_frame_rect.GetBottom(); int winH = m_frame_rect.GetHeight(); - BL_warp_pointer(m_win, winX + x, winY + (winH-y)); + WM_cursor_warp(m_win, winX + x, winY + (winH-y)); } +/* get shot from frontbuffer sort of a copy from screendump.c */ +static unsigned int *screenshot(ScrArea *curarea, int *dumpsx, int *dumpsy) +{ + int x=0, y=0; + unsigned int *dumprect= NULL; + + x= curarea->totrct.xmin; + y= curarea->totrct.ymin; + *dumpsx= curarea->totrct.xmax-x; + *dumpsy= curarea->totrct.ymax-y; + + if (*dumpsx && *dumpsy) { + + dumprect= (unsigned int *)MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect"); + glReadBuffer(GL_FRONT); + glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect); + glFinish(); + glReadBuffer(GL_BACK); + } + + return dumprect; +} void KX_BlenderCanvas::MakeScreenShot(const char *filename) { ScrArea area_dummy= {0}; + bScreen *screen = m_win->screen; + unsigned int *dumprect; + int dumpsx, dumpsy; + area_dummy.totrct.xmin = m_frame_rect.GetLeft(); area_dummy.totrct.xmax = m_frame_rect.GetRight(); area_dummy.totrct.ymin = m_frame_rect.GetBottom(); area_dummy.totrct.ymax = m_frame_rect.GetTop(); - BL_MakeScreenShot(m_win->screen, &area_dummy, filename); + dumprect = screenshot(&area_dummy, &dumpsx, &dumpsy); + + if (dumprect) { + /* initialize image file format data */ + Scene *scene = (screen)? screen->scene: NULL; + ImageFormatData im_format; + + if (scene) + im_format = scene->r.im_format; + else + BKE_imformat_defaults(&im_format); + + /* create file path */ + char path[FILE_MAX]; + BLI_strncpy(path, filename, sizeof(path)); + BLI_path_abs(path, G.main->name); + BKE_add_image_extension_from_type(path, im_format.imtype); + + /* create and save imbuf */ + ImBuf *ibuf = IMB_allocImBuf(dumpsx, dumpsy, 24, 0); + ibuf->rect = dumprect; + + BKE_imbuf_write_as(ibuf, path, &im_format, false); + + ibuf->rect = NULL; + IMB_freeImBuf(ibuf); + MEM_freeN(dumprect); + } } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index c5318b882fa..9ad80cb1737 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -34,15 +34,11 @@ #ifdef WIN32 #include -#endif - -#include "GL/glew.h" +#endif #include "RAS_ICanvas.h" #include "RAS_Rect.h" -#include "KX_BlenderGL.h" - #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" #endif @@ -70,7 +66,7 @@ public: * * \param area The Blender ARegion to run the game within. */ - KX_BlenderCanvas(struct wmWindowManager *wm, struct wmWindow* win, class RAS_Rect &rect, struct ARegion* ar); + KX_BlenderCanvas(struct wmWindowManager *wm, struct wmWindow* win, RAS_Rect &rect, struct ARegion* ar); ~KX_BlenderCanvas(); void diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp deleted file mode 100644 index 3770d81f4d5..00000000000 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file gameengine/BlenderRoutines/KX_BlenderGL.cpp - * \ingroup blroutines - */ - - -#include "KX_BlenderGL.h" - -/* - * This little block needed for linking to Blender... - */ -#ifdef WIN32 -#include -#include "BLI_winstuff.h" -#endif - -#include -#include - -#include "GL/glew.h" - -#include "MEM_guardedalloc.h" - -#include "BL_Material.h" // MAXTEX - -/* Data types encoding the game world: */ -#include "DNA_object_types.h" -#include "DNA_scene_types.h" -#include "DNA_screen_types.h" -#include "DNA_camera_types.h" -#include "DNA_world_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_image_types.h" -#include "DNA_view3d_types.h" -#include "DNA_material_types.h" -#include "DNA_space_types.h" -#include "DNA_windowmanager_types.h" - -#include "BKE_global.h" -#include "BKE_main.h" -#include "BKE_bmfont.h" -#include "BKE_image.h" - -#include "BLI_path_util.h" -#include "BLI_string.h" - -extern "C" { -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" -#include "WM_api.h" -#include "WM_types.h" -#include "wm_event_system.h" -#include "wm_cursors.h" -#include "wm_window.h" -#include "BLF_api.h" -} - -/* end of blender block */ -void BL_warp_pointer(wmWindow *win, int x,int y) -{ - WM_cursor_warp(win, x, y); -} - -void BL_SwapBuffers(wmWindow *win) -{ - wm_window_swap_buffers(win); -} - -void BL_MakeDrawable(wmWindowManager *wm, wmWindow *win) -{ - wm_window_make_drawable(wm, win); -} - -void BL_SetSwapInterval(struct wmWindow *win, int interval) -{ - wm_window_set_swap_interval(win, interval); -} - -int BL_GetSwapInterval(struct wmWindow *win) -{ - return wm_window_get_swap_interval(win); -} - -void BL_HideMouse(wmWindow *win) -{ - WM_cursor_set(win, CURSOR_NONE); -} - - -void BL_WaitMouse(wmWindow *win) -{ - WM_cursor_set(win, CURSOR_WAIT); -} - - -void BL_NormalMouse(wmWindow *win) -{ - WM_cursor_set(win, CURSOR_STD); -} -/* get shot from frontbuffer sort of a copy from screendump.c */ -static unsigned int *screenshot(ScrArea *curarea, int *dumpsx, int *dumpsy) -{ - int x=0, y=0; - unsigned int *dumprect= NULL; - - x= curarea->totrct.xmin; - y= curarea->totrct.ymin; - *dumpsx= curarea->totrct.xmax-x; - *dumpsy= curarea->totrct.ymax-y; - - if (*dumpsx && *dumpsy) { - - dumprect= (unsigned int *)MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect"); - glReadBuffer(GL_FRONT); - glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect); - glFinish(); - glReadBuffer(GL_BACK); - } - - return dumprect; -} - -/* based on screendump.c::screenshot_exec */ -void BL_MakeScreenShot(bScreen *screen, ScrArea *curarea, const char *filename) -{ - unsigned int *dumprect; - int dumpsx, dumpsy; - - dumprect = screenshot(curarea, &dumpsx, &dumpsy); - - if (dumprect) { - /* initialize image file format data */ - Scene *scene = (screen)? screen->scene: NULL; - ImageFormatData im_format; - - if (scene) - im_format = scene->r.im_format; - else - BKE_imformat_defaults(&im_format); - - /* create file path */ - char path[FILE_MAX]; - BLI_strncpy(path, filename, sizeof(path)); - BLI_path_abs(path, G.main->name); - BKE_add_image_extension_from_type(path, im_format.imtype); - - /* create and save imbuf */ - ImBuf *ibuf = IMB_allocImBuf(dumpsx, dumpsy, 24, 0); - ibuf->rect = dumprect; - - BKE_imbuf_write_as(ibuf, path, &im_format, false); - - ibuf->rect = NULL; - IMB_freeImBuf(ibuf); - MEM_freeN(dumprect); - } -} - diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h deleted file mode 100644 index 13d563a687b..00000000000 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file KX_BlenderGL.h - * \ingroup blroutines - */ - -#ifndef __KX_BLENDERGL_H__ -#define __KX_BLENDERGL_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -struct ARegion; -struct bScreen; -struct wmWindow; -struct wmWindowManager; - -// special swapbuffers, that takes care of which area (viewport) needs to be swapped -void BL_SwapBuffers(struct wmWindow *win); -void BL_SetSwapInterval(struct wmWindow *win, int interval); -int BL_GetSwapInterval(struct wmWindow *win); - -void BL_MakeDrawable(struct wmWindowManager *wm, struct wmWindow *win); - -void BL_warp_pointer(struct wmWindow *win,int x,int y); - -void BL_MakeScreenShot(struct bScreen *screen, struct ScrArea *curarea, const char *filename); - -void BL_HideMouse(struct wmWindow *win); -void BL_NormalMouse(struct wmWindow *win); -void BL_WaitMouse(struct wmWindow *win); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __KX_BLENDERGL_H__ */ diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 7456670fcdb..d87541ce080 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -39,7 +39,6 @@ #include #include "BL_BlenderDataConversion.h" -#include "KX_BlenderGL.h" #include "KX_BlenderScalarInterpolator.h" #include "RAS_IPolygonMaterial.h" diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp index 25da8155867..f1f264b3367 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.cpp +++ b/source/gameengine/Converter/BlenderWorldInfo.cpp @@ -33,7 +33,6 @@ #include // printf() #include "BlenderWorldInfo.h" -#include "KX_BlenderGL.h" /* This little block needed for linking to Blender... */ #ifdef WIN32 diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h index 30de5e89269..af535d65d62 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ b/source/gameengine/Converter/BlenderWorldInfo.h @@ -33,7 +33,6 @@ #define __BLENDERWORLDINFO_H__ #include "MT_CmMatrix4x4.h" #include "KX_WorldInfo.h" -#include "KX_BlenderGL.h" class BlenderWorldInfo : public KX_WorldInfo { diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 3bb12c12cd1..b9bd9aabc54 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -80,7 +80,6 @@ #include "KX_Scene.h" #include "IntValue.h" #include "KX_BlenderKeyboardDevice.h" -#include "KX_BlenderGL.h" #include "RAS_ICanvas.h" #include "PHY_IPhysicsEnvironment.h" -- cgit v1.2.3 From e2c91b570d5c00c2a4882ff2418de085b5dccbfc Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:21:21 +0000 Subject: BGE Rasterizer Cleanup: Getting rid of RAS_IRasterizer::RenderText(), and just adding the code to IndexPrimitives_3DText(), which is the only function that uses RenderText(). --- source/gameengine/Rasterizer/RAS_IRasterizer.h | 10 ----- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 49 ++++++++-------------- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 8 ---- 3 files changed, 18 insertions(+), 49 deletions(-) diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 8291b9a2d5b..034ea7f87a9 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -495,16 +495,6 @@ public: int height ) = 0; - // 3d text, mapped on polygon - virtual void RenderText(int mode, - RAS_IPolyMaterial* polymat, - float v1[3], - float v2[3], - float v3[3], - float v4[3], - int glattrib - )=0; - virtual void ProcessLighting(bool uselights, const MT_Transform& trans)=0; virtual void PushMatrix()=0; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 9d1fb3ba63c..4a8afb2b652 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -681,6 +681,12 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms, bool obcolor = ms.m_bObjectColor; MT_Vector4& rgba = ms.m_RGBAcolor; RAS_MeshSlot::iterator it; + struct MTFace* tface = 0; + + const STR_String& mytext = ((CValue*)m_clientobject)->GetPropertyText("Text"); + + const unsigned int flag = polymat->GetFlag(); + unsigned int *col = 0; // handle object color if (obcolor) { @@ -732,9 +738,18 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms, for (unit=0; unitGetDrawingMode(), polymat, - v[0], v[1], v[2], (numvert == 4)? v[3]: NULL, glattrib); + + if (flag & RAS_BLENDERMAT) { + KX_BlenderMaterial *bl_mat = static_cast(polymat); + tface = bl_mat->GetMTFace(); + col = bl_mat->GetMCol(); + } else { + KX_PolygonMaterial* blenderpoly = static_cast(polymat); + tface = blenderpoly->GetMTFace(); + col = blenderpoly->GetMCol(); + } + + GPU_render_text(tface, polymat->GetDrawingMode(), mytext, mytext.Length(), col, v[1], v[2], v[3], v[4], glattrib); ClearCachingInfo(); } @@ -1500,34 +1515,6 @@ void RAS_OpenGLRasterizer::RenderText2D(RAS_TEXT_RENDER_MODE mode, glEnable(GL_DEPTH_TEST); } -/* Render Text renders text into a (series of) polygon, using a texture font, - * Each character consists of one polygon (one quad or two triangles) */ - -void RAS_OpenGLRasterizer::RenderText( - int mode, - RAS_IPolyMaterial* polymat, - float v1[3], float v2[3], float v3[3], float v4[3], int glattrib) -{ - const STR_String& mytext = ((CValue*)m_clientobject)->GetPropertyText("Text"); - - const unsigned int flag = polymat->GetFlag(); - struct MTFace* tface = 0; - unsigned int *col = 0; - - if (flag & RAS_BLENDERMAT) { - KX_BlenderMaterial *bl_mat = static_cast(polymat); - tface = bl_mat->GetMTFace(); - col = bl_mat->GetMCol(); - } else { - KX_PolygonMaterial* blenderpoly = static_cast(polymat); - tface = blenderpoly->GetMTFace(); - col = blenderpoly->GetMCol(); - } - - GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib); -} - - void RAS_OpenGLRasterizer::PushMatrix() { glPushMatrix(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index bd9e479464a..a6fa057e6c0 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -366,14 +366,6 @@ public: int width, int height); - void RenderText(int mode, - class RAS_IPolyMaterial* polymat, - float v1[3], - float v2[3], - float v3[3], - float v4[3], - int glattrib); - void applyTransform(double* oglmatrix, int objectdrawmode); int applyLights(int objectlayer, const MT_Transform& viewmat); -- cgit v1.2.3 From 5348682f3aad87c1c598af04d407a91a50b71e7e Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:21:25 +0000 Subject: BGE Rasterizer Cleanup: Getting rid of the BL_Material.h include in RAS_OpenGLRasterizer.cpp. --- .../Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 4a8afb2b652..aada984ef76 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -64,7 +64,6 @@ extern "C"{ // XXX Clean these up <<< -#include "BL_Material.h" // MAXTEX #include "Value.h" #include "KX_BlenderMaterial.h" #include "KX_PolygonMaterial.h" @@ -1370,7 +1369,7 @@ static void DisableForText() glDisable(GL_COLOR_MATERIAL); if (GLEW_ARB_multitexture) { - for (int i=0; i Date: Mon, 4 Nov 2013 19:21:32 +0000 Subject: BGE Rasterizer Cleanup: Removing the need to reference KX_BlenderMaterial or KX_PolygonMaterial in RAS_OpenGLRasterizer. --- source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 4 ++-- source/gameengine/Ketsji/KX_BlenderMaterial.h | 4 ++-- source/gameengine/Ketsji/KX_PolygonMaterial.h | 4 ++-- source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp | 9 +++++++++ source/gameengine/Rasterizer/RAS_IPolygonMaterial.h | 2 ++ .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 18 +----------------- 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index e5b8159753b..efaaed7b567 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -129,13 +129,13 @@ KX_BlenderMaterial::~KX_BlenderMaterial() OnExit(); } -MTFace* KX_BlenderMaterial::GetMTFace(void) const +MTFace* KX_BlenderMaterial::GetMTFace() const { // fonts on polys return &mMaterial->tface; } -unsigned int* KX_BlenderMaterial::GetMCol(void) const +unsigned int* KX_BlenderMaterial::GetMCol() const { // fonts on polys return mMaterial->rgb; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 0a2675f04a8..b7c64215eaf 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -79,8 +79,8 @@ public: Material* GetBlenderMaterial() const; Image* GetBlenderImage() const; - MTFace* GetMTFace(void) const; - unsigned int* GetMCol(void) const; + MTFace* GetMTFace() const; + unsigned int* GetMCol() const; BL_Texture * getTex (unsigned int idx) { return (idx < MAXTEX) ? mTextures + idx : NULL; } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index 89bfb4ff9fb..380ac5f523d 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -118,12 +118,12 @@ public: * Returns the Blender texture face structure that is used for this material. * \return The material's texture face. */ - MTFace* GetMTFace(void) const + MTFace* GetMTFace() const { return &m_tface; } - unsigned int* GetMCol(void) const + unsigned int* GetMCol() const { return &m_mcol; } diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index ddadd97b567..9d55fde20c3 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -235,6 +235,15 @@ Image *RAS_IPolyMaterial::GetBlenderImage() const { return NULL; } +MTFace *RAS_IPolyMaterial::GetMTFace() const +{ + return NULL; +} + +unsigned int *RAS_IPolyMaterial::GetMCol() const +{ + return NULL; +} Scene* RAS_IPolyMaterial::GetBlenderScene() const { diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index 7aeeb364b47..67e74dfaa3b 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -167,6 +167,8 @@ public: virtual Material* GetBlenderMaterial() const; virtual Image* GetBlenderImage() const; + virtual MTFace* GetMTFace() const; + virtual unsigned int* GetMCol() const; virtual Scene* GetBlenderScene() const; virtual void ReleaseMaterial(); virtual void GetMaterialRGBAColor(unsigned char *rgba) const; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index aada984ef76..cdfeac5ce9c 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -65,8 +65,6 @@ extern "C"{ // XXX Clean these up <<< #include "Value.h" -#include "KX_BlenderMaterial.h" -#include "KX_PolygonMaterial.h" #include "KX_Light.h" #include "KX_Scene.h" #include "KX_RayCast.h" @@ -680,13 +678,9 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms, bool obcolor = ms.m_bObjectColor; MT_Vector4& rgba = ms.m_RGBAcolor; RAS_MeshSlot::iterator it; - struct MTFace* tface = 0; const STR_String& mytext = ((CValue*)m_clientobject)->GetPropertyText("Text"); - const unsigned int flag = polymat->GetFlag(); - unsigned int *col = 0; - // handle object color if (obcolor) { glDisableClientState(GL_COLOR_ARRAY); @@ -738,17 +732,7 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms, if (m_attrib[unit] == RAS_TEXCO_UV) glattrib = unit; - if (flag & RAS_BLENDERMAT) { - KX_BlenderMaterial *bl_mat = static_cast(polymat); - tface = bl_mat->GetMTFace(); - col = bl_mat->GetMCol(); - } else { - KX_PolygonMaterial* blenderpoly = static_cast(polymat); - tface = blenderpoly->GetMTFace(); - col = blenderpoly->GetMCol(); - } - - GPU_render_text(tface, polymat->GetDrawingMode(), mytext, mytext.Length(), col, v[1], v[2], v[3], v[4], glattrib); + GPU_render_text(polymat->GetMTFace(), polymat->GetDrawingMode(), mytext, mytext.Length(), polymat->GetMCol(), v[1], v[2], v[3], v[4], glattrib); ClearCachingInfo(); } -- cgit v1.2.3 From a35e9daaef3c4342e7c4881dbb535c96ecc7bc34 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:21:37 +0000 Subject: BGE Rasterizer Cleanup: Moving the RAS_OpenGLRasterizer::ApplyLights() code into RAS_OpenGLRasterizer::ProcessLighting(). --- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 58 ++++++++++------------ .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 1 - 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index cdfeac5ce9c..2bd988145c3 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -1159,8 +1159,33 @@ void RAS_OpenGLRasterizer::ProcessLighting(bool uselights, const MT_Transform& v m_lastauxinfo = m_auxilaryClientInfo; /* enable/disable lights as needed */ - if (layer >= 0) - enable = ApplyLights(layer, viewmat); + if (layer >= 0) { + //enable = ApplyLights(layer, viewmat); + // taken from blender source, incompatibility between Blender Object / GameObject + KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; + float glviewmat[16]; + unsigned int count; + std::vector::iterator lit = m_lights.begin(); + + for (count=0; countm_light; + + if (kxlight->ApplyLight(kxscene, layer, count)) + count++; + } + glPopMatrix(); + + enable = count > 0; + } if (enable) EnableOpenGLLights(); @@ -1508,35 +1533,6 @@ void RAS_OpenGLRasterizer::PopMatrix() glPopMatrix(); } - -int RAS_OpenGLRasterizer::ApplyLights(int objectlayer, const MT_Transform& viewmat) -{ - // taken from blender source, incompatibility between Blender Object / GameObject - KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; - float glviewmat[16]; - unsigned int count; - std::vector::iterator lit = m_lights.begin(); - - for (count=0; countm_light; - - if (kxlight->ApplyLight(kxscene, objectlayer, count)) - count++; - } - glPopMatrix(); - - return count; -} - void RAS_OpenGLRasterizer::MotionBlur() { int state = GetMotionBlurState(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index a6fa057e6c0..1fc97201480 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -367,7 +367,6 @@ public: int height); void applyTransform(double* oglmatrix, int objectdrawmode); - int applyLights(int objectlayer, const MT_Transform& viewmat); void PushMatrix(); void PopMatrix(); -- cgit v1.2.3 From 0cec5c63dabf1fa8a1c54642cc029bbf0001ef01 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:21:50 +0000 Subject: BGE Rasterizer Cleanup: Removing the Singletexture material mode. More conversion code will probably be needed. --- source/blender/blenloader/intern/readfile.c | 10 + source/blender/makesdna/DNA_scene_types.h | 2 +- source/blender/makesrna/intern/rna_scene.c | 1 - .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 2 +- .../Converter/BL_BlenderDataConversion.cpp | 174 +-------- .../Converter/KX_BlenderSceneConverter.cpp | 23 +- .../GamePlayer/ghost/GPG_Application.cpp | 2 +- source/gameengine/Ketsji/CMakeLists.txt | 2 - source/gameengine/Ketsji/KX_MeshProxy.cpp | 11 +- source/gameengine/Ketsji/KX_PolyProxy.cpp | 13 +- source/gameengine/Ketsji/KX_PolygonMaterial.cpp | 422 --------------------- source/gameengine/Ketsji/KX_PolygonMaterial.h | 156 -------- source/gameengine/Ketsji/KX_PythonInit.cpp | 8 +- source/gameengine/Ketsji/KX_PythonInitTypes.cpp | 2 - source/gameengine/VideoTexture/Texture.cpp | 10 +- 15 files changed, 42 insertions(+), 796 deletions(-) delete mode 100644 source/gameengine/Ketsji/KX_PolygonMaterial.cpp delete mode 100644 source/gameengine/Ketsji/KX_PolygonMaterial.h diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index bc7cd2d9143..17ae0b103ca 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9783,6 +9783,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + { + Scene *scene; + + for (scene = main->scene.first; scene; scene = scene->id.next) { + if (scene->gm.matmode == GAME_MAT_TEXFACE) { + scene->gm.matmode = GAME_MAT_MULTITEX; + } + } + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 6ebc604bc7e..1ddc7d6ee06 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -725,7 +725,7 @@ typedef struct GameData { #define GAME_PLAYER_DESKTOP_RESOLUTION (1 << 1) /* GameData.matmode */ -#define GAME_MAT_TEXFACE 0 +#define GAME_MAT_TEXFACE 0 /* deprecated */ #define GAME_MAT_MULTITEX 1 #define GAME_MAT_GLSL 2 diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 7e726c9b16b..ef3ee07e211 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3143,7 +3143,6 @@ static void rna_def_scene_game_data(BlenderRNA *brna) }; static EnumPropertyItem material_items[] = { - {GAME_MAT_TEXFACE, "SINGLETEXTURE", 0, "Singletexture", "Singletexture face materials"}, {GAME_MAT_MULTITEX, "MULTITEXTURE", 0, "Multitexture", "Multitexture materials"}, {GAME_MAT_GLSL, "GLSL", 0, "GLSL", "OpenGL shading language shaders"}, {0, NULL, 0, NULL, NULL} diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 0c259f1ad79..2b1c8a10cce 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -470,7 +470,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c else if (gs.matmode == GAME_MAT_GLSL) usemat = false; - if (usemat && (gs.matmode != GAME_MAT_TEXFACE)) + if (usemat) sceneconverter->SetMaterials(true); if (useglslmat && (gs.matmode == GAME_MAT_GLSL)) sceneconverter->SetGLSLMaterials(true); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index d87541ce080..b753f667e70 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -42,7 +42,6 @@ #include "KX_BlenderScalarInterpolator.h" #include "RAS_IPolygonMaterial.h" -#include "KX_PolygonMaterial.h" // Expressions #include "ListValue.h" @@ -891,167 +890,33 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace RAS_IPolyMaterial* polymat = converter->FindCachedPolyMaterial(scene, ma); BL_Material* bl_mat = converter->FindCachedBlenderMaterial(scene, ma); KX_BlenderMaterial* kx_blmat = NULL; - KX_PolygonMaterial* kx_polymat = NULL; - - if (converter->GetMaterials()) { - /* do Blender Multitexture and Blender GLSL materials */ - - /* first is the BL_Material */ - if (!bl_mat) - { - bl_mat = new BL_Material(); - - ConvertMaterial(bl_mat, ma, tface, tfaceName, mface, mcol, - converter->GetGLSLMaterials()); - if (ma && (ma->mode & MA_FACETEXTURE) == 0) - converter->CacheBlenderMaterial(scene, ma, bl_mat); - } - - const bool use_vcol = GetMaterialUseVColor(ma, bl_mat->glslmat); - GetRGB(use_vcol, mface, mcol, ma, rgb); + /* first is the BL_Material */ + if (!bl_mat) + { + bl_mat = new BL_Material(); - GetUVs(bl_mat, layers, mface, tface, uvs); - - /* then the KX_BlenderMaterial */ - if (polymat == NULL) - { - kx_blmat = new KX_BlenderMaterial(); + ConvertMaterial(bl_mat, ma, tface, tfaceName, mface, mcol, + converter->GetGLSLMaterials()); - kx_blmat->Initialize(scene, bl_mat, (ma?&ma->game:NULL), lightlayer); - polymat = static_cast(kx_blmat); - if (ma && (ma->mode & MA_FACETEXTURE) == 0) - converter->CachePolyMaterial(scene, ma, polymat); - } + if (ma && (ma->mode & MA_FACETEXTURE) == 0) + converter->CacheBlenderMaterial(scene, ma, bl_mat); } - else { - /* do Texture Face materials */ - Image* bima = (tface)? (Image*)tface->tpage: NULL; - STR_String imastr = (tface)? (bima? (bima)->id.name : "" ) : ""; - - char alpha_blend=0; - short tile=0; - int tilexrep=4,tileyrep = 4; - - /* set material properties - old TexFace */ - if (ma) { - alpha_blend = ma->game.alpha_blend; - /* Commented out for now. If we ever get rid of - * "Texture Face/Singletexture" we can then think about it */ - - /* Texture Face mode ignores texture but requires "Face Textures to be True "*/ - #if 0 - if ((ma->mode &MA_FACETEXTURE)==0 && (ma->game.flag &GEMAT_TEXT)==0) { - bima = NULL; - imastr = ""; - alpha_blend = GEMAT_SOLID; - } - else { - alpha_blend = ma->game.alpha_blend; - } - #endif - } - /* check for tface tex to fallback on */ - else { - if (bima) { - /* see if depth of the image is 32 */ - if (BKE_image_has_alpha(bima)) - alpha_blend = GEMAT_ALPHA; - else - alpha_blend = GEMAT_SOLID; - } - else { - alpha_blend = GEMAT_SOLID; - } - } - if (bima) { - tilexrep = bima->xrep; - tileyrep = bima->yrep; - } + const bool use_vcol = GetMaterialUseVColor(ma, bl_mat->glslmat); + GetRGB(use_vcol, mface, mcol, ma, rgb); - /* set UV properties */ - if (tface) { - uvs[0][0].setValue(tface->uv[0]); - uvs[1][0].setValue(tface->uv[1]); - uvs[2][0].setValue(tface->uv[2]); - - if (mface->v4) - uvs[3][0].setValue(tface->uv[3]); + GetUVs(bl_mat, layers, mface, tface, uvs); - tile = tface->tile; - } - else { - /* no texfaces */ - tile = 0; - } - - /* get vertex colors */ - if (mcol) { - /* we have vertex colors */ - rgb[0] = KX_Mcol2uint_new(mcol[0]); - rgb[1] = KX_Mcol2uint_new(mcol[1]); - rgb[2] = KX_Mcol2uint_new(mcol[2]); - - if (mface->v4) - rgb[3] = KX_Mcol2uint_new(mcol[3]); - } - else { - /* no vertex colors, take from material, otherwise white */ - unsigned int color = 0xFFFFFFFFL; - - if (ma) - { - union - { - unsigned char cp[4]; - unsigned int integer; - } col_converter; - - col_converter.cp[3] = (unsigned char) (ma->r*255.0); - col_converter.cp[2] = (unsigned char) (ma->g*255.0); - col_converter.cp[1] = (unsigned char) (ma->b*255.0); - col_converter.cp[0] = (unsigned char) (ma->alpha*255.0); - - color = col_converter.integer; - } - - rgb[0] = KX_rgbaint2uint_new(color); - rgb[1] = KX_rgbaint2uint_new(color); - rgb[2] = KX_rgbaint2uint_new(color); - - if (mface->v4) - rgb[3] = KX_rgbaint2uint_new(color); - } - - // only zsort alpha + add - const bool alpha = ELEM3(alpha_blend, GEMAT_ALPHA, GEMAT_ADD, GEMAT_ALPHA_SORT); - const bool zsort = (alpha_blend == GEMAT_ALPHA_SORT); - const bool light = (ma)?(ma->mode & MA_SHLESS)==0:default_light_mode; - - // don't need zort anymore, deal as if it it's alpha blend - if (alpha_blend == GEMAT_ALPHA_SORT) alpha_blend = GEMAT_ALPHA; - - if (polymat == NULL) - { - kx_polymat = new KX_PolygonMaterial(); - kx_polymat->Initialize(imastr, ma, (int)mface->mat_nr, - tile, tilexrep, tileyrep, - alpha_blend, alpha, zsort, light, lightlayer, tface, (unsigned int*)mcol); - polymat = static_cast(kx_polymat); - - if (ma) { - polymat->m_specular = MT_Vector3(ma->specr, ma->specg, ma->specb)*ma->spec; - polymat->m_shininess = (float)ma->har/4.0f; // 0 < ma->har <= 512 - polymat->m_diffuse = MT_Vector3(ma->r, ma->g, ma->b)*(ma->emit + ma->ref); - } - else { - polymat->m_specular.setValue(0.0f,0.0f,0.0f); - polymat->m_shininess = 35.0; - } + /* then the KX_BlenderMaterial */ + if (polymat == NULL) + { + kx_blmat = new KX_BlenderMaterial(); + kx_blmat->Initialize(scene, bl_mat, (ma?&ma->game:NULL), lightlayer); + polymat = static_cast(kx_blmat); + if (ma && (ma->mode & MA_FACETEXTURE) == 0) converter->CachePolyMaterial(scene, ma, polymat); - } } // see if a bucket was reused or a new one was created @@ -1061,8 +926,7 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace if (bucketCreated) { // this is needed to free up memory afterwards converter->RegisterPolyMaterial(polymat); - if (converter->GetMaterials()) - converter->RegisterBlenderMaterial(bl_mat); + converter->RegisterBlenderMaterial(bl_mat); } return bucket; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 05a2c344c1a..f642fd43aef 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -46,7 +46,6 @@ #include "BL_Material.h" #include "BL_ActionActuator.h" #include "KX_BlenderMaterial.h" -#include "KX_PolygonMaterial.h" #include "BL_System.h" @@ -1419,15 +1418,8 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) RAS_IPolyMaterial *mat= (*polymit).second; Material *bmat= NULL; - /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject *)? - Campbell */ - if (mat->GetFlag() & RAS_BLENDERMAT) { - KX_BlenderMaterial *bl_mat = static_cast(mat); - bmat= bl_mat->GetBlenderMaterial(); - - } else { - KX_PolygonMaterial *kx_mat = static_cast(mat); - bmat= kx_mat->GetBlenderMaterial(); - } + KX_BlenderMaterial *bl_mat = static_cast(mat); + bmat= bl_mat->GetBlenderMaterial(); if (IS_TAGGED(bmat)) { /* only remove from bucket */ @@ -1444,15 +1436,8 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) RAS_IPolyMaterial *mat= (*polymit).second; Material *bmat= NULL; - /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject *)? - Campbell */ - if (mat->GetFlag() & RAS_BLENDERMAT) { - KX_BlenderMaterial *bl_mat = static_cast(mat); - bmat= bl_mat->GetBlenderMaterial(); - - } else { - KX_PolygonMaterial *kx_mat = static_cast(mat); - bmat= kx_mat->GetBlenderMaterial(); - } + KX_BlenderMaterial *bl_mat = static_cast(mat); + bmat= bl_mat->GetBlenderMaterial(); if (bmat) { //printf("FOUND MAT '%s' !!! ", ((ID*)bmat)->name+2); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index d8eb224d5f7..d51d0bf5c10 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -703,7 +703,7 @@ bool GPG_Application::startEngine(void) // if (always_use_expand_framing) // sceneconverter->SetAlwaysUseExpandFraming(true); - if (m_blendermat && (m_globalSettings->matmode != GAME_MAT_TEXFACE)) + if (m_blendermat) m_sceneconverter->SetMaterials(true); if (m_blenderglslmat && (m_globalSettings->matmode == GAME_MAT_GLSL)) m_sceneconverter->SetGLSLMaterials(true); diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 7da63dcc6f4..c3c733c66ba 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -103,7 +103,6 @@ set(SRC KX_OrientationInterpolator.cpp KX_ParentActuator.cpp KX_PolyProxy.cpp - KX_PolygonMaterial.cpp KX_PositionInterpolator.cpp KX_PyConstraintBinding.cpp KX_PyMath.cpp @@ -186,7 +185,6 @@ set(SRC KX_ParentActuator.h KX_PhysicsEngineEnums.h KX_PolyProxy.h - KX_PolygonMaterial.h KX_PositionInterpolator.h KX_PyConstraintBinding.h KX_PyMath.h diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 2a9d59e8b7b..c288c647fa2 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -39,7 +39,6 @@ #include "KX_VertexProxy.h" #include "KX_PolyProxy.h" -#include "KX_PolygonMaterial.h" #include "KX_BlenderMaterial.h" #include "KX_PyMath.h" @@ -388,14 +387,8 @@ PyObject *KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_ for (i=0; im_bucket->GetPolyMaterial(); - if (polymat->GetFlag() & RAS_BLENDERMAT) { - KX_BlenderMaterial *mat = static_cast(polymat); - PyList_SET_ITEM(materials, i, mat->GetProxy()); - } - else { - KX_PolygonMaterial *mat = static_cast(polymat); - PyList_SET_ITEM(materials, i, mat->GetProxy()); - } + KX_BlenderMaterial *mat = static_cast(polymat); + PyList_SET_ITEM(materials, i, mat->GetProxy()); } return materials; } diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index 83092c7d89c..ea26cb56e52 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -36,7 +36,6 @@ #include "KX_MeshProxy.h" #include "RAS_MeshObject.h" #include "KX_BlenderMaterial.h" -#include "KX_PolygonMaterial.h" #include "KX_PyMath.h" @@ -259,16 +258,8 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterial, "getMaterial() : returns a material\n") { RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial(); - if (polymat->GetFlag() & RAS_BLENDERMAT) - { - KX_BlenderMaterial* mat = static_cast(polymat); - return mat->GetProxy(); - } - else - { - KX_PolygonMaterial* mat = static_cast(polymat); - return mat->GetProxy(); - } + KX_BlenderMaterial* mat = static_cast(polymat); + return mat->GetProxy(); } #endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp deleted file mode 100644 index 0f53c510cf7..00000000000 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ /dev/null @@ -1,422 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file gameengine/Ketsji/KX_PolygonMaterial.cpp - * \ingroup ketsji - */ - - -#include - -#include "KX_PolygonMaterial.h" - -#include "BKE_mesh.h" -#include "BKE_global.h" -#include "BKE_image.h" - -#include "DNA_material_types.h" -#include "DNA_texture_types.h" -#include "DNA_image_types.h" -#include "DNA_meshdata_types.h" - -#include "IMB_imbuf_types.h" - -#include "GPU_draw.h" - -#include "MEM_guardedalloc.h" - -#include "RAS_LightObject.h" -#include "RAS_MaterialBucket.h" - -#include "KX_PyMath.h" - -#define KX_POLYGONMATERIAL_CAPSULE_ID "KX_POLYGONMATERIAL_PTR" - -KX_PolygonMaterial::KX_PolygonMaterial() - : PyObjectPlus(), - RAS_IPolyMaterial(), - - m_material(NULL), -#ifdef WITH_PYTHON - m_pymaterial(NULL), -#endif - m_pass(0) -{ - memset(&m_tface, 0, sizeof(m_tface)); - memset(&m_mcol, 0, sizeof(m_mcol)); -} - -void KX_PolygonMaterial::Initialize( - const STR_String &texname, - Material* ma, - int materialindex, - int tile, - int tilexrep, - int tileyrep, - int alphablend, - bool alpha, - bool zsort, - bool light, - int lightlayer, - struct MTFace* tface, - unsigned int* mcol) -{ - RAS_IPolyMaterial::Initialize( - texname, - ma?ma->id.name:"", - materialindex, - tile, - tilexrep, - tileyrep, - alphablend, - alpha, - zsort, - light, - (texname && texname != ""?true:false), /* if we have a texture we have image */ - ma?&ma->game:NULL); - - if (tface) { - m_tface = *tface; - } - else { - memset(&m_tface, 0, sizeof(m_tface)); - } - if (mcol) { - m_mcol = *mcol; - } - else { - memset(&m_mcol, 0, sizeof(m_mcol)); - } - - m_material = ma; -#ifdef WITH_PYTHON - m_pymaterial = 0; -#endif - m_pass = 0; -} - -KX_PolygonMaterial::~KX_PolygonMaterial() -{ -#ifdef WITH_PYTHON - if (m_pymaterial) - { - Py_DECREF(m_pymaterial); - } -#endif // WITH_PYTHON -} - -Image *KX_PolygonMaterial::GetBlenderImage() const -{ - return m_tface.tpage; -} - -bool KX_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const -{ - bool dopass = false; - -#ifdef WITH_PYTHON - if (m_pymaterial) - { - PyObject *pyRasty = PyCapsule_New((void*)rasty, KX_POLYGONMATERIAL_CAPSULE_ID, NULL); /* new reference */ - PyObject *pyCachingInfo = PyCapsule_New((void*) &cachingInfo, KX_POLYGONMATERIAL_CAPSULE_ID, NULL); /* new reference */ - PyObject *ret = PyObject_CallMethod(m_pymaterial, (char *)"activate", (char *)"(NNO)", pyRasty, pyCachingInfo, (PyObject *) this->m_proxy); - if (ret) - { - bool value = PyLong_AsLong(ret); - Py_DECREF(ret); - dopass = value; - } - else - { - PyErr_Print(); - PyErr_Clear(); - PySys_SetObject("last_traceback", NULL); - } - } - else -#endif // WITH_PYTHON - { - switch (m_pass++) - { - case 0: - DefaultActivate(rasty, cachingInfo); - dopass = true; - break; - default: - m_pass = 0; - dopass = false; - break; - } - } - - return dopass; -} - -void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const -{ - if (GetCachingInfo() != cachingInfo) - { - if (!cachingInfo) - GPU_set_tpage(NULL, 0, 0); - - cachingInfo = GetCachingInfo(); - - if ((m_drawingmode & RAS_IRasterizer::KX_TEX)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)) - { - Image *ima = m_tface.tpage; - GPU_update_image_time(ima, rasty->GetTime()); - GPU_set_tpage(&m_tface, 1, m_alphablend); - } - else - GPU_set_tpage(NULL, 0, 0); - - if (m_drawingmode & RAS_IRasterizer::KX_BACKCULL) - rasty->SetCullFace(true); - else - rasty->SetCullFace(false); - - if ((m_drawingmode & RAS_IRasterizer::KX_LINES) || - (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) - rasty->SetLines(true); - else - rasty->SetLines(false); - rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity); - rasty->SetShinyness(m_shininess); - rasty->SetDiffuse(m_diffuse[0], m_diffuse[1],m_diffuse[2], 1.0); - if (m_material) - rasty->SetPolygonOffset(-m_material->zoffs, 0.0); - } - - //rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity); - //rasty->SetShinyness(m_shininess); - //rasty->SetDiffuse(m_diffuse[0], m_diffuse[1],m_diffuse[2], 1.0); - //if (m_material) - // rasty->SetPolygonOffset(-m_material->zoffs, 0.0); -} - -void KX_PolygonMaterial::GetMaterialRGBAColor(unsigned char *rgba) const -{ - if (m_material) { - *rgba++ = (unsigned char) (m_material->r*255.0); - *rgba++ = (unsigned char) (m_material->g*255.0); - *rgba++ = (unsigned char) (m_material->b*255.0); - *rgba++ = (unsigned char) (m_material->alpha*255.0); - } else - RAS_IPolyMaterial::GetMaterialRGBAColor(rgba); -} - -#ifdef WITH_PYTHON - -//---------------------------------------------------------------------------- -//Python - - -PyMethodDef KX_PolygonMaterial::Methods[] = { - KX_PYMETHODTABLE(KX_PolygonMaterial, setCustomMaterial), - KX_PYMETHODTABLE(KX_PolygonMaterial, updateTexture), - KX_PYMETHODTABLE(KX_PolygonMaterial, setTexture), - KX_PYMETHODTABLE(KX_PolygonMaterial, activate), -// KX_PYMETHODTABLE(KX_PolygonMaterial, setPerPixelLights), - - {NULL,NULL} //Sentinel -}; - -PyAttributeDef KX_PolygonMaterial::Attributes[] = { - KX_PYATTRIBUTE_RO_FUNCTION("texture", KX_PolygonMaterial, pyattr_get_texture), - KX_PYATTRIBUTE_RO_FUNCTION("material", KX_PolygonMaterial, pyattr_get_material), /* should probably be .name ? */ - - KX_PYATTRIBUTE_INT_RW("tile", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tile), - KX_PYATTRIBUTE_INT_RW("tilexrep", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tilexrep), - KX_PYATTRIBUTE_INT_RW("tileyrep", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_tileyrep), - KX_PYATTRIBUTE_INT_RW("drawingmode", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_drawingmode), - //KX_PYATTRIBUTE_INT_RW("lightlayer", INT_MIN, INT_MAX, true, KX_PolygonMaterial, m_lightlayer), - - KX_PYATTRIBUTE_BOOL_RW("transparent", KX_PolygonMaterial, m_alpha), - KX_PYATTRIBUTE_BOOL_RW("zsort", KX_PolygonMaterial, m_zsort), - - KX_PYATTRIBUTE_FLOAT_RW("shininess", 0.0f, 1000.0f, KX_PolygonMaterial, m_shininess), - KX_PYATTRIBUTE_FLOAT_RW("specularity", 0.0f, 1000.0f, KX_PolygonMaterial, m_specularity), - - KX_PYATTRIBUTE_RW_FUNCTION("diffuse", KX_PolygonMaterial, pyattr_get_diffuse, pyattr_set_diffuse), - KX_PYATTRIBUTE_RW_FUNCTION("specular",KX_PolygonMaterial, pyattr_get_specular, pyattr_set_specular), - - KX_PYATTRIBUTE_RO_FUNCTION("tface", KX_PolygonMaterial, pyattr_get_tface), /* How the heck is this even useful??? - Campbell */ - KX_PYATTRIBUTE_RO_FUNCTION("gl_texture", KX_PolygonMaterial, pyattr_get_gl_texture), /* could be called 'bindcode' */ - { NULL } //Sentinel -}; - -PyTypeObject KX_PolygonMaterial::Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "KX_PolygonMaterial", - sizeof(PyObjectPlus_Proxy), - 0, - py_base_dealloc, - 0, - 0, - 0, - 0, - py_base_repr, - 0,0,0,0,0,0,0,0,0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - 0,0,0,0,0,0,0, - Methods, - 0, - 0, - &PyObjectPlus::Type, - 0,0,0,0,0,0, - py_base_new -}; - -KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setCustomMaterial, "setCustomMaterial(material)") -{ - PyObject *material; - if (PyArg_ParseTuple(args, "O:setCustomMaterial", &material)) - { - if (m_pymaterial) { - Py_DECREF(m_pymaterial); - } - m_pymaterial = material; - Py_INCREF(m_pymaterial); - Py_RETURN_NONE; - } - - return NULL; -} - -KX_PYMETHODDEF_DOC(KX_PolygonMaterial, updateTexture, "updateTexture(tface, rasty)") -{ - PyObject *pyrasty, *pytface; - if (PyArg_ParseTuple(args, "O!O!:updateTexture", &PyCapsule_Type, &pytface, &PyCapsule_Type, &pyrasty)) - { - MTFace *tface = (MTFace*) PyCapsule_GetPointer(pytface, KX_POLYGONMATERIAL_CAPSULE_ID); - RAS_IRasterizer *rasty = (RAS_IRasterizer*) PyCapsule_GetPointer(pyrasty, KX_POLYGONMATERIAL_CAPSULE_ID); - Image *ima = (Image*)tface->tpage; - GPU_update_image_time(ima, rasty->GetTime()); - - Py_RETURN_NONE; - } - - return NULL; -} - -KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setTexture, "setTexture(tface)") -{ - PyObject *pytface; - if (PyArg_ParseTuple(args, "O!:setTexture", &PyCapsule_Type, &pytface)) - { - MTFace *tface = (MTFace*) PyCapsule_GetPointer(pytface, KX_POLYGONMATERIAL_CAPSULE_ID); - GPU_set_tpage(tface, 1, m_alphablend); - Py_RETURN_NONE; - } - - return NULL; -} - -KX_PYMETHODDEF_DOC(KX_PolygonMaterial, activate, "activate(rasty, cachingInfo)") -{ - PyObject *pyrasty, *pyCachingInfo; - if (PyArg_ParseTuple(args, "O!O!:activate", &PyCapsule_Type, &pyrasty, &PyCapsule_Type, &pyCachingInfo)) - { - RAS_IRasterizer *rasty = static_cast(PyCapsule_GetPointer(pyrasty, KX_POLYGONMATERIAL_CAPSULE_ID)); - TCachingInfo *cachingInfo = static_cast(PyCapsule_GetPointer(pyCachingInfo, KX_POLYGONMATERIAL_CAPSULE_ID)); - if (rasty && cachingInfo) - { - DefaultActivate(rasty, *cachingInfo); - Py_RETURN_NONE; - } - } - - return NULL; -} - -PyObject *KX_PolygonMaterial::pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_PolygonMaterial* self = static_cast(self_v); - return PyUnicode_From_STR_String(self->m_texturename); -} - -PyObject *KX_PolygonMaterial::pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_PolygonMaterial* self = static_cast(self_v); - return PyUnicode_From_STR_String(self->m_materialname); -} - -/* this does not seem useful */ -PyObject *KX_PolygonMaterial::pyattr_get_tface(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_PolygonMaterial* self = static_cast(self_v); - return PyCapsule_New(&self->m_tface, KX_POLYGONMATERIAL_CAPSULE_ID, NULL); -} - -PyObject *KX_PolygonMaterial::pyattr_get_gl_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_PolygonMaterial* self = static_cast(self_v); - int bindcode= 0; - if (self->m_tface.tpage) - bindcode= self->m_tface.tpage->bindcode; - - return PyLong_FromLong(bindcode); -} - - -PyObject *KX_PolygonMaterial::pyattr_get_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_PolygonMaterial* self = static_cast(self_v); - return PyObjectFrom(self->m_diffuse); -} - -int KX_PolygonMaterial::pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) -{ - KX_PolygonMaterial* self = static_cast(self_v); - MT_Vector3 vec; - - if (!PyVecTo(value, vec)) - return PY_SET_ATTR_FAIL; - - self->m_diffuse= vec; - return PY_SET_ATTR_SUCCESS; -} - -PyObject *KX_PolygonMaterial::pyattr_get_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) -{ - KX_PolygonMaterial* self = static_cast(self_v); - return PyObjectFrom(self->m_specular); -} - -int KX_PolygonMaterial::pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) -{ - KX_PolygonMaterial* self = static_cast(self_v); - MT_Vector3 vec; - - if (!PyVecTo(value, vec)) - return PY_SET_ATTR_FAIL; - - self->m_specular= vec; - return PY_SET_ATTR_SUCCESS; -} - -#endif // WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h deleted file mode 100644 index 380ac5f523d..00000000000 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file KX_PolygonMaterial.h - * \ingroup ketsji - */ - -#ifndef __KX_POLYGONMATERIAL_H__ -#define __KX_POLYGONMATERIAL_H__ - -#include "PyObjectPlus.h" - -#include "RAS_MaterialBucket.h" -#include "RAS_IRasterizer.h" -#include "DNA_ID.h" -#include "DNA_meshdata_types.h" - -#ifdef WITH_CXX_GUARDEDALLOC -#include "MEM_guardedalloc.h" -#endif - -struct MTFace; -struct Material; -struct MTex; -struct Image; - -/** - * Material class. - * - * This holds the shader, textures and python methods for setting the render state before - * rendering. - */ -class KX_PolygonMaterial : public PyObjectPlus, public RAS_IPolyMaterial -{ - Py_Header -private: - /** Blender texture face structure. */ - mutable MTFace m_tface; - mutable unsigned int m_mcol; - Material* m_material; - -#ifdef WITH_PYTHON - PyObject* m_pymaterial; -#endif - - mutable int m_pass; -public: - - KX_PolygonMaterial(); - void Initialize(const STR_String &texname, - Material* ma, - int materialindex, - int tile, - int tilexrep, - int tileyrep, - int alphablend, - bool alpha, - bool zsort, - bool light, - int lightlayer, - struct MTFace* tface, - unsigned int* mcol); - - virtual ~KX_PolygonMaterial(); - - /** - * Returns the caching information for this material, - * This can be used to speed up the rasterizing process. - * \return The caching information. - */ - virtual TCachingInfo GetCachingInfo(void) const - { - return (void*) this; - } - - /** - * Activates the material in the (OpenGL) rasterizer. - * On entry, the cachingInfo contains info about the last activated material. - * On exit, the cachingInfo should contain updated info about this material. - * \param rasty The rasterizer in which the material should be active. - * \param cachingInfo The information about the material used to speed up rasterizing. - */ - void DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const; - virtual bool Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const; - - Material *GetBlenderMaterial() const - { - return m_material; - } - - Image *GetBlenderImage() const; - - /** - * Returns the Blender texture face structure that is used for this material. - * \return The material's texture face. - */ - MTFace* GetMTFace() const - { - return &m_tface; - } - - unsigned int* GetMCol() const - { - return &m_mcol; - } - virtual void GetMaterialRGBAColor(unsigned char *rgba) const; - -#ifdef WITH_PYTHON - KX_PYMETHOD_DOC(KX_PolygonMaterial, updateTexture); - KX_PYMETHOD_DOC(KX_PolygonMaterial, setTexture); - KX_PYMETHOD_DOC(KX_PolygonMaterial, activate); - - KX_PYMETHOD_DOC(KX_PolygonMaterial, setCustomMaterial); - KX_PYMETHOD_DOC(KX_PolygonMaterial, loadProgram); - - virtual PyObject *py_repr(void) { return PyUnicode_FromString(m_material ? ((ID *)m_material)->name+2 : ""); } - - static PyObject* pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - - static PyObject* pyattr_get_tface(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_gl_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - - static PyObject* pyattr_get_diffuse(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static int pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - static PyObject* pyattr_get_specular(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static int pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); -#endif - -}; - -#endif /* __KX_POLYGONMATERIAL_H__ */ diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 29f28b7cc24..311653e72e7 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1226,7 +1226,6 @@ static PyObject *gPyGetGLSLMaterialSetting(PyObject *, return PyLong_FromLong(enabled); } -#define KX_TEXFACE_MATERIAL 0 #define KX_BLENDER_MULTITEX_MATERIAL 1 #define KX_BLENDER_GLSL_MATERIAL 2 @@ -1244,8 +1243,6 @@ static PyObject *gPySetMaterialType(PyObject *, gs->matmode= GAME_MAT_GLSL; else if (type == KX_BLENDER_MULTITEX_MATERIAL) gs->matmode= GAME_MAT_MULTITEX; - else if (type == KX_TEXFACE_MATERIAL) - gs->matmode= GAME_MAT_TEXFACE; else { PyErr_SetString(PyExc_ValueError, "Rasterizer.setMaterialType(int): material type is not known"); return NULL; @@ -1261,10 +1258,8 @@ static PyObject *gPyGetMaterialType(PyObject *) if (gs->matmode == GAME_MAT_GLSL) flag = KX_BLENDER_GLSL_MATERIAL; - else if (gs->matmode == GAME_MAT_MULTITEX) - flag = KX_BLENDER_MULTITEX_MATERIAL; else - flag = KX_TEXFACE_MATERIAL; + flag = KX_BLENDER_MULTITEX_MATERIAL; return PyLong_FromLong(flag); } @@ -2209,7 +2204,6 @@ PyObject *initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) Py_DECREF(ErrorObject); /* needed for get/setMaterialType */ - KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL); KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL); KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL); diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp index 05bdb3463a6..bacace9199a 100644 --- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp @@ -57,7 +57,6 @@ #include "KX_ObjectActuator.h" #include "KX_ParentActuator.h" #include "KX_PolyProxy.h" -#include "KX_PolygonMaterial.h" #include "KX_PythonSeq.h" #include "KX_SCA_AddObjectActuator.h" #include "KX_SCA_EndObjectActuator.h" @@ -211,7 +210,6 @@ void initPyTypes(void) PyType_Ready_Attr(dict, KX_ObjectActuator, init_getset); PyType_Ready_Attr(dict, KX_ParentActuator, init_getset); PyType_Ready_Attr(dict, KX_PolyProxy, init_getset); - PyType_Ready_Attr(dict, KX_PolygonMaterial, init_getset); PyType_Ready_Attr(dict, KX_RadarSensor, init_getset); PyType_Ready_Attr(dict, KX_RaySensor, init_getset); PyType_Ready_Attr(dict, KX_SCA_AddObjectActuator, init_getset); diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 1efbc50bfe0..c187f7c41c1 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -40,7 +40,6 @@ #include "DNA_meshdata_types.h" #include "DNA_image_types.h" #include "IMB_imbuf_types.h" -#include "KX_PolygonMaterial.h" #include "MEM_guardedalloc.h" @@ -229,19 +228,12 @@ static int Texture_init(Texture *self, PyObject *args, PyObject *kwds) { self->m_imgTexture = static_cast(mat)->getImage(texID); self->m_useMatTexture = false; - } else if (mat->GetFlag() & RAS_BLENDERMAT) + } else { // get blender material texture self->m_matTexture = static_cast(mat)->getTex(texID); self->m_useMatTexture = true; } - else - { - // get texture pointer from polygon material - MTFace * tface = static_cast(mat)->GetMTFace(); - self->m_imgTexture = (Image*)tface->tpage; - self->m_useMatTexture = false; - } } else if (lamp != NULL) { -- cgit v1.2.3 From fb94a539789e06148b28a73f59f0aefd0ad71e00 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:22:10 +0000 Subject: BGE Rasterizer Cleanup: Cleaning up some includes. --- source/gameengine/Ketsji/KX_Camera.cpp | 3 +++ source/gameengine/Ketsji/KX_Light.cpp | 1 + source/gameengine/Ketsji/KX_Light.h | 1 - source/gameengine/Ketsji/KX_NavMeshObject.cpp | 1 + source/gameengine/Ketsji/KX_PolyProxy.cpp | 1 + source/gameengine/Ketsji/KX_Scene.cpp | 1 + .../Physics/Bullet/CcdPhysicsController.cpp | 2 ++ source/gameengine/Rasterizer/RAS_2DFilterManager.h | 3 ++- source/gameengine/Rasterizer/RAS_BucketManager.cpp | 5 ++--- .../gameengine/Rasterizer/RAS_IPolygonMaterial.cpp | 2 -- .../gameengine/Rasterizer/RAS_IPolygonMaterial.h | 1 - .../gameengine/Rasterizer/RAS_MaterialBucket.cpp | 2 +- source/gameengine/Rasterizer/RAS_MaterialBucket.h | 20 +++++++++--------- source/gameengine/Rasterizer/RAS_MeshObject.cpp | 24 ++++++++++++++-------- source/gameengine/Rasterizer/RAS_MeshObject.h | 17 ++++----------- .../RAS_GLExtensionManager.cpp | 2 ++ .../RAS_OpenGLRasterizer/RAS_GLExtensionManager.h | 2 -- .../Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h | 11 ++-------- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 10 ++------- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 13 ++++++++++-- .../RAS_OpenGLRasterizer/RAS_StorageIM.cpp | 5 ++--- source/gameengine/Rasterizer/RAS_Polygon.cpp | 1 + source/gameengine/Rasterizer/RAS_Polygon.h | 6 +++--- source/gameengine/VideoTexture/ImageRender.cpp | 1 + source/gameengine/VideoTexture/ImageViewport.cpp | 1 + 25 files changed, 68 insertions(+), 68 deletions(-) diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 73ebf89bea3..4ab768e4240 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -37,6 +37,9 @@ #include "KX_PythonInit.h" #include "KX_Python.h" #include "KX_PyMath.h" + +#include "RAS_ICanvas.h" + KX_Camera::KX_Camera(void* sgReplicationInfo, SG_Callbacks callbacks, const RAS_CameraData& camdata, diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 1d314c577ca..4567c17cc3e 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -40,6 +40,7 @@ #include "KX_Light.h" #include "KX_Camera.h" #include "RAS_IRasterizer.h" +#include "RAS_ICanvas.h" #include "KX_PyMath.h" diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index 9a81388d43b..4f11c535cf0 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -38,7 +38,6 @@ struct GPULamp; struct Scene; struct Base; -struct RAS_LightObject; class KX_Camera; class RAS_IRasterizer; class MT_Transform; diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index c8e2370ab7f..42f62886ff7 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -30,6 +30,7 @@ #include "BLI_math_vector.h" #include "KX_NavMeshObject.h" #include "RAS_MeshObject.h" +#include "RAS_Polygon.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index ea26cb56e52..ccc10eb06e3 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -35,6 +35,7 @@ #include "KX_PolyProxy.h" #include "KX_MeshProxy.h" #include "RAS_MeshObject.h" +#include "RAS_Polygon.h" #include "KX_BlenderMaterial.h" #include "KX_PyMath.h" diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index dba26d4e3a7..a34764d7d17 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -62,6 +62,7 @@ #include "SCA_IScene.h" #include "RAS_IRasterizer.h" +#include "RAS_ICanvas.h" #include "RAS_BucketManager.h" #include "FloatValue.h" diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 1a8fda0749a..8a3ad82d179 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -29,6 +29,8 @@ subject to the following restrictions: #include "PHY_IMotionState.h" #include "CcdPhysicsEnvironment.h" #include "RAS_MeshObject.h" +#include "RAS_Polygon.h" +#include "RAS_Deformer.h" #include "KX_GameObject.h" #include "BulletSoftBody/btSoftBody.h" diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index a637baa3d09..bb727fe3b29 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -32,13 +32,14 @@ #ifndef __RAS_2DFILTERMANAGER_H__ #define __RAS_2DFILTERMANAGER_H__ -#include "RAS_ICanvas.h" #define MAX_RENDER_PASS 100 #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" #endif +class RAS_ICanvas; + class RAS_2DFilterManager { private: diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 02c50df3dd3..eaa9b3df494 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -35,15 +35,14 @@ #endif #include "RAS_MaterialBucket.h" -#include "STR_HashedString.h" #include "RAS_MeshObject.h" +#include "RAS_Polygon.h" +#include "RAS_IPolygonMaterial.h" #include "RAS_IRasterizer.h" #include "RAS_BucketManager.h" #include -#include - /* sorting */ struct RAS_BucketManager::sortedmeshslot diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index 9d55fde20c3..47e52318b33 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -33,8 +33,6 @@ #include "RAS_IPolygonMaterial.h" #include "RAS_IRasterizer.h" -#include "DNA_image_types.h" -#include "DNA_meshdata_types.h" #include "DNA_material_types.h" void RAS_IPolyMaterial::Initialize( diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index 67e74dfaa3b..2db71c3a2fe 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -35,7 +35,6 @@ #include "STR_HashedString.h" #include "MT_Vector3.h" -#include "STR_HashedString.h" #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 726b9106340..0c715524218 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -40,7 +40,7 @@ #include #endif // WIN32 -#include "RAS_Polygon.h" +#include "RAS_IPolygonMaterial.h" #include "RAS_TexVert.h" #include "RAS_IRasterizer.h" #include "RAS_MeshObject.h" diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index c112d44f774..007fdf240c4 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -34,17 +34,23 @@ #include "RAS_TexVert.h" #include "CTR_Map.h" -#include "STR_HashedString.h" #include "SG_QList.h" #include "MT_Transform.h" -#include "RAS_IPolygonMaterial.h" -#include "RAS_IRasterizer.h" -#include "RAS_Deformer.h" +#include "MT_Matrix4x4.h" #include #include #include + +class RAS_MaterialBucket; +struct DerivedMesh; +class CTR_HashedPtr; +class RAS_Deformer; +class RAS_IPolyMaterial; +class RAS_IRasterizer; +class RAS_MeshObject; + using namespace std; /* Display List Slot */ @@ -69,12 +75,6 @@ public: virtual void SetModified(bool mod)=0; }; -class RAS_DisplayArray; -class RAS_MeshSlot; -class RAS_MeshMaterial; -class RAS_MaterialBucket; -struct DerivedMesh; - /* An array with data used for OpenGL drawing */ class RAS_DisplayArray diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 8a9672f0092..ff909b5955f 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -29,23 +29,19 @@ * \ingroup bgerast */ -#include "MEM_guardedalloc.h" - -#include "DNA_object_types.h" #include "DNA_key_types.h" #include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" + +#include "CTR_HashedPtr.h" #include "RAS_MeshObject.h" -#include "RAS_IRasterizer.h" -#include "MT_MinMax.h" +#include "RAS_Polygon.h" +#include "RAS_IPolygonMaterial.h" +#include "RAS_Deformer.h" #include "MT_Point3.h" #include -extern "C" { -# include "BKE_deform.h" -} /* polygon sorting */ @@ -540,6 +536,16 @@ void RAS_MeshObject::SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transfor } +bool RAS_MeshObject::HasColliderPolygon() +{ + int numpolys= NumPolygons(); + for (int p=0; pIsCollider()) + return true; + + return false; +} + void RAS_MeshObject::SchedulePolygons(int drawingmode) { if (m_bModified) diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index e5ae78d006e..4f352379d39 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -38,17 +38,15 @@ #endif #include -#include #include -#include "RAS_Polygon.h" #include "RAS_MaterialBucket.h" #include "MT_Transform.h" - -#include "CTR_HashedPtr.h" +#include "STR_String.h" struct Mesh; class RAS_Deformer; +class RAS_Polygon; /* RAS_MeshObject is a mesh used for rendering. It stores polygons, * but the actual vertices and index arrays are stored in material @@ -65,7 +63,7 @@ private: STR_String m_name; static STR_String s_emptyname; - vector m_Polygons; + vector m_Polygons; /* polygon sorting */ struct polygonSlot; @@ -150,14 +148,7 @@ public: void SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform); - bool HasColliderPolygon() { - int numpolys= NumPolygons(); - for (int p=0; pIsCollider()) - return true; - - return false; - } + bool HasColliderPolygon(); /* for construction to find shared vertices */ struct SharedVertex { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp index 665053984e6..32cc4ba9fea 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp @@ -32,6 +32,8 @@ #include +#include "GL/glew.h" + #include "RAS_GLExtensionManager.h" namespace bgl diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h index 1b4d3219335..9f2039b4c6f 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h @@ -32,8 +32,6 @@ #ifndef __RAS_GLEXTENSIONMANAGER_H__ #define __RAS_GLEXTENSIONMANAGER_H__ -#include "GL/glew.h" - /** Note: this used to have a lot more code, but now extension handling * is done by GLEW, so it does mostly debug stuff */ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h index f5c16bc8cd8..5a803115553 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h @@ -28,14 +28,7 @@ #ifndef __KX_STORAGE #define __KX_STORAGE -#include "RAS_MaterialBucket.h" - -enum RAS_STORAGE_TYPE { - RAS_AUTO_STORAGE, - RAS_IMMEDIATE, - RAS_VA, - RAS_VBO -}; +class RAS_MeshSlot; class RAS_IStorage { @@ -47,7 +40,7 @@ public: virtual void Exit()=0; virtual void IndexPrimitives(RAS_MeshSlot& ms)=0; - virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms)=0; + virtual void IndexPrimitivesMulti(RAS_MeshSlot& ms)=0; virtual void SetDrawingMode(int drawingmode)=0; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 2bd988145c3..41847bb0f8f 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -37,9 +37,11 @@ #include "GL/glew.h" +#include "RAS_ICanvas.h" #include "RAS_Rect.h" #include "RAS_TexVert.h" #include "RAS_MeshObject.h" +#include "RAS_Polygon.h" #include "RAS_LightObject.h" #include "MT_CmMatrix4x4.h" @@ -49,16 +51,8 @@ #include "GPU_draw.h" #include "GPU_material.h" -#include "GPU_extensions.h" - -#include "DNA_image_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_material_types.h" -#include "DNA_scene_types.h" extern "C"{ - #include "BLI_utildefines.h" - #include "BKE_DerivedMesh.h" #include "BLF_api.h" } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 1fc97201480..e1159ab3d2d 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -41,13 +41,22 @@ using namespace std; #include "RAS_IRasterizer.h" -#include "RAS_IStorage.h" #include "RAS_MaterialBucket.h" -#include "RAS_ICanvas.h" +#include "RAS_IPolygonMaterial.h" + +class RAS_IStorage; +class RAS_ICanvas; #define RAS_MAX_TEXCO 8 // match in BL_Material #define RAS_MAX_ATTRIB 16 // match in BL_BlenderShader +enum RAS_STORAGE_TYPE { + RAS_AUTO_STORAGE, + RAS_IMMEDIATE, + RAS_VA, + RAS_VBO +}; + struct OglDebugShape { enum SHAPE_TYPE{ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp index 77bd540a039..40afcf04aac 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp @@ -26,16 +26,15 @@ */ #include "RAS_StorageIM.h" +#include "RAS_MaterialBucket.h" +#include "RAS_IPolygonMaterial.h" #include "GL/glew.h" #include "GPU_draw.h" #include "GPU_extensions.h" #include "GPU_material.h" -#include "DNA_meshdata_types.h" - extern "C"{ - #include "BLI_utildefines.h" #include "BKE_DerivedMesh.h" } diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp index 72e09c9667d..1f23df90753 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.cpp +++ b/source/gameengine/Rasterizer/RAS_Polygon.cpp @@ -34,6 +34,7 @@ #endif #include "RAS_Polygon.h" +#include "RAS_MaterialBucket.h" RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert) { diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h index 088bdbd6844..665056c0ccc 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.h +++ b/source/gameengine/Rasterizer/RAS_Polygon.h @@ -32,10 +32,10 @@ #ifndef __RAS_POLYGON_H__ #define __RAS_POLYGON_H__ -#include "RAS_TexVert.h" -#include "RAS_MaterialBucket.h" +class RAS_DisplayArray; +class RAS_MaterialBucket; +class RAS_TexVert; -#include using namespace std; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 68adb07b1f8..6908bc6db9c 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -42,6 +42,7 @@ #include "DNA_scene_types.h" #include "RAS_CameraData.h" #include "RAS_MeshObject.h" +#include "RAS_Polygon.h" #include "BLI_math.h" #include "ImageRender.h" diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index 28fff8b9a6c..789b6006f99 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -36,6 +36,7 @@ #include "GL/glew.h" #include "KX_PythonInit.h" +#include "RAS_ICanvas.h" #include "Texture.h" #include "ImageBase.h" #include "VideoBase.h" -- cgit v1.2.3 From 64c346ed1ec76bf91303a7f8ca0bbd0587ba2635 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:22:15 +0000 Subject: BGE Rasterizer Cleanup: The Blenderplayer now loads the monospace font so it can properly draw the framerate and profile display. --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 4 ++++ .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 16 ++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 5bed4fa40b6..385fa0a42d8 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -88,6 +88,8 @@ extern "C" #include "BLF_translation.h" extern int datatoc_bfont_ttf_size; extern char datatoc_bfont_ttf[]; +extern int datatoc_bmonofont_ttf_size; +extern char datatoc_bmonofont_ttf[]; #ifdef __cplusplus } @@ -475,6 +477,8 @@ int main(int argc, char** argv) BLF_lang_set(""); BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size); + if (blf_mono_font == -1) + blf_mono_font = BLF_load_mem_unique("monospace", (unsigned char*)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); // Parse command line options #if defined(DEBUG) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 41847bb0f8f..7360b1b1d8e 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -1498,18 +1498,14 @@ void RAS_OpenGLRasterizer::RenderText2D(RAS_TEXT_RENDER_MODE mode, BLF_size(blf_mono_font, 11, 72); BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f); BLF_draw(blf_mono_font, (char *)text, 65535);/* XXX, use real len */ - - glColor3ub(255, 255, 255); - BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f); - BLF_draw(blf_mono_font, (char *)text, 65535); - } else { - /* the actual drawing */ - glColor3ub(255, 255, 255); - BLF_size(blf_mono_font, 11, 72); - BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f); - BLF_draw(blf_mono_font, (char *)text, 65535); /* XXX, use real len */ } + /* the actual drawing */ + glColor3ub(255, 255, 255); + BLF_size(blf_mono_font, 11, 72); + BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f); + BLF_draw(blf_mono_font, (char *)text, 65535); /* XXX, use real len */ + glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); -- cgit v1.2.3 From b90de0331df6c92af909b20a3e183596ff3511e4 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:22:47 +0000 Subject: BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. This is a squashed commit of the following: BGE Physics Cleanup: Fix crashes with LibLoading and replication. Also fixing some memory leaks. BGE Physics Cleanup: Removing KX_IPhysicsController and KX_BulletPhysicsController. BGE Physics Cleanup: Moving the replication code outside of KX_BlenderBulletController and switching KX_ConvertPhysicsObjects to create a CcdPhysicsController instead of a KX_BlenderBulletController. BGE Physics Cleanup: Getting rid of an unsued KX_BulletPhysicsController.h include in KX_Scene.cpp. BGE Physics Cleanup: Removing unused KX_IPhysicsController and KX_BulletPhysicsController includes. BGE Physics Cleanup: Removing m_pPhysicsController1 and GetPhysicsController1() from KX_GameObject. BGE Physics Cleanup: Remove SetRigidBody() from KX_IPhysicsController and remove GetName() from CcdPhysicsController. BGE Physics Cleanup: Moving Add/RemoveCompoundChild() from KX_IPhysicsController to PHY_IPhysicsController. BGE Physics Cleanup: Removing GetLocalInertia() from KX_IPhysicsController. BGE Physics Cleanup: Making BlenderBulletCharacterController derive from PHY_ICharacter and removing CharacterWrapper from CcdPhysicsEnvironment.cpp. Also removing the character functions from KX_IPhysicsController. BGE Physics Cleanup: Removing GetOrientation(), SetOrientation(), SetPosition(), SetScaling(), and GetRadius() from KX_IPhysicsController. BGE Physics Cleanup: Removing GetReactionForce() since all implementations returned (0, 0, 0). The Python interface for KX_GameObject still has reaction force code, but it still also returns (0, 0, 0). This can probably be removed as well, but removing it can break scripts, so I'll leave it for now. BGE Physics Cleanup: Removing Get/SetLinVelocityMin() and Get/SetLinVelocityMax() from KX_IPhysicsController. BGE Physics Cleanup: Removing SetMargin(), RelativeTranslate(), and RelativeRotate() from KX_IPhysicsController. BGE Physics Cleanup: Using constant references for function arguments in PHY_IPhysicsController where appropriate. BGE Physics Cleanup: Removing ApplyImpulse() from KX_IPhysicsController. BGE Physics Cleanup: Removing ResolveCombinedVelocities() from KX_IPhysicsController. BGE Physics Cleanup: Accidently removed a return when cleaning up KX_GameObject::PyGetVelocity(). BGE Physics Cleanup: Remove GetLinearVelocity(), GetAngularVelocity() and GetVelocity() from KX_IPhysicsController. The corresponding PHY_IPhysicsController functions now also take Moto types instead of scalars to match the KX_IPhysicsController interface. BGE Physics Cleanup: Moving SuspendDynamics, RestoreDynamics, SetMass, GetMass, and SetTransform from KX_IPhysicsController to PHY_IPhysicsController. BGE Physics Cleanup: PHY_IPhysicsEnvironment and derived classes now use the same naming scheme as PHY_IController. BGE Physics Cleanup: PHY_IMotionState and derived classes now use the same naming convention as PHY_IController. BGE Phsyics Cleanup: Making PHY_IController and its derived classes follow a consistent naming scheme for member functions. They now all start with capital letters (e.g., setWorldOrientation becomes SetWorldOrientation). BGE Physics Cleanup: Getting rid of KX_GameObject::SuspendDynamics() and KX_GameObject::RestoreDynamics(). Instead, use the functions from the physics controller. BGE: Some first steps in trying to cleanup the KX_IPhysicsController mess. KX_GameObject now has a GetPhysicsController() and a GetPhysicsController1(). The former returns a PHY_IPhysicsController* while the latter returns a KX_IPhysicsController. The goal is to get everything using GetPhysicsController() instead of GetPhysicsController1(). --- .../Converter/BL_BlenderDataConversion.cpp | 40 +- .../gameengine/Converter/BL_ModifierDeformer.cpp | 2 +- .../Converter/KX_BlenderSceneConverter.cpp | 14 +- .../gameengine/Converter/KX_SoftBodyDeformer.cpp | 3 +- source/gameengine/Ketsji/BL_Action.cpp | 2 + source/gameengine/Ketsji/CMakeLists.txt | 4 - .../Ketsji/KX_BulletPhysicsController.cpp | 577 --------------------- .../gameengine/Ketsji/KX_BulletPhysicsController.h | 102 ---- source/gameengine/Ketsji/KX_CharacterWrapper.cpp | 2 - source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 12 +- source/gameengine/Ketsji/KX_ConstraintWrapper.cpp | 4 +- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 20 +- source/gameengine/Ketsji/KX_GameObject.cpp | 193 ++++--- source/gameengine/Ketsji/KX_GameObject.h | 37 +- source/gameengine/Ketsji/KX_IPO_SGController.cpp | 9 +- source/gameengine/Ketsji/KX_IPhysicsController.cpp | 49 -- source/gameengine/Ketsji/KX_IPhysicsController.h | 151 ------ source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 10 +- source/gameengine/Ketsji/KX_MotionState.cpp | 16 +- source/gameengine/Ketsji/KX_MotionState.h | 16 +- source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 3 +- source/gameengine/Ketsji/KX_NearSensor.cpp | 16 +- source/gameengine/Ketsji/KX_ObjectActuator.cpp | 23 +- .../gameengine/Ketsji/KX_PyConstraintBinding.cpp | 44 +- source/gameengine/Ketsji/KX_PythonInit.cpp | 4 +- source/gameengine/Ketsji/KX_RadarSensor.cpp | 4 +- source/gameengine/Ketsji/KX_RayCast.cpp | 9 +- source/gameengine/Ketsji/KX_RayCast.h | 7 +- source/gameengine/Ketsji/KX_RaySensor.cpp | 3 +- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 1 - .../gameengine/Ketsji/KX_SCA_DynamicActuator.cpp | 11 +- source/gameengine/Ketsji/KX_SCA_DynamicActuator.h | 1 - source/gameengine/Ketsji/KX_Scene.cpp | 45 +- source/gameengine/Ketsji/KX_TouchEventManager.cpp | 14 +- source/gameengine/Ketsji/KX_TouchSensor.cpp | 24 +- .../Physics/Bullet/CcdGraphicController.cpp | 28 +- .../Physics/Bullet/CcdGraphicController.h | 18 +- .../Physics/Bullet/CcdPhysicsController.cpp | 490 +++++++++++------ .../Physics/Bullet/CcdPhysicsController.h | 127 +++-- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 220 +++----- .../Physics/Bullet/CcdPhysicsEnvironment.h | 119 ++--- .../Physics/Dummy/DummyPhysicsEnvironment.cpp | 20 +- .../Physics/Dummy/DummyPhysicsEnvironment.h | 40 +- source/gameengine/Physics/common/PHY_IController.h | 4 +- .../Physics/common/PHY_IGraphicController.h | 4 +- .../gameengine/Physics/common/PHY_IMotionState.h | 16 +- .../Physics/common/PHY_IPhysicsController.h | 62 ++- .../Physics/common/PHY_IPhysicsEnvironment.h | 77 +-- 48 files changed, 973 insertions(+), 1724 deletions(-) delete mode 100644 source/gameengine/Ketsji/KX_BulletPhysicsController.cpp delete mode 100644 source/gameengine/Ketsji/KX_BulletPhysicsController.h delete mode 100644 source/gameengine/Ketsji/KX_IPhysicsController.cpp delete mode 100644 source/gameengine/Ketsji/KX_IPhysicsController.h diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index b753f667e70..1b27fde4fa4 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1419,12 +1419,12 @@ static void BL_CreateGraphicObjectNew(KX_GameObject* gameobj, PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode()); CcdGraphicController* ctrl = new CcdGraphicController(env, motionstate); gameobj->SetGraphicController(ctrl); - ctrl->setNewClientInfo(gameobj->getClientInfo()); - ctrl->setLocalAabb(localAabbMin, localAabbMax); + ctrl->SetNewClientInfo(gameobj->getClientInfo()); + ctrl->SetLocalAabb(localAabbMin, localAabbMax); if (isActive) { // add first, this will create the proxy handle, only if the object is visible if (gameobj->GetVisible()) - env->addCcdGraphicController(ctrl); + env->AddCcdGraphicController(ctrl); // update the mesh if there is a deformer, this will also update the bounding box for modifiers RAS_Deformer* deformer = gameobj->GetDeformer(); if (deformer) @@ -2027,22 +2027,8 @@ static void UNUSED_FUNCTION(RBJconstraints)(Object *ob)//not used } #include "PHY_IPhysicsEnvironment.h" -#include "KX_IPhysicsController.h" #include "PHY_DynamicTypes.h" -#if 0 /* UNUSED */ -static KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc) {//not used - - for (int j=0;jGetCount();j++) - { - KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j); - if (gameobje->GetName()==busc) - return gameobje->GetPhysicsController(); - } - - return 0; -} -#endif static KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist) { @@ -2585,7 +2571,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, kxscene->SetDbvtOcclusionRes(blenderscene->gm.occlusionRes); } if (blenderscene->world) - kxscene->GetPhysicsEnvironment()->setNumTimeSubSteps(blenderscene->gm.physubstep); + kxscene->GetPhysicsEnvironment()->SetNumTimeSubSteps(blenderscene->gm.physubstep); // now that the scenegraph is complete, let's instantiate the deformers. // We need that to create reusable derived mesh and physic shapes @@ -2676,12 +2662,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { KX_GameObject *gotar=getGameOb(dat->tar->id.name+2,sumolist); if (gotar && ((gotar->GetLayer()&activeLayerBitInfo)!=0) && gotar->GetPhysicsController()) - physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData(); + physctr2 = gotar->GetPhysicsController(); } if (gameobj->GetPhysicsController()) { - PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData(); + PHY_IPhysicsController* physctrl = gameobj->GetPhysicsController(); //we need to pass a full constraint frame, not just axis //localConstraintFrameBasis @@ -2690,7 +2676,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, MT_Vector3 axis1 = localCFrame.getColumn(1); MT_Vector3 axis2 = localCFrame.getColumn(2); - int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX, + int constraintId = kxscene->GetPhysicsEnvironment()->CreateConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX, (float)dat->pivY,(float)dat->pivZ, (float)axis0.x(),(float)axis0.y(),(float)axis0.z(), (float)axis1.x(),(float)axis1.y(),(float)axis1.z(), @@ -2706,11 +2692,11 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { if (dat->flag & dofbit) { - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); + kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); } else { //minLimit > maxLimit means free(disabled limit) for this degree of freedom - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); + kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1); } dofbit<<=1; } @@ -2724,12 +2710,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { if (dat->flag & dofbit) { - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); + kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); } else { //maxLimit < 0 means free(disabled limit) for this degree of freedom - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); + kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1); } dofbit<<=1; } @@ -2741,12 +2727,12 @@ void BL_ConvertBlenderObjects(struct Main* maggie, if (dat->flag & dofbit) { - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof, + kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof, dat->minLimit[dof],dat->maxLimit[dof]); } else { //minLimit > maxLimit means free(disabled limit) for this degree of freedom - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); + kxscene->GetPhysicsEnvironment()->SetConstraintParam(constraintId,dof,1,-1); } } } diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp index ec52eaac637..82f49ad5227 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.cpp +++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp @@ -192,7 +192,7 @@ bool BL_ModifierDeformer::Update(void) float min_r[3], max_r[3]; INIT_MINMAX(min_r, max_r); m_dm->getMinMax(m_dm, min_r, max_r); - ctrl->setLocalAabb(min_r, max_r); + ctrl->SetLocalAabb(min_r, max_r); } } m_lastModifierUpdate=m_gameobj->GetLastFrame(); diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index f642fd43aef..e682f335608 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -42,7 +42,6 @@ #include "PHY_IPhysicsEnvironment.h" #include "KX_KetsjiEngine.h" #include "KX_PythonInit.h" // So we can handle adding new text datablocks for Python to import -#include "KX_IPhysicsController.h" #include "BL_Material.h" #include "BL_ActionActuator.h" #include "KX_BlenderMaterial.h" @@ -355,15 +354,15 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene, case UseBullet: { CcdPhysicsEnvironment* ccdPhysEnv = new CcdPhysicsEnvironment(useDbvtCulling); - ccdPhysEnv->setDebugDrawer(new BlenderDebugDraw()); - ccdPhysEnv->setDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold); - ccdPhysEnv->setDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold); - ccdPhysEnv->setDeactivationTime(blenderscene->gm.deactivationtime); + ccdPhysEnv->SetDebugDrawer(new BlenderDebugDraw()); + ccdPhysEnv->SetDeactivationLinearTreshold(blenderscene->gm.lineardeactthreshold); + ccdPhysEnv->SetDeactivationAngularTreshold(blenderscene->gm.angulardeactthreshold); + ccdPhysEnv->SetDeactivationTime(blenderscene->gm.deactivationtime); SYS_SystemHandle syshandle = SYS_GetSystem(); /*unused*/ int visualizePhysics = SYS_GetCommandLineInt(syshandle,"show_physics",0); if (visualizePhysics) - ccdPhysEnv->setDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints); + ccdPhysEnv->SetDebugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb|btIDebugDraw::DBG_DrawContactPoints|btIDebugDraw::DBG_DrawText|btIDebugDraw::DBG_DrawConstraintLimits|btIDebugDraw::DBG_DrawConstraints); //todo: get a button in blender ? //disable / enable debug drawing (contact points, aabb's etc) @@ -709,7 +708,6 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo) KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g); if (gameObj->IsDynamic()) { - //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject) @@ -825,7 +823,6 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject && blenderObject->parent==NULL && gameObj->IsDynamic()) { - //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); if (blenderObject->adt==NULL) BKE_id_add_animdata(&blenderObject->id); @@ -944,7 +941,6 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo() KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g); if (gameObj->IsDynamic()) { - //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); #if 0 Object* blenderObject = gameObj->GetBlenderObject(); diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp index d860b2ee694..fcdaaaa761a 100644 --- a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp +++ b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp @@ -48,7 +48,6 @@ #include "CcdPhysicsController.h" #include "BulletSoftBody/btSoftBody.h" -#include "KX_BulletPhysicsController.h" #include "btBulletDynamicsCommon.h" void KX_SoftBodyDeformer::Relink(CTR_Map*map) @@ -66,7 +65,7 @@ void KX_SoftBodyDeformer::Relink(CTR_Map*map) bool KX_SoftBodyDeformer::Apply(class RAS_IPolyMaterial *polymat) { - KX_BulletPhysicsController* ctrl = (KX_BulletPhysicsController*) m_gameobj->GetPhysicsController(); + CcdPhysicsController* ctrl = (CcdPhysicsController*) m_gameobj->GetPhysicsController(); if (!ctrl) return false; diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 6d9b22eed91..a974ffbf672 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -34,6 +34,8 @@ #include "KX_IpoConvert.h" #include "KX_GameObject.h" +#include "SG_Controller.h" + // These three are for getting the action from the logic manager #include "KX_Scene.h" #include "SCA_LogicManager.h" diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index c3c733c66ba..141dd5e25f3 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -71,7 +71,6 @@ set(SRC BL_Texture.cpp KX_ArmatureSensor.cpp KX_BlenderMaterial.cpp - KX_BulletPhysicsController.cpp KX_Camera.cpp KX_CameraActuator.cpp KX_CameraIpoSGController.cpp @@ -86,7 +85,6 @@ set(SRC KX_GameObject.cpp KX_IpoConvert.cpp KX_IPO_SGController.cpp - KX_IPhysicsController.cpp KX_IpoActuator.cpp KX_KetsjiEngine.cpp KX_Light.cpp @@ -146,7 +144,6 @@ set(SRC BL_Texture.h KX_ArmatureSensor.h KX_BlenderMaterial.h - KX_BulletPhysicsController.h KX_Camera.h KX_CameraActuator.h KX_CameraIpoSGController.h @@ -164,7 +161,6 @@ set(SRC KX_IpoConvert.h KX_IPOTransform.h KX_IPO_SGController.h - KX_IPhysicsController.h KX_IScalarInterpolator.h KX_ISceneConverter.h KX_ISystem.h diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp deleted file mode 100644 index e990974a646..00000000000 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ /dev/null @@ -1,577 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file gameengine/Ketsji/KX_BulletPhysicsController.cpp - * \ingroup ketsji - */ - -//under visual studio the #define in KX_ConvertPhysicsObject.h is quicker for recompilation -#include "KX_ConvertPhysicsObject.h" - -#ifdef WITH_BULLET - -#include "KX_BulletPhysicsController.h" - -#include "btBulletDynamicsCommon.h" -#include "SG_Spatial.h" - -#include "KX_GameObject.h" -#include "KX_MotionState.h" -#include "KX_ClientObjectInfo.h" - -#include "PHY_IPhysicsEnvironment.h" -#include "CcdPhysicsEnvironment.h" -#include "BulletSoftBody/btSoftBody.h" - - -KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool character, bool compound) -: KX_IPhysicsController(dyna,sensor,character,compound,(PHY_IPhysicsController*)this), -CcdPhysicsController(ci), -m_savedCollisionFlags(0), -m_savedCollisionFilterGroup(0), -m_savedCollisionFilterMask(0), -m_savedMass(0.0), -m_savedDyna(false), -m_suspended(false), -m_bulletChildShape(NULL) -{ -} - -KX_BulletPhysicsController::~KX_BulletPhysicsController () -{ - // The game object has a direct link to - if (m_pObject) - { - // If we cheat in SetObject, we must also cheat here otherwise the - // object will still things it has a physical controller - // Note that it requires that m_pObject is reset in case the object is deleted - // before the controller (usual case, see KX_Scene::RemoveNodeDestructObjec) - // The non usual case is when the object is not deleted because its reference is hanging - // in a AddObject actuator but the node is deleted. This case is covered here. - KX_GameObject* gameobj = (KX_GameObject*) m_pObject->GetSGClientObject(); - gameobj->SetPhysicsController(NULL,false); - } -} - -void KX_BulletPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) -{ - CcdPhysicsController::resolveCombinedVelocities(linvelX,linvelY,linvelZ,angVelX,angVelY,angVelZ); - -} - - - /////////////////////////////////// - // KX_IPhysicsController interface - //////////////////////////////////// - -void KX_BulletPhysicsController::applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse) -{ - CcdPhysicsController::applyImpulse(attach[0],attach[1],attach[2],impulse[0],impulse[1],impulse[2]); - -} - -float KX_BulletPhysicsController::GetLinVelocityMin() -{ - return (float)CcdPhysicsController::GetLinVelocityMin(); -} -void KX_BulletPhysicsController::SetLinVelocityMin(float val) -{ - CcdPhysicsController::SetLinVelocityMin(val); -} - -void KX_BulletPhysicsController::Jump() -{ - CcdPhysicsController::Jump(); -} - -float KX_BulletPhysicsController::GetLinVelocityMax() -{ - return (float)CcdPhysicsController::GetLinVelocityMax(); -} -void KX_BulletPhysicsController::SetLinVelocityMax(float val) -{ - CcdPhysicsController::SetLinVelocityMax(val); -} - -void KX_BulletPhysicsController::SetObject (SG_IObject* object) -{ - SG_Controller::SetObject(object); - - // cheating here... - //should not be necessary, is it for duplicates ? - - KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject(); - gameobj->SetPhysicsController(this,gameobj->IsDynamic()); - CcdPhysicsController::setNewClientInfo(gameobj->getClientInfo()); - - if (m_bSensor) - { - // use a different callback function for sensor object, - // bullet will not synchronize, we must do it explicitly - SG_Callbacks& callbacks = gameobj->GetSGNode()->GetCallBackFunctions(); - callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc; - } -} - -MT_Scalar KX_BulletPhysicsController::GetRadius() -{ - return MT_Scalar(CcdPhysicsController::GetRadius()); -} - -void KX_BulletPhysicsController::setMargin (float collisionMargin) -{ - CcdPhysicsController::SetMargin(collisionMargin); -} -void KX_BulletPhysicsController::RelativeTranslate(const MT_Vector3& dloc,bool local) -{ - CcdPhysicsController::RelativeTranslate(dloc[0],dloc[1],dloc[2],local); - -} - -void KX_BulletPhysicsController::SetWalkDirection(const MT_Vector3& dloc,bool local) -{ - CcdPhysicsController::SetWalkDirection(dloc[0],dloc[1],dloc[2],local); -} - -void KX_BulletPhysicsController::RelativeRotate(const MT_Matrix3x3& drot,bool local) -{ - float rotval[9]; - drot.getValue3x3(rotval); - CcdPhysicsController::RelativeRotate(rotval,local); -} - -void KX_BulletPhysicsController::ApplyTorque(const MT_Vector3& torque,bool local) -{ - CcdPhysicsController::ApplyTorque(torque.x(),torque.y(),torque.z(),local); -} -void KX_BulletPhysicsController::ApplyForce(const MT_Vector3& force,bool local) -{ - CcdPhysicsController::ApplyForce(force.x(),force.y(),force.z(),local); -} -MT_Vector3 KX_BulletPhysicsController::GetLinearVelocity() -{ - float angVel[3]; - //CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]); - CcdPhysicsController::GetLinearVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz - return MT_Vector3(angVel[0],angVel[1],angVel[2]); -} -MT_Vector3 KX_BulletPhysicsController::GetAngularVelocity() -{ - float angVel[3]; - //CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]); - CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz - return MT_Vector3(angVel[0],angVel[1],angVel[2]); -} -MT_Vector3 KX_BulletPhysicsController::GetVelocity(const MT_Point3& pos) -{ - float linVel[3]; - CcdPhysicsController::GetVelocity(pos[0], pos[1], pos[2], linVel[0],linVel[1],linVel[2]); - return MT_Vector3(linVel[0],linVel[1],linVel[2]); -} - -MT_Vector3 KX_BulletPhysicsController::GetWalkDirection() -{ - float dir[3]; - CcdPhysicsController::GetWalkDirection(dir[0], dir[1], dir[2]); - return MT_Vector3(dir[0], dir[1], dir[2]); -} - -void KX_BulletPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local) -{ - CcdPhysicsController::SetAngularVelocity(ang_vel.x(),ang_vel.y(),ang_vel.z(),local); - -} -void KX_BulletPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local) -{ - CcdPhysicsController::SetLinearVelocity(lin_vel.x(),lin_vel.y(),lin_vel.z(),local); -} -void KX_BulletPhysicsController::getOrientation(MT_Quaternion& orn) -{ - float myorn[4]; - CcdPhysicsController::getOrientation(myorn[0],myorn[1],myorn[2],myorn[3]); - orn = MT_Quaternion(myorn[0],myorn[1],myorn[2],myorn[3]); -} -void KX_BulletPhysicsController::setOrientation(const MT_Matrix3x3& orn) -{ - btMatrix3x3 btmat(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]); - CcdPhysicsController::setWorldOrientation(btmat); -} -void KX_BulletPhysicsController::setPosition(const MT_Point3& pos) -{ - CcdPhysicsController::setPosition(pos.x(),pos.y(),pos.z()); -} -void KX_BulletPhysicsController::setScaling(const MT_Vector3& scaling) -{ - CcdPhysicsController::setScaling(scaling.x(),scaling.y(),scaling.z()); -} -void KX_BulletPhysicsController::SetTransform() -{ - btVector3 pos; - btVector3 scale; - float ori[12]; - m_MotionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]); - m_MotionState->getWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]); - m_MotionState->getWorldOrientation(ori); - btMatrix3x3 rot(ori[0], ori[4], ori[8], - ori[1], ori[5], ori[9], - ori[2], ori[6], ori[10]); - CcdPhysicsController::forceWorldTransform(rot, pos); -} - -MT_Scalar KX_BulletPhysicsController::GetMass() -{ - if (GetSoftBody()) - return GetSoftBody()->getTotalMass(); - - MT_Scalar invmass = 0.f; - if (GetRigidBody()) - invmass = GetRigidBody()->getInvMass(); - if (invmass) - return 1.f/invmass; - return 0.f; - -} - -MT_Vector3 KX_BulletPhysicsController::GetLocalInertia() -{ - MT_Vector3 inertia(0.f, 0.f, 0.f); - btVector3 inv_inertia; - if (GetRigidBody()) { - inv_inertia = GetRigidBody()->getInvInertiaDiagLocal(); - if (!btFuzzyZero(inv_inertia.getX()) && - !btFuzzyZero(inv_inertia.getY()) && - !btFuzzyZero(inv_inertia.getZ())) - inertia = MT_Vector3(1.f/inv_inertia.getX(), 1.f/inv_inertia.getY(), 1.f/inv_inertia.getZ()); - } - return inertia; -} - -MT_Vector3 KX_BulletPhysicsController::getReactionForce() -{ - assert(0); - return MT_Vector3(0.f,0.f,0.f); -} -void KX_BulletPhysicsController::setRigidBody(bool rigid) -{ - CcdPhysicsController::setRigidBody(rigid); -} - -/* This function dynamically adds the collision shape of another controller to - * the current controller shape provided it is a compound shape. - * The idea is that dynamic parenting on a compound object will dynamically extend the shape - */ -void KX_BulletPhysicsController::AddCompoundChild(KX_IPhysicsController* child) -{ - if (child == NULL || !IsCompound()) - return; - // other controller must be a bullet controller too - // verify that body and shape exist and match - KX_BulletPhysicsController* childCtrl = dynamic_cast(child); - btRigidBody* rootBody = GetRigidBody(); - btRigidBody* childBody = childCtrl->GetRigidBody(); - if (!rootBody || !childBody) - return; - const btCollisionShape* rootShape = rootBody->getCollisionShape(); - const btCollisionShape* childShape = childBody->getCollisionShape(); - if (!rootShape || - !childShape || - rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE || - childShape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) - return; - btCompoundShape* compoundShape = (btCompoundShape*)rootShape; - // compute relative transformation between parent and child - btTransform rootTrans; - btTransform childTrans; - rootBody->getMotionState()->getWorldTransform(rootTrans); - childBody->getMotionState()->getWorldTransform(childTrans); - btVector3 rootScale = rootShape->getLocalScaling(); - rootScale[0] = 1.0/rootScale[0]; - rootScale[1] = 1.0/rootScale[1]; - rootScale[2] = 1.0/rootScale[2]; - // relative scale = child_scale/parent_scale - btVector3 relativeScale = childShape->getLocalScaling()*rootScale; - btMatrix3x3 rootRotInverse = rootTrans.getBasis().transpose(); - // relative pos = parent_rot^-1 * ((parent_pos-child_pos)/parent_scale) - btVector3 relativePos = rootRotInverse*((childTrans.getOrigin()-rootTrans.getOrigin())*rootScale); - // relative rot = parent_rot^-1 * child_rot - btMatrix3x3 relativeRot = rootRotInverse*childTrans.getBasis(); - // create a proxy shape info to store the transformation - CcdShapeConstructionInfo* proxyShapeInfo = new CcdShapeConstructionInfo(); - // store the transformation to this object shapeinfo - proxyShapeInfo->m_childTrans.setOrigin(relativePos); - proxyShapeInfo->m_childTrans.setBasis(relativeRot); - proxyShapeInfo->m_childScale.setValue(relativeScale[0], relativeScale[1], relativeScale[2]); - // we will need this to make sure that we remove the right proxy later when unparenting - proxyShapeInfo->m_userData = childCtrl; - proxyShapeInfo->SetProxy(childCtrl->GetShapeInfo()->AddRef()); - // add to parent compound shapeinfo (increments ref count) - GetShapeInfo()->AddShape(proxyShapeInfo); - // create new bullet collision shape from the object shapeinfo and set scaling - btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape(childCtrl->GetMargin(), childCtrl->getConstructionInfo().m_bGimpact, true); - newChildShape->setLocalScaling(relativeScale); - // add bullet collision shape to parent compound collision shape - compoundShape->addChildShape(proxyShapeInfo->m_childTrans,newChildShape); - // proxyShapeInfo is not needed anymore, release it - proxyShapeInfo->Release(); - // remember we created this shape - childCtrl->m_bulletChildShape = newChildShape; - // recompute inertia of parent - if (!rootBody->isStaticOrKinematicObject()) - { - btVector3 localInertia; - float mass = 1.f/rootBody->getInvMass(); - compoundShape->calculateLocalInertia(mass,localInertia); - rootBody->setMassProps(mass,localInertia); - } - // must update the broadphase cache, - GetPhysicsEnvironment()->refreshCcdPhysicsController(this); - // remove the children - GetPhysicsEnvironment()->disableCcdPhysicsController(childCtrl); -} - -/* Reverse function of the above, it will remove a shape from a compound shape - * provided that the former was added to the later using AddCompoundChild() - */ -void KX_BulletPhysicsController::RemoveCompoundChild(KX_IPhysicsController* child) -{ - if (child == NULL || !IsCompound()) - return; - // other controller must be a bullet controller too - // verify that body and shape exist and match - KX_BulletPhysicsController* childCtrl = dynamic_cast(child); - btRigidBody* rootBody = GetRigidBody(); - btRigidBody* childBody = childCtrl->GetRigidBody(); - if (!rootBody || !childBody) - return; - const btCollisionShape* rootShape = rootBody->getCollisionShape(); - if (!rootShape || - rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE) - return; - btCompoundShape* compoundShape = (btCompoundShape*)rootShape; - // retrieve the shapeInfo - CcdShapeConstructionInfo* childShapeInfo = childCtrl->GetShapeInfo(); - CcdShapeConstructionInfo* rootShapeInfo = GetShapeInfo(); - // and verify that the child is part of the parent - int i = rootShapeInfo->FindChildShape(childShapeInfo, childCtrl); - if (i < 0) - return; - rootShapeInfo->RemoveChildShape(i); - if (childCtrl->m_bulletChildShape) - { - int numChildren = compoundShape->getNumChildShapes(); - for (i=0; igetChildShape(i) == childCtrl->m_bulletChildShape) - { - compoundShape->removeChildShapeByIndex(i); - compoundShape->recalculateLocalAabb(); - break; - } - } - delete childCtrl->m_bulletChildShape; - childCtrl->m_bulletChildShape = NULL; - } - // recompute inertia of parent - if (!rootBody->isStaticOrKinematicObject()) - { - btVector3 localInertia; - float mass = 1.f/rootBody->getInvMass(); - compoundShape->calculateLocalInertia(mass,localInertia); - rootBody->setMassProps(mass,localInertia); - } - // must update the broadphase cache, - GetPhysicsEnvironment()->refreshCcdPhysicsController(this); - // reactivate the children - GetPhysicsEnvironment()->enableCcdPhysicsController(childCtrl); -} - -void KX_BulletPhysicsController::SetMass(MT_Scalar newmass) -{ - btRigidBody *body = GetRigidBody(); - if (body && !m_suspended && newmass>MT_EPSILON && GetMass()>MT_EPSILON) - { - btVector3 grav = body->getGravity(); - btVector3 accel = grav / GetMass(); - - btBroadphaseProxy* handle = body->getBroadphaseHandle(); - GetPhysicsEnvironment()->updateCcdPhysicsController(this, - newmass, - body->getCollisionFlags(), - handle->m_collisionFilterGroup, - handle->m_collisionFilterMask); - body->setGravity(accel); - } -} - -void KX_BulletPhysicsController::SuspendDynamics(bool ghost) -{ - btRigidBody *body = GetRigidBody(); - if (body && !m_suspended && !IsSensor()) - { - btBroadphaseProxy* handle = body->getBroadphaseHandle(); - m_savedCollisionFlags = body->getCollisionFlags(); - m_savedMass = GetMass(); - m_savedDyna = m_bDyna; - m_savedCollisionFilterGroup = handle->m_collisionFilterGroup; - m_savedCollisionFilterMask = handle->m_collisionFilterMask; - m_suspended = true; - GetPhysicsEnvironment()->updateCcdPhysicsController(this, - 0.0, - btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)), - btBroadphaseProxy::StaticFilter, - btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter); - m_bDyna = false; - } -} - -void KX_BulletPhysicsController::RestoreDynamics() -{ - btRigidBody *body = GetRigidBody(); - if (body && m_suspended) - { - // before make sure any position change that was done in this logic frame are accounted for - SetTransform(); - GetPhysicsEnvironment()->updateCcdPhysicsController(this, - m_savedMass, - m_savedCollisionFlags, - m_savedCollisionFilterGroup, - m_savedCollisionFilterMask); - body->activate(); - m_bDyna = m_savedDyna; - m_suspended = false; - } -} - -SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode) -{ - PHY_IMotionState* motionstate = new KX_MotionState(destnode); - - KX_BulletPhysicsController* physicsreplica = new KX_BulletPhysicsController(*this); - - //parentcontroller is here be able to avoid collisions between parent/child - - PHY_IPhysicsController* parentctrl = NULL; - KX_BulletPhysicsController* parentKxCtrl = NULL; - CcdPhysicsController* ccdParent = NULL; - - - if (destnode != destnode->GetRootSGParent()) - { - KX_GameObject* clientgameobj = (KX_GameObject*) destnode->GetRootSGParent()->GetSGClientObject(); - if (clientgameobj) - { - parentctrl = (KX_BulletPhysicsController*)clientgameobj->GetPhysicsController(); - } else - { - // it could be a false node, try the children - NodeList::const_iterator childit; - for ( - childit = destnode->GetSGChildren().begin(); - childit!= destnode->GetSGChildren().end(); - ++childit - ) { - KX_GameObject *clientgameobj_child = static_cast( (*childit)->GetSGClientObject()); - if (clientgameobj_child) - { - parentKxCtrl = (KX_BulletPhysicsController*)clientgameobj_child->GetPhysicsController(); - parentctrl = parentKxCtrl; - ccdParent = parentKxCtrl; - } - } - } - } - - physicsreplica->setParentCtrl(ccdParent); - physicsreplica->PostProcessReplica(motionstate,parentctrl); - physicsreplica->m_userdata = (PHY_IPhysicsController*)physicsreplica; - physicsreplica->m_bulletChildShape = NULL; - return physicsreplica; - -} - - - -void KX_BulletPhysicsController::SetSumoTransform(bool nondynaonly) -{ - - if (!m_bDyna && !m_bSensor && !m_bCharacter) - { - btCollisionObject* object = GetRigidBody(); - object->setActivationState(ACTIVE_TAG); - object->setCollisionFlags(object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); - } else - { - if (!nondynaonly) - { - /* - btTransform worldTrans; - if (GetRigidBody()) - { - GetRigidBody()->getMotionState()->getWorldTransform(worldTrans); - GetRigidBody()->setCenterOfMassTransform(worldTrans); - } - */ - /* - scaling? - if (m_bDyna) - { - m_sumoObj->setScaling(MT_Vector3(1,1,1)); - } else - { - MT_Vector3 scale; - GetWorldScaling(scale); - m_sumoObj->setScaling(scale); - } - */ - - } - } -} - -// todo: remove next line ! -void KX_BulletPhysicsController::SetSimulatedTime(double time) -{ -} - -// call from scene graph to update -bool KX_BulletPhysicsController::Update(double time) -{ - return false; - - // todo: check this code - //if (GetMass()) - //{ - // return false;//true; -// } -// return false; -} - - -const char* KX_BulletPhysicsController::getName() -{ - if (m_pObject) - { - KX_GameObject* gameobj = (KX_GameObject*) m_pObject->GetSGClientObject(); - return gameobj->GetName(); - } - return 0; -} - -#endif // WITH_BULLET diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h deleted file mode 100644 index 3d13744567b..00000000000 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ /dev/null @@ -1,102 +0,0 @@ - -/** \file KX_BulletPhysicsController.h - * \ingroup ketsji - */ - -#ifndef __KX_BULLETPHYSICSCONTROLLER_H__ -#define __KX_BULLETPHYSICSCONTROLLER_H__ - - -#include "KX_IPhysicsController.h" -#ifdef WITH_BULLET -#include "CcdPhysicsController.h" -#endif - -class KX_BulletPhysicsController : public KX_IPhysicsController, public CcdPhysicsController -{ -private: - int m_savedCollisionFlags; - int m_savedActivationState; - short int m_savedCollisionFilterGroup; - short int m_savedCollisionFilterMask; - MT_Scalar m_savedMass; - bool m_savedDyna; - bool m_suspended; - btCollisionShape* m_bulletChildShape; - -public: -#ifdef WITH_BULLET - KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna, bool sensor, bool character, bool compound); - virtual ~KX_BulletPhysicsController (); -#endif - /////////////////////////////////// - // KX_IPhysicsController interface - //////////////////////////////////// - - virtual void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse); - virtual void SetObject (SG_IObject* object); - virtual void setMargin (float collisionMargin); - virtual void RelativeTranslate(const MT_Vector3& dloc,bool local); - virtual void RelativeRotate(const MT_Matrix3x3& drot,bool local); - virtual void ApplyTorque(const MT_Vector3& torque,bool local); - virtual void ApplyForce(const MT_Vector3& force,bool local); - virtual void SetWalkDirection(const MT_Vector3& dir,bool local); - virtual MT_Vector3 GetLinearVelocity(); - virtual MT_Vector3 GetAngularVelocity(); - virtual MT_Vector3 GetVelocity(const MT_Point3& pos); - virtual MT_Vector3 GetWalkDirection(); - virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local); - virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local); - virtual void Jump(); - virtual void getOrientation(MT_Quaternion& orn); - virtual void setOrientation(const MT_Matrix3x3& orn); - virtual void setPosition(const MT_Point3& pos); - virtual void setScaling(const MT_Vector3& scaling); - virtual void SetTransform(); - virtual MT_Scalar GetMass(); - virtual void SetMass(MT_Scalar newmass); - virtual MT_Vector3 GetLocalInertia(); - virtual MT_Vector3 getReactionForce(); - virtual void setRigidBody(bool rigid); - virtual void AddCompoundChild(KX_IPhysicsController* child); - virtual void RemoveCompoundChild(KX_IPhysicsController* child); - - virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ); - - virtual void SuspendDynamics(bool ghost); - virtual void RestoreDynamics(); - - virtual SG_Controller* GetReplica(class SG_Node* destnode); - - virtual MT_Scalar GetRadius(); - - virtual float GetLinVelocityMin(); - virtual void SetLinVelocityMin(float val); - virtual float GetLinVelocityMax(); - virtual void SetLinVelocityMax(float val); - - virtual void SetSumoTransform(bool nondynaonly); - // todo: remove next line ! - virtual void SetSimulatedTime(double time); - - // call from scene graph to update - virtual bool Update(double time); - void* GetUserData() { return m_userdata;} - - virtual const char* getName(); - - void - SetOption( - int option, - int value - ) { - // intentionally empty - }; - - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BulletPhysicsController") -#endif -}; - -#endif /* __KX_BULLETPHYSICSCONTROLLER_H__ */ diff --git a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp index 899a153d80f..fdf4fa01b03 100644 --- a/source/gameengine/Ketsji/KX_CharacterWrapper.cpp +++ b/source/gameengine/Ketsji/KX_CharacterWrapper.cpp @@ -34,8 +34,6 @@ KX_CharacterWrapper::KX_CharacterWrapper(PHY_ICharacter* character) : KX_CharacterWrapper::~KX_CharacterWrapper() { - if (m_character) - delete m_character; // We're responsible for the character object! } #ifdef WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index a3059317d36..0c5e21322df 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -331,7 +331,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) { MT_Point3 topoint = position + (m_maximumBound) * direction; PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); - KX_IPhysicsController *spc = obj->GetPhysicsController(); + PHY_IPhysicsController *spc = obj->GetPhysicsController(); if (!pe) { std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no physics environment!" << std::endl; @@ -345,7 +345,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) parent->Release(); } } - KX_RayCast::Callback callback(this,spc); + KX_RayCast::Callback callback(this,dynamic_cast(spc)); result = KX_RayCast::RayTest(pe, position, topoint, callback); if (result) { MT_Vector3 newnormal = callback.m_hitNormal; @@ -379,7 +379,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) // logically we should cancel the speed along the ray direction as we set the // position along that axis spc = obj->GetPhysicsController(); - if (spc && spc->IsDyna()) { + if (spc && spc->IsDynamic()) { MT_Vector3 linV = spc->GetLinearVelocity(); // cancel the projection along the ray direction MT_Scalar fallspeed = linV.dot(direction); @@ -444,20 +444,20 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) normal.normalize(); { PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); - KX_IPhysicsController *spc = obj->GetPhysicsController(); + PHY_IPhysicsController *spc = obj->GetPhysicsController(); if (!pe) { std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no physics environment!" << std::endl; goto CHECK_TIME; } - if (!spc || !spc->IsDyna()) { + if (!spc || !spc->IsDynamic()) { // the object is not dynamic, it won't support setting speed goto CHECK_TIME; } m_hitObject = NULL; // distance of Fh area is stored in m_minimum MT_Point3 topoint = position + (m_minimumBound+spc->GetRadius()) * direction; - KX_RayCast::Callback callback(this,spc); + KX_RayCast::Callback callback(this, spc); result = KX_RayCast::RayTest(pe, position, topoint, callback); // we expect a hit object if (!m_hitObject) diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index e09449c4f1d..793324fab75 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -64,7 +64,7 @@ PyObject *KX_ConstraintWrapper::PyGetParam(PyObject *args, PyObject *kwds) if (!PyArg_ParseTuple(args,"i:getParam",&dof)) return NULL; - value = m_physenv->getConstraintParam(m_constraintId,dof); + value = m_physenv->GetConstraintParam(m_constraintId,dof); return PyFloat_FromDouble(value); } @@ -77,7 +77,7 @@ PyObject *KX_ConstraintWrapper::PySetParam(PyObject *args, PyObject *kwds) if (!PyArg_ParseTuple(args,"iff:setParam",&dof,&minLimit,&maxLimit)) return NULL; - m_physenv->setConstraintParam(m_constraintId,dof,minLimit,maxLimit); + m_physenv->SetConstraintParam(m_constraintId,dof,minLimit,maxLimit); Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index ece6abc9447..bde50588fd3 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -65,7 +65,6 @@ extern "C"{ #include "CcdPhysicsController.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" -#include "KX_BulletPhysicsController.h" #include "btBulletDynamicsCommon.h" #ifdef WIN32 @@ -255,7 +254,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, { //find parent, compound shape and add to it //take relative transform into account! - KX_BulletPhysicsController* parentCtrl = (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController(); + CcdPhysicsController* parentCtrl = (CcdPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController(); assert(parentCtrl); CcdShapeConstructionInfo* parentShapeInfo = parentCtrl->GetShapeInfo(); btRigidBody* rigidbody = parentCtrl->GetRigidBody(); @@ -424,12 +423,13 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_contactProcessingThreshold = objprop->m_contactProcessingThreshold;//todo: expose this in advanced settings, just like margin, default to 10000 or so ci.m_bSoft = objprop->m_softbody; + ci.m_bDyna = isbulletdyna; ci.m_bSensor = isbulletsensor; ci.m_bCharacter = isbulletchar; ci.m_bGimpact = useGimpact; MT_Vector3 scaling = gameobj->NodeGetWorldScaling(); ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]); - KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna,isbulletsensor,isbulletchar,objprop->m_hasCompoundChildren); + CcdPhysicsController* physicscontroller = new CcdPhysicsController(ci); // shapeInfo is reference counted, decrement now as we don't use it anymore if (shapeInfo) shapeInfo->Release(); @@ -438,9 +438,9 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, // don't add automatically sensor object, they are added when a collision sensor is registered if (!isbulletsensor && objprop->m_in_active_layer) { - env->addCcdPhysicsController( physicscontroller); + env->AddCcdPhysicsController( physicscontroller); } - physicscontroller->setNewClientInfo(gameobj->getClientInfo()); + physicscontroller->SetNewClientInfo(gameobj->getClientInfo()); { btRigidBody* rbody = physicscontroller->GetRigidBody(); @@ -459,8 +459,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, } } - CcdPhysicsController* parentCtrl = objprop->m_dynamic_parent ? (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController() : 0; - physicscontroller->setParentCtrl(parentCtrl); + CcdPhysicsController* parentCtrl = objprop->m_dynamic_parent ? (CcdPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController() : 0; + physicscontroller->SetParentCtrl(parentCtrl); //Now done directly in ci.m_collisionFlags so that it propagates to replica @@ -504,13 +504,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, } - gameobj->GetSGNode()->AddSGController(physicscontroller); STR_String materialname; if (meshobj) materialname = meshobj->GetMaterialName(0); - physicscontroller->SetObject(gameobj->GetSGNode()); #if 0 ///test for soft bodies @@ -546,7 +544,7 @@ void KX_ClearBulletSharedShapes() */ bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *from_gameobj, RAS_MeshObject* from_meshobj) { - KX_BulletPhysicsController *spc= static_cast((gameobj->GetPhysicsController())); + CcdPhysicsController *spc= static_cast(gameobj->GetPhysicsController()); CcdShapeConstructionInfo *shapeInfo; /* if this is the child of a compound shape this can happen @@ -568,7 +566,7 @@ bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *fro shapeInfo->UpdateMesh(from_gameobj, from_meshobj); /* create the new bullet mesh */ - CcdConstructionInfo& cci = spc->getConstructionInfo(); + CcdConstructionInfo& cci = spc->GetConstructionInfo(); btCollisionShape* bm= shapeInfo->CreateBulletShape(cci.m_margin, cci.m_bGimpact, !cci.m_bSoft); spc->ReplaceControllerShape(bm); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index e06f7ab6633..96f76ff21b1 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -55,7 +55,6 @@ typedef unsigned long uint_ptr; #include "KX_PolyProxy.h" #include // printf #include "SG_Controller.h" -#include "KX_IPhysicsController.h" #include "PHY_IGraphicController.h" #include "SG_Node.h" #include "SG_Controller.h" @@ -105,7 +104,7 @@ KX_GameObject::KX_GameObject( m_bVisible(true), m_bCulled(true), m_bOccluder(false), - m_pPhysicsController1(NULL), + m_pPhysicsController(NULL), m_pGraphicController(NULL), m_xray(false), m_pHitObject(NULL), @@ -177,6 +176,11 @@ KX_GameObject::~KX_GameObject() delete m_pGraphicController; } + if (m_pPhysicsController) + { + delete m_pPhysicsController; + } + if (m_pObstacleSimulation) { m_pObstacleSimulation->DestroyObstacleForObj(this); @@ -245,9 +249,9 @@ void KX_GameObject::SetName(const char *name) m_name = name; } -KX_IPhysicsController* KX_GameObject::GetPhysicsController() +PHY_IPhysicsController* KX_GameObject::GetPhysicsController() { - return m_pPhysicsController1; + return m_pPhysicsController; } KX_GameObject* KX_GameObject::GetDupliGroupObject() @@ -333,9 +337,9 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom RemoveParent(scene); obj->GetSGNode()->AddChild(GetSGNode()); - if (m_pPhysicsController1) + if (m_pPhysicsController) { - m_pPhysicsController1->SuspendDynamics(ghost); + m_pPhysicsController->SuspendDynamics(ghost); } // Set us to our new scale, position, and orientation scale2[0] = 1.0/scale2[0]; @@ -356,16 +360,16 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj, bool addToCom Release(); // if the new parent is a compound object, add this object shape to the compound shape. // step 0: verify this object has physical controller - if (m_pPhysicsController1 && addToCompound) + if (m_pPhysicsController && addToCompound) { // step 1: find the top parent (not necessarily obj) KX_GameObject* rootobj = (KX_GameObject*)obj->GetSGNode()->GetRootSGParent()->GetSGClientObject(); // step 2: verify it has a physical controller and compound shape if (rootobj != NULL && - rootobj->m_pPhysicsController1 != NULL && - rootobj->m_pPhysicsController1->IsCompound()) + rootobj->m_pPhysicsController != NULL && + rootobj->m_pPhysicsController->IsCompound()) { - rootobj->m_pPhysicsController1->AddCompoundChild(m_pPhysicsController1); + rootobj->m_pPhysicsController->AddCompoundChild(m_pPhysicsController); } } // graphically, the object hasn't change place, no need to update m_pGraphicController @@ -392,27 +396,27 @@ void KX_GameObject::RemoveParent(KX_Scene *scene) if (!rootlist->SearchValue(this)) // object was not in root list, add it now and increment ref count rootlist->Add(AddRef()); - if (m_pPhysicsController1) + if (m_pPhysicsController) { // in case this controller was added as a child shape to the parent if (rootobj != NULL && - rootobj->m_pPhysicsController1 != NULL && - rootobj->m_pPhysicsController1->IsCompound()) + rootobj->m_pPhysicsController != NULL && + rootobj->m_pPhysicsController->IsCompound()) { - rootobj->m_pPhysicsController1->RemoveCompoundChild(m_pPhysicsController1); + rootobj->m_pPhysicsController->RemoveCompoundChild(m_pPhysicsController); } - m_pPhysicsController1->RestoreDynamics(); - if (m_pPhysicsController1->IsDyna() && (rootobj != NULL && rootobj->m_pPhysicsController1)) + m_pPhysicsController->RestoreDynamics(); + if (m_pPhysicsController->IsDynamic() && (rootobj != NULL && rootobj->m_pPhysicsController)) { // dynamic object should remember the velocity they had while being parented MT_Point3 childPoint = GetSGNode()->GetWorldPosition(); MT_Point3 rootPoint = rootobj->GetSGNode()->GetWorldPosition(); MT_Point3 relPoint; relPoint = (childPoint-rootPoint); - MT_Vector3 linVel = rootobj->m_pPhysicsController1->GetVelocity(relPoint); - MT_Vector3 angVel = rootobj->m_pPhysicsController1->GetAngularVelocity(); - m_pPhysicsController1->SetLinearVelocity(linVel, false); - m_pPhysicsController1->SetAngularVelocity(angVel, false); + MT_Vector3 linVel = rootobj->m_pPhysicsController->GetVelocity(relPoint); + MT_Vector3 angVel = rootobj->m_pPhysicsController->GetAngularVelocity(); + m_pPhysicsController->SetLinearVelocity(linVel, false); + m_pPhysicsController->SetAngularVelocity(angVel, false); } } // graphically, the object hasn't change place, no need to update m_pGraphicController @@ -488,9 +492,9 @@ void KX_GameObject::SetTimes(short layer, float start, float end) void KX_GameObject::ProcessReplica() { SCA_IObject::ProcessReplica(); - - m_pPhysicsController1 = NULL; + m_pGraphicController = NULL; + m_pPhysicsController = NULL; m_pSGNode = NULL; m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info); m_pClient_info->m_gameobject = this; @@ -570,16 +574,16 @@ CValue* KX_GameObject::GetReplica() void KX_GameObject::ApplyForce(const MT_Vector3& force,bool local) { - if (m_pPhysicsController1) - m_pPhysicsController1->ApplyForce(force,local); + if (m_pPhysicsController) + m_pPhysicsController->ApplyForce(force,local); } void KX_GameObject::ApplyTorque(const MT_Vector3& torque,bool local) { - if (m_pPhysicsController1) - m_pPhysicsController1->ApplyTorque(torque,local); + if (m_pPhysicsController) + m_pPhysicsController->ApplyTorque(torque,local); } @@ -588,9 +592,9 @@ void KX_GameObject::ApplyMovement(const MT_Vector3& dloc,bool local) { if (GetSGNode()) { - if (m_pPhysicsController1) // (IsDynamic()) + if (m_pPhysicsController) // (IsDynamic()) { - m_pPhysicsController1->RelativeTranslate(dloc,local); + m_pPhysicsController->RelativeTranslate(dloc,local); } GetSGNode()->RelativeTranslate(dloc,GetSGNode()->GetSGParent(),local); } @@ -605,8 +609,8 @@ void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local) if (GetSGNode()) { GetSGNode()->RelativeRotate(rotmat,local); - if (m_pPhysicsController1) { // (IsDynamic()) - m_pPhysicsController1->RelativeRotate(rotmat,local); + if (m_pPhysicsController) { // (IsDynamic()) + m_pPhysicsController->RelativeRotate(rotmat,local); } } } @@ -730,11 +734,8 @@ void KX_GameObject::RemoveMeshes() void KX_GameObject::UpdateTransform() { // HACK: saves function call for dynamic object, they are handled differently - if (m_pPhysicsController1 && !m_pPhysicsController1->IsDyna()) - // Note that for Bullet, this does not even update the transform of static object - // but merely sets there collision flag to "kinematic" because the synchronization is - // done during physics simulation - m_pPhysicsController1->SetSumoTransform(true); + if (m_pPhysicsController && !m_pPhysicsController->IsDynamic()) + m_pPhysicsController->SetTransform(); if (m_pGraphicController) // update the culling tree m_pGraphicController->SetGraphicTransform(); @@ -749,8 +750,8 @@ void KX_GameObject::UpdateTransformFunc(SG_IObject* node, void* gameobj, void* s void KX_GameObject::SynchronizeTransform() { // only used for sensor object, do full synchronization as bullet doesn't do it - if (m_pPhysicsController1) - m_pPhysicsController1->SetTransform(); + if (m_pPhysicsController) + m_pPhysicsController->SetTransform(); if (m_pGraphicController) m_pGraphicController->SetGraphicTransform(); } @@ -935,10 +936,10 @@ KX_GameObject::GetLayer( void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local) { - if (m_pPhysicsController1) + if (m_pPhysicsController) { MT_Vector3 lv = local ? NodeGetWorldOrientation() * lin_vel : lin_vel; - m_pPhysicsController1->SetLinearVelocity(lv + m_pPhysicsController1->GetLinearVelocity(), 0); + m_pPhysicsController->SetLinearVelocity(lv + m_pPhysicsController->GetLinearVelocity(), 0); } } @@ -946,16 +947,16 @@ void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local) void KX_GameObject::setLinearVelocity(const MT_Vector3& lin_vel,bool local) { - if (m_pPhysicsController1) - m_pPhysicsController1->SetLinearVelocity(lin_vel,local); + if (m_pPhysicsController) + m_pPhysicsController->SetLinearVelocity(lin_vel,local); } void KX_GameObject::setAngularVelocity(const MT_Vector3& ang_vel,bool local) { - if (m_pPhysicsController1) - m_pPhysicsController1->SetAngularVelocity(ang_vel,local); + if (m_pPhysicsController) + m_pPhysicsController->SetAngularVelocity(ang_vel,local); } @@ -965,12 +966,12 @@ void KX_GameObject::ResolveCombinedVelocities( bool lin_vel_local, bool ang_vel_local ) { - if (m_pPhysicsController1) + if (m_pPhysicsController) { MT_Vector3 lv = lin_vel_local ? NodeGetWorldOrientation() * lin_vel : lin_vel; MT_Vector3 av = ang_vel_local ? NodeGetWorldOrientation() * ang_vel : ang_vel; - m_pPhysicsController1->resolveCombinedVelocities( + m_pPhysicsController->ResolveCombinedVelocities( lv.x(),lv.y(),lv.z(),av.x(),av.y(),av.z()); } } @@ -1082,9 +1083,9 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) MT_Scalar KX_GameObject::GetMass() { - if (m_pPhysicsController1) + if (m_pPhysicsController) { - return m_pPhysicsController1->GetMass(); + return m_pPhysicsController->GetMass(); } return 0.0; } @@ -1092,9 +1093,9 @@ MT_Scalar KX_GameObject::GetMass() MT_Vector3 KX_GameObject::GetLocalInertia() { MT_Vector3 local_inertia(0.0,0.0,0.0); - if (m_pPhysicsController1) + if (m_pPhysicsController) { - local_inertia = m_pPhysicsController1->GetLocalInertia(); + local_inertia = m_pPhysicsController->GetLocalInertia(); } return local_inertia; } @@ -1103,9 +1104,9 @@ MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { MT_Vector3 velocity(0.0,0.0,0.0), locvel; MT_Matrix3x3 ori; - if (m_pPhysicsController1) + if (m_pPhysicsController) { - velocity = m_pPhysicsController1->GetLinearVelocity(); + velocity = m_pPhysicsController->GetLinearVelocity(); if (local) { @@ -1122,9 +1123,9 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) { MT_Vector3 velocity(0.0,0.0,0.0), locvel; MT_Matrix3x3 ori; - if (m_pPhysicsController1) + if (m_pPhysicsController) { - velocity = m_pPhysicsController1->GetAngularVelocity(); + velocity = m_pPhysicsController->GetAngularVelocity(); if (local) { @@ -1139,9 +1140,9 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point) { - if (m_pPhysicsController1) + if (m_pPhysicsController) { - return m_pPhysicsController1->GetVelocity(point); + return m_pPhysicsController->GetVelocity(point); } return MT_Vector3(0.0,0.0,0.0); } @@ -1154,13 +1155,13 @@ void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans) if (!GetSGNode()) return; - if (m_pPhysicsController1 && !GetSGNode()->GetSGParent()) + if (m_pPhysicsController && !GetSGNode()->GetSGParent()) { // don't update physic controller if the object is a child: // 1) the transformation will not be right // 2) in this case, the physic controller is necessarily a static object // that is updated from the normal kinematic synchronization - m_pPhysicsController1->setPosition(trans); + m_pPhysicsController->SetPosition(trans); } GetSGNode()->SetLocalPosition(trans); @@ -1175,10 +1176,10 @@ void KX_GameObject::NodeSetLocalOrientation(const MT_Matrix3x3& rot) if (!GetSGNode()) return; - if (m_pPhysicsController1 && !GetSGNode()->GetSGParent()) + if (m_pPhysicsController && !GetSGNode()->GetSGParent()) { // see note above - m_pPhysicsController1->setOrientation(rot); + m_pPhysicsController->SetOrientation(rot); } GetSGNode()->SetLocalOrientation(rot); } @@ -1201,10 +1202,10 @@ void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale) if (!GetSGNode()) return; - if (m_pPhysicsController1 && !GetSGNode()->GetSGParent()) + if (m_pPhysicsController && !GetSGNode()->GetSGParent()) { // see note above - m_pPhysicsController1->setScaling(scale); + m_pPhysicsController->SetScaling(scale); } GetSGNode()->SetLocalScale(scale); } @@ -1216,13 +1217,13 @@ void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale) if (GetSGNode()) { GetSGNode()->RelativeScale(scale); - if (m_pPhysicsController1 && (!GetSGNode()->GetSGParent())) + if (m_pPhysicsController && (!GetSGNode()->GetSGParent())) { // see note above // we can use the local scale: it's the same thing for a root object // and the world scale is not yet updated MT_Vector3 newscale = GetSGNode()->GetLocalScale(); - m_pPhysicsController1->setScaling(newscale); + m_pPhysicsController->SetScaling(newscale); } } } @@ -1355,13 +1356,13 @@ void KX_GameObject::UnregisterCollisionCallbacks() // Unregister from callbacks KX_Scene* scene = GetScene(); PHY_IPhysicsEnvironment* pe = scene->GetPhysicsEnvironment(); - PHY_IPhysicsController* spc = static_cast (GetPhysicsController()->GetUserData()); + PHY_IPhysicsController* spc = GetPhysicsController(); // If we are the last to unregister on this physics controller - if (pe->removeCollisionCallback(spc)){ + if (pe->RemoveCollisionCallback(spc)){ // If we are a sensor object if (m_pClient_info->isSensor()) // Remove sensor body from physics world - pe->removeSensor(spc); + pe->RemoveSensor(spc); } } @@ -1375,13 +1376,13 @@ void KX_GameObject::RegisterCollisionCallbacks() // Register from callbacks KX_Scene* scene = GetScene(); PHY_IPhysicsEnvironment* pe = scene->GetPhysicsEnvironment(); - PHY_IPhysicsController* spc = static_cast (GetPhysicsController()->GetUserData()); + PHY_IPhysicsController* spc = GetPhysicsController(); // If we are the first to register on this physics controller - if (pe->requestCollisionCallback(spc)){ + if (pe->RequestCollisionCallback(spc)){ // If we are a sensor object if (m_pClient_info->isSensor()) // Add sensor body to physics world - pe->addSensor(spc); + pe->AddSensor(spc); } } void KX_GameObject::RunCollisionCallbacks(KX_GameObject *collider) @@ -2170,14 +2171,14 @@ PyObject *KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF PyObject *KX_GameObject::pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self = static_cast(self_v); - KX_IPhysicsController *spc = self->GetPhysicsController(); + PHY_IPhysicsController *spc = self->GetPhysicsController(); return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0); } int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { KX_GameObject* self = static_cast(self_v); - KX_IPhysicsController *spc = self->GetPhysicsController(); + PHY_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); if (val < 0.0) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.mass = float: KX_GameObject, expected a float zero or above"); @@ -2193,14 +2194,14 @@ int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrd PyObject *KX_GameObject::pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self = static_cast(self_v); - KX_IPhysicsController *spc = self->GetPhysicsController(); + PHY_IPhysicsController *spc = self->GetPhysicsController(); return PyFloat_FromDouble(spc ? spc->GetLinVelocityMin() : 0.0f); } int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { KX_GameObject* self = static_cast(self_v); - KX_IPhysicsController *spc = self->GetPhysicsController(); + PHY_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); if (val < 0.0) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above"); @@ -2216,14 +2217,14 @@ int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF PyObject *KX_GameObject::pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self = static_cast(self_v); - KX_IPhysicsController *spc = self->GetPhysicsController(); + PHY_IPhysicsController *spc = self->GetPhysicsController(); return PyFloat_FromDouble(spc ? spc->GetLinVelocityMax() : 0.0f); } int KX_GameObject::pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { KX_GameObject* self = static_cast(self_v); - KX_IPhysicsController *spc = self->GetPhysicsController(); + PHY_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); if (val < 0.0) { /* also accounts for non float */ PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above"); @@ -2307,8 +2308,8 @@ PyObject *KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIB return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL); #else KX_GameObject* self = static_cast(self_v); - if (self->GetPhysicsController()) - return PyObjectFrom(self->GetPhysicsController()->GetLocalInertia()); + if (self->GetPhysicsController1()) + return PyObjectFrom(self->GetPhysicsController1()->GetLocalInertia()); return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f); #endif } @@ -2854,14 +2855,8 @@ PyObject *KX_GameObject::PyGetVelocity(PyObject *args) if (!PyArg_ParseTuple(args, "|O:getVelocity", &pypos) || (pypos && !PyVecTo(pypos, point))) return NULL; - - if (m_pPhysicsController1) - { - return PyObjectFrom(m_pPhysicsController1->GetVelocity(point)); - } - else { - return PyObjectFrom(MT_Vector3(0.0,0.0,0.0)); - } + + return PyObjectFrom(GetVelocity(point)); } PyObject *KX_GameObject::PyGetReactionForce() @@ -2870,8 +2865,8 @@ PyObject *KX_GameObject::PyGetReactionForce() // XXX - Currently not working with bullet intergration, see KX_BulletPhysicsController.cpp's getReactionForce #if 0 - if (GetPhysicsController()) - return PyObjectFrom(GetPhysicsController()->getReactionForce()); + if (GetPhysicsController1()) + return PyObjectFrom(GetPhysicsController1()->getReactionForce()); return PyObjectFrom(dummy_point); #endif @@ -2884,7 +2879,7 @@ PyObject *KX_GameObject::PyGetReactionForce() PyObject *KX_GameObject::PyEnableRigidBody() { if (GetPhysicsController()) - GetPhysicsController()->setRigidBody(true); + GetPhysicsController()->SetRigidBody(true); Py_RETURN_NONE; } @@ -2894,7 +2889,7 @@ PyObject *KX_GameObject::PyEnableRigidBody() PyObject *KX_GameObject::PyDisableRigidBody() { if (GetPhysicsController()) - GetPhysicsController()->setRigidBody(false); + GetPhysicsController()->SetRigidBody(false); Py_RETURN_NONE; } @@ -2935,9 +2930,9 @@ PyObject *KX_GameObject::PySetCollisionMargin(PyObject *value) return NULL; } - if (m_pPhysicsController1) + if (m_pPhysicsController) { - m_pPhysicsController1->setMargin(collisionMargin); + m_pPhysicsController->SetMargin(collisionMargin); Py_RETURN_NONE; } PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller"); @@ -2951,7 +2946,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args) PyObject *pyattach; PyObject *pyimpulse; - if (!m_pPhysicsController1) { + if (!m_pPhysicsController) { PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller"); return NULL; } @@ -2962,7 +2957,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args) MT_Vector3 impulse; if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse)) { - m_pPhysicsController1->applyImpulse(attach, impulse); + m_pPhysicsController->ApplyImpulse(attach, impulse); Py_RETURN_NONE; } @@ -2975,7 +2970,7 @@ PyObject *KX_GameObject::PyApplyImpulse(PyObject *args) PyObject *KX_GameObject::PySuspendDynamics() { - SuspendDynamics(); + GetPhysicsController()->SuspendDynamics(); Py_RETURN_NONE; } @@ -2983,7 +2978,7 @@ PyObject *KX_GameObject::PySuspendDynamics() PyObject *KX_GameObject::PyRestoreDynamics() { - RestoreDynamics(); + GetPhysicsController()->RestoreDynamics(); Py_RETURN_NONE; } @@ -3023,11 +3018,11 @@ PyObject *KX_GameObject::PyGetAxisVect(PyObject *value) PyObject *KX_GameObject::PyGetPhysicsId() { - KX_IPhysicsController* ctrl = GetPhysicsController(); + PHY_IPhysicsController* ctrl = GetPhysicsController(); uint_ptr physid=0; if (ctrl) { - physid= (uint_ptr)ctrl->GetUserData(); + physid= (uint_ptr)ctrl; } return PyLong_FromLong((long)physid); } @@ -3190,7 +3185,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized(); PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment(); - KX_IPhysicsController *spc = GetPhysicsController(); + PHY_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); if (!spc && parent) spc = parent->GetPhysicsController(); @@ -3336,7 +3331,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, } PHY_IPhysicsEnvironment* pe = GetScene()->GetPhysicsEnvironment(); - KX_IPhysicsController *spc = GetPhysicsController(); + PHY_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); if (!spc && parent) spc = parent->GetPhysicsController(); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index dde3ff53299..55e2b31c5bf 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -49,7 +49,6 @@ #include "CTR_HashedPtr.h" #include "KX_Scene.h" #include "KX_KetsjiEngine.h" /* for m_anim_framerate */ -#include "KX_IPhysicsController.h" /* for suspend/resume */ #include "DNA_object_types.h" #include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */ @@ -57,9 +56,9 @@ struct KX_ClientObjectInfo; class KX_RayCast; class RAS_MeshObject; -class KX_IPhysicsController; class PHY_IGraphicController; class PHY_IPhysicsEnvironment; +class PHY_IPhysicsController; class BL_ActionManager; struct Object; class KX_ObstacleSimulation; @@ -107,7 +106,7 @@ protected: bool m_bCulled; bool m_bOccluder; - KX_IPhysicsController* m_pPhysicsController1; + PHY_IPhysicsController* m_pPhysicsController; PHY_IGraphicController* m_pGraphicController; STR_String m_testPropName; bool m_xray; @@ -465,12 +464,12 @@ public: * \return a pointer to the physics controller owned by this class. */ - KX_IPhysicsController* GetPhysicsController(); + PHY_IPhysicsController* GetPhysicsController(); - void SetPhysicsController(KX_IPhysicsController* physicscontroller,bool isDynamic) + void SetPhysicsController(PHY_IPhysicsController* physicscontroller,bool isDynamic) { m_bDyna = isDynamic; - m_pPhysicsController1 = physicscontroller; + m_pPhysicsController = physicscontroller; } virtual class RAS_Deformer* GetDeformer() @@ -885,32 +884,6 @@ public: * Resume making progress */ void Resume(void); - - void SuspendDynamics(void) { - if (m_bSuspendDynamics) - { - return; - } - - if (m_pPhysicsController1) - { - m_pPhysicsController1->SuspendDynamics(); - } - m_bSuspendDynamics = true; - } - - void RestoreDynamics(void) { - if (!m_bSuspendDynamics) - { - return; - } - - if (m_pPhysicsController1) - { - m_pPhysicsController1->RestoreDynamics(); - } - m_bSuspendDynamics = false; - } void RegisterObstacle(KX_ObstacleSimulation* obstacleSimulation) { diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index f221b7c6cd4..f75633659ff 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -48,7 +48,7 @@ typedef unsigned long uint_ptr; #include "KX_IPO_SGController.h" #include "KX_ScalarInterpolator.h" #include "KX_GameObject.h" -#include "KX_IPhysicsController.h" +#include "PHY_IPhysicsController.h" #include "DNA_ipo_types.h" #include "BLI_math.h" @@ -154,9 +154,10 @@ bool KX_IpoSGController::Update(double currentTime) { if (m_game_object && ob && m_game_object->GetPhysicsController()) { - m_game_object->GetPhysicsController()->ApplyForce(m_ipo_local ? - ob->GetWorldOrientation() * m_ipo_xform.GetPosition() : - m_ipo_xform.GetPosition(), false); + MT_Vector3 vec = m_ipo_local ? + ob->GetWorldOrientation() * m_ipo_xform.GetPosition() : + m_ipo_xform.GetPosition(); + m_game_object->GetPhysicsController()->ApplyForce(vec, false); } } else diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.cpp b/source/gameengine/Ketsji/KX_IPhysicsController.cpp deleted file mode 100644 index f0e57ceac02..00000000000 --- a/source/gameengine/Ketsji/KX_IPhysicsController.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file gameengine/Ketsji/KX_IPhysicsController.cpp - * \ingroup ketsji - */ - -#include "KX_IPhysicsController.h" - -#include "PHY_DynamicTypes.h" - -KX_IPhysicsController::KX_IPhysicsController(bool dyna, bool sensor, bool character, bool compound, void* userdata) - -: m_bDyna(dyna), - m_bSensor(sensor), - m_bCharacter(character), - m_bCompound(compound), - m_suspendDynamics(false), - m_userdata(userdata) -{ -} - -KX_IPhysicsController::~KX_IPhysicsController() -{ -} diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h deleted file mode 100644 index 2019be57679..00000000000 --- a/source/gameengine/Ketsji/KX_IPhysicsController.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file KX_IPhysicsController.h - * \ingroup ketsji - */ - -#ifndef __KX_IPHYSICSCONTROLLER_H__ -#define __KX_IPHYSICSCONTROLLER_H__ - -#include "SG_Controller.h" -#include "MT_Vector3.h" -#include "MT_Point3.h" -#include "MT_Transform.h" -#include "MT_Matrix3x3.h" - -struct KX_ClientObjectInfo; - -/** - * Physics Controller, a special kind of Scene Graph Transformation Controller. - * It get's callbacks from Physics in case a transformation change took place. - * Each time the scene graph get's updated, the controller get's a chance - * in the 'Update' method to reflect changed. - */ - -class KX_IPhysicsController : public SG_Controller - -{ -protected: - bool m_bDyna; - bool m_bSensor; - bool m_bCharacter; - bool m_bCompound; - bool m_suspendDynamics; - void* m_userdata; -public: - KX_IPhysicsController(bool dyna,bool sensor,bool character,bool compound, void* userdata); - virtual ~KX_IPhysicsController(); - - - virtual void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)=0; - virtual void SetObject (SG_IObject* object)=0; - virtual void setMargin (float collisionMargin)=0; - - virtual void RelativeTranslate(const MT_Vector3& dloc,bool local)=0; - virtual void RelativeRotate(const MT_Matrix3x3& drot,bool local)=0; - virtual void ApplyTorque(const MT_Vector3& torque,bool local)=0; - virtual void ApplyForce(const MT_Vector3& force,bool local)=0; - virtual void SetWalkDirection(const MT_Vector3& dir,bool local)=0; - virtual MT_Vector3 GetLinearVelocity()=0; - virtual MT_Vector3 GetAngularVelocity()=0; - virtual MT_Vector3 GetVelocity(const MT_Point3& pos)=0; - virtual MT_Vector3 GetWalkDirection()=0; - virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0; - virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0; - virtual void Jump()=0; - virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0; - - virtual void getOrientation(MT_Quaternion& orn)=0; - virtual void setOrientation(const MT_Matrix3x3& orn)=0; - virtual void SetTransform()=0; - //virtual void setOrientation(const MT_Quaternion& orn)=0; - virtual void setPosition(const MT_Point3& pos)=0; - virtual void setScaling(const MT_Vector3& scaling)=0; - virtual MT_Scalar GetMass()=0; - virtual void SetMass(MT_Scalar newmass)=0; - - virtual float GetLinVelocityMin()=0; - virtual void SetLinVelocityMin(float newmass)=0; - virtual float GetLinVelocityMax()=0; - virtual void SetLinVelocityMax(float newmass)=0; - - virtual MT_Vector3 GetLocalInertia()=0; - virtual MT_Vector3 getReactionForce()=0; - virtual void setRigidBody(bool rigid)=0; - virtual void AddCompoundChild(KX_IPhysicsController* child) = 0; - virtual void RemoveCompoundChild(KX_IPhysicsController* child) = 0; - - virtual void SuspendDynamics(bool ghost=false)=0; - virtual void RestoreDynamics()=0; - - virtual SG_Controller* GetReplica(class SG_Node* destnode)=0; - - void SetDyna(bool isDynamic) { - m_bDyna = isDynamic; - } - - void SetSensor(bool isSensor) { - m_bSensor = isSensor; - } - - void SetCharacter(bool isCharacter) { - m_bCharacter = isCharacter; - } - - bool IsDyna(void) { - return m_bDyna; - } - - bool IsSensor(void) { - return m_bSensor; - } - - bool IsCharacter(void) { - return m_bCharacter; - } - - bool IsCompound(void) { - return m_bCompound; - } - - virtual MT_Scalar GetRadius()=0; - virtual void SetSumoTransform(bool nondynaonly)=0; - // todo: remove next line ! - virtual void SetSimulatedTime(double time)=0; - - // call from scene graph to update - virtual bool Update(double time)=0; - void* GetUserData() { return m_userdata;} - - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_IPhysicsController") -#endif -}; - -#endif /* __KX_IPHYSICSCONTROLLER_H__ */ diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 48ef8cdd50d..0e9e2cd8328 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -646,7 +646,7 @@ bool KX_KetsjiEngine::NextFrame() #endif KX_SetActiveScene(scene); - scene->GetPhysicsEnvironment()->endFrame(); + scene->GetPhysicsEnvironment()->EndFrame(); // Update scenegraph after physics step. This maps physics calculations // into node positions. @@ -688,11 +688,11 @@ bool KX_KetsjiEngine::NextFrame() m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_PHYSICS2); - scene->GetPhysicsEnvironment()->beginFrame(); + scene->GetPhysicsEnvironment()->BeginFrame(); // Perform physics calculations on the scene. This can involve // many iterations of the physics solver. - scene->GetPhysicsEnvironment()->proceedDeltaTime(m_frameTime,timestep,framestep);//m_deltatimerealDeltaTime); + scene->GetPhysicsEnvironment()->ProceedDeltaTime(m_frameTime,timestep,framestep);//m_deltatimerealDeltaTime); m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_PHYSICS2_UPDATE); @@ -762,7 +762,7 @@ bool KX_KetsjiEngine::NextFrame() // Perform physics calculations on the scene. This can involve // many iterations of the physics solver. m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true); - scene->GetPhysicsEnvironment()->proceedDeltaTime(m_clockTime,timestep,timestep); + scene->GetPhysicsEnvironment()->ProceedDeltaTime(m_clockTime,timestep,timestep); // Update scenegraph after physics step. This maps physics calculations // into node positions. m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); @@ -1329,7 +1329,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) scene->RenderFonts(); if (scene->GetPhysicsEnvironment()) - scene->GetPhysicsEnvironment()->debugDrawWorld(); + scene->GetPhysicsEnvironment()->DebugDrawWorld(); } /* diff --git a/source/gameengine/Ketsji/KX_MotionState.cpp b/source/gameengine/Ketsji/KX_MotionState.cpp index 3ca01e7af74..4728f71a6ea 100644 --- a/source/gameengine/Ketsji/KX_MotionState.cpp +++ b/source/gameengine/Ketsji/KX_MotionState.cpp @@ -41,7 +41,7 @@ KX_MotionState::~KX_MotionState() { } -void KX_MotionState::getWorldPosition(float& posX,float& posY,float& posZ) +void KX_MotionState::GetWorldPosition(float& posX,float& posY,float& posZ) { const MT_Point3& pos = m_node->GetWorldPosition(); posX = pos[0]; @@ -49,7 +49,7 @@ void KX_MotionState::getWorldPosition(float& posX,float& posY,float& posZ) posZ = pos[2]; } -void KX_MotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ) +void KX_MotionState::GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ) { const MT_Vector3& scale = m_node->GetWorldScaling(); scaleX = scale[0]; @@ -57,7 +57,7 @@ void KX_MotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ) scaleZ = scale[2]; } -void KX_MotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal) +void KX_MotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal) { MT_Quaternion orn = m_node->GetWorldOrientation().getRotation(); quatIma0 = orn[0]; @@ -66,24 +66,24 @@ void KX_MotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatReal = orn[3]; } -void KX_MotionState::getWorldOrientation(float* ori) +void KX_MotionState::GetWorldOrientation(float* ori) { const MT_Matrix3x3& mat = m_node->GetWorldOrientation(); mat.getValue(ori); } -void KX_MotionState::setWorldOrientation(const float* ori) +void KX_MotionState::SetWorldOrientation(const float* ori) { m_node->SetLocalOrientation(ori); } -void KX_MotionState::setWorldPosition(float posX,float posY,float posZ) +void KX_MotionState::SetWorldPosition(float posX,float posY,float posZ) { m_node->SetLocalPosition(MT_Point3(posX,posY,posZ)); //m_node->SetWorldPosition(MT_Point3(posX,posY,posZ)); } -void KX_MotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal) +void KX_MotionState::SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal) { MT_Quaternion orn; orn[0] = quatIma0; @@ -96,7 +96,7 @@ void KX_MotionState::setWorldOrientation(float quatIma0,float quatIma1,float qua } -void KX_MotionState::calculateWorldTransformations() +void KX_MotionState::CalculateWorldTransformations() { //Not needed, will be done in KX_Scene::UpdateParents() after the physics simulation //bool parentUpdated = false; diff --git a/source/gameengine/Ketsji/KX_MotionState.h b/source/gameengine/Ketsji/KX_MotionState.h index 116e62f408f..38046fe4ff9 100644 --- a/source/gameengine/Ketsji/KX_MotionState.h +++ b/source/gameengine/Ketsji/KX_MotionState.h @@ -46,15 +46,15 @@ public: KX_MotionState(class SG_Spatial* spatial); virtual ~KX_MotionState(); - virtual void getWorldPosition(float& posX,float& posY,float& posZ); - virtual void getWorldScaling(float& scaleX,float& scaleY,float& scaleZ); - virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal); - virtual void setWorldPosition(float posX,float posY,float posZ); - virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal); - virtual void getWorldOrientation(float* ori); - virtual void setWorldOrientation(const float* ori); + virtual void GetWorldPosition(float& posX,float& posY,float& posZ); + virtual void GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ); + virtual void GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal); + virtual void SetWorldPosition(float posX,float posY,float posZ); + virtual void SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal); + virtual void GetWorldOrientation(float* ori); + virtual void SetWorldOrientation(const float* ori); - virtual void calculateWorldTransformations(); + virtual void CalculateWorldTransformations(); #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 82ae8c13633..2dbafdad3d9 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -47,7 +47,6 @@ #include "KX_PyMath.h" #include "KX_RayCast.h" -#include "KX_IPhysicsController.h" #include "PHY_IPhysicsController.h" #include "PHY_IPhysicsEnvironment.h" @@ -280,7 +279,7 @@ bool KX_MouseFocusSensor::ParentObjectHasFocusCamera(KX_Camera *cam) /* 2. Get the object from PhysicsEnvironment */ /* Shoot! Beware that the first argument here is an * ignore-object. We don't ignore anything... */ - KX_IPhysicsController* physics_controller = cam->GetPhysicsController(); + PHY_IPhysicsController* physics_controller = cam->GetPhysicsController(); PHY_IPhysicsEnvironment* physics_environment = m_kxscene->GetPhysicsEnvironment(); // get UV mapping diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index cbb4e77d165..6459f35192d 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -68,7 +68,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr, if (m_physCtrl) { m_physCtrl->SetMargin(m_Margin); - m_physCtrl->setNewClientInfo(m_client_info); + m_physCtrl->SetNewClientInfo(m_client_info); } SynchronizeTransform(); } @@ -84,8 +84,8 @@ void KX_NearSensor::SynchronizeTransform() const MT_Point3& pos = parent->NodeGetWorldPosition(); float ori[12]; parent->NodeGetWorldOrientation().getValue(ori); - motionState->setWorldPosition(pos[0], pos[1], pos[2]); - motionState->setWorldOrientation(ori); + motionState->SetWorldPosition(pos[0], pos[1], pos[2]); + motionState->SetWorldOrientation(ori); m_physCtrl->WriteMotionStateToDynamics(true); } } @@ -105,12 +105,12 @@ void KX_NearSensor::ProcessReplica() if (m_physCtrl) { - m_physCtrl = m_physCtrl->GetReplica(); + m_physCtrl = m_physCtrl->GetReplicaForSensors(); if (m_physCtrl) { //static_cast(m_eventmgr)->GetPhysicsEnvironment()->addSensor(replica->m_physCtrl); m_physCtrl->SetMargin(m_Margin); - m_physCtrl->setNewClientInfo(m_client_info); + m_physCtrl->SetNewClientInfo(m_client_info); } } @@ -186,7 +186,7 @@ bool KX_NearSensor::BroadPhaseFilterCollision(void*obj1,void*obj2) // need the mapping from PHY_IPhysicsController to gameobjects now assert(obj1==m_physCtrl && obj2); - KX_ClientObjectInfo *client_info = static_cast((static_cast(obj2))->getNewClientInfo()); + KX_ClientObjectInfo *client_info = static_cast((static_cast(obj2))->GetNewClientInfo()); KX_GameObject* gameobj = ( client_info ? client_info->m_gameobject : @@ -216,8 +216,8 @@ bool KX_NearSensor::NewHandleCollision(void *obj1, void *obj2, const PHY_CollDat // need the mapping from PHY_IPhysicsController to gameobjects now KX_ClientObjectInfo *client_info = static_cast (obj1 == m_physCtrl? - ((PHY_IPhysicsController*)obj2)->getNewClientInfo() : - ((PHY_IPhysicsController*)obj1)->getNewClientInfo()); + ((PHY_IPhysicsController*)obj2)->GetNewClientInfo() : + ((PHY_IPhysicsController*)obj1)->GetNewClientInfo()); KX_GameObject* gameobj = ( client_info ? client_info->m_gameobject : diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 2965faba8f4..2f85453dd23 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -36,7 +36,9 @@ #include "KX_ObjectActuator.h" #include "KX_GameObject.h" #include "KX_PyMath.h" // For PyVecTo - should this include be put in PyObjectPlus? -#include "KX_IPhysicsController.h" +#include "PHY_IPhysicsController.h" +#include "PHY_ICharacter.h" +#include "PHY_IPhysicsEnvironment.h" /* ------------------------------------------------------------------------- */ /* Native functions */ @@ -84,8 +86,9 @@ KX_ObjectActuator( if (m_bitLocalFlag.CharacterMotion) { KX_GameObject *parent = static_cast(GetParent()); + PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent); - if (!parent->GetPhysicsController() || !parent->GetPhysicsController()->IsCharacter()) + if (!character) { printf("Character motion enabled on non-character object (%s), falling back to simple motion.\n", parent->GetName().Ptr()); m_bitLocalFlag.CharacterMotion = false; @@ -109,6 +112,7 @@ bool KX_ObjectActuator::Update() RemoveAllEvents(); KX_GameObject *parent = static_cast(GetParent()); + PHY_ICharacter *character = parent->GetScene()->GetPhysicsEnvironment()->GetCharacterController(parent); if (bNegativeEvent) { // If we previously set the linear velocity we now have to inform @@ -128,8 +132,7 @@ bool KX_ObjectActuator::Update() // Explicitly stop the movement if we're using character motion if (m_bitLocalFlag.CharacterMotion) { - MT_Vector3 vec(0.0, 0.0, 0.0); - parent->GetPhysicsController()->SetWalkDirection(vec, true); + character->SetWalkDirection(MT_Vector3 (0.0, 0.0, 0.0)); } m_linear_damping_active = false; @@ -220,7 +223,7 @@ bool KX_ObjectActuator::Update() MT_Vector3 dir = m_dloc; if (m_bitLocalFlag.AddOrSetCharLoc) { - MT_Vector3 old_dir = parent->GetPhysicsController()->GetWalkDirection(); + MT_Vector3 old_dir = character->GetWalkDirection(); if (!old_dir.fuzzyZero()) { MT_Scalar mag = old_dir.length(); @@ -232,7 +235,12 @@ bool KX_ObjectActuator::Update() } // We always want to set the walk direction since a walk direction of (0, 0, 0) should stop the character - parent->GetPhysicsController()->SetWalkDirection(dir, (m_bitLocalFlag.DLoc) != 0); + if (m_bitLocalFlag.DLoc) + { + MT_Matrix3x3 basis = parent->GetPhysicsController()->GetOrientation(); + dir = basis*dir; + } + character->SetWalkDirection(dir/parent->GetScene()->GetPhysicsEnvironment()->GetNumTimeSubSteps()); if (!m_bitLocalFlag.ZeroDRot) { @@ -240,7 +248,8 @@ bool KX_ObjectActuator::Update() } if (m_bitLocalFlag.CharacterJump) { - parent->GetPhysicsController()->Jump(); + + character->Jump(); } } else { diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 2e9b988dff1..e9843b0af5b 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -100,7 +100,7 @@ static PyObject *gPySetGravity(PyObject *self, if (PyArg_ParseTuple(args,"fff",&x,&y,&z)) { if (PHY_GetActiveEnvironment()) - PHY_GetActiveEnvironment()->setGravity(x,y,z); + PHY_GetActiveEnvironment()->SetGravity(x,y,z); } else { return NULL; @@ -118,7 +118,7 @@ static PyObject *gPySetDebugMode(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setDebugMode(mode); + PHY_GetActiveEnvironment()->SetDebugMode(mode); } @@ -141,7 +141,7 @@ static PyObject *gPySetNumTimeSubSteps(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setNumTimeSubSteps(substep); + PHY_GetActiveEnvironment()->SetNumTimeSubSteps(substep); } } else { @@ -160,7 +160,7 @@ static PyObject *gPySetNumIterations(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setNumIterations(iter); + PHY_GetActiveEnvironment()->SetNumIterations(iter); } } else { @@ -179,7 +179,7 @@ static PyObject *gPySetDeactivationTime(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setDeactivationTime(deactive_time); + PHY_GetActiveEnvironment()->SetDeactivationTime(deactive_time); } } else { @@ -198,7 +198,7 @@ static PyObject *gPySetDeactivationLinearTreshold(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setDeactivationLinearTreshold( linearDeactivationTreshold); + PHY_GetActiveEnvironment()->SetDeactivationLinearTreshold( linearDeactivationTreshold); } } else { @@ -217,7 +217,7 @@ static PyObject *gPySetDeactivationAngularTreshold(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setDeactivationAngularTreshold( angularDeactivationTreshold); + PHY_GetActiveEnvironment()->SetDeactivationAngularTreshold( angularDeactivationTreshold); } } else { @@ -235,7 +235,7 @@ static PyObject *gPySetContactBreakingTreshold(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setContactBreakingTreshold( contactBreakingTreshold); + PHY_GetActiveEnvironment()->SetContactBreakingTreshold( contactBreakingTreshold); } } else { @@ -254,7 +254,7 @@ static PyObject *gPySetCcdMode(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setCcdMode( ccdMode); + PHY_GetActiveEnvironment()->SetCcdMode( ccdMode); } } else { @@ -272,7 +272,7 @@ static PyObject *gPySetSorConstant(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setSolverSorConstant( sor); + PHY_GetActiveEnvironment()->SetSolverSorConstant( sor); } } else { @@ -290,7 +290,7 @@ static PyObject *gPySetSolverTau(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setSolverTau( tau); + PHY_GetActiveEnvironment()->SetSolverTau( tau); } } else { @@ -309,7 +309,7 @@ static PyObject *gPySetSolverDamping(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setSolverDamping( damping); + PHY_GetActiveEnvironment()->SetSolverDamping( damping); } } else { @@ -327,7 +327,7 @@ static PyObject *gPySetLinearAirDamping(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setLinearAirDamping( damping); + PHY_GetActiveEnvironment()->SetLinearAirDamping( damping); } } else { @@ -346,7 +346,7 @@ static PyObject *gPySetUseEpa(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setUseEpa(epa); + PHY_GetActiveEnvironment()->SetUseEpa(epa); } } else { @@ -363,7 +363,7 @@ static PyObject *gPySetSolverType(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->setSolverType(solverType); + PHY_GetActiveEnvironment()->SetSolverType(solverType); } } else { @@ -389,7 +389,7 @@ static PyObject *gPyGetVehicleConstraint(PyObject *self, if (PHY_GetActiveEnvironment()) { - PHY_IVehicle* vehicle = PHY_GetActiveEnvironment()->getVehicleConstraint(constraintid); + PHY_IVehicle* vehicle = PHY_GetActiveEnvironment()->GetVehicleConstraint(constraintid); if (vehicle) { KX_VehicleWrapper* pyWrapper = new KX_VehicleWrapper(vehicle,PHY_GetActiveEnvironment()); @@ -421,7 +421,7 @@ static PyObject* gPyGetCharacter(PyObject* self, if (PHY_GetActiveEnvironment()) { - PHY_ICharacter* character= PHY_GetActiveEnvironment()->getCharacterController(ob); + PHY_ICharacter* character= PHY_GetActiveEnvironment()->GetCharacterController(ob); if (character) { KX_CharacterWrapper* pyWrapper = new KX_CharacterWrapper(character); @@ -523,14 +523,14 @@ static PyObject *gPyCreateConstraint(PyObject *self, MT_Vector3 axis1 = localCFrame.getColumn(1); MT_Vector3 axis2 = localCFrame.getColumn(2); - constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype, + constraintid = PHY_GetActiveEnvironment()->CreateConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype, pivotX,pivotY,pivotZ, (float)axis0.x(),(float)axis0.y(),(float)axis0.z(), (float)axis1.x(),(float)axis1.y(),(float)axis1.z(), (float)axis2.x(),(float)axis2.y(),(float)axis2.z(),flag); } else { - constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0); + constraintid = PHY_GetActiveEnvironment()->CreateConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0); } KX_ConstraintWrapper* wrap = new KX_ConstraintWrapper((enum PHY_ConstraintType)constrainttype,constraintid,PHY_GetActiveEnvironment()); @@ -567,7 +567,7 @@ static PyObject *gPyGetAppliedImpulse(PyObject *self, { if (PHY_GetActiveEnvironment()) { - appliedImpulse = PHY_GetActiveEnvironment()->getAppliedImpulse(constraintid); + appliedImpulse = PHY_GetActiveEnvironment()->GetAppliedImpulse(constraintid); } } else { @@ -592,7 +592,7 @@ static PyObject *gPyRemoveConstraint(PyObject *self, { if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->removeConstraint(constraintid); + PHY_GetActiveEnvironment()->RemoveConstraint(constraintid); } } else { @@ -610,7 +610,7 @@ static PyObject *gPyExportBulletFile(PyObject *, PyObject *args) if (PHY_GetActiveEnvironment()) { - PHY_GetActiveEnvironment()->exportFile(filename); + PHY_GetActiveEnvironment()->ExportFile(filename); } Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 311653e72e7..08e240903d1 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -480,7 +480,7 @@ static PyObject *gPySetPhysicsTicRate(PyObject *, PyObject *args) if (!PyArg_ParseTuple(args, "f:setPhysicsTicRate", &ticrate)) return NULL; - PHY_GetActiveEnvironment()->setFixedTimeStep(true,ticrate); + PHY_GetActiveEnvironment()->SetFixedTimeStep(true,ticrate); Py_RETURN_NONE; } #if 0 // unused @@ -498,7 +498,7 @@ static PyObject *gPySetPhysicsDebug(PyObject *, PyObject *args) static PyObject *gPyGetPhysicsTicRate(PyObject *) { - return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep()); + return PyFloat_FromDouble(PHY_GetActiveEnvironment()->GetFixedTimeStep()); } static PyObject *gPyGetAverageFrameRate(PyObject *) diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 04d67fc73e1..732bcdc3773 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -166,8 +166,8 @@ void KX_RadarSensor::SynchronizeTransform() const MT_Point3& pos = trans.getOrigin(); float ori[12]; trans.getBasis().getValue(ori); - motionState->setWorldPosition(pos[0], pos[1], pos[2]); - motionState->setWorldOrientation(ori); + motionState->SetWorldPosition(pos[0], pos[1], pos[2]); + motionState->SetWorldOrientation(ori); m_physCtrl->WriteMotionStateToDynamics(true); } diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index f1bfb10220a..333e7b57d67 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -39,12 +39,11 @@ #include "MT_Point3.h" #include "MT_Vector3.h" -#include "KX_IPhysicsController.h" #include "PHY_IPhysicsEnvironment.h" #include "PHY_IPhysicsController.h" -KX_RayCast::KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal, bool faceUV) - :PHY_IRayCastFilterCallback(dynamic_cast(ignoreController), faceNormal, faceUV) +KX_RayCast::KX_RayCast(PHY_IPhysicsController* ignoreController, bool faceNormal, bool faceUV) + :PHY_IRayCastFilterCallback(ignoreController, faceNormal, faceUV) { } @@ -76,11 +75,11 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_ PHY_IPhysicsController* hit_controller; - while ((hit_controller = physics_environment->rayTest(callback, + while ((hit_controller = physics_environment->RayTest(callback, frompoint.x(),frompoint.y(),frompoint.z(), topoint.x(),topoint.y(),topoint.z())) != NULL) { - KX_ClientObjectInfo *info = static_cast(hit_controller->getNewClientInfo()); + KX_ClientObjectInfo *info = static_cast(hit_controller->GetNewClientInfo()); if (!info) { diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h index 544080f31d0..e47ac676eb1 100644 --- a/source/gameengine/Ketsji/KX_RayCast.h +++ b/source/gameengine/Ketsji/KX_RayCast.h @@ -40,7 +40,6 @@ class RAS_MeshObject; struct KX_ClientObjectInfo; -class KX_IPhysicsController; /** * Defines a function for doing a ray cast. @@ -65,7 +64,7 @@ public: int m_hitUVOK; // !=0 if UV coordinate in m_hitUV is valid MT_Vector2 m_hitUV; - KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal, bool faceUV); + KX_RayCast(PHY_IPhysicsController* ignoreController, bool faceNormal, bool faceUV); virtual ~KX_RayCast() {} /** @@ -105,7 +104,7 @@ template class KX_RayCast::Callback : public KX_RayCast T *self; void *data; public: - Callback(T *_self, KX_IPhysicsController* controller=NULL, void *_data = NULL, bool faceNormal=false, bool faceUV=false) + Callback(T *_self, PHY_IPhysicsController* controller=NULL, void *_data = NULL, bool faceNormal=false, bool faceUV=false) : KX_RayCast(controller, faceNormal, faceUV), self(_self), data(_data) @@ -121,7 +120,7 @@ public: virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller) { - KX_ClientObjectInfo* info = static_cast(controller->getNewClientInfo()); + KX_ClientObjectInfo* info = static_cast(controller->GetNewClientInfo()); if (!info) { diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 3fbce690a9f..afd39557130 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -44,7 +44,6 @@ #include "KX_RayCast.h" #include "KX_PyMath.h" #include "PHY_IPhysicsEnvironment.h" -#include "KX_IPhysicsController.h" #include "PHY_IPhysicsController.h" #include "DNA_sensor_types.h" @@ -261,7 +260,7 @@ bool KX_RaySensor::Evaluate() return false; } - KX_IPhysicsController *spc = obj->GetPhysicsController(); + PHY_IPhysicsController *spc = obj->GetPhysicsController(); KX_GameObject *parent = obj->GetParent(); if (!spc && parent) spc = parent->GetPhysicsController(); diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 56dccc1d045..f8f79269eaa 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -38,7 +38,6 @@ #include "KX_SCA_AddObjectActuator.h" #include "SCA_IScene.h" #include "KX_GameObject.h" -#include "KX_IPhysicsController.h" #include "PyObjectPlus.h" /* ------------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp index 5dc67a4cff3..e02eca3db63 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -35,6 +35,7 @@ * Please look here for revision history. */ #include "KX_SCA_DynamicActuator.h" +#include "PHY_IPhysicsController.h" #ifdef WITH_PYTHON @@ -105,7 +106,7 @@ bool KX_SCA_DynamicActuator::Update() // bool result = false; /*unused*/ KX_GameObject *obj = (KX_GameObject*) GetParent(); bool bNegativeEvent = IsNegativeEvent(); - KX_IPhysicsController* controller; + PHY_IPhysicsController* controller; RemoveAllEvents(); if (bNegativeEvent) @@ -120,16 +121,16 @@ bool KX_SCA_DynamicActuator::Update() switch (m_dyn_operation) { case 0: - obj->RestoreDynamics(); + controller->RestoreDynamics(); break; case 1: - obj->SuspendDynamics(); + controller->SuspendDynamics(); break; case 2: - controller->setRigidBody(true); + controller->SetRigidBody(true); break; case 3: - controller->setRigidBody(false); + controller->SetRigidBody(false); break; case 4: controller->SetMass(m_setmass); diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h index 01a91624c41..4eb337c54f5 100644 --- a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h @@ -38,7 +38,6 @@ #include "SCA_LogicManager.h" #include "KX_GameObject.h" -#include "KX_IPhysicsController.h" class KX_SCA_DynamicActuator : public SCA_IActuator { diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index a34764d7d17..1d95beed6e9 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -82,7 +82,6 @@ #include "KX_NetworkEventManager.h" #include "NG_NetworkScene.h" #include "PHY_IPhysicsEnvironment.h" -#include "KX_IPhysicsController.h" #include "PHY_IGraphicController.h" #include "KX_BlenderSceneConverter.h" #include "KX_MotionState.h" @@ -545,7 +544,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal for (cit = scenegraphcontrollers.begin();!(cit==scenegraphcontrollers.end());++cit) { // controller replication is quite complicated - // only replicate ipo and physics controller for now + // only replicate ipo controller for now SG_Controller* replicacontroller = (*cit)->GetReplica((SG_Node*) replicanode); if (replicacontroller) @@ -559,9 +558,21 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal { PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode()); PHY_IGraphicController* newctrl = orgobj->GetGraphicController()->GetReplica(motionstate); - newctrl->setNewClientInfo(newobj->getClientInfo()); + newctrl->SetNewClientInfo(newobj->getClientInfo()); newobj->SetGraphicController(newctrl); } + + // replicate physics controller + if (orgobj->GetPhysicsController()) + { + PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode()); + PHY_IPhysicsController* newctrl = orgobj->GetPhysicsController()->GetReplica(); + PHY_IPhysicsController* parentctrl = (newobj->GetParent()) ? newobj->GetParent()->GetPhysicsController() : NULL; + + newctrl->SetNewClientInfo(newobj->getClientInfo()); + newobj->SetPhysicsController(newctrl, newobj->IsDynamic()); + newctrl->PostProcessReplica(motionstate, parentctrl); + } return newobj; } @@ -1525,7 +1536,7 @@ void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int double pmat[16] = {0}; cam->GetProjectionMatrix().getValue(pmat); - dbvt_culling = m_physicsEnvironment->cullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res, + dbvt_culling = m_physicsEnvironment->CullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res, KX_GetActiveEngine()->GetCanvas()->GetViewPort(), mvmat, pmat); } @@ -1755,14 +1766,14 @@ void KX_Scene::SetNetworkScene(NG_NetworkScene *newScene) void KX_Scene::SetGravity(const MT_Vector3& gravity) { - GetPhysicsEnvironment()->setGravity(gravity[0],gravity[1],gravity[2]); + GetPhysicsEnvironment()->SetGravity(gravity[0],gravity[1],gravity[2]); } MT_Vector3 KX_Scene::GetGravity() { MT_Vector3 gravity; - GetPhysicsEnvironment()->getGravity(gravity); + GetPhysicsEnvironment()->GetGravity(gravity); return gravity; } @@ -1803,10 +1814,6 @@ short KX_Scene::GetAnimationFPS() return m_blenderScene->r.frs_sec; } -#ifdef WITH_BULLET -#include "KX_BulletPhysicsController.h" -#endif - static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to) { SCA_LogicManager *logicmgr= to->GetLogicManager(); @@ -1839,7 +1846,6 @@ static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to) #ifdef WITH_BULLET #include "CcdGraphicController.h" // XXX ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment()); #include "CcdPhysicsEnvironment.h" // XXX ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment()); -#include "KX_BulletPhysicsController.h" #endif static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene *from) @@ -1888,12 +1894,17 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene } /* graphics controller */ - PHY_IGraphicController *ctrl = gameobj->GetGraphicController(); + PHY_IController *ctrl = gameobj->GetGraphicController(); if (ctrl) { /* SHOULD update the m_cullingTree */ ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment()); } + ctrl = gameobj->GetPhysicsController(); + if (ctrl) { + ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment()); + } + /* SG_Node can hold a scene reference */ SG_Node *sg= gameobj->GetSGNode(); if (sg) { @@ -1905,16 +1916,6 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene for (int i=0; iSetSGClientInfo(to); } -#ifdef WITH_BULLET - SGControllerList::iterator contit; - SGControllerList& controllers = sg->GetSGControllerList(); - for (contit = controllers.begin();contit!=controllers.end();++contit) - { - KX_BulletPhysicsController *phys_ctrl= dynamic_cast(*contit); - if (phys_ctrl) - phys_ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment()); - } -#endif // WITH_BULLET } /* If the object is a light, update it's scene */ if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT) diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp index 1a9e1442cc8..d010d3d50a0 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp +++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp @@ -48,9 +48,9 @@ KX_TouchEventManager::KX_TouchEventManager(class SCA_LogicManager* logicmgr, //m_scene->addTouchCallback(OBJECT_RESPONSE, KX_TouchEventManager::collisionResponse, this); //m_scene->addTouchCallback(SENSOR_RESPONSE, KX_TouchEventManager::collisionResponse, this); - m_physEnv->addTouchCallback(PHY_OBJECT_RESPONSE, KX_TouchEventManager::newCollisionResponse, this); - m_physEnv->addTouchCallback(PHY_SENSOR_RESPONSE, KX_TouchEventManager::newCollisionResponse, this); - m_physEnv->addTouchCallback(PHY_BROADPH_RESPONSE, KX_TouchEventManager::newBroadphaseResponse, this); + m_physEnv->AddTouchCallback(PHY_OBJECT_RESPONSE, KX_TouchEventManager::newCollisionResponse, this); + m_physEnv->AddTouchCallback(PHY_SENSOR_RESPONSE, KX_TouchEventManager::newCollisionResponse, this); + m_physEnv->AddTouchCallback(PHY_BROADPH_RESPONSE, KX_TouchEventManager::newBroadphaseResponse, this); } @@ -84,8 +84,8 @@ bool KX_TouchEventManager::newBroadphaseResponse(void *client_data, PHY_IPhysicsController* ctrl1 = static_cast(object1); PHY_IPhysicsController* ctrl2 = static_cast(object2); - KX_ClientObjectInfo *info1 = (ctrl1) ? static_cast(ctrl1->getNewClientInfo()) : NULL; - KX_ClientObjectInfo *info2 = (ctrl1) ? static_cast(ctrl2->getNewClientInfo()) : NULL; + KX_ClientObjectInfo *info1 = (ctrl1) ? static_cast(ctrl1->GetNewClientInfo()) : NULL; + KX_ClientObjectInfo *info2 = (ctrl1) ? static_cast(ctrl2->GetNewClientInfo()) : NULL; // This call back should only be called for controllers of Near and Radar sensor if (!info1) @@ -184,7 +184,7 @@ void KX_TouchEventManager::NextFrame() list::iterator sit; // First client info - KX_ClientObjectInfo *client_info = static_cast(ctrl1->getNewClientInfo()); + KX_ClientObjectInfo *client_info = static_cast(ctrl1->GetNewClientInfo()); // First gameobject KX_GameObject *kxObj1 = KX_GameObject::GetClientObject(client_info); // Invoke sensor response for each object @@ -195,7 +195,7 @@ void KX_TouchEventManager::NextFrame() } // Second client info - client_info = static_cast(ctrl2->getNewClientInfo()); + client_info = static_cast(ctrl2->GetNewClientInfo()); // Second gameobject KX_GameObject *kxObj2 = KX_GameObject::GetClientObject(client_info); if (client_info) { diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 9d87da48fae..b231a2191ed 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -117,7 +117,7 @@ m_bTouchPulse(bTouchPulse) //client_info->m_auxilary_info = NULL; client_info->m_sensors.push_back(this); - m_physCtrl = dynamic_cast(gameobj->GetPhysicsController()); + m_physCtrl = gameobj->GetPhysicsController(); MT_assert( !gameobj->GetPhysicsController() || m_physCtrl ); Init(); } @@ -156,7 +156,7 @@ void KX_TouchSensor::ProcessReplica() void KX_TouchSensor::ReParent(SCA_IObject* parent) { KX_GameObject *gameobj = static_cast(parent); - PHY_IPhysicsController *sphy = dynamic_cast(((KX_GameObject*)parent)->GetPhysicsController()); + PHY_IPhysicsController *sphy = ((KX_GameObject*)parent)->GetPhysicsController(); if (sphy) m_physCtrl = sphy; @@ -173,11 +173,11 @@ void KX_TouchSensor::RegisterSumo(KX_TouchEventManager *touchman) { if (m_physCtrl) { - if (touchman->GetPhysicsEnvironment()->requestCollisionCallback(m_physCtrl)) + if (touchman->GetPhysicsEnvironment()->RequestCollisionCallback(m_physCtrl)) { - KX_ClientObjectInfo *client_info = static_cast(m_physCtrl->getNewClientInfo()); + KX_ClientObjectInfo *client_info = static_cast(m_physCtrl->GetNewClientInfo()); if (client_info->isSensor()) - touchman->GetPhysicsEnvironment()->addSensor(m_physCtrl); + touchman->GetPhysicsEnvironment()->AddSensor(m_physCtrl); } } } @@ -185,12 +185,12 @@ void KX_TouchSensor::UnregisterSumo(KX_TouchEventManager* touchman) { if (m_physCtrl) { - if (touchman->GetPhysicsEnvironment()->removeCollisionCallback(m_physCtrl)) + if (touchman->GetPhysicsEnvironment()->RemoveCollisionCallback(m_physCtrl)) { // no more sensor on the controller, can remove it if it is a sensor object - KX_ClientObjectInfo *client_info = static_cast(m_physCtrl->getNewClientInfo()); + KX_ClientObjectInfo *client_info = static_cast(m_physCtrl->GetNewClientInfo()); if (client_info->isSensor()) - touchman->GetPhysicsEnvironment()->removeSensor(m_physCtrl); + touchman->GetPhysicsEnvironment()->RemoveSensor(m_physCtrl); } } } @@ -203,8 +203,8 @@ bool KX_TouchSensor::BroadPhaseSensorFilterCollision(void*obj1,void*obj2) KX_GameObject* myobj = (KX_GameObject*)GetParent(); KX_GameObject* myparent = myobj->GetParent(); - KX_ClientObjectInfo *client_info = static_cast(((PHY_IPhysicsController*)obj2)->getNewClientInfo()); - KX_ClientObjectInfo *my_client_info = static_cast(m_physCtrl->getNewClientInfo()); + KX_ClientObjectInfo *client_info = static_cast(((PHY_IPhysicsController*)obj2)->GetNewClientInfo()); + KX_ClientObjectInfo *my_client_info = static_cast(m_physCtrl->GetNewClientInfo()); KX_GameObject* otherobj = ( client_info ? client_info->m_gameobject : NULL); // first, decrement refcount as GetParent() increases it @@ -244,8 +244,8 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll // need the mapping from PHY_IPhysicsController to gameobjects now KX_ClientObjectInfo *client_info = static_cast (object1 == m_physCtrl? - ((PHY_IPhysicsController*)object2)->getNewClientInfo(): - ((PHY_IPhysicsController*)object1)->getNewClientInfo()); + ((PHY_IPhysicsController*)object2)->GetNewClientInfo(): + ((PHY_IPhysicsController*)object1)->GetNewClientInfo()); KX_GameObject* gameobj = ( client_info ? client_info->m_gameobject : diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp index 3cb80e53e12..fdafc4e507d 100644 --- a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp +++ b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp @@ -35,48 +35,48 @@ CcdGraphicController::CcdGraphicController (CcdPhysicsEnvironment* phyEnv, PHY_I CcdGraphicController::~CcdGraphicController() { if (m_phyEnv) - m_phyEnv->removeCcdGraphicController(this); + m_phyEnv->RemoveCcdGraphicController(this); if (m_motionState) delete m_motionState; } -void CcdGraphicController::setLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax) +void CcdGraphicController::SetLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax) { m_localAabbMin = aabbMin; m_localAabbMax = aabbMax; SetGraphicTransform(); } -void CcdGraphicController::setLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax) +void CcdGraphicController::SetLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax) { m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]); m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]); SetGraphicTransform(); } -void CcdGraphicController::setLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax) +void CcdGraphicController::SetLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax) { m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]); m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]); SetGraphicTransform(); } -void CcdGraphicController::setLocalAabb(const float* aabbMin,const float* aabbMax) +void CcdGraphicController::SetLocalAabb(const float* aabbMin,const float* aabbMax) { m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]); m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]); SetGraphicTransform(); } -void CcdGraphicController::getAabb(btVector3& aabbMin, btVector3& aabbMax) +void CcdGraphicController::GetAabb(btVector3& aabbMin, btVector3& aabbMax) { btVector3 pos; btVector3 scale; float ori[12]; - m_motionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]); - m_motionState->getWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]); - m_motionState->getWorldOrientation(ori); + m_motionState->GetWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]); + m_motionState->GetWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]); + m_motionState->GetWorldOrientation(ori); btMatrix3x3 rot(ori[0], ori[4], ori[8], ori[1], ori[5], ori[9], ori[2], ori[6], ori[10]); @@ -109,9 +109,9 @@ bool CcdGraphicController::SetGraphicTransform() return false; btVector3 aabbMin; btVector3 aabbMax; - getAabb(aabbMin, aabbMax); + GetAabb(aabbMin, aabbMax); // update Aabb in broadphase - m_phyEnv->getCullingTree()->setAabb(m_handle,aabbMin,aabbMax,NULL); + m_phyEnv->GetCullingTree()->setAabb(m_handle,aabbMin,aabbMax,NULL); return true; } @@ -131,7 +131,7 @@ void CcdGraphicController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* { CcdPhysicsEnvironment* phyEnv = static_cast(env); /* Updates the m_phyEnv's m_cullingTree & m_cullingCache */ - if (getBroadphaseHandle()) { + if (GetBroadphaseHandle()) { /* insert into the new physics scene */ Activate(false); m_phyEnv= phyEnv; @@ -145,8 +145,8 @@ void CcdGraphicController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* void CcdGraphicController::Activate(bool active) { if (active) - m_phyEnv->addCcdGraphicController(this); + m_phyEnv->AddCcdGraphicController(this); else - m_phyEnv->removeCcdGraphicController(this); + m_phyEnv->RemoveCcdGraphicController(this); } diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h index 064f86040f6..e76ad86301e 100644 --- a/source/gameengine/Physics/Bullet/CcdGraphicController.h +++ b/source/gameengine/Physics/Bullet/CcdGraphicController.h @@ -40,16 +40,16 @@ public: virtual ~CcdGraphicController(); - void setLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax); - void setLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax); - virtual void setLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax); - virtual void setLocalAabb(const float aabbMin[3],const float aabbMax[3]); + void SetLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax); + void SetLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax); + virtual void SetLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax); + virtual void SetLocalAabb(const float aabbMin[3],const float aabbMax[3]); PHY_IMotionState* GetMotionState() { return m_motionState; } - void getAabb(btVector3& aabbMin, btVector3& aabbMax); + void GetAabb(btVector3& aabbMin, btVector3& aabbMax); - virtual void setBroadphaseHandle(btBroadphaseProxy* handle) { m_handle = handle; } - virtual btBroadphaseProxy* getBroadphaseHandle() { return m_handle; } + virtual void SetBroadphaseHandle(btBroadphaseProxy* handle) { m_handle = handle; } + virtual btBroadphaseProxy* GetBroadphaseHandle() { return m_handle; } virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* env); @@ -67,8 +67,8 @@ public: virtual void Activate(bool active); // client info for culling - virtual void* getNewClientInfo() { return m_newClientInfo; } - virtual void setNewClientInfo(void* clientinfo) { m_newClientInfo = clientinfo; } + virtual void* GetNewClientInfo() { return m_newClientInfo; } + virtual void SetNewClientInfo(void* clientinfo) { m_newClientInfo = clientinfo; } virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate); private: diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 8a3ad82d179..a3838a148e1 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -139,9 +139,14 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) m_shapeInfo = ci.m_shapeInfo; if (m_shapeInfo) m_shapeInfo->AddRef(); + + m_bulletChildShape = NULL; m_bulletMotionState = 0; m_characterController = 0; + m_savedCollisionFlags = 0; + m_savedMass = 0.0; + m_suspended = false; CreateRigidbody(); } @@ -150,11 +155,11 @@ btTransform& CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState* { static btTransform trans; btVector3 tmp; - motionState->getWorldPosition(tmp.m_floats[0], tmp.m_floats[1], tmp.m_floats[2]); + motionState->GetWorldPosition(tmp.m_floats[0], tmp.m_floats[1], tmp.m_floats[2]); trans.setOrigin(tmp); float ori[12]; - motionState->getWorldOrientation(ori); + motionState->GetWorldOrientation(ori); trans.getBasis().setFromOpenGLSubMatrix(ori); //btQuaternion orn; //motionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]); @@ -180,18 +185,18 @@ public: btVector3 pos; float ori[12]; - m_blenderMotionState->getWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]); - m_blenderMotionState->getWorldOrientation(ori); + m_blenderMotionState->GetWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]); + m_blenderMotionState->GetWorldOrientation(ori); worldTrans.setOrigin(pos); worldTrans.getBasis().setFromOpenGLSubMatrix(ori); } void setWorldTransform(const btTransform& worldTrans) { - m_blenderMotionState->setWorldPosition(worldTrans.getOrigin().getX(),worldTrans.getOrigin().getY(),worldTrans.getOrigin().getZ()); + m_blenderMotionState->SetWorldPosition(worldTrans.getOrigin().getX(),worldTrans.getOrigin().getY(),worldTrans.getOrigin().getZ()); btQuaternion rotQuat = worldTrans.getRotation(); - m_blenderMotionState->setWorldOrientation(rotQuat[0],rotQuat[1],rotQuat[2],rotQuat[3]); - m_blenderMotionState->calculateWorldTransformations(); + m_blenderMotionState->SetWorldOrientation(rotQuat[0],rotQuat[1],rotQuat[2],rotQuat[3]); + m_blenderMotionState->CalculateWorldTransformations(); } }; @@ -238,7 +243,7 @@ bool CcdPhysicsController::CreateSoftbody() btVector3 p(0,0,0);// = getOrigin(); //btSoftBody* psb=btSoftBodyHelpers::CreateRope(worldInfo, btVector3(-10,0,i*0.25),btVector3(10,0,i*0.25), 16,1+2); btSoftBody* psb = 0; - btSoftBodyWorldInfo& worldInfo = m_cci.m_physicsEnv->getDynamicsWorld()->getWorldInfo(); + btSoftBodyWorldInfo& worldInfo = m_cci.m_physicsEnv->GetDynamicsWorld()->getWorldInfo(); if (m_cci.m_collisionShape->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE) { btConvexHullShape* convexHull = (btConvexHullShape* )m_cci.m_collisionShape; @@ -456,8 +461,8 @@ bool CcdPhysicsController::CreateSoftbody() btTransform startTrans; rbci.m_motionState->getWorldTransform(startTrans); - m_MotionState->setWorldPosition(startTrans.getOrigin().getX(),startTrans.getOrigin().getY(),startTrans.getOrigin().getZ()); - m_MotionState->setWorldOrientation(0,0,0,1); + m_MotionState->SetWorldPosition(startTrans.getOrigin().getX(),startTrans.getOrigin().getY(),startTrans.getOrigin().getZ()); + m_MotionState->SetWorldOrientation(0,0,0,1); if (!m_prototypeTransformInitialized) { @@ -609,7 +614,7 @@ bool CcdPhysicsController::ReplaceControllerShape(btCollisionShape *newShape) if (GetSoftBody()) { // soft body must be recreated - m_cci.m_physicsEnv->removeCcdPhysicsController(this); + m_cci.m_physicsEnv->RemoveCcdPhysicsController(this); delete m_object; m_object = NULL; // force complete reinitialization @@ -619,14 +624,14 @@ bool CcdPhysicsController::ReplaceControllerShape(btCollisionShape *newShape) CreateSoftbody(); assert(m_object); // reinsert the new body - m_cci.m_physicsEnv->addCcdPhysicsController(this); + m_cci.m_physicsEnv->AddCcdPhysicsController(this); } /* Copied from CcdPhysicsEnvironment::addCcdPhysicsController() */ /* without this, an object can rest on the old physics mesh * and not move to account for the physics mesh, even with 'nosleep' */ - btSoftRigidDynamicsWorld* dw= GetPhysicsEnvironment()->getDynamicsWorld(); + btSoftRigidDynamicsWorld* dw= GetPhysicsEnvironment()->GetDynamicsWorld(); btCollisionObjectArray &obarr= dw->getCollisionObjectArray(); btCollisionObject *ob; btBroadphaseProxy* proxy; @@ -648,7 +653,7 @@ CcdPhysicsController::~CcdPhysicsController() { //will be reference counted, due to sharing if (m_cci.m_physicsEnv) - m_cci.m_physicsEnv->removeCcdPhysicsController(this); + m_cci.m_physicsEnv->RemoveCcdPhysicsController(this); if (m_MotionState) delete m_MotionState; @@ -683,17 +688,17 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) btQuaternion worldquat; btMatrix3x3 trs = sb->m_pose.m_rot*sb->m_pose.m_scl; trs.getRotation(worldquat); - m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]); - m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]); + m_MotionState->SetWorldPosition(worldPos[0],worldPos[1],worldPos[2]); + m_MotionState->SetWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]); } else { btVector3 aabbMin,aabbMax; sb->getAabb(aabbMin,aabbMax); btVector3 worldPos = (aabbMax+aabbMin)*0.5f; - m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]); + m_MotionState->SetWorldPosition(worldPos[0],worldPos[1],worldPos[2]); } - m_MotionState->calculateWorldTransformations(); + m_MotionState->CalculateWorldTransformations(); return true; } @@ -719,12 +724,12 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) const btVector3& worldPos = xform.getOrigin(); float ori[12]; worldOri.getOpenGLSubMatrix(ori); - m_MotionState->setWorldOrientation(ori); - m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]); - m_MotionState->calculateWorldTransformations(); + m_MotionState->SetWorldOrientation(ori); + m_MotionState->SetWorldPosition(worldPos[0],worldPos[1],worldPos[2]); + m_MotionState->CalculateWorldTransformations(); float scale[3]; - m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]); + m_MotionState->GetWorldScaling(scale[0],scale[1],scale[2]); btVector3 scaling(scale[0],scale[1],scale[2]); GetCollisionShape()->setLocalScaling(scaling); } else @@ -743,7 +748,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) m_MotionState->calculateWorldTransformations(); */ float scale[3]; - m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]); + m_MotionState->GetWorldScaling(scale[0],scale[1],scale[2]); btVector3 scaling(scale[0],scale[1],scale[2]); GetCollisionShape()->setLocalScaling(scaling); } @@ -767,7 +772,7 @@ void CcdPhysicsController::WriteDynamicsToMotionState() // controller replication void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl) { - + SetParentCtrl((CcdPhysicsController*)parentctrl); m_softBodyTransformInitialized=false; m_MotionState = motionstate; m_registerCount = 0; @@ -812,7 +817,7 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta } // sensor object are added when needed if (!m_cci.m_bSensor) - m_cci.m_physicsEnv->addCcdPhysicsController(this); + m_cci.m_physicsEnv->AddCcdPhysicsController(this); /* SM_Object* dynaparent=0; @@ -857,9 +862,9 @@ void CcdPhysicsController::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment * // since the environment is changing, we must also move the controler to the // new environment. Note that we don't handle sensor explicitly: this // function can be called on sensor but only when they are not registered - if (m_cci.m_physicsEnv->removeCcdPhysicsController(this)) + if (m_cci.m_physicsEnv->RemoveCcdPhysicsController(this)) { - physicsEnv->addCcdPhysicsController(this); + physicsEnv->AddCcdPhysicsController(this); // Set the object to be active so it can at least by evaluated once. // This fixes issues with static objects not having their physics meshes @@ -904,7 +909,7 @@ void CcdPhysicsController::SetCenterOfMassTransform(btTransform& xform) } // kinematic methods -void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local) +void CcdPhysicsController::RelativeTranslate(const MT_Vector3& dlocin,bool local) { if (m_object) { @@ -917,7 +922,7 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc return; } - btVector3 dloc(dlocX,dlocY,dlocZ); + btVector3 dloc(dlocin.x(), dlocin.y(), dlocin.z()); btTransform xform = m_object->getWorldTransform(); if (local) @@ -929,22 +934,7 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc } -void CcdPhysicsController::SetWalkDirection(float dirX,float dirY,float dirZ,bool local) -{ - - if (m_object && m_characterController) - { - btVector3 dir(dirX,dirY,dirZ); - btTransform xform = m_object->getWorldTransform(); - - if (local) - dir = xform.getBasis()*dir; - - m_characterController->setWalkDirection(dir/GetPhysicsEnvironment()->getNumTimeSubSteps()); - } -} - -void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local) +void CcdPhysicsController::RelativeRotate(const MT_Matrix3x3& rotval,bool local) { if (m_object) { @@ -957,9 +947,9 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local) return; } - btMatrix3x3 drotmat(rotval[0], rotval[3], rotval[6], - rotval[1], rotval[4], rotval[7], - rotval[2], rotval[5], rotval[8]); + btMatrix3x3 drotmat(rotval[0].x(), rotval[1].x(), rotval[2].x(), + rotval[0].y(), rotval[1].y(), rotval[2].y(), + rotval[0].z(), rotval[1].z(), rotval[2].z()); btMatrix3x3 currentOrn; @@ -978,45 +968,23 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local) void CcdPhysicsController::GetWorldOrientation(btMatrix3x3& mat) { float ori[12]; - m_MotionState->getWorldOrientation(ori); + m_MotionState->GetWorldOrientation(ori); mat.setFromOpenGLSubMatrix(ori); } -void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal) +MT_Matrix3x3 CcdPhysicsController::GetOrientation() { - btQuaternion q = m_object->getWorldTransform().getRotation(); - quatImag0 = q[0]; - quatImag1 = q[1]; - quatImag2 = q[2]; - quatReal = q[3]; + btMatrix3x3 orn = m_object->getWorldTransform().getBasis(); + return MT_Matrix3x3(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]); } -void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal) -{ - if (m_object) - { - m_object->activate(true); - if (m_object->isStaticObject()) - { - if (!m_cci.m_bSensor) - m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); - // kinematic object should not set the transform, it disturbs the velocity interpolation - return; - } - // not required - //m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal); - btTransform xform = m_object->getWorldTransform(); - xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal)); - SetCenterOfMassTransform(xform); - // not required - //m_bulletMotionState->setWorldTransform(xform); - - - - } +void CcdPhysicsController::SetOrientation(const MT_Matrix3x3& orn) +{ + btMatrix3x3 btmat(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]); + SetWorldOrientation(btmat); } -void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn) +void CcdPhysicsController::SetWorldOrientation(const btMatrix3x3& orn) { if (m_object) { @@ -1045,7 +1013,7 @@ void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn) } -void CcdPhysicsController::setPosition(float posX,float posY,float posZ) +void CcdPhysicsController::SetPosition(const MT_Vector3& pos) { if (m_object) { @@ -1060,7 +1028,7 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ) // not required, this function is only used to update the physic controller //m_MotionState->setWorldPosition(posX,posY,posZ); btTransform xform = m_object->getWorldTransform(); - xform.setOrigin(btVector3(posX,posY,posZ)); + xform.setOrigin(btVector3(pos.x(), pos.y(), pos.z())); SetCenterOfMassTransform(xform); if (!m_softBodyTransformInitialized) m_softbodyStartTrans.setOrigin(xform.getOrigin()); @@ -1069,7 +1037,7 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ) } } -void CcdPhysicsController::forceWorldTransform(const btMatrix3x3& mat, const btVector3& pos) +void CcdPhysicsController::ForceWorldTransform(const btMatrix3x3& mat, const btVector3& pos) { if (m_object) { @@ -1080,11 +1048,44 @@ void CcdPhysicsController::forceWorldTransform(const btMatrix3x3& mat, const btV } -void CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) +void CcdPhysicsController::ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) { } -void CcdPhysicsController::getPosition(MT_Vector3& pos) const +void CcdPhysicsController::SuspendDynamics(bool ghost) +{ + btRigidBody *body = GetRigidBody(); + if (body && !m_suspended && !GetConstructionInfo().m_bSensor) + { + m_savedCollisionFlags = body->getCollisionFlags(); + m_savedMass = GetMass(); + m_suspended = true; + GetPhysicsEnvironment()->UpdateCcdPhysicsController(this, + 0.0, + btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)), + btBroadphaseProxy::StaticFilter, + btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter); + } +} + +void CcdPhysicsController::RestoreDynamics() +{ + btRigidBody *body = GetRigidBody(); + if (body && m_suspended) + { + // before make sure any position change that was done in this logic frame are accounted for + SetTransform(); + GetPhysicsEnvironment()->UpdateCcdPhysicsController(this, + m_savedMass, + m_savedCollisionFlags, + GetConstructionInfo().m_collisionFilterGroup, + GetConstructionInfo().m_collisionFilterMask); + body->activate(); + m_suspended = false; + } +} + +void CcdPhysicsController::GetPosition(MT_Vector3& pos) const { const btTransform& xform = m_object->getWorldTransform(); pos[0] = xform.getOrigin().x(); @@ -1092,13 +1093,13 @@ void CcdPhysicsController::getPosition(MT_Vector3& pos) const pos[2] = xform.getOrigin().z(); } -void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ) +void CcdPhysicsController::SetScaling(const MT_Vector3& scale) { - if (!btFuzzyZero(m_cci.m_scaling.x()-scaleX) || - !btFuzzyZero(m_cci.m_scaling.y()-scaleY) || - !btFuzzyZero(m_cci.m_scaling.z()-scaleZ)) + if (!btFuzzyZero(m_cci.m_scaling.x()-scale.x()) || + !btFuzzyZero(m_cci.m_scaling.y()-scale.y()) || + !btFuzzyZero(m_cci.m_scaling.z()-scale.z())) { - m_cci.m_scaling = btVector3(scaleX,scaleY,scaleZ); + m_cci.m_scaling = btVector3(scale.x(),scale.y(),scale.z()); if (m_object && m_object->getCollisionShape()) { @@ -1116,11 +1117,64 @@ void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ) } } } + +void CcdPhysicsController::SetTransform() +{ + btVector3 pos; + btVector3 scale; + float ori[12]; + m_MotionState->GetWorldPosition(pos.m_floats[0],pos.m_floats[1],pos.m_floats[2]); + m_MotionState->GetWorldScaling(scale.m_floats[0],scale.m_floats[1],scale.m_floats[2]); + m_MotionState->GetWorldOrientation(ori); + btMatrix3x3 rot(ori[0], ori[4], ori[8], + ori[1], ori[5], ori[9], + ori[2], ori[6], ori[10]); + ForceWorldTransform(rot, pos); + + if (!IsDynamic() && !GetConstructionInfo().m_bSensor && !GetCharacterController()) + { + btCollisionObject* object = GetRigidBody(); + object->setActivationState(ACTIVE_TAG); + object->setCollisionFlags(object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } +} + +MT_Scalar CcdPhysicsController::GetMass() +{ + if (GetSoftBody()) + return GetSoftBody()->getTotalMass(); + + MT_Scalar invmass = 0.f; + if (GetRigidBody()) + invmass = GetRigidBody()->getInvMass(); + if (invmass) + return 1.f/invmass; + return 0.f; + +} + +void CcdPhysicsController::SetMass(MT_Scalar newmass) +{ + btRigidBody *body = GetRigidBody(); + if (body && !m_suspended && newmass>MT_EPSILON && GetMass()>MT_EPSILON) + { + btVector3 grav = body->getGravity(); + btVector3 accel = grav / GetMass(); + + btBroadphaseProxy* handle = body->getBroadphaseHandle(); + GetPhysicsEnvironment()->UpdateCcdPhysicsController(this, + newmass, + body->getCollisionFlags(), + handle->m_collisionFilterGroup, + handle->m_collisionFilterMask); + body->setGravity(accel); + } +} // physics methods -void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local) +void CcdPhysicsController::ApplyTorque(const MT_Vector3& torquein,bool local) { - btVector3 torque(torqueX,torqueY,torqueZ); + btVector3 torque(torquein.x(),torquein.y(),torquein.z()); btTransform xform = m_object->getWorldTransform(); @@ -1158,9 +1212,9 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque } } -void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local) +void CcdPhysicsController::ApplyForce(const MT_Vector3& forcein,bool local) { - btVector3 force(forceX,forceY,forceZ); + btVector3 force(forcein.x(),forcein.y(),forcein.z()); if (m_object && force.length2() > (SIMD_EPSILON*SIMD_EPSILON)) @@ -1191,9 +1245,9 @@ void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bo } } } -void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local) +void CcdPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local) { - btVector3 angvel(ang_velX,ang_velY,ang_velZ); + btVector3 angvel(ang_vel.x(),ang_vel.y(),ang_vel.z()); if (m_object && angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { m_object->activate(true); @@ -1214,10 +1268,10 @@ void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,flo } } -void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local) +void CcdPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local) { - btVector3 linVel(lin_velX,lin_velY,lin_velZ); + btVector3 linVel(lin_vel.x(),lin_vel.y(),lin_vel.z()); if (m_object/* && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)*/) { m_object->activate(true); @@ -1249,9 +1303,9 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa } } } -void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ) +void CcdPhysicsController::ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein) { - btVector3 impulse(impulseX,impulseY,impulseZ); + btVector3 impulse(impulsein.x(), impulsein.y(), impulsein.z()); if (m_object && impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { @@ -1263,7 +1317,7 @@ void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attac return; } - btVector3 pos(attachX,attachY,attachZ); + btVector3 pos(attach.x(), attach.y(), attach.z()); btRigidBody* body = GetRigidBody(); if (body) body->applyImpulse(impulse,pos); @@ -1282,82 +1336,59 @@ void CcdPhysicsController::SetActive(bool active) { } // reading out information from physics -void CcdPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ) +MT_Vector3 CcdPhysicsController::GetLinearVelocity() { btRigidBody* body = GetRigidBody(); if (body) { const btVector3& linvel = body->getLinearVelocity(); - linvX = linvel.x(); - linvY = linvel.y(); - linvZ = linvel.z(); - } else - { - linvX = 0.f; - linvY = 0.f; - linvZ = 0.f; + return MT_Vector3(linvel.x(), linvel.y(), linvel.z()); } + return MT_Vector3(0.f, 0.f, 0.f); } -void CcdPhysicsController::GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ) +MT_Vector3 CcdPhysicsController::GetAngularVelocity() { btRigidBody* body = GetRigidBody(); if (body) { const btVector3& angvel= body->getAngularVelocity(); - angVelX = angvel.x(); - angVelY = angvel.y(); - angVelZ = angvel.z(); - } else - { - angVelX = 0.f; - angVelY = 0.f; - angVelZ = 0.f; + return MT_Vector3(angvel.x(), angvel.y(), angvel.z()); } + + return MT_Vector3(0.f, 0.f, 0.f); } -void CcdPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ) +MT_Vector3 CcdPhysicsController::GetVelocity(const MT_Point3 &posin) { - btVector3 pos(posX,posY,posZ); + btVector3 pos(pos.x(), pos.y(), pos.z()); btRigidBody* body = GetRigidBody(); if (body) { btVector3 linvel = body->getVelocityInLocalPoint(pos); - linvX = linvel.x(); - linvY = linvel.y(); - linvZ = linvel.z(); - } else - { - linvX = 0.f; - linvY = 0.f; - linvZ = 0.f; + return MT_Vector3(linvel.x(), linvel.y(), linvel.z()); } -} -void CcdPhysicsController::GetWalkDirection(float& dirX,float& dirY,float& dirZ) -{ - if (m_object && m_characterController) - { - const btVector3 dir = m_characterController->getWalkDirection(); - dirX = dir.x(); - dirY = dir.y(); - dirZ = dir.z(); - } - else - { - dirX = 0.f; - dirY = 0.f; - dirZ = 0.f; - } + return MT_Vector3(0.f, 0.f, 0.f); } -void CcdPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ) +MT_Vector3 CcdPhysicsController::GetLocalInertia() { + MT_Vector3 inertia(0.f, 0.f, 0.f); + btVector3 inv_inertia; + if (GetRigidBody()) { + inv_inertia = GetRigidBody()->getInvInertiaDiagLocal(); + if (!btFuzzyZero(inv_inertia.getX()) && + !btFuzzyZero(inv_inertia.getY()) && + !btFuzzyZero(inv_inertia.getZ())) + inertia = MT_Vector3(1.f/inv_inertia.getX(), 1.f/inv_inertia.getY(), 1.f/inv_inertia.getZ()); + } + return inertia; } // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted -void CcdPhysicsController::setRigidBody(bool rigid) +void CcdPhysicsController::SetRigidBody(bool rigid) { btRigidBody* body = GetRigidBody(); if (body) @@ -1373,13 +1404,21 @@ void CcdPhysicsController::setRigidBody(bool rigid) } // clientinfo for raycasts for example -void* CcdPhysicsController::getNewClientInfo() +void* CcdPhysicsController::GetNewClientInfo() { return m_newClientInfo; } -void CcdPhysicsController::setNewClientInfo(void* clientinfo) +void CcdPhysicsController::SetNewClientInfo(void* clientinfo) { m_newClientInfo = clientinfo; + + if (m_cci.m_bSensor) + { + // use a different callback function for sensor object, + // bullet will not synchronize, we must do it explicitly + SG_Callbacks& callbacks = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)clientinfo)->GetSGNode()->GetCallBackFunctions(); + callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc; + } } @@ -1392,7 +1431,7 @@ void CcdPhysicsController::UpdateDeactivation(float timeStep) } } -bool CcdPhysicsController::wantsSleeping() +bool CcdPhysicsController::WantsSleeping() { btRigidBody* body = GetRigidBody(); if (body) @@ -1402,8 +1441,143 @@ bool CcdPhysicsController::wantsSleeping() //check it out return true; } +/* This function dynamically adds the collision shape of another controller to + * the current controller shape provided it is a compound shape. + * The idea is that dynamic parenting on a compound object will dynamically extend the shape + */ +void CcdPhysicsController::AddCompoundChild(PHY_IPhysicsController* child) +{ + if (child == NULL || !IsCompound()) + return; + // other controller must be a bullet controller too + // verify that body and shape exist and match + CcdPhysicsController* childCtrl = dynamic_cast(child); + btRigidBody* rootBody = GetRigidBody(); + btRigidBody* childBody = childCtrl->GetRigidBody(); + if (!rootBody || !childBody) + return; + const btCollisionShape* rootShape = rootBody->getCollisionShape(); + const btCollisionShape* childShape = childBody->getCollisionShape(); + if (!rootShape || + !childShape || + rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE || + childShape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) + return; + btCompoundShape* compoundShape = (btCompoundShape*)rootShape; + // compute relative transformation between parent and child + btTransform rootTrans; + btTransform childTrans; + rootBody->getMotionState()->getWorldTransform(rootTrans); + childBody->getMotionState()->getWorldTransform(childTrans); + btVector3 rootScale = rootShape->getLocalScaling(); + rootScale[0] = 1.0/rootScale[0]; + rootScale[1] = 1.0/rootScale[1]; + rootScale[2] = 1.0/rootScale[2]; + // relative scale = child_scale/parent_scale + btVector3 relativeScale = childShape->getLocalScaling()*rootScale; + btMatrix3x3 rootRotInverse = rootTrans.getBasis().transpose(); + // relative pos = parent_rot^-1 * ((parent_pos-child_pos)/parent_scale) + btVector3 relativePos = rootRotInverse*((childTrans.getOrigin()-rootTrans.getOrigin())*rootScale); + // relative rot = parent_rot^-1 * child_rot + btMatrix3x3 relativeRot = rootRotInverse*childTrans.getBasis(); + // create a proxy shape info to store the transformation + CcdShapeConstructionInfo* proxyShapeInfo = new CcdShapeConstructionInfo(); + // store the transformation to this object shapeinfo + proxyShapeInfo->m_childTrans.setOrigin(relativePos); + proxyShapeInfo->m_childTrans.setBasis(relativeRot); + proxyShapeInfo->m_childScale.setValue(relativeScale[0], relativeScale[1], relativeScale[2]); + // we will need this to make sure that we remove the right proxy later when unparenting + proxyShapeInfo->m_userData = childCtrl; + proxyShapeInfo->SetProxy(childCtrl->GetShapeInfo()->AddRef()); + // add to parent compound shapeinfo (increments ref count) + GetShapeInfo()->AddShape(proxyShapeInfo); + // create new bullet collision shape from the object shapeinfo and set scaling + btCollisionShape* newChildShape = proxyShapeInfo->CreateBulletShape(childCtrl->GetMargin(), childCtrl->GetConstructionInfo().m_bGimpact, true); + newChildShape->setLocalScaling(relativeScale); + // add bullet collision shape to parent compound collision shape + compoundShape->addChildShape(proxyShapeInfo->m_childTrans,newChildShape); + // proxyShapeInfo is not needed anymore, release it + proxyShapeInfo->Release(); + // remember we created this shape + childCtrl->m_bulletChildShape = newChildShape; + // recompute inertia of parent + if (!rootBody->isStaticOrKinematicObject()) + { + btVector3 localInertia; + float mass = 1.f/rootBody->getInvMass(); + compoundShape->calculateLocalInertia(mass,localInertia); + rootBody->setMassProps(mass,localInertia); + } + // must update the broadphase cache, + GetPhysicsEnvironment()->RefreshCcdPhysicsController(this); + // remove the children + GetPhysicsEnvironment()->DisableCcdPhysicsController(childCtrl); +} + +/* Reverse function of the above, it will remove a shape from a compound shape + * provided that the former was added to the later using AddCompoundChild() + */ +void CcdPhysicsController::RemoveCompoundChild(PHY_IPhysicsController* child) +{ + if (child == NULL || !IsCompound()) + return; + // other controller must be a bullet controller too + // verify that body and shape exist and match + CcdPhysicsController* childCtrl = dynamic_cast(child); + btRigidBody* rootBody = GetRigidBody(); + btRigidBody* childBody = childCtrl->GetRigidBody(); + if (!rootBody || !childBody) + return; + const btCollisionShape* rootShape = rootBody->getCollisionShape(); + if (!rootShape || + rootShape->getShapeType() != COMPOUND_SHAPE_PROXYTYPE) + return; + btCompoundShape* compoundShape = (btCompoundShape*)rootShape; + // retrieve the shapeInfo + CcdShapeConstructionInfo* childShapeInfo = childCtrl->GetShapeInfo(); + CcdShapeConstructionInfo* rootShapeInfo = GetShapeInfo(); + // and verify that the child is part of the parent + int i = rootShapeInfo->FindChildShape(childShapeInfo, childCtrl); + if (i < 0) + return; + rootShapeInfo->RemoveChildShape(i); + if (childCtrl->m_bulletChildShape) + { + int numChildren = compoundShape->getNumChildShapes(); + for (i=0; igetChildShape(i) == childCtrl->m_bulletChildShape) + { + compoundShape->removeChildShapeByIndex(i); + compoundShape->recalculateLocalAabb(); + break; + } + } + delete childCtrl->m_bulletChildShape; + childCtrl->m_bulletChildShape = NULL; + } + // recompute inertia of parent + if (!rootBody->isStaticOrKinematicObject()) + { + btVector3 localInertia; + float mass = 1.f/rootBody->getInvMass(); + compoundShape->calculateLocalInertia(mass,localInertia); + rootBody->setMassProps(mass,localInertia); + } + // must update the broadphase cache, + GetPhysicsEnvironment()->RefreshCcdPhysicsController(this); + // reactivate the children + GetPhysicsEnvironment()->EnableCcdPhysicsController(childCtrl); +} + +PHY_IPhysicsController* CcdPhysicsController::GetReplica() +{ + CcdPhysicsController* replica = new CcdPhysicsController(*this); + return replica; +} -PHY_IPhysicsController* CcdPhysicsController::GetReplica() +// Keeping this separate for now, maybe we can combine it with GetReplica()... +PHY_IPhysicsController* CcdPhysicsController::GetReplicaForSensors() { // This is used only to replicate Near and Radar sensor controllers // The replication of object physics controller is done in KX_BulletPhysicsController::GetReplica() @@ -1462,21 +1636,21 @@ DefaultMotionState::~DefaultMotionState() } -void DefaultMotionState::getWorldPosition(float& posX,float& posY,float& posZ) +void DefaultMotionState::GetWorldPosition(float& posX,float& posY,float& posZ) { posX = m_worldTransform.getOrigin().x(); posY = m_worldTransform.getOrigin().y(); posZ = m_worldTransform.getOrigin().z(); } -void DefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ) +void DefaultMotionState::GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ) { scaleX = m_localScaling.getX(); scaleY = m_localScaling.getY(); scaleZ = m_localScaling.getZ(); } -void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal) +void DefaultMotionState::GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal) { btQuaternion quat = m_worldTransform.getRotation(); quatIma0 = quat.x(); @@ -1485,28 +1659,28 @@ void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,flo quatReal = quat[3]; } -void DefaultMotionState::getWorldOrientation(float* ori) +void DefaultMotionState::GetWorldOrientation(float* ori) { m_worldTransform.getBasis().getOpenGLSubMatrix(ori); } -void DefaultMotionState::setWorldOrientation(const float* ori) +void DefaultMotionState::SetWorldOrientation(const float* ori) { m_worldTransform.getBasis().setFromOpenGLSubMatrix(ori); } -void DefaultMotionState::setWorldPosition(float posX,float posY,float posZ) +void DefaultMotionState::SetWorldPosition(float posX,float posY,float posZ) { btVector3 pos(posX,posY,posZ); m_worldTransform.setOrigin( pos ); } -void DefaultMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal) +void DefaultMotionState::SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal) { btQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); m_worldTransform.setRotation( orn ); } -void DefaultMotionState::calculateWorldTransformations() +void DefaultMotionState::CalculateWorldTransformations() { } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index f1f0ca31419..ecb894c1e8d 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -33,6 +33,7 @@ subject to the following restrictions: #include "LinearMath/btTransform.h" #include "PHY_IMotionState.h" +#include "PHY_ICharacter.h" extern float gDeactivationTime; extern float gLinearSleepingTreshold; @@ -266,6 +267,7 @@ struct CcdConstructionInfo m_soft_kSHR(1.0f), m_soft_kAHR(0.7f), m_collisionFlags(0), + m_bDyna(false), m_bRigid(false), m_bSoft(false), m_bSensor(false), @@ -349,6 +351,7 @@ struct CcdConstructionInfo int m_collisionFlags; + bool m_bDyna; bool m_bRigid; bool m_bSoft; bool m_bSensor; @@ -396,7 +399,7 @@ class btCollisionObject; class btSoftBody; class btPairCachingGhostObject; -class BlenderBulletCharacterController : public btKinematicCharacterController +class BlenderBulletCharacterController : public btKinematicCharacterController, public PHY_ICharacter { private: btMotionState* m_motionState; @@ -419,6 +422,25 @@ public: virtual void jump(); const btVector3& getWalkDirection(); + + // PHY_ICharacter interface + virtual void Jump() { jump(); } + virtual bool OnGround(){ return onGround(); } + virtual float GetGravity() { return getGravity(); } + virtual void SetGravity(float gravity) { setGravity(gravity); } + virtual int GetMaxJumps() { return getMaxJumps(); } + virtual void SetMaxJumps(int maxJumps) { setMaxJumps(maxJumps); } + virtual int GetJumpCount() { return getJumpCount(); } + virtual void SetWalkDirection(const MT_Vector3& dir) + { + btVector3 vec = btVector3(dir[0], dir[1], dir[2]); + setWalkDirection(vec); + } + virtual MT_Vector3 GetWalkDirection() + { + btVector3 vec = getWalkDirection(); + return MT_Vector3(vec[0], vec[1], vec[2]); + } }; ///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution. @@ -433,6 +455,7 @@ protected: btMotionState* m_bulletMotionState; class btCollisionShape* m_collisionShape; class CcdShapeConstructionInfo* m_shapeInfo; + btCollisionShape* m_bulletChildShape; friend class CcdPhysicsEnvironment; // needed when updating the controller @@ -449,6 +472,10 @@ protected: CcdPhysicsController* m_parentCtrl; + int m_savedCollisionFlags; + MT_Scalar m_savedMass; + bool m_suspended; + void GetWorldOrientation(btMatrix3x3& mat); void CreateRigidbody(); @@ -462,8 +489,8 @@ protected: return (--m_registerCount == 0) ? true : false; } - void setWorldOrientation(const btMatrix3x3& mat); - void forceWorldTransform(const btMatrix3x3& mat, const btVector3& pos); + void SetWorldOrientation(const btMatrix3x3& mat); + void ForceWorldTransform(const btMatrix3x3& mat, const btVector3& pos); public: @@ -477,11 +504,11 @@ protected: virtual ~CcdPhysicsController(); - CcdConstructionInfo& getConstructionInfo() + CcdConstructionInfo& GetConstructionInfo() { return m_cci; } - const CcdConstructionInfo& getConstructionInfo() const + const CcdConstructionInfo& GetConstructionInfo() const { return m_cci; } @@ -518,42 +545,51 @@ protected: virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env); // kinematic methods - virtual void RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local); - virtual void SetWalkDirection(float dirX,float dirY,float dirZ,bool local); - virtual void RelativeRotate(const float drot[9],bool local); - virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal); - virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal); - virtual void setPosition(float posX,float posY,float posZ); - virtual void getPosition(MT_Vector3& pos) const; - - virtual void setScaling(float scaleX,float scaleY,float scaleZ); + virtual void RelativeTranslate(const MT_Vector3& dloc,bool local); + virtual void RelativeRotate(const MT_Matrix3x3&rotval, bool local); + virtual MT_Matrix3x3 GetOrientation(); + virtual void SetOrientation(const MT_Matrix3x3& orn); + virtual void SetPosition(const MT_Vector3& pos); + virtual void GetPosition(MT_Vector3& pos) const; + virtual void SetScaling(const MT_Vector3& scale); + virtual void SetTransform(); + + virtual MT_Scalar GetMass(); + virtual void SetMass(MT_Scalar newmass); // physics methods - virtual void ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local); - virtual void ApplyForce(float forceX,float forceY,float forceZ,bool local); - virtual void SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local); - virtual void SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local); - virtual void applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ); + virtual void ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulsein); + virtual void ApplyTorque(const MT_Vector3& torque,bool local); + virtual void ApplyForce(const MT_Vector3& force,bool local); + virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local); + virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local); virtual void Jump(); virtual void SetActive(bool active); // reading out information from physics - virtual void GetLinearVelocity(float& linvX,float& linvY,float& linvZ); - virtual void GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ); - virtual void GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ); - virtual void getReactionForce(float& forceX,float& forceY,float& forceZ); - virtual void GetWalkDirection(float& dirX,float& dirY,float& dirZ); + virtual MT_Vector3 GetLinearVelocity(); + virtual MT_Vector3 GetAngularVelocity(); + virtual MT_Vector3 GetVelocity(const MT_Point3& posin); + virtual MT_Vector3 GetLocalInertia(); // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted - virtual void setRigidBody(bool rigid); + virtual void SetRigidBody(bool rigid); - virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ); + virtual void ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ); + + virtual void SuspendDynamics(bool ghost); + virtual void RestoreDynamics(); + + // Shape control + virtual void AddCompoundChild(PHY_IPhysicsController* child); + virtual void RemoveCompoundChild(PHY_IPhysicsController* child); // clientinfo for raycasts for example - virtual void* getNewClientInfo(); - virtual void setNewClientInfo(void* clientinfo); + virtual void* GetNewClientInfo(); + virtual void SetNewClientInfo(void* clientinfo); virtual PHY_IPhysicsController* GetReplica(); + virtual PHY_IPhysicsController* GetReplicaForSensors(); ///There should be no 'SetCollisionFilterGroup' method, as changing this during run-time is will result in errors short int GetCollisionFilterGroup() const @@ -566,7 +602,7 @@ protected: return m_cci.m_collisionFilterMask; } - virtual void calcXform() {} + virtual void CalcXform() {} virtual void SetMargin(float margin) { if (m_collisionShape) @@ -609,7 +645,7 @@ protected: return m_cci.m_clamp_vel_max; } - bool wantsSleeping(); + bool WantsSleeping(); void UpdateDeactivation(float timeStep); @@ -635,24 +671,29 @@ protected: return m_cci.m_physicsEnv; } - void setParentCtrl(CcdPhysicsController* parentCtrl) + void SetParentCtrl(CcdPhysicsController* parentCtrl) { m_parentCtrl = parentCtrl; } - CcdPhysicsController* getParentCtrl() + CcdPhysicsController* GetParentCtrl() { return m_parentCtrl; } - const CcdPhysicsController* getParentCtrl() const + const CcdPhysicsController* GetParentCtrl() const { return m_parentCtrl; } - virtual const char* getName() + virtual bool IsDynamic() + { + return GetConstructionInfo().m_bDyna; + } + + virtual bool IsCompound() { - return 0; + return GetConstructionInfo().m_shapeInfo->m_shapeType == PHY_SHAPE_COMPOUND; } #ifdef WITH_CXX_GUARDEDALLOC @@ -672,16 +713,16 @@ class DefaultMotionState : public PHY_IMotionState virtual ~DefaultMotionState(); - virtual void getWorldPosition(float& posX,float& posY,float& posZ); - virtual void getWorldScaling(float& scaleX,float& scaleY,float& scaleZ); - virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal); + virtual void GetWorldPosition(float& posX,float& posY,float& posZ); + virtual void GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ); + virtual void GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal); - virtual void setWorldPosition(float posX,float posY,float posZ); - virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal); - virtual void getWorldOrientation(float* ori); - virtual void setWorldOrientation(const float* ori); + virtual void SetWorldPosition(float posX,float posY,float posZ); + virtual void SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal); + virtual void GetWorldOrientation(float* ori); + virtual void SetWorldOrientation(const float* ori); - virtual void calculateWorldTransformations(); + virtual void CalculateWorldTransformations(); btTransform m_worldTransform; btVector3 m_localScaling; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index e01530f2b11..10be1876e41 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -127,8 +127,8 @@ public: btTransform trans = m_vehicle->getWheelInfo(i).m_worldTransform; btQuaternion orn = trans.getRotation(); const btVector3& pos = trans.getOrigin(); - motionState->setWorldOrientation(orn.x(),orn.y(),orn.z(),orn[3]); - motionState->setWorldPosition(pos.x(),pos.y(),pos.z()); + motionState->SetWorldOrientation(orn.x(),orn.y(),orn.z(),orn[3]); + motionState->SetWorldPosition(pos.x(),pos.y(),pos.z()); } } @@ -265,63 +265,6 @@ public: }; #endif //NEW_BULLET_VEHICLE_SUPPORT -class CharacterWrapper : public PHY_ICharacter -{ -private: - BlenderBulletCharacterController* m_controller; - -public: - CharacterWrapper(BlenderBulletCharacterController* cont) - : m_controller(cont) - {} - - virtual void Jump() - { - m_controller->jump(); - } - - virtual bool OnGround() - { - return m_controller->onGround(); - } - - virtual float GetGravity() - { - return m_controller->getGravity(); - } - virtual void SetGravity(float gravity) - { - m_controller->setGravity(gravity); - } - - virtual int GetMaxJumps() - { - return m_controller->getMaxJumps(); - } - - virtual void SetMaxJumps(int maxJumps) - { - m_controller->setMaxJumps(maxJumps); - } - - virtual int GetJumpCount() - { - return m_controller->getJumpCount(); - } - - virtual void SetWalkDirection(const MT_Vector3& dir) - { - btVector3 vec = btVector3(dir[0], dir[1], dir[2]); - m_controller->setWalkDirection(vec); - } - - virtual MT_Vector3 GetWalkDirection() - { - btVector3 vec = m_controller->getWalkDirection(); - return MT_Vector3(vec[0], vec[1], vec[2]); - } -}; - class CcdOverlapFilterCallBack : public btOverlapFilterCallback { private: @@ -339,7 +282,7 @@ public: }; -void CcdPhysicsEnvironment::setDebugDrawer(btIDebugDraw* debugDrawer) +void CcdPhysicsEnvironment::SetDebugDrawer(btIDebugDraw* debugDrawer) { if (debugDrawer && m_dynamicsWorld) m_dynamicsWorld->setDebugDrawer(debugDrawer); @@ -429,17 +372,17 @@ m_scalingPropagated(false) m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback); m_broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(m_ghostPairCallback); - setSolverType(1);//issues with quickstep and memory allocations + SetSolverType(1);//issues with quickstep and memory allocations // m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration); m_dynamicsWorld = new btSoftRigidDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration); //m_dynamicsWorld->getSolverInfo().m_linearSlop = 0.01f; //m_dynamicsWorld->getSolverInfo().m_solverMode= SOLVER_USE_WARMSTARTING + SOLVER_USE_2_FRICTION_DIRECTIONS + SOLVER_RANDMIZE_ORDER + SOLVER_USE_FRICTION_WARMSTARTING; m_debugDrawer = 0; - setGravity(0.f,0.f,-9.81f); + SetGravity(0.f,0.f,-9.81f); } -void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) +void CcdPhysicsEnvironment::AddCcdPhysicsController(CcdPhysicsController* ctrl) { btRigidBody* body = ctrl->GetRigidBody(); btCollisionObject* obj = ctrl->GetCollisionObject(); @@ -483,7 +426,7 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) -bool CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctrl) +bool CcdPhysicsEnvironment::RemoveCcdPhysicsController(CcdPhysicsController* ctrl) { //also remove constraint btRigidBody* body = ctrl->GetRigidBody(); @@ -522,7 +465,7 @@ bool CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr return (m_controllers.erase(ctrl) != 0); } -void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask) +void CcdPhysicsEnvironment::UpdateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask) { // this function is used when the collisionning group of a controller is changed // remove and add the collistioning object @@ -551,7 +494,7 @@ void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctr ctrl->m_cci.m_collisionFlags = newCollisionFlags; } -void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctrl) +void CcdPhysicsEnvironment::EnableCcdPhysicsController(CcdPhysicsController* ctrl) { if (m_controllers.insert(ctrl).second) { @@ -568,7 +511,7 @@ void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctr } } -void CcdPhysicsEnvironment::disableCcdPhysicsController(CcdPhysicsController* ctrl) +void CcdPhysicsEnvironment::DisableCcdPhysicsController(CcdPhysicsController* ctrl) { if (m_controllers.erase(ctrl)) { @@ -588,7 +531,7 @@ void CcdPhysicsEnvironment::disableCcdPhysicsController(CcdPhysicsController* ct } } -void CcdPhysicsEnvironment::refreshCcdPhysicsController(CcdPhysicsController* ctrl) +void CcdPhysicsEnvironment::RefreshCcdPhysicsController(CcdPhysicsController* ctrl) { btCollisionObject* obj = ctrl->GetCollisionObject(); if (obj) @@ -601,15 +544,15 @@ void CcdPhysicsEnvironment::refreshCcdPhysicsController(CcdPhysicsController* ct } } -void CcdPhysicsEnvironment::addCcdGraphicController(CcdGraphicController* ctrl) +void CcdPhysicsEnvironment::AddCcdGraphicController(CcdGraphicController* ctrl) { - if (m_cullingTree && !ctrl->getBroadphaseHandle()) + if (m_cullingTree && !ctrl->GetBroadphaseHandle()) { btVector3 minAabb; btVector3 maxAabb; - ctrl->getAabb(minAabb, maxAabb); + ctrl->GetAabb(minAabb, maxAabb); - ctrl->setBroadphaseHandle(m_cullingTree->createProxy( + ctrl->SetBroadphaseHandle(m_cullingTree->createProxy( minAabb, maxAabb, INVALID_SHAPE_PROXYTYPE, // this parameter is not used @@ -619,35 +562,35 @@ void CcdPhysicsEnvironment::addCcdGraphicController(CcdGraphicController* ctrl) NULL, // dispatcher => this parameter is not used 0)); - assert(ctrl->getBroadphaseHandle()); + assert(ctrl->GetBroadphaseHandle()); } } -void CcdPhysicsEnvironment::removeCcdGraphicController(CcdGraphicController* ctrl) +void CcdPhysicsEnvironment::RemoveCcdGraphicController(CcdGraphicController* ctrl) { if (m_cullingTree) { - btBroadphaseProxy* bp = ctrl->getBroadphaseHandle(); + btBroadphaseProxy* bp = ctrl->GetBroadphaseHandle(); if (bp) { m_cullingTree->destroyProxy(bp,NULL); - ctrl->setBroadphaseHandle(0); + ctrl->SetBroadphaseHandle(0); } } } -void CcdPhysicsEnvironment::beginFrame() +void CcdPhysicsEnvironment::BeginFrame() { } -void CcdPhysicsEnvironment::debugDrawWorld() +void CcdPhysicsEnvironment::DebugDrawWorld() { if (m_dynamicsWorld->getDebugDrawer() && m_dynamicsWorld->getDebugDrawer()->getDebugMode() >0) m_dynamicsWorld->debugDrawWorld(); } -bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float interval) +bool CcdPhysicsEnvironment::ProceedDeltaTime(double curTime,float timeStep,float interval) { std::set::iterator it; int i; @@ -662,7 +605,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float //uncomment next line to see where Bullet spend its time (printf in console) //CProfileManager::dumpAll(); - processFhSprings(curTime,i*subStep); + ProcessFhSprings(curTime,i*subStep); for (it=m_controllers.begin(); it!=m_controllers.end(); it++) { @@ -714,7 +657,7 @@ public: }; -void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval) +void CcdPhysicsEnvironment::ProcessFhSprings(double curTime,float interval) { std::set::iterator it; // dynamic of Fh spring is based on a timestep of 1/60 @@ -725,12 +668,12 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval) CcdPhysicsController* ctrl = (*it); btRigidBody* body = ctrl->GetRigidBody(); - if (body && (ctrl->getConstructionInfo().m_do_fh || ctrl->getConstructionInfo().m_do_rot_fh)) + if (body && (ctrl->GetConstructionInfo().m_do_fh || ctrl->GetConstructionInfo().m_do_rot_fh)) { //printf("has Fh or RotFh\n"); //re-implement SM_FhObject.cpp using btCollisionWorld::rayTest and info from ctrl->getConstructionInfo() //send a ray from {0.0, 0.0, 0.0} towards {0.0, 0.0, -10.0}, in local coordinates - CcdPhysicsController* parentCtrl = ctrl->getParentCtrl(); + CcdPhysicsController* parentCtrl = ctrl->GetParentCtrl(); btRigidBody* parentBody = parentCtrl?parentCtrl->GetRigidBody() : 0; btRigidBody* cl_object = parentBody ? parentBody : body; @@ -756,16 +699,16 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval) if (controller) { - if (controller->getConstructionInfo().m_fh_distance < SIMD_EPSILON) + if (controller->GetConstructionInfo().m_fh_distance < SIMD_EPSILON) continue; btRigidBody* hit_object = controller->GetRigidBody(); if (!hit_object) continue; - CcdConstructionInfo& hitObjShapeProps = controller->getConstructionInfo(); + CcdConstructionInfo& hitObjShapeProps = controller->GetConstructionInfo(); - float distance = resultCallback.m_closestHitFraction*rayDirLocal.length()-ctrl->getConstructionInfo().m_radius; + float distance = resultCallback.m_closestHitFraction*rayDirLocal.length()-ctrl->GetConstructionInfo().m_radius; if (distance >= hitObjShapeProps.m_fh_distance) continue; @@ -778,7 +721,7 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval) for (int i=0; igetConstructionInfo().m_do_fh) + if (ctrl->GetConstructionInfo().m_do_fh) { btVector3 lspot = cl_object->getCenterOfMassPosition() + rayDirLocal * resultCallback.m_closestHitFraction; @@ -790,7 +733,7 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval) btVector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocityInLocalPoint(lspot); btScalar rel_vel_ray = ray_dir.dot(rel_vel); btScalar spring_extent = 1.0 - distance / hitObjShapeProps.m_fh_distance; - + btScalar i_spring = spring_extent * hitObjShapeProps.m_fh_spring; btScalar i_damp = rel_vel_ray * hitObjShapeProps.m_fh_damping; @@ -803,7 +746,7 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval) btVector3 lateral = rel_vel - rel_vel_ray * ray_dir; - if (ctrl->getConstructionInfo().m_do_anisotropic) { + if (ctrl->GetConstructionInfo().m_do_anisotropic) { //Bullet basis contains no scaling/shear etc. const btMatrix3x3& lcs = cl_object->getCenterOfMassTransform().getBasis(); btVector3 loc_lateral = lateral * lcs; @@ -830,7 +773,7 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval) } - if (ctrl->getConstructionInfo().m_do_rot_fh) { + if (ctrl->GetConstructionInfo().m_do_rot_fh) { btVector3 up2 = cl_object->getWorldTransform().getBasis().getColumn(2); btVector3 t_spring = up2.cross(normal) * hitObjShapeProps.m_fh_spring; @@ -850,69 +793,69 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float interval) } } -void CcdPhysicsEnvironment::setDebugMode(int debugMode) +void CcdPhysicsEnvironment::SetDebugMode(int debugMode) { if (m_debugDrawer) { m_debugDrawer->setDebugMode(debugMode); } } -void CcdPhysicsEnvironment::setNumIterations(int numIter) +void CcdPhysicsEnvironment::SetNumIterations(int numIter) { m_numIterations = numIter; } -void CcdPhysicsEnvironment::setDeactivationTime(float dTime) +void CcdPhysicsEnvironment::SetDeactivationTime(float dTime) { gDeactivationTime = dTime; } -void CcdPhysicsEnvironment::setDeactivationLinearTreshold(float linTresh) +void CcdPhysicsEnvironment::SetDeactivationLinearTreshold(float linTresh) { gLinearSleepingTreshold = linTresh; } -void CcdPhysicsEnvironment::setDeactivationAngularTreshold(float angTresh) +void CcdPhysicsEnvironment::SetDeactivationAngularTreshold(float angTresh) { gAngularSleepingTreshold = angTresh; } -void CcdPhysicsEnvironment::setContactBreakingTreshold(float contactBreakingTreshold) +void CcdPhysicsEnvironment::SetContactBreakingTreshold(float contactBreakingTreshold) { gContactBreakingThreshold = contactBreakingTreshold; } -void CcdPhysicsEnvironment::setCcdMode(int ccdMode) +void CcdPhysicsEnvironment::SetCcdMode(int ccdMode) { m_ccdMode = ccdMode; } -void CcdPhysicsEnvironment::setSolverSorConstant(float sor) +void CcdPhysicsEnvironment::SetSolverSorConstant(float sor) { m_dynamicsWorld->getSolverInfo().m_sor = sor; } -void CcdPhysicsEnvironment::setSolverTau(float tau) +void CcdPhysicsEnvironment::SetSolverTau(float tau) { m_dynamicsWorld->getSolverInfo().m_tau = tau; } -void CcdPhysicsEnvironment::setSolverDamping(float damping) +void CcdPhysicsEnvironment::SetSolverDamping(float damping) { m_dynamicsWorld->getSolverInfo().m_damping = damping; } -void CcdPhysicsEnvironment::setLinearAirDamping(float damping) +void CcdPhysicsEnvironment::SetLinearAirDamping(float damping) { //gLinearAirDamping = damping; } -void CcdPhysicsEnvironment::setUseEpa(bool epa) +void CcdPhysicsEnvironment::SetUseEpa(bool epa) { //gUseEpa = epa; } -void CcdPhysicsEnvironment::setSolverType(int solverType) +void CcdPhysicsEnvironment::SetSolverType(int solverType) { switch (solverType) @@ -945,7 +888,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType) -void CcdPhysicsEnvironment::getGravity(MT_Vector3& grav) +void CcdPhysicsEnvironment::GetGravity(MT_Vector3& grav) { const btVector3& gravity = m_dynamicsWorld->getGravity(); grav[0] = gravity.getX(); @@ -954,7 +897,7 @@ void CcdPhysicsEnvironment::getGravity(MT_Vector3& grav) } -void CcdPhysicsEnvironment::setGravity(float x,float y,float z) +void CcdPhysicsEnvironment::SetGravity(float x,float y,float z) { m_gravity = btVector3(x,y,z); m_dynamicsWorld->setGravity(m_gravity); @@ -967,7 +910,7 @@ void CcdPhysicsEnvironment::setGravity(float x,float y,float z) static int gConstraintUid = 1; //Following the COLLADA physics specification for constraints -int CcdPhysicsEnvironment::createUniversalD6Constraint( +int CcdPhysicsEnvironment::CreateUniversalD6Constraint( class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther, btTransform& frameInA, btTransform& frameInB, @@ -1025,7 +968,7 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint( -void CcdPhysicsEnvironment::removeConstraint(int constraintId) +void CcdPhysicsEnvironment::RemoveConstraint(int constraintId) { int i; @@ -1144,7 +1087,7 @@ static bool GetHitTriangle(btCollisionShape* shape, CcdShapeConstructionInfo* sh return true; } -PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ) +PHY_IPhysicsController* CcdPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ) { btVector3 rayFrom(fromX,fromY,fromZ); btVector3 rayTo(toX,toY,toZ); @@ -1798,7 +1741,7 @@ struct DbvtCullingCallback : btDbvt::ICollide btBroadphaseProxy* proxy=(btBroadphaseProxy*)leaf->data; // the client object is a graphic controller CcdGraphicController* ctrl = static_cast(proxy->m_clientObject); - KX_ClientObjectInfo *info = (KX_ClientObjectInfo*)ctrl->getNewClientInfo(); + KX_ClientObjectInfo *info = (KX_ClientObjectInfo*)ctrl->GetNewClientInfo(); if (m_ocb) { // means we are doing occlusion culling. Check if this object is an occluders @@ -1846,7 +1789,7 @@ struct DbvtCullingCallback : btDbvt::ICollide }; static OcclusionBuffer gOcb; -bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) +bool CcdPhysicsEnvironment::CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { if (!m_cullingTree) return false; @@ -1876,12 +1819,12 @@ bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* user return true; } -int CcdPhysicsEnvironment::getNumContactPoints() +int CcdPhysicsEnvironment::GetNumContactPoints() { return 0; } -void CcdPhysicsEnvironment::getContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ) +void CcdPhysicsEnvironment::GetContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ) { } @@ -1889,12 +1832,12 @@ void CcdPhysicsEnvironment::getContactPoint(int i,float& hitX,float& hitY,float& -btBroadphaseInterface* CcdPhysicsEnvironment::getBroadphase() +btBroadphaseInterface* CcdPhysicsEnvironment::GetBroadphase() { return m_dynamicsWorld->getBroadphase(); } -btDispatcher* CcdPhysicsEnvironment::getDispatcher() +btDispatcher* CcdPhysicsEnvironment::GetDispatcher() { return m_dynamicsWorld->getDispatcher(); } @@ -1908,8 +1851,8 @@ void CcdPhysicsEnvironment::MergeEnvironment(CcdPhysicsEnvironment *other) it= other->m_controllers.begin(); CcdPhysicsController* ctrl= (*it); - other->removeCcdPhysicsController(ctrl); - this->addCcdPhysicsController(ctrl); + other->RemoveCcdPhysicsController(ctrl); + this->AddCcdPhysicsController(ctrl); } } @@ -1961,9 +1904,9 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment() } -float CcdPhysicsEnvironment::getConstraintParam(int constraintId,int param) +float CcdPhysicsEnvironment::GetConstraintParam(int constraintId,int param) { - btTypedConstraint* typedConstraint = getConstraintById(constraintId); + btTypedConstraint* typedConstraint = GetConstraintById(constraintId); switch (typedConstraint->getUserConstraintType()) { case PHY_GENERIC_6DOF_CONSTRAINT: @@ -2000,9 +1943,9 @@ float CcdPhysicsEnvironment::getConstraintParam(int constraintId,int param) return 0.f; } -void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float value0,float value1) +void CcdPhysicsEnvironment::SetConstraintParam(int constraintId,int param,float value0,float value1) { - btTypedConstraint* typedConstraint = getConstraintById(constraintId); + btTypedConstraint* typedConstraint = GetConstraintById(constraintId); switch (typedConstraint->getUserConstraintType()) { case PHY_GENERIC_6DOF_CONSTRAINT: @@ -2110,7 +2053,7 @@ void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float }; } -btTypedConstraint* CcdPhysicsEnvironment::getConstraintById(int constraintId) +btTypedConstraint* CcdPhysicsEnvironment::GetConstraintById(int constraintId) { int numConstraints = m_dynamicsWorld->getNumConstraints(); @@ -2127,7 +2070,7 @@ btTypedConstraint* CcdPhysicsEnvironment::getConstraintById(int constraintId) } -void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl) +void CcdPhysicsEnvironment::AddSensor(PHY_IPhysicsController* ctrl) { CcdPhysicsController* ctrl1 = (CcdPhysicsController* )ctrl; @@ -2137,10 +2080,10 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl) //{ // addCcdPhysicsController(ctrl1); //} - enableCcdPhysicsController(ctrl1); + EnableCcdPhysicsController(ctrl1); } -bool CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl) +bool CcdPhysicsEnvironment::RemoveCollisionCallback(PHY_IPhysicsController* ctrl) { CcdPhysicsController* ccdCtrl = (CcdPhysicsController*)ctrl; if (!ccdCtrl->Unregister()) @@ -2150,12 +2093,12 @@ bool CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl } -void CcdPhysicsEnvironment::removeSensor(PHY_IPhysicsController* ctrl) +void CcdPhysicsEnvironment::RemoveSensor(PHY_IPhysicsController* ctrl) { - disableCcdPhysicsController((CcdPhysicsController*)ctrl); + DisableCcdPhysicsController((CcdPhysicsController*)ctrl); } -void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user) +void CcdPhysicsEnvironment::AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user) { /* printf("addTouchCallback\n(response class = %i)\n",response_class); @@ -2187,7 +2130,7 @@ void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCal m_triggerCallbacksUserPtrs[response_class] = user; } -bool CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl) +bool CcdPhysicsEnvironment::RequestCollisionCallback(PHY_IPhysicsController* ctrl) { CcdPhysicsController* ccdCtrl = static_cast(ctrl); @@ -2270,12 +2213,12 @@ bool CcdOverlapFilterCallBack::needBroadphaseCollision(btBroadphaseProxy* proxy0 (KX_ClientObjectInfo*) ((CcdPhysicsController*) (((btCollisionObject*)proxy0->m_clientObject)->getUserPointer())) - ->getNewClientInfo()); + ->GetNewClientInfo()); KX_GameObject *kxObj1 = KX_GameObject::GetClientObject( (KX_ClientObjectInfo*) ((CcdPhysicsController*) (((btCollisionObject*)proxy1->m_clientObject)->getUserPointer())) - ->getNewClientInfo()); + ->GetNewClientInfo()); // First check the filters. Note that this is called during scene // conversion, so we can't assume the KX_GameObject instances exist. This @@ -2324,7 +2267,7 @@ bool CcdOverlapFilterCallBack::needBroadphaseCollision(btBroadphaseProxy* proxy0 #ifdef NEW_BULLET_VEHICLE_SUPPORT //complex constraint for vehicles -PHY_IVehicle* CcdPhysicsEnvironment::getVehicleConstraint(int constraintId) +PHY_IVehicle* CcdPhysicsEnvironment::GetVehicleConstraint(int constraintId) { int i; @@ -2342,13 +2285,10 @@ PHY_IVehicle* CcdPhysicsEnvironment::getVehicleConstraint(int constraintId) #endif //NEW_BULLET_VEHICLE_SUPPORT -PHY_ICharacter* CcdPhysicsEnvironment::getCharacterController(KX_GameObject *ob) +PHY_ICharacter* CcdPhysicsEnvironment::GetCharacterController(KX_GameObject *ob) { - CcdPhysicsController* controller = (CcdPhysicsController*)ob->GetPhysicsController()->GetUserData(); - if (controller->GetCharacterController()) - return new CharacterWrapper((BlenderBulletCharacterController*)controller->GetCharacterController()); - - return NULL; + CcdPhysicsController* controller = (CcdPhysicsController*)ob->GetPhysicsController(); + return dynamic_cast(controller->GetCharacterController()); } @@ -2398,7 +2338,7 @@ int findClosestNode(btSoftBody* sb,const btVector3& worldPoint) return node; } -int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl0,class PHY_IPhysicsController* ctrl1,PHY_ConstraintType type, +int CcdPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl0,class PHY_IPhysicsController* ctrl1,PHY_ConstraintType type, float pivotX,float pivotY,float pivotZ, float axisX,float axisY,float axisZ, float axis1X,float axis1Y,float axis1Z, @@ -2891,7 +2831,7 @@ float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid) return 0.f; } -void CcdPhysicsEnvironment::exportFile(const char* filename) +void CcdPhysicsEnvironment::ExportFile(const char* filename) { btDefaultSerializer* serializer = new btDefaultSerializer(); @@ -2904,7 +2844,7 @@ void CcdPhysicsEnvironment::exportFile(const char* filename) CcdPhysicsController* controller = static_cast(colObj->getUserPointer()); if (controller) { - const char* name = controller->getName(); + const char* name = KX_GameObject::GetClientObject((KX_ClientObjectInfo*)controller->GetNewClientInfo())->GetName(); if (name) { serializer->registerNameForPointer(colObj,name); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 8cf88526969..0e8ac9417f0 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -24,6 +24,7 @@ subject to the following restrictions: #include "PHY_IPhysicsEnvironment.h" #include #include +#include class CcdPhysicsController; class CcdGraphicController; #include "LinearMath/btVector3.h" @@ -83,7 +84,7 @@ protected: int m_profileTimings; bool m_enableSatCollisionDetection; - void processFhSprings(double curTime,float timeStep); + void ProcessFhSprings(double curTime,float timeStep); public: CcdPhysicsEnvironment(bool useDbvtCulling, btDispatcher* dispatcher=0, btOverlappingPairCache* pairCache=0); @@ -96,54 +97,54 @@ protected: /// Perform an integration step of duration 'timeStep'. - virtual void setDebugDrawer(btIDebugDraw* debugDrawer); + virtual void SetDebugDrawer(btIDebugDraw* debugDrawer); - virtual void setNumIterations(int numIter); - virtual void setNumTimeSubSteps(int numTimeSubSteps) + virtual void SetNumIterations(int numIter); + virtual void SetNumTimeSubSteps(int numTimeSubSteps) { m_numTimeSubSteps = numTimeSubSteps; } - virtual void setDeactivationTime(float dTime); - virtual void setDeactivationLinearTreshold(float linTresh); - virtual void setDeactivationAngularTreshold(float angTresh); - virtual void setContactBreakingTreshold(float contactBreakingTreshold); - virtual void setCcdMode(int ccdMode); - virtual void setSolverType(int solverType); - virtual void setSolverSorConstant(float sor); - virtual void setSolverTau(float tau); - virtual void setSolverDamping(float damping); - virtual void setLinearAirDamping(float damping); - virtual void setUseEpa(bool epa); - - int getNumTimeSubSteps() + virtual void SetDeactivationTime(float dTime); + virtual void SetDeactivationLinearTreshold(float linTresh); + virtual void SetDeactivationAngularTreshold(float angTresh); + virtual void SetContactBreakingTreshold(float contactBreakingTreshold); + virtual void SetCcdMode(int ccdMode); + virtual void SetSolverType(int solverType); + virtual void SetSolverSorConstant(float sor); + virtual void SetSolverTau(float tau); + virtual void SetSolverDamping(float damping); + virtual void SetLinearAirDamping(float damping); + virtual void SetUseEpa(bool epa); + + virtual int GetNumTimeSubSteps() { return m_numTimeSubSteps; } - virtual void beginFrame(); - virtual void endFrame() {} + virtual void BeginFrame(); + virtual void EndFrame() {} /// Perform an integration step of duration 'timeStep'. - virtual bool proceedDeltaTime(double curTime,float timeStep,float interval); - - virtual void debugDrawWorld(); + virtual bool ProceedDeltaTime(double curTime,float timeStep,float interval); + + virtual void DebugDrawWorld(); // virtual bool proceedDeltaTimeOneStep(float timeStep); - virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep) + virtual void SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep) { //based on DEFAULT_PHYSICS_TIC_RATE of 60 hertz - setNumTimeSubSteps((int)(fixedTimeStep / 60.f)); + SetNumTimeSubSteps((int)(fixedTimeStep / 60.f)); } //returns 0.f if no fixed timestep is used - virtual float getFixedTimeStep() { return 0.f; } + virtual float GetFixedTimeStep() { return 0.f; } - virtual void setDebugMode(int debugMode); + virtual void SetDebugMode(int debugMode); - virtual void setGravity(float x,float y,float z); - virtual void getGravity(MT_Vector3& grav); + virtual void SetGravity(float x,float y,float z); + virtual void GetGravity(MT_Vector3& grav); - virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, + virtual int CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, float pivotX,float pivotY,float pivotZ, float axisX,float axisY,float axisZ, float axis1X=0,float axis1Y=0,float axis1Z=0, @@ -152,7 +153,7 @@ protected: //Following the COLLADA physics specification for constraints - virtual int createUniversalD6Constraint( + virtual int CreateUniversalD6Constraint( class PHY_IPhysicsController* ctrlRef,class PHY_IPhysicsController* ctrlOther, btTransform& localAttachmentFrameRef, btTransform& localAttachmentOther, @@ -163,11 +164,11 @@ protected: ); - virtual void setConstraintParam(int constraintId,int param,float value,float value1); + virtual void SetConstraintParam(int constraintId,int param,float value,float value1); - virtual float getConstraintParam(int constraintId,int param); + virtual float GetConstraintParam(int constraintId,int param); - virtual void removeConstraint(int constraintid); + virtual void RemoveConstraint(int constraintid); virtual float getAppliedImpulse(int constraintid); @@ -177,61 +178,61 @@ protected: #ifdef NEW_BULLET_VEHICLE_SUPPORT //complex constraint for vehicles - virtual PHY_IVehicle* getVehicleConstraint(int constraintId); + virtual PHY_IVehicle* GetVehicleConstraint(int constraintId); #else - virtual class PHY_IVehicle* getVehicleConstraint(int constraintId) + virtual class PHY_IVehicle* GetVehicleConstraint(int constraintId) { return 0; } #endif /* NEW_BULLET_VEHICLE_SUPPORT */ // Character physics wrapper - virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob); + virtual PHY_ICharacter* GetCharacterController(class KX_GameObject* ob); - btTypedConstraint* getConstraintById(int constraintId); + btTypedConstraint* GetConstraintById(int constraintId); - virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); - virtual bool cullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]); + virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); + virtual bool CullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]); //Methods for gamelogic collision/physics callbacks - virtual void addSensor(PHY_IPhysicsController* ctrl); - virtual void removeSensor(PHY_IPhysicsController* ctrl); - virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user); - virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl); - virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl); + virtual void AddSensor(PHY_IPhysicsController* ctrl); + virtual void RemoveSensor(PHY_IPhysicsController* ctrl); + virtual void AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user); + virtual bool RequestCollisionCallback(PHY_IPhysicsController* ctrl); + virtual bool RemoveCollisionCallback(PHY_IPhysicsController* ctrl); //These two methods are used *solely* to create controllers for Near/Radar sensor! Don't use for anything else virtual PHY_IPhysicsController* CreateSphereController(float radius,const MT_Vector3& position); virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight); - virtual int getNumContactPoints(); + virtual int GetNumContactPoints(); - virtual void getContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ); + virtual void GetContactPoint(int i,float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ); ////////////////////// //CcdPhysicsEnvironment interface //////////////////////// - void addCcdPhysicsController(CcdPhysicsController* ctrl); + void AddCcdPhysicsController(CcdPhysicsController* ctrl); - bool removeCcdPhysicsController(CcdPhysicsController* ctrl); + bool RemoveCcdPhysicsController(CcdPhysicsController* ctrl); - void updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask); + void UpdateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask); - void disableCcdPhysicsController(CcdPhysicsController* ctrl); + void DisableCcdPhysicsController(CcdPhysicsController* ctrl); - void enableCcdPhysicsController(CcdPhysicsController* ctrl); + void EnableCcdPhysicsController(CcdPhysicsController* ctrl); - void refreshCcdPhysicsController(CcdPhysicsController* ctrl); + void RefreshCcdPhysicsController(CcdPhysicsController* ctrl); - void addCcdGraphicController(CcdGraphicController* ctrl); + void AddCcdGraphicController(CcdGraphicController* ctrl); - void removeCcdGraphicController(CcdGraphicController* ctrl); + void RemoveCcdGraphicController(CcdGraphicController* ctrl); - btBroadphaseInterface* getBroadphase(); - btDbvtBroadphase* getCullingTree() { return m_cullingTree; } + btBroadphaseInterface* GetBroadphase(); + btDbvtBroadphase* GetCullingTree() { return m_cullingTree; } - btDispatcher* getDispatcher(); + btDispatcher* GetDispatcher(); bool IsSatCollisionDetectionEnabled() const @@ -250,7 +251,7 @@ protected: void SyncMotionStates(float timeStep); - class btSoftRigidDynamicsWorld* getDynamicsWorld() + class btSoftRigidDynamicsWorld* GetDynamicsWorld() { return m_dynamicsWorld; } @@ -291,7 +292,7 @@ protected: bool m_scalingPropagated; - virtual void exportFile(const char* filename); + virtual void ExportFile(const char* filename); #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp index 72450e4307c..1bb5431c749 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp @@ -47,19 +47,19 @@ DummyPhysicsEnvironment::~DummyPhysicsEnvironment() //destroy physicsengine data } -void DummyPhysicsEnvironment::beginFrame() +void DummyPhysicsEnvironment::BeginFrame() { // beginning of logic frame: apply forces } -void DummyPhysicsEnvironment::endFrame() +void DummyPhysicsEnvironment::EndFrame() { // end of logic frame: clear forces } -bool DummyPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float interval) +bool DummyPhysicsEnvironment::ProceedDeltaTime(double curTime,float timeStep,float interval) { //step physics simulation, typically perform @@ -69,11 +69,11 @@ bool DummyPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,f // return true if an update was done. return true; } -void DummyPhysicsEnvironment::setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep) +void DummyPhysicsEnvironment::SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep) { } -float DummyPhysicsEnvironment::getFixedTimeStep() +float DummyPhysicsEnvironment::GetFixedTimeStep() { return 0.f; } @@ -81,18 +81,18 @@ float DummyPhysicsEnvironment::getFixedTimeStep() -void DummyPhysicsEnvironment::setGravity(float x,float y,float z) +void DummyPhysicsEnvironment::SetGravity(float x,float y,float z) { } -void DummyPhysicsEnvironment::getGravity(class MT_Vector3& grav) +void DummyPhysicsEnvironment::GetGravity(class MT_Vector3& grav) { } -int DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, +int DummyPhysicsEnvironment::CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ, float axis1X,float axis1Y,float axis1Z, float axis2X,float axis2Y,float axis2Z,int flag @@ -104,14 +104,14 @@ int DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ct } -void DummyPhysicsEnvironment::removeConstraint(int constraintid) +void DummyPhysicsEnvironment::RemoveConstraint(int constraintid) { if (constraintid) { } } -PHY_IPhysicsController* DummyPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ) +PHY_IPhysicsController* DummyPhysicsEnvironment::RayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ) { //collision detection / raytesting return NULL; diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index 9f6bc85fced..41462f91840 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -48,57 +48,57 @@ class DummyPhysicsEnvironment : public PHY_IPhysicsEnvironment public: DummyPhysicsEnvironment (); virtual ~DummyPhysicsEnvironment (); - virtual void beginFrame(); - virtual void endFrame(); + virtual void BeginFrame(); + virtual void EndFrame(); // Perform an integration step of duration 'timeStep'. - virtual bool proceedDeltaTime(double curTime,float timeStep,float interval); - virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep); - virtual float getFixedTimeStep(); + virtual bool ProceedDeltaTime(double curTime,float timeStep,float interval); + virtual void SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep); + virtual float GetFixedTimeStep(); - virtual void setGravity(float x,float y,float z); - virtual void getGravity(class MT_Vector3& grav); + virtual void SetGravity(float x,float y,float z); + virtual void GetGravity(class MT_Vector3& grav); - virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, + virtual int CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, float pivotX,float pivotY,float pivotZ, float axisX,float axisY,float axisZ, float axis1X=0,float axis1Y=0,float axis1Z=0, float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0 ); - virtual void removeConstraint(int constraintid); + virtual void RemoveConstraint(int constraintid); //complex constraint for vehicles - virtual PHY_IVehicle* getVehicleConstraint(int constraintId) + virtual PHY_IVehicle* GetVehicleConstraint(int constraintId) { return 0; } // Character physics wrapper - virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob) + virtual PHY_ICharacter* GetCharacterController(class KX_GameObject* ob) { return 0; } - virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); - virtual bool cullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; } + virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); + virtual bool CullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; } //gamelogic callbacks - virtual void addSensor(PHY_IPhysicsController* ctrl) {} - virtual void removeSensor(PHY_IPhysicsController* ctrl) {} - virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user) + virtual void AddSensor(PHY_IPhysicsController* ctrl) {} + virtual void RemoveSensor(PHY_IPhysicsController* ctrl) {} + virtual void AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user) { } - virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl) { return false; } - virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl) { return false;} + virtual bool RequestCollisionCallback(PHY_IPhysicsController* ctrl) { return false; } + virtual bool RemoveCollisionCallback(PHY_IPhysicsController* ctrl) { return false;} virtual PHY_IPhysicsController* CreateSphereController(float radius,const class MT_Vector3& position) {return 0;} virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;} - virtual void setConstraintParam(int constraintId,int param,float value,float value1) + virtual void SetConstraintParam(int constraintId,int param,float value,float value1) { } - virtual float getConstraintParam(int constraintId,int param) + virtual float GetConstraintParam(int constraintId,int param) { return 0.f; } diff --git a/source/gameengine/Physics/common/PHY_IController.h b/source/gameengine/Physics/common/PHY_IController.h index ae1b2d9ad53..284d77ca221 100644 --- a/source/gameengine/Physics/common/PHY_IController.h +++ b/source/gameengine/Physics/common/PHY_IController.h @@ -50,8 +50,8 @@ class PHY_IController public: virtual ~PHY_IController(){}; // clientinfo for raycasts for example - virtual void* getNewClientInfo()=0; - virtual void setNewClientInfo(void* clientinfo)=0; + virtual void* GetNewClientInfo()=0; + virtual void SetNewClientInfo(void* clientinfo)=0; virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env)=0; diff --git a/source/gameengine/Physics/common/PHY_IGraphicController.h b/source/gameengine/Physics/common/PHY_IGraphicController.h index 5f64e7ccc80..b047edd93eb 100644 --- a/source/gameengine/Physics/common/PHY_IGraphicController.h +++ b/source/gameengine/Physics/common/PHY_IGraphicController.h @@ -47,8 +47,8 @@ class PHY_IGraphicController : public PHY_IController */ virtual bool SetGraphicTransform()=0; virtual void Activate(bool active=true)=0; - virtual void setLocalAabb(const class MT_Vector3& aabbMin,const class MT_Vector3& aabbMax)=0; - virtual void setLocalAabb(const float* aabbMin,const float* aabbMax)=0; + virtual void SetLocalAabb(const class MT_Vector3& aabbMin,const class MT_Vector3& aabbMax)=0; + virtual void SetLocalAabb(const float* aabbMin,const float* aabbMax)=0; virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate) {return 0;} diff --git a/source/gameengine/Physics/common/PHY_IMotionState.h b/source/gameengine/Physics/common/PHY_IMotionState.h index be5b2b54907..d40b8da9451 100644 --- a/source/gameengine/Physics/common/PHY_IMotionState.h +++ b/source/gameengine/Physics/common/PHY_IMotionState.h @@ -46,18 +46,18 @@ class PHY_IMotionState public: virtual ~PHY_IMotionState(){}; - virtual void getWorldPosition(float& posX,float& posY,float& posZ)=0; - virtual void getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)=0; - virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)=0; + virtual void GetWorldPosition(float& posX,float& posY,float& posZ)=0; + virtual void GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ)=0; + virtual void GetWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)=0; // ori = array 12 floats, [0..3] = first column + 0, [4..7] = second column, [8..11] = third column - virtual void getWorldOrientation(float* ori)=0; - virtual void setWorldOrientation(const float* ori)=0; + virtual void GetWorldOrientation(float* ori)=0; + virtual void SetWorldOrientation(const float* ori)=0; - virtual void setWorldPosition(float posX,float posY,float posZ)=0; - virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)=0; + virtual void SetWorldPosition(float posX,float posY,float posZ)=0; + virtual void SetWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)=0; - virtual void calculateWorldTransformations()=0; + virtual void CalculateWorldTransformations()=0; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h index 18af42adc15..a1d0972a950 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsController.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h @@ -37,6 +37,10 @@ class PHY_IMotionState; class PHY_IPhysicsEnvironment; +class MT_Vector3; +class MT_Point3; +class MT_Matrix3x3; + /** * PHY_IPhysicsController is the abstract simplified Interface to a physical object. * It contains the IMotionState and IDeformableMesh Interfaces. @@ -59,37 +63,47 @@ class PHY_IPhysicsController : public PHY_IController virtual class PHY_IMotionState* GetMotionState() = 0; // controller replication virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)=0; + virtual void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment *env)=0; // kinematic methods - virtual void RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)=0; - virtual void RelativeRotate(const float drot[12],bool local)=0; - virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)=0; - virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)=0; - virtual void setPosition(float posX,float posY,float posZ)=0; - virtual void getPosition(class MT_Vector3& pos) const=0; - virtual void setScaling(float scaleX,float scaleY,float scaleZ)=0; - + virtual void RelativeTranslate(const MT_Vector3& dloc,bool local)=0; + virtual void RelativeRotate(const MT_Matrix3x3&,bool local)=0; + virtual MT_Matrix3x3 GetOrientation()=0; + virtual void SetOrientation(const MT_Matrix3x3& orn)=0; + virtual void SetPosition(const MT_Vector3& pos)=0; + virtual void GetPosition(MT_Vector3& pos) const=0; + virtual void SetScaling(const MT_Vector3& scale)=0; + virtual void SetTransform()=0; + + virtual MT_Scalar GetMass()=0; + virtual void SetMass(MT_Scalar newmass)=0; + // physics methods - virtual void ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)=0; - virtual void ApplyForce(float forceX,float forceY,float forceZ,bool local)=0; - virtual void SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)=0; - virtual void SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)=0; - virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0; + virtual void ApplyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)=0; + virtual void ApplyTorque(const MT_Vector3& torque,bool local)=0; + virtual void ApplyForce(const MT_Vector3& force,bool local)=0; + virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0; + virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0; + virtual void ResolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0; + + virtual void SuspendDynamics(bool ghost=false)=0; + virtual void RestoreDynamics()=0; - virtual void applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)=0; virtual void SetActive(bool active)=0; // reading out information from physics - virtual void GetLinearVelocity(float& linvX,float& linvY,float& linvZ)=0; - virtual void GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)=0; - virtual void getReactionForce(float& forceX,float& forceY,float& forceZ)=0; + virtual MT_Vector3 GetLinearVelocity()=0; + virtual MT_Vector3 GetAngularVelocity()=0; + virtual MT_Vector3 GetVelocity(const MT_Point3& pos)=0; + virtual MT_Vector3 GetLocalInertia()=0; // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted - virtual void setRigidBody(bool rigid)=0; + virtual void SetRigidBody(bool rigid)=0; virtual PHY_IPhysicsController* GetReplica() {return 0;} + virtual PHY_IPhysicsController* GetReplicaForSensors() {return 0;} - virtual void calcXform() =0; + virtual void CalcXform() =0; virtual void SetMargin(float margin) =0; virtual float GetMargin() const=0; virtual float GetRadius() const=0; @@ -100,7 +114,15 @@ class PHY_IPhysicsController : public PHY_IController virtual float GetLinVelocityMax() const=0; virtual void SetLinVelocityMax(float val) = 0; - class MT_Vector3 GetWorldPosition(class MT_Vector3& localpos); + MT_Vector3 GetWorldPosition(MT_Vector3& localpos); + + // Shape control + virtual void AddCompoundChild(PHY_IPhysicsController* child) = 0; + virtual void RemoveCompoundChild(PHY_IPhysicsController* child) = 0; + + + virtual bool IsDynamic() = 0; + virtual bool IsCompound() = 0; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index 14904a70553..b1a0480ab14 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -105,87 +105,88 @@ public: class PHY_IPhysicsEnvironment { public: - virtual ~PHY_IPhysicsEnvironment(){}; - virtual void beginFrame() = 0; - virtual void endFrame() = 0; + virtual ~PHY_IPhysicsEnvironment(){} + virtual void BeginFrame() = 0; + virtual void EndFrame() = 0; /// Perform an integration step of duration 'timeStep'. - virtual bool proceedDeltaTime(double curTime,float timeStep,float interval)=0; + virtual bool ProceedDeltaTime(double curTime,float timeStep,float interval)=0; ///draw debug lines (make sure to call this during the render phase, otherwise lines are not drawn properly) - virtual void debugDrawWorld() {} - virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)=0; + virtual void DebugDrawWorld() {} + virtual void SetFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)=0; //returns 0.f if no fixed timestep is used - virtual float getFixedTimeStep()=0; + virtual float GetFixedTimeStep()=0; ///setDebugMode is used to support several ways of debug lines, contact point visualization - virtual void setDebugMode(int debugMode) {} + virtual void SetDebugMode(int debugMode) {} ///setNumIterations set the number of iterations for iterative solvers - virtual void setNumIterations(int numIter) {} + virtual void SetNumIterations(int numIter) {} ///setNumTimeSubSteps set the number of divisions of the timestep. Tradeoff quality versus performance. - virtual void setNumTimeSubSteps(int numTimeSubSteps) {} + virtual void SetNumTimeSubSteps(int numTimeSubSteps) {} + virtual int GetNumTimeSubSteps() {return 0; } ///setDeactivationTime sets the minimum time that an objects has to stay within the velocity tresholds until it gets fully deactivated - virtual void setDeactivationTime(float dTime) {} + virtual void SetDeactivationTime(float dTime) {} ///setDeactivationLinearTreshold sets the linear velocity treshold, see setDeactivationTime - virtual void setDeactivationLinearTreshold(float linTresh) {} + virtual void SetDeactivationLinearTreshold(float linTresh) {} ///setDeactivationAngularTreshold sets the angular velocity treshold, see setDeactivationTime - virtual void setDeactivationAngularTreshold(float angTresh) {} + virtual void SetDeactivationAngularTreshold(float angTresh) {} ///setContactBreakingTreshold sets tresholds to do with contact point management - virtual void setContactBreakingTreshold(float contactBreakingTreshold) {} + virtual void SetContactBreakingTreshold(float contactBreakingTreshold) {} ///continuous collision detection mode, very experimental for Bullet - virtual void setCcdMode(int ccdMode) {} + virtual void SetCcdMode(int ccdMode) {} ///successive overrelaxation constant, in case PSOR is used, values in between 1 and 2 guarantee converging behavior - virtual void setSolverSorConstant(float sor) {} + virtual void SetSolverSorConstant(float sor) {} ///setSolverType, internal setting, chooses solvertype, PSOR, Dantzig, impulse based, penalty based - virtual void setSolverType(int solverType) {} + virtual void SetSolverType(int solverType) {} ///setTau sets the spring constant of a penalty based solver - virtual void setSolverTau(float tau) {} + virtual void SetSolverTau(float tau) {} ///setDamping sets the damper constant of a penalty based solver - virtual void setSolverDamping(float damping) {} + virtual void SetSolverDamping(float damping) {} ///linear air damping for rigidbodies - virtual void setLinearAirDamping(float damping) {} + virtual void SetLinearAirDamping(float damping) {} /// penetrationdepth setting - virtual void setUseEpa(bool epa) {} + virtual void SetUseEpa(bool epa) {} - virtual void setGravity(float x,float y,float z)=0; - virtual void getGravity(MT_Vector3& grav) = 0; + virtual void SetGravity(float x,float y,float z)=0; + virtual void GetGravity(MT_Vector3& grav) = 0; - virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, + virtual int CreateConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, float pivotX,float pivotY,float pivotZ, float axis0X,float axis0Y,float axis0Z, float axis1X=0,float axis1Y=0,float axis1Z=0, float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0 )=0; - virtual void removeConstraint(int constraintid)=0; - virtual float getAppliedImpulse(int constraintid) { return 0.0f; } + virtual void RemoveConstraint(int constraintid)=0; + virtual float GetAppliedImpulse(int constraintid) { return 0.0f; } //complex constraint for vehicles - virtual PHY_IVehicle* getVehicleConstraint(int constraintId) =0; + virtual PHY_IVehicle* GetVehicleConstraint(int constraintId) =0; // Character physics wrapper - virtual PHY_ICharacter* getCharacterController(class KX_GameObject* ob) =0; + virtual PHY_ICharacter* GetCharacterController(class KX_GameObject* ob) =0; - virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)=0; + virtual PHY_IPhysicsController* RayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)=0; //culling based on physical broad phase // the plane number must be set as follow: near, far, left, right, top, botton // the near plane must be the first one and must always be present, it is used to get the direction of the view - virtual bool cullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0; + virtual bool CullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0; //Methods for gamelogic collision/physics callbacks //todo: - virtual void addSensor(PHY_IPhysicsController* ctrl)=0; - virtual void removeSensor(PHY_IPhysicsController* ctrl)=0; - virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0; - virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl)=0; - virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl)=0; + virtual void AddSensor(PHY_IPhysicsController* ctrl)=0; + virtual void RemoveSensor(PHY_IPhysicsController* ctrl)=0; + virtual void AddTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0; + virtual bool RequestCollisionCallback(PHY_IPhysicsController* ctrl)=0; + virtual bool RemoveCollisionCallback(PHY_IPhysicsController* ctrl)=0; //These two methods are *solely* used to create controllers for sensor! Don't use for anything else virtual PHY_IPhysicsController* CreateSphereController(float radius,const MT_Vector3& position) =0; virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight)=0; - virtual void setConstraintParam(int constraintId,int param,float value,float value1) = 0; - virtual float getConstraintParam(int constraintId,int param) = 0; + virtual void SetConstraintParam(int constraintId,int param,float value,float value1) = 0; + virtual float GetConstraintParam(int constraintId,int param) = 0; - virtual void exportFile(const char* filename) {}; + virtual void ExportFile(const char* filename) {}; #ifdef WITH_CXX_GUARDEDALLOC -- cgit v1.2.3 From be114086f223345f97f033dd9350a918dbb0eec5 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:22:52 +0000 Subject: BGE: The recent physics cleanup was using KX_GameObject::GetParent() with out calling parent->Release(). Since GetParent() does an AddRef(), this was causing a leak, which resulted in Zombie Object errors. --- source/gameengine/Ketsji/KX_Scene.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 1d95beed6e9..2cddb073b41 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -567,11 +567,16 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal { PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode()); PHY_IPhysicsController* newctrl = orgobj->GetPhysicsController()->GetReplica(); - PHY_IPhysicsController* parentctrl = (newobj->GetParent()) ? newobj->GetParent()->GetPhysicsController() : NULL; + + KX_GameObject *parent = newobj->GetParent(); + PHY_IPhysicsController* parentctrl = (parent) ? parent->GetPhysicsController() : NULL; newctrl->SetNewClientInfo(newobj->getClientInfo()); newobj->SetPhysicsController(newctrl, newobj->IsDynamic()); newctrl->PostProcessReplica(motionstate, parentctrl); + + if (parent) + parent->Release(); } return newobj; } -- cgit v1.2.3 From efa40ea590aacc9a37486dd5109f735d3890947c Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:22:56 +0000 Subject: BGE: Fixing up a small issue from merging Rasterizer cleanup code. --- .../gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 7360b1b1d8e..2a8c3ac7929 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -1332,7 +1332,7 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode ) KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo; PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment(); - KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController(); + PHY_IPhysicsController* physics_controller = gameobj->GetPhysicsController(); KX_GameObject *parent = gameobj->GetParent(); if (!physics_controller && parent) -- cgit v1.2.3 From b792ad2b461a1bf33411cd45b061a5bf2b9b2477 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 4 Nov 2013 19:23:00 +0000 Subject: BGE Physics Cleanup: Fixing an error that GCC didn't catch. --- source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index a3838a148e1..71bdce0e1ae 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -1362,7 +1362,7 @@ MT_Vector3 CcdPhysicsController::GetAngularVelocity() MT_Vector3 CcdPhysicsController::GetVelocity(const MT_Point3 &posin) { - btVector3 pos(pos.x(), pos.y(), pos.z()); + btVector3 pos(posin.x(), posin.y(), posin.z()); btRigidBody* body = GetRigidBody(); if (body) { -- cgit v1.2.3 From ee854a04fa8e38b00777eb65bbdb18dc409e3cab Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 4 Nov 2013 22:14:04 +0000 Subject: * Fix blenfont scons include after recent GE changes. Mitchell: Please check if these includes also need to be added in scons: https://projects.blender.org/scm/viewvc.php/trunk/blender/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt?root=bf-blender&r1=61087&r2=61086&pathrev=61087 --- source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index ce2f98b3837..6de29e65ac0 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -13,6 +13,7 @@ incs = [ '#extern/glew/include', '#intern/moto/include', '#source/blender/blenkernel', + '#source/blender/blenfont', '#source/blender/blenlib', '#source/blender/gpu', '#source/blender/makesdna', -- cgit v1.2.3 From 93de84f267157c7e8558b2595e0dcdbbd45df7eb Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 4 Nov 2013 22:22:54 +0000 Subject: Fix for recent BGE commits, when building with c++ guardedalloc. --- source/gameengine/Physics/Bullet/CcdPhysicsController.h | 5 +++++ source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index ecb894c1e8d..194a47ae2df 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -441,6 +441,11 @@ public: btVector3 vec = getWalkDirection(); return MT_Vector3(vec[0], vec[1], vec[2]); } + +#ifdef WITH_CXX_GUARDEDALLOC + using PHY_ICharacter::operator new; + using PHY_ICharacter::operator delete; +#endif }; ///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution. diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h index 5a803115553..bfa6e1a6cb7 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_IStorage.h @@ -28,6 +28,10 @@ #ifndef __KX_STORAGE #define __KX_STORAGE +#ifdef WITH_CXX_GUARDEDALLOC + #include "MEM_guardedalloc.h" +#endif + class RAS_MeshSlot; class RAS_IStorage @@ -46,9 +50,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IStorage"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IStorage") #endif }; -- cgit v1.2.3 From cbbf6bfe25adc83ec7112c2f8ad5748263f910ab Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 4 Nov 2013 22:33:02 +0000 Subject: * More fixes to make scons / Windows happy. :) --- source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript | 5 ++++- source/gameengine/Rasterizer/RAS_Polygon.h | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index 6de29e65ac0..0a7417656c6 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -18,9 +18,12 @@ incs = [ '#source/blender/gpu', '#source/blender/makesdna', '#source/gameengine/BlenderRoutines', + '#source/gameengine/Expressions', + '#source/gameengine/GameLogic', + '#source/gameengine/Physics/common', '#source/gameengine/Rasterizer', '#source/gameengine/SceneGraph', - '#source/blender/gameengine/Ketsji', + '#source/gameengine/Ketsji', env['BF_OPENGL_INC'], ] incs = ' '.join(incs) diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h index 665056c0ccc..b18477a72d2 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.h +++ b/source/gameengine/Rasterizer/RAS_Polygon.h @@ -36,8 +36,6 @@ class RAS_DisplayArray; class RAS_MaterialBucket; class RAS_TexVert; -using namespace std; - #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" #endif -- cgit v1.2.3 From 1de0e3c8c1de959a5ab68b4951a18bf4c7763139 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 4 Nov 2013 22:49:49 +0000 Subject: Interface: * Move the "Add" menu from the Info header into the 3D View header. Patch by Andrew Buttery (axb), with small tweaks by myself. (Patch ID #37241). Approved by Brecht and Jonathan. --- release/scripts/startup/bl_ui/space_info.py | 126 ------------------------ release/scripts/startup/bl_ui/space_view3d.py | 133 ++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 126 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 5a570d18312..6b0c1150f5d 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -37,7 +37,6 @@ class INFO_HT_header(Header): if context.area.show_menus: sub = row.row(align=True) sub.menu("INFO_MT_file") - sub.menu("INFO_MT_add") if rd.use_game_engine: sub.menu("INFO_MT_game") else: @@ -199,131 +198,6 @@ class INFO_MT_file_external_data(Menu): layout.operator("file.find_missing_files") -class INFO_MT_mesh_add(Menu): - bl_idname = "INFO_MT_mesh_add" - bl_label = "Mesh" - - def draw(self, context): - layout = self.layout - - layout.operator_context = 'INVOKE_REGION_WIN' - layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane") - layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube") - layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle") - layout.operator("mesh.primitive_uv_sphere_add", icon='MESH_UVSPHERE', text="UV Sphere") - layout.operator("mesh.primitive_ico_sphere_add", icon='MESH_ICOSPHERE', text="Icosphere") - layout.operator("mesh.primitive_cylinder_add", icon='MESH_CYLINDER', text="Cylinder") - layout.operator("mesh.primitive_cone_add", icon='MESH_CONE', text="Cone") - layout.separator() - layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid") - layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey") - layout.operator("mesh.primitive_torus_add", icon='MESH_TORUS', text="Torus") - - -class INFO_MT_curve_add(Menu): - bl_idname = "INFO_MT_curve_add" - bl_label = "Curve" - - def draw(self, context): - layout = self.layout - - layout.operator_context = 'INVOKE_REGION_WIN' - layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier") - layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle") - layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve") - layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle") - layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path") - - -class INFO_MT_surface_add(Menu): - bl_idname = "INFO_MT_surface_add" - bl_label = "Surface" - - def draw(self, context): - layout = self.layout - - layout.operator_context = 'INVOKE_REGION_WIN' - layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve") - layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle") - layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface") - layout.operator("surface.primitive_nurbs_surface_cylinder_add", icon='SURFACE_NCYLINDER', text="NURBS Cylinder") - layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere") - layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus") - - -class INFO_MT_edit_curve_add(Menu): - bl_idname = "INFO_MT_edit_curve_add" - bl_label = "Add" - - def draw(self, context): - is_surf = context.active_object.type == 'SURFACE' - - layout = self.layout - layout.operator_context = 'EXEC_REGION_WIN' - - if is_surf: - INFO_MT_surface_add.draw(self, context) - else: - INFO_MT_curve_add.draw(self, context) - - -class INFO_MT_armature_add(Menu): - bl_idname = "INFO_MT_armature_add" - bl_label = "Armature" - - def draw(self, context): - layout = self.layout - - layout.operator_context = 'EXEC_REGION_WIN' - layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA') - - -class INFO_MT_add(Menu): - bl_label = "Add" - - def draw(self, context): - layout = self.layout - - # note, don't use 'EXEC_SCREEN' or operators wont get the 'v3d' context. - - # Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents - # "align_view" to work on first call (see [#32719]). - layout.operator_context = 'EXEC_REGION_WIN' - - #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH') - layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH') - - #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE') - layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE') - #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE') - layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE') - layout.operator_context = 'INVOKE_REGION_WIN' - layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META') - layout.operator_context = 'EXEC_REGION_WIN' - layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT') - layout.separator() - - layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE') - layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE' - layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY') - layout.separator() - - layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER') - layout.separator() - - layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA') - layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP') - layout.separator() - - layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY') - layout.separator() - - if len(bpy.data.groups) > 10: - layout.operator_context = 'INVOKE_REGION_WIN' - layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY') - else: - layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY') - class INFO_MT_game(Menu): bl_label = "Game" diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index aa9eda40406..fd1f7f5c4bf 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -54,6 +54,9 @@ class VIEW3D_HT_header(Header): elif mode_string not in {'EDIT_TEXT', 'SCULPT'}: sub.menu("VIEW3D_MT_select_%s" % mode_string.lower()) + if mode_string in {'OBJECT', 'EDIT_MESH', 'EDIT_CURVE', 'EDIT_SURFACE', 'EDIT_METABALL'}: + sub.menu("INFO_MT_add") + if edit_object: sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower()) elif obj: @@ -132,6 +135,7 @@ class VIEW3D_HT_header(Header): # ********** Menu ********** + # ********** Utilities ********** @@ -816,6 +820,135 @@ class VIEW3D_MT_select_paint_mask_vertex(Menu): layout.operator("paint.vert_select_ungrouped", text="Ungrouped Verts") +# ********** Add menu ********** + +# XXX: INFO_MT_ names used to keep backwards compatibility (Addons etc that hook into the menu) + +class INFO_MT_mesh_add(Menu): + bl_idname = "INFO_MT_mesh_add" + bl_label = "Mesh" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'INVOKE_REGION_WIN' + layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane") + layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube") + layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle") + layout.operator("mesh.primitive_uv_sphere_add", icon='MESH_UVSPHERE', text="UV Sphere") + layout.operator("mesh.primitive_ico_sphere_add", icon='MESH_ICOSPHERE', text="Icosphere") + layout.operator("mesh.primitive_cylinder_add", icon='MESH_CYLINDER', text="Cylinder") + layout.operator("mesh.primitive_cone_add", icon='MESH_CONE', text="Cone") + layout.separator() + layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid") + layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey") + layout.operator("mesh.primitive_torus_add", icon='MESH_TORUS', text="Torus") + + +class INFO_MT_curve_add(Menu): + bl_idname = "INFO_MT_curve_add" + bl_label = "Curve" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'INVOKE_REGION_WIN' + layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier") + layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle") + layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve") + layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle") + layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path") + + +class INFO_MT_surface_add(Menu): + bl_idname = "INFO_MT_surface_add" + bl_label = "Surface" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'INVOKE_REGION_WIN' + layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve") + layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle") + layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface") + layout.operator("surface.primitive_nurbs_surface_cylinder_add", icon='SURFACE_NCYLINDER', text="NURBS Cylinder") + layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere") + layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus") + + +class INFO_MT_edit_curve_add(Menu): + bl_idname = "INFO_MT_edit_curve_add" + bl_label = "Add" + + def draw(self, context): + is_surf = context.active_object.type == 'SURFACE' + + layout = self.layout + layout.operator_context = 'EXEC_REGION_WIN' + + if is_surf: + INFO_MT_surface_add.draw(self, context) + else: + INFO_MT_curve_add.draw(self, context) + + +class INFO_MT_armature_add(Menu): + bl_idname = "INFO_MT_armature_add" + bl_label = "Armature" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'EXEC_REGION_WIN' + layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA') + + +class INFO_MT_add(Menu): + bl_label = "Add" + + def draw(self, context): + layout = self.layout + + # note, don't use 'EXEC_SCREEN' or operators wont get the 'v3d' context. + + # Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents + # "align_view" to work on first call (see [#32719]). + layout.operator_context = 'EXEC_REGION_WIN' + + #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH') + layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH') + + #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE') + layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE') + #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE') + layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE') + layout.operator_context = 'INVOKE_REGION_WIN' + layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META') + layout.operator_context = 'EXEC_REGION_WIN' + layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT') + layout.separator() + + layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE') + layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE' + layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY') + layout.separator() + + layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER') + layout.separator() + + layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA') + layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP') + layout.separator() + + layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY') + layout.separator() + + if len(bpy.data.groups) > 10: + layout.operator_context = 'INVOKE_REGION_WIN' + layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY') + else: + layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY') + # ********** Object menu ********** -- cgit v1.2.3 From 26dc289d99a09406b38d87d8963db05328da711c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 4 Nov 2013 23:33:23 +0000 Subject: Fix [#37315] Mirror+MeshDeform cause crash when Vertex Group is referred One hour of efforts to spot such a small dummy typo! --- source/blender/modifiers/intern/MOD_meshdeform.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 8386f0ff9af..e540d5c1b2c 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -199,10 +199,10 @@ static void meshdeformModifier_do( if (!mmd->object || (!mmd->bindcagecos && !mmd->bindfunc)) return; - + /* get cage derivedmesh */ if (em) { - tmpdm = editbmesh_get_derived_cage_and_final(md->scene, ob, em, &cagedm, 0); + tmpdm = editbmesh_get_derived_cage_and_final(md->scene, mmd->object, em, &cagedm, 0); if (tmpdm) tmpdm->release(tmpdm); } @@ -346,7 +346,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false); modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ - + meshdeformModifier_do(md, ob, dm, vertexCos, numVerts); if (dm && dm != derivedData) -- cgit v1.2.3 From 737239c4c4f1b422c741d53b19bf21939d7382c3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 5 Nov 2013 00:19:21 +0000 Subject: Bugfix [#36844] Cannot set Restrict Frame Start for FModifiers until Frame End has been adjusted Previously, the RNA settings tried to strictly enforce the constraint that the start frame must be less than the end frame. However, this behaviour was problematic, as it meant that you had to firstly move the end frame to its new (higher) value, before moving the start frame. The same also applied in the opposite direction. Now, this behaves in the same way that the scene start/end buttons work: if the new start frame is past the end frame, the end frame is "pushed" along to be the same value as the start frame. The same applies in the opposite direction. --- source/blender/makesrna/intern/rna_fcurve.c | 60 +++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 4b50127d999..3d236b1d1bd 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -453,28 +453,66 @@ static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, Pointe static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value)) { - FModifier *fm = (FModifier *)ptr->data; + FModifier *fcm = (FModifier *)ptr->data; /* don't toggle, always switch on */ - fm->flag |= FMODIFIER_FLAG_ACTIVE; + fcm->flag |= FMODIFIER_FLAG_ACTIVE; +} + +static void rna_FModifier_start_frame_set(PointerRNA *ptr, float value) +{ + FModifier *fcm = (FModifier *)ptr->data; + + CLAMP(value, MINAFRAME, MAXFRAME); + fcm->sfra = value; + + /* XXX: maintain old offset? */ + if (fcm->sfra >= fcm->efra) { + fcm->efra = fcm->sfra; + } +} + +static void rna_FModifer_end_frame_set(PointerRNA *ptr, float value) +{ + FModifier *fcm = (FModifier *)ptr->data; + + CLAMP(value, MINAFRAME, MAXFRAME); + fcm->efra = value; + + /* XXX: maintain old offset? */ + if (fcm->efra <= fcm->sfra) { + fcm->sfra = fcm->efra; + } } static void rna_FModifier_start_frame_range(PointerRNA *ptr, float *min, float *max, - float *UNUSED(softmin), float *UNUSED(softmax)) + float *softmin, float *softmax) { FModifier *fcm = (FModifier *)ptr->data; - *min = MINAFRAMEF; - *max = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->efra : MAXFRAMEF; + /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that, + * or else it becomes tricky to adjust the range... [#36844] + */ + *min = MINAFRAMEF; + *softmin = MINAFRAMEF; + + *softmax = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->efra : MAXFRAMEF; + *max = MAXFRAMEF; } static void rna_FModifier_end_frame_range(PointerRNA *ptr, float *min, float *max, - float *UNUSED(softmin), float *UNUSED(softmax)) + float *softmin, float *softmax) { FModifier *fcm = (FModifier *)ptr->data; - - *min = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->sfra : MINAFRAMEF; - *max = MAXFRAMEF; + + /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that, + * or else it becomes tricky to adjust the range... [#36844] + */ + *min = MINAFRAMEF; + *softmin = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->sfra : MINAFRAMEF; + + *softmax = MAXFRAMEF; + *max = MAXFRAMEF; } static void rna_FModifier_blending_range(PointerRNA *ptr, float *min, float *max, @@ -1191,14 +1229,14 @@ static void rna_def_fmodifier(BlenderRNA *brna) prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "sfra"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_start_frame_range"); + RNA_def_property_float_funcs(prop, NULL, "rna_FModifier_start_frame_set", "rna_FModifier_start_frame_range"); RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if Restrict Frame Range is in use)"); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "efra"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_end_frame_range"); + RNA_def_property_float_funcs(prop, NULL, "rna_FModifer_end_frame_set", "rna_FModifier_end_frame_range"); RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's influence ends (if Restrict Frame Range is in use)"); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); -- cgit v1.2.3 From 8c5597eb4964086c715b7d0038ddb4c6cb718296 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Tue, 5 Nov 2013 00:51:59 +0000 Subject: Additional code improvements: avoid unnecessary Python object allocations in Freestyle. --- .../freestyle/intern/python/BPy_Convert.cpp | 193 +++++++++++---------- .../blender/freestyle/intern/python/BPy_Convert.h | 28 +-- .../freestyle/intern/python/BPy_FrsNoise.cpp | 28 ++- .../intern/python/BPy_StrokeAttribute.cpp | 14 +- .../blender/freestyle/intern/python/Director.cpp | 28 +-- .../intern/python/Interface0D/BPy_SVertex.cpp | 8 +- 6 files changed, 154 insertions(+), 145 deletions(-) diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp index bb907ec572c..56c096a1eae 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.cpp +++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp @@ -512,103 +512,100 @@ Nature::EdgeNature EdgeNature_from_BPy_Nature(PyObject *obj) return static_cast(PyLong_AsLong(obj)); } -Vec2f *Vec2f_ptr_from_PyObject(PyObject *obj) -{ - Vec2f *v; - if ((v = Vec2f_ptr_from_Vector(obj))) - return v; - if ((v = Vec2f_ptr_from_PyList(obj))) - return v; - if ((v = Vec2f_ptr_from_PyTuple(obj))) - return v; - return NULL; +bool Vec2f_ptr_from_PyObject(PyObject *obj, Vec2f *vec) +{ + if (Vec2f_ptr_from_Vector(obj, vec)) + return true; + if (Vec2f_ptr_from_PyList(obj, vec)) + return true; + if (Vec2f_ptr_from_PyTuple(obj, vec)) + return true; + return false; } -Vec3f *Vec3f_ptr_from_PyObject(PyObject *obj) +bool Vec3f_ptr_from_PyObject(PyObject *obj, Vec3f *vec) { - Vec3f *v; - if ((v = Vec3f_ptr_from_Vector(obj))) - return v; - if ((v = Vec3f_ptr_from_Color(obj))) - return v; - if ((v = Vec3f_ptr_from_PyList(obj))) - return v; - if ((v = Vec3f_ptr_from_PyTuple(obj))) - return v; - return NULL; + if (Vec3f_ptr_from_Vector(obj, vec)) + return true; + if (Vec3f_ptr_from_Color(obj, vec)) + return true; + if (Vec3f_ptr_from_PyList(obj, vec)) + return true; + if (Vec3f_ptr_from_PyTuple(obj, vec)) + return true; + return false; } -Vec3r *Vec3r_ptr_from_PyObject(PyObject *obj) +bool Vec3r_ptr_from_PyObject(PyObject *obj, Vec3r *vec) { - Vec3r *v; - if ((v = Vec3r_ptr_from_Vector(obj))) - return v; - if ((v = Vec3r_ptr_from_Color(obj))) - return v; - if ((v = Vec3r_ptr_from_PyList(obj))) - return v; - if ((v = Vec3r_ptr_from_PyTuple(obj))) - return v; - return NULL; + if (Vec3r_ptr_from_Vector(obj, vec)) + return true; + if (Vec3r_ptr_from_Color(obj, vec)) + return true; + if (Vec3r_ptr_from_PyList(obj, vec)) + return true; + if (Vec3r_ptr_from_PyTuple(obj, vec)) + return true; + return false; } -Vec2f *Vec2f_ptr_from_Vector(PyObject *obj) +bool Vec2f_ptr_from_Vector(PyObject *obj, Vec2f *vec) { if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 2) - return NULL; + return false; if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) - return NULL; - float x = ((VectorObject *)obj)->vec[0]; - float y = ((VectorObject *)obj)->vec[1]; - return new Vec2f(x, y); + return false; + vec[0] = ((VectorObject *)obj)->vec[0]; + vec[1] = ((VectorObject *)obj)->vec[1]; + return true; } -Vec3f *Vec3f_ptr_from_Vector(PyObject *obj) +bool Vec3f_ptr_from_Vector(PyObject *obj, Vec3f *vec) { if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3) - return NULL; + return false; if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) - return NULL; - float x = ((VectorObject *)obj)->vec[0]; - float y = ((VectorObject *)obj)->vec[1]; - float z = ((VectorObject *)obj)->vec[2]; - return new Vec3f(x, y, z); + return false; + vec[0] = ((VectorObject *)obj)->vec[0]; + vec[1] = ((VectorObject *)obj)->vec[1]; + vec[2] = ((VectorObject *)obj)->vec[2]; + return true; } -Vec3r *Vec3r_ptr_from_Vector(PyObject *obj) +bool Vec3r_ptr_from_Vector(PyObject *obj, Vec3r *vec) { if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3) - return NULL; + return false; if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) - return NULL; - real x = ((VectorObject *)obj)->vec[0]; - real y = ((VectorObject *)obj)->vec[1]; - real z = ((VectorObject *)obj)->vec[2]; - return new Vec3r(x, y, z); + return false; + vec[0] = ((VectorObject *)obj)->vec[0]; + vec[1] = ((VectorObject *)obj)->vec[1]; + vec[2] = ((VectorObject *)obj)->vec[2]; + return true; } -Vec3f *Vec3f_ptr_from_Color(PyObject *obj) +bool Vec3f_ptr_from_Color(PyObject *obj, Vec3f *vec) { if (!ColorObject_Check(obj)) - return NULL; + return false; if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) - return NULL; - float r = ((ColorObject *)obj)->col[0]; - float g = ((ColorObject *)obj)->col[1]; - float b = ((ColorObject *)obj)->col[2]; - return new Vec3f(r, g, b); + return false; + vec[0] = ((ColorObject *)obj)->col[0]; + vec[1] = ((ColorObject *)obj)->col[1]; + vec[2] = ((ColorObject *)obj)->col[2]; + return true; } -Vec3r *Vec3r_ptr_from_Color(PyObject *obj) +bool Vec3r_ptr_from_Color(PyObject *obj, Vec3r *vec) { if (!ColorObject_Check(obj)) - return NULL; + return false; if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) - return NULL; - real r = ((ColorObject *)obj)->col[0]; - real g = ((ColorObject *)obj)->col[1]; - real b = ((ColorObject *)obj)->col[2]; - return new Vec3r(r, g, b); + return false; + vec[0] = ((ColorObject *)obj)->col[0]; + vec[1] = ((ColorObject *)obj)->col[1]; + vec[2] = ((ColorObject *)obj)->col[2]; + return true; } static int float_array_from_PyList(PyObject *obj, float *v, int n) @@ -623,37 +620,45 @@ static int float_array_from_PyList(PyObject *obj, float *v, int n) return 1; } -Vec2f *Vec2f_ptr_from_PyList(PyObject *obj) +bool Vec2f_ptr_from_PyList(PyObject *obj, Vec2f *vec) { float v[2]; if (!PyList_Check(obj) || PyList_Size(obj) != 2) - return NULL; + return false; if (!float_array_from_PyList(obj, v, 2)) - return NULL; - return new Vec2f(v[0], v[1]); + return false; + vec[0] = v[0]; + vec[1] = v[1]; + return true; } -Vec3f *Vec3f_ptr_from_PyList(PyObject *obj) +bool Vec3f_ptr_from_PyList(PyObject *obj, Vec3f *vec) { float v[3]; if (!PyList_Check(obj) || PyList_Size(obj) != 3) - return NULL; + return false; if (!float_array_from_PyList(obj, v, 3)) - return NULL; - return new Vec3f(v[0], v[1], v[2]); + return false; + vec[0] = v[0]; + vec[1] = v[1]; + vec[2] = v[2]; + return true; } -Vec3r *Vec3r_ptr_from_PyList(PyObject *obj) +bool Vec3r_ptr_from_PyList(PyObject *obj, Vec3r *vec) { float v[3]; if (!PyList_Check(obj) || PyList_Size(obj) != 3) - return NULL; + return false; if (!float_array_from_PyList(obj, v, 3)) - return NULL; - return new Vec3r(v[0], v[1], v[2]); + return false; + vec[0] = v[0]; + vec[1] = v[1]; + vec[2] = v[2]; + return true; } static int float_array_from_PyTuple(PyObject *obj, float *v, int n) @@ -668,37 +673,45 @@ static int float_array_from_PyTuple(PyObject *obj, float *v, int n) return 1; } -Vec2f *Vec2f_ptr_from_PyTuple(PyObject *obj) +bool Vec2f_ptr_from_PyTuple(PyObject *obj, Vec2f *vec) { float v[2]; if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 2) - return NULL; + return false; if (!float_array_from_PyTuple(obj, v, 2)) - return NULL; - return new Vec2f(v[0], v[1]); + return false; + vec[0] = v[0]; + vec[1] = v[1]; + return true; } -Vec3f *Vec3f_ptr_from_PyTuple(PyObject *obj) +bool Vec3f_ptr_from_PyTuple(PyObject *obj, Vec3f *vec) { float v[3]; if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3) - return NULL; + return false; if (!float_array_from_PyTuple(obj, v, 3)) - return NULL; - return new Vec3f(v[0], v[1], v[2]); + return false; + vec[0] = v[0]; + vec[1] = v[1]; + vec[2] = v[2]; + return true; } -Vec3r *Vec3r_ptr_from_PyTuple(PyObject *obj) +bool Vec3r_ptr_from_PyTuple(PyObject *obj, Vec3r *vec) { float v[3]; if (!PyTuple_Check(obj) || PyTuple_Size(obj) != 3) - return NULL; + return false; if (!float_array_from_PyTuple(obj, v, 3)) - return NULL; - return new Vec3r(v[0], v[1], v[2]); + return false; + vec[0] = v[0]; + vec[1] = v[1]; + vec[2] = v[2]; + return true; } // helper for argument parsing diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h index 1df4901757b..a8bc7eaa306 100644 --- a/source/blender/freestyle/intern/python/BPy_Convert.h +++ b/source/blender/freestyle/intern/python/BPy_Convert.h @@ -150,20 +150,20 @@ bool bool_from_PyBool(PyObject *b); IntegrationType IntegrationType_from_BPy_IntegrationType(PyObject *obj); Stroke::MediumType MediumType_from_BPy_MediumType(PyObject *obj); Nature::EdgeNature EdgeNature_from_BPy_Nature(PyObject *obj); -Vec2f * Vec2f_ptr_from_PyObject(PyObject *obj); -Vec3f * Vec3f_ptr_from_PyObject(PyObject *obj); -Vec3r * Vec3r_ptr_from_PyObject(PyObject *obj); -Vec2f * Vec2f_ptr_from_Vector(PyObject *obj); -Vec3f * Vec3f_ptr_from_Vector(PyObject *obj); -Vec3r * Vec3r_ptr_from_Vector(PyObject *obj); -Vec3f * Vec3f_ptr_from_Color(PyObject *obj); -Vec3r * Vec3r_ptr_from_Color(PyObject *obj); -Vec2f * Vec2f_ptr_from_PyList(PyObject *obj); -Vec3f * Vec3f_ptr_from_PyList(PyObject *obj); -Vec3r * Vec3r_ptr_from_PyList(PyObject *obj); -Vec2f * Vec2f_ptr_from_PyTuple(PyObject *obj); -Vec3f * Vec3f_ptr_from_PyTuple(PyObject *obj); -Vec3r * Vec3r_ptr_from_PyTuple(PyObject *obj); +bool Vec2f_ptr_from_PyObject(PyObject *obj, Vec2f *vec); +bool Vec3f_ptr_from_PyObject(PyObject *obj, Vec3f *vec); +bool Vec3r_ptr_from_PyObject(PyObject *obj, Vec3r *vec); +bool Vec2f_ptr_from_Vector(PyObject *obj, Vec2f *vec); +bool Vec3f_ptr_from_Vector(PyObject *obj, Vec3f *vec); +bool Vec3r_ptr_from_Vector(PyObject *obj, Vec3r *vec); +bool Vec3f_ptr_from_Color(PyObject *obj, Vec3f *vec); +bool Vec3r_ptr_from_Color(PyObject *obj, Vec3r *vec); +bool Vec2f_ptr_from_PyList(PyObject *obj, Vec2f *vec); +bool Vec3f_ptr_from_PyList(PyObject *obj, Vec3f *vec); +bool Vec3r_ptr_from_PyList(PyObject *obj, Vec3r *vec); +bool Vec2f_ptr_from_PyTuple(PyObject *obj, Vec2f *vec); +bool Vec3f_ptr_from_PyTuple(PyObject *obj, Vec3f *vec); +bool Vec3r_ptr_from_PyTuple(PyObject *obj, Vec3r *vec); int float_array_from_PyObject(PyObject *obj, float *v, int n); diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp index abdcbaff6e1..2575b16b27a 100644 --- a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp +++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp @@ -132,16 +132,15 @@ static PyObject *FrsNoise_turbulence2(BPy_FrsNoise *self, PyObject *args, PyObje PyObject *obj1; float f2, f3; unsigned int i = 4; + Vec2f vec; if (!PyArg_ParseTupleAndKeywords(args, kwds, "Off|I", (char **)kwlist, &obj1, &f2, &f3, &i)) return NULL; - Vec2f *v = Vec2f_ptr_from_PyObject(obj1); - if (!v) { + if (!Vec2f_ptr_from_PyObject(obj1, &vec)) { PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)"); return NULL; } - float t = self->n->turbulence2(*v, f2, f3, i); - delete v; + float t = self->n->turbulence2(vec, f2, f3, i); return PyFloat_FromDouble(t); } @@ -167,16 +166,15 @@ static PyObject *FrsNoise_turbulence3(BPy_FrsNoise *self, PyObject *args, PyObje PyObject *obj1; float f2, f3; unsigned int i = 4; + Vec3f vec; if (!PyArg_ParseTupleAndKeywords(args, kwds, "Off|I", (char **)kwlist, &obj1, &f2, &f3, &i)) return NULL; - Vec3f *v = Vec3f_ptr_from_PyObject(obj1); - if (!v) { + if (!Vec3f_ptr_from_PyObject(obj1, &vec)) { PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); return NULL; } - float t = self->n->turbulence3(*v, f2, f3, i); - delete v; + float t = self->n->turbulence3(vec, f2, f3, i); return PyFloat_FromDouble(t); } @@ -214,16 +212,15 @@ static PyObject *FrsNoise_smoothNoise2(BPy_FrsNoise *self, PyObject *args, PyObj { static const char *kwlist[] = {"v", NULL}; PyObject *obj; + Vec2f vec; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) return NULL; - Vec2f *v = Vec2f_ptr_from_PyObject(obj); - if (!v) { + if (!Vec2f_ptr_from_PyObject(obj, &vec)) { PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)"); return NULL; } - float t = self->n->smoothNoise2(*v); - delete v; + float t = self->n->smoothNoise2(vec); return PyFloat_FromDouble(t); } @@ -241,16 +238,15 @@ static PyObject *FrsNoise_smoothNoise3(BPy_FrsNoise *self, PyObject *args, PyObj { static const char *kwlist[] = {"v", NULL}; PyObject *obj; + Vec3f vec; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) return NULL; - Vec3f *v = Vec3f_ptr_from_PyObject(obj); - if (!v) { + if (!Vec3f_ptr_from_PyObject(obj, &vec)) { PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); return NULL; } - float t = self->n->smoothNoise3(*v); - delete v; + float t = self->n->smoothNoise3(vec); return PyFloat_FromDouble(t); } diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp index e17f16a2fa7..b08fcfa8dba 100644 --- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp +++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp @@ -311,16 +311,15 @@ static PyObject * StrokeAttribute_set_attribute_vec2(BPy_StrokeAttribute *self, static const char *kwlist[] = {"name", "value", NULL}; char *s; PyObject *obj = 0; + Vec2f vec; if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", (char **)kwlist, &s, &obj)) return NULL; - Vec2f *v = Vec2f_ptr_from_PyObject(obj); - if (!v) { + if (!Vec2f_ptr_from_PyObject(obj, &vec)) { PyErr_SetString(PyExc_TypeError, "argument 2 must be a 2D vector (either a list of 2 elements or Vector)"); return NULL; } - self->sa->setAttributeVec2f(s, *v); - delete v; + self->sa->setAttributeVec2f(s, vec); Py_RETURN_NONE; } @@ -341,16 +340,15 @@ static PyObject * StrokeAttribute_set_attribute_vec3(BPy_StrokeAttribute *self, static const char *kwlist[] = {"name", "value", NULL}; char *s; PyObject *obj = 0; + Vec3f vec; if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", (char **)kwlist, &s, &obj)) return NULL; - Vec3f *v = Vec3f_ptr_from_PyObject(obj); - if (!v) { + if (!Vec3f_ptr_from_PyObject(obj, &vec)) { PyErr_SetString(PyExc_TypeError, "argument 2 must be a 3D vector (either a list of 3 elements or Vector)"); return NULL; } - self->sa->setAttributeVec3f(s, *v); - delete v; + self->sa->setAttributeVec3f(s, vec); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Director.cpp b/source/blender/freestyle/intern/python/Director.cpp index cd6f9da3e05..011609bb343 100644 --- a/source/blender/freestyle/intern/python/Director.cpp +++ b/source/blender/freestyle/intern/python/Director.cpp @@ -251,14 +251,16 @@ int Director_BPy_UnaryFunction0D___call__(void *uf0D, PyObject *obj, Interface0D ((UnaryFunction0D *)uf0D)->result = PyLong_AsLong(result); } else if (BPy_UnaryFunction0DVec2f_Check(obj)) { - Vec2f *v = Vec2f_ptr_from_Vector(result); - ((UnaryFunction0D *)uf0D)->result = *v; - delete v; + Vec2f vec; + if (!Vec2f_ptr_from_Vector(result, &vec)) + return -1; + ((UnaryFunction0D *)uf0D)->result = vec; } else if (BPy_UnaryFunction0DVec3f_Check(obj)) { - Vec3f *v = Vec3f_ptr_from_Vector(result); - ((UnaryFunction0D *)uf0D)->result = *v; - delete v; + Vec3f vec; + if (!Vec3f_ptr_from_Vector(result, &vec)) + return -1; + ((UnaryFunction0D *)uf0D)->result = vec; } else if (BPy_UnaryFunction0DVectorViewShape_Check(obj)) { vector vec; @@ -301,14 +303,16 @@ int Director_BPy_UnaryFunction1D___call__(void *uf1D, PyObject *obj, Interface1D ((UnaryFunction1D *)uf1D)->result = PyLong_AsLong(result); } else if (BPy_UnaryFunction1DVec2f_Check(obj)) { - Vec2f *v = Vec2f_ptr_from_Vector(result); - ((UnaryFunction1D *)uf1D)->result = *v; - delete v; + Vec2f vec; + if (!Vec2f_ptr_from_Vector(result, &vec)) + return -1; + ((UnaryFunction1D *)uf1D)->result = vec; } else if (BPy_UnaryFunction1DVec3f_Check(obj)) { - Vec3f *v = Vec3f_ptr_from_Vector(result); - ((UnaryFunction1D *)uf1D)->result = *v; - delete v; + Vec3f vec; + if (!Vec3f_ptr_from_Vector(result, &vec)) + return -1; + ((UnaryFunction1D *)uf1D)->result = vec; } else if (BPy_UnaryFunction1DVectorViewShape_Check(obj)) { vector vec; diff --git a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp index 3205a3a3d7e..d2dd1657770 100644 --- a/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/BPy_SVertex.cpp @@ -107,17 +107,15 @@ static PyObject *SVertex_add_normal(BPy_SVertex *self, PyObject *args, PyObject { static const char *kwlist[] = {"normal", NULL}; PyObject *py_normal; + Vec3r n; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &py_normal)) return NULL; - Vec3r *n = Vec3r_ptr_from_PyObject(py_normal); - if (!n) { + if (!Vec3r_ptr_from_PyObject(py_normal, &n)) { PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)"); return NULL; } - self->sv->AddNormal(*n); - delete n; - + self->sv->AddNormal(n); Py_RETURN_NONE; } -- cgit v1.2.3 From 1241f868e92409898fcac8f9798d630c52f7c15a Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 5 Nov 2013 01:04:23 +0000 Subject: Applying same fix used for [#36844] to Limits FModifier settings --- source/blender/makesrna/intern/rna_fcurve.c | 101 ++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 20 deletions(-) diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 3d236b1d1bd..212c1ff118c 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -565,44 +565,105 @@ static void rna_FModifierGenerator_coefficients_set(PointerRNA *ptr, const float memcpy(gen->coefficients, values, gen->arraysize * sizeof(float)); } -static void rna_FModifierLimits_minx_range(PointerRNA *ptr, float *min, float *max, - float *UNUSED(softmin), float *UNUSED(softmax)) + +static void rna_FModifierLimits_minx_set(PointerRNA *ptr, float value) { FModifier *fcm = (FModifier *)ptr->data; FMod_Limits *data = fcm->data; + + data->rect.xmin = value; + + if (data->rect.xmin >= data->rect.xmax) { + data->rect.xmax = data->rect.xmin; + } +} - *min = MINAFRAMEF; - *max = (data->flag & FCM_LIMIT_XMAX) ? data->rect.xmax : MAXFRAMEF; +static void rna_FModifierLimits_maxx_set(PointerRNA *ptr, float value) +{ + FModifier *fcm = (FModifier *)ptr->data; + FMod_Limits *data = fcm->data; + + data->rect.xmax = value; + + if (data->rect.xmax <= data->rect.xmin) { + data->rect.xmin = data->rect.xmax; + } } -static void rna_FModifierLimits_maxx_range(PointerRNA *ptr, float *min, float *max, - float *UNUSED(softmin), float *UNUSED(softmax)) +static void rna_FModifierLimits_miny_set(PointerRNA *ptr, float value) { FModifier *fcm = (FModifier *)ptr->data; FMod_Limits *data = fcm->data; + + data->rect.ymin = value; + + if (data->rect.ymin >= data->rect.ymax) { + data->rect.ymax = data->rect.ymin; + } +} - *min = (data->flag & FCM_LIMIT_XMIN) ? data->rect.xmin : MINAFRAMEF; - *max = MAXFRAMEF; +static void rna_FModifierLimits_maxy_set(PointerRNA *ptr, float value) +{ + FModifier *fcm = (FModifier *)ptr->data; + FMod_Limits *data = fcm->data; + + data->rect.ymax = value; + + if (data->rect.ymax <= data->rect.ymin) { + data->rect.ymin = data->rect.ymax; + } } -static void rna_FModifierLimits_miny_range(PointerRNA *ptr, float *min, float *max, - float *UNUSED(softmin), float *UNUSED(softmax)) +static void rna_FModifierLimits_minx_range(PointerRNA *ptr, float *min, float *max, + float *softmin, float *softmax) { FModifier *fcm = (FModifier *)ptr->data; FMod_Limits *data = fcm->data; + + *min = MINAFRAMEF; + *softmin = MINAFRAMEF; + + *softmax = (data->flag & FCM_LIMIT_XMAX) ? data->rect.xmax : MAXFRAMEF; + *max = MAXFRAMEF; +} + +static void rna_FModifierLimits_maxx_range(PointerRNA *ptr, float *min, float *max, + float *softmin, float *softmax) +{ + FModifier *fcm = (FModifier *)ptr->data; + FMod_Limits *data = fcm->data; + + *min = MINAFRAMEF; + *softmin = (data->flag & FCM_LIMIT_XMIN) ? data->rect.xmin : MINAFRAMEF; + + *softmax = MAXFRAMEF; + *max = MAXFRAMEF; +} - *min = -FLT_MAX; - *max = (data->flag & FCM_LIMIT_YMAX) ? data->rect.ymax : FLT_MAX; +static void rna_FModifierLimits_miny_range(PointerRNA *ptr, float *min, float *max, + float *softmin, float *softmax) +{ + FModifier *fcm = (FModifier *)ptr->data; + FMod_Limits *data = fcm->data; + + *min = -FLT_MAX; + *softmin = -FLT_MAX; + + *softmax = (data->flag & FCM_LIMIT_YMAX) ? data->rect.ymax : FLT_MAX; + *max = FLT_MAX; } static void rna_FModifierLimits_maxy_range(PointerRNA *ptr, float *min, float *max, - float *UNUSED(softmin), float *UNUSED(softmax)) + float *softmin, float *softmax) { FModifier *fcm = (FModifier *)ptr->data; FMod_Limits *data = fcm->data; - - *min = (data->flag & FCM_LIMIT_YMIN) ? data->rect.ymin : -FLT_MAX; - *max = FLT_MAX; + + *min = -FLT_MAX; + *softmin = (data->flag & FCM_LIMIT_YMIN) ? data->rect.ymin : -FLT_MAX; + + *softmax = FLT_MAX; + *max = FLT_MAX; } @@ -1046,25 +1107,25 @@ static void rna_def_fmodifier_limits(BlenderRNA *brna) prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rect.xmin"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_minx_range"); + RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_minx_set", "rna_FModifierLimits_minx_range"); RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow"); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rect.ymin"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_miny_range"); + RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_miny_set", "rna_FModifierLimits_miny_range"); RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow"); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rect.xmax"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxx_range"); + RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_maxx_set", "rna_FModifierLimits_maxx_range"); RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow"); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rect.ymax"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxy_range"); + RNA_def_property_float_funcs(prop, NULL, "rna_FModifierLimits_maxy_set", "rna_FModifierLimits_maxy_range"); RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow"); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } -- cgit v1.2.3 From d504cee1208dc8d78e4ac2a69ef1919b7ef4127c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 5 Nov 2013 01:20:30 +0000 Subject: Remove soft limits from lower-end of ranges for last two commits - This turned out to be too restrictive/confusing again. --- source/blender/makesrna/intern/rna_fcurve.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 212c1ff118c..4809291e35e 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -463,7 +463,7 @@ static void rna_FModifier_start_frame_set(PointerRNA *ptr, float value) { FModifier *fcm = (FModifier *)ptr->data; - CLAMP(value, MINAFRAME, MAXFRAME); + CLAMP(value, MINAFRAMEF, MAXFRAMEF); fcm->sfra = value; /* XXX: maintain old offset? */ @@ -476,7 +476,7 @@ static void rna_FModifer_end_frame_set(PointerRNA *ptr, float value) { FModifier *fcm = (FModifier *)ptr->data; - CLAMP(value, MINAFRAME, MAXFRAME); + CLAMP(value, MINAFRAMEF, MAXFRAMEF); fcm->efra = value; /* XXX: maintain old offset? */ @@ -492,11 +492,11 @@ static void rna_FModifier_start_frame_range(PointerRNA *ptr, float *min, float * /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that, * or else it becomes tricky to adjust the range... [#36844] + * + * NOTE: we do not set soft-limits on lower bounds, as it's too confusing when you + * can't easily use the slider to set things here */ *min = MINAFRAMEF; - *softmin = MINAFRAMEF; - - *softmax = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->efra : MAXFRAMEF; *max = MAXFRAMEF; } @@ -615,15 +615,13 @@ static void rna_FModifierLimits_maxy_set(PointerRNA *ptr, float value) } static void rna_FModifierLimits_minx_range(PointerRNA *ptr, float *min, float *max, - float *softmin, float *softmax) + float *UNUSED(softmin), float *UNUSED(softmax)) { FModifier *fcm = (FModifier *)ptr->data; FMod_Limits *data = fcm->data; + /* no soft-limits on lower bound - it's too confusing when you can't easily use the slider to set things here */ *min = MINAFRAMEF; - *softmin = MINAFRAMEF; - - *softmax = (data->flag & FCM_LIMIT_XMAX) ? data->rect.xmax : MAXFRAMEF; *max = MAXFRAMEF; } @@ -646,10 +644,8 @@ static void rna_FModifierLimits_miny_range(PointerRNA *ptr, float *min, float *m FModifier *fcm = (FModifier *)ptr->data; FMod_Limits *data = fcm->data; + /* no soft-limits on lower bound - it's too confusing when you can't easily use the slider to set things here */ *min = -FLT_MAX; - *softmin = -FLT_MAX; - - *softmax = (data->flag & FCM_LIMIT_YMAX) ? data->rect.ymax : FLT_MAX; *max = FLT_MAX; } -- cgit v1.2.3 From 98be88653d43ee04990f7ee7413b7475aef0eea2 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 5 Nov 2013 01:29:45 +0000 Subject: Bugfix [#37304] Arrow Keys Stop Working When Mouse Over Outliner Frame change hotkeys now work in the following places: 1) Outliner - Main region 2) Action/NLA Editors - Channels Region 3) Info View - Reports region Other places identified by the bugreport (but which I've decided to leave alone): - Text Editor (when no file open) - The way the keymaps work here means that this can't be done without affecting normal text editing - File Browser - What's the point of changing frames when you're about to open/save the file? - User Prefs - Is there any real point here either? Also, this is usually shown in a separate window. --- source/blender/editors/space_action/space_action.c | 2 +- source/blender/editors/space_info/space_info.c | 2 +- source/blender/editors/space_nla/space_nla.c | 2 +- source/blender/editors/space_outliner/space_outliner.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index a89a02b7e01..fdccedd9c3c 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -541,7 +541,7 @@ void ED_spacetype_action(void) art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = 200; - art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; art->init = action_channel_area_init; art->draw = action_channel_area_draw; diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 07f4b64d187..aaa52597357 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -327,7 +327,7 @@ void ED_spacetype_info(void) /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype info region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; art->init = info_main_area_init; art->draw = info_main_area_draw; diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 4d4f27cf1ad..d0ba33358e4 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -544,7 +544,7 @@ void ED_spacetype_nla(void) art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = 200; - art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; art->init = nla_channel_area_init; art->draw = nla_channel_area_draw; diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index d695ffa46d5..3a7d001f432 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -476,9 +476,9 @@ void ED_spacetype_outliner(void) st->dropboxes = outliner_dropboxes; /* regions: main window */ - art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype outliner region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; art->init = outliner_main_area_init; art->draw = outliner_main_area_draw; @@ -487,7 +487,7 @@ void ED_spacetype_outliner(void) BLI_addhead(&st->regiontypes, art); /* regions: header */ - art = MEM_callocN(sizeof(ARegionType), "spacetype time header region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype outliner header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; -- cgit v1.2.3 From 7a10bacaf9261d39e6bd1f244e4b8fc1eb99d8ea Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 5 Nov 2013 01:44:38 +0000 Subject: Bugfix [#36203] Transformation bone constraint breaks Track To / Dumped Track Limited crazy-space constraint correction for Transform constraint to only get applied when only rotating bones with such constraints. --- source/blender/editors/transform/transform_conversions.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index ce346c7952d..cfc78a0e0ef 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4715,13 +4715,12 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list) if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) { /* (affirmative) returns for specific constraints here... */ /* constraints that require this regardless */ - if (ELEM6(con->type, + if (ELEM5(con->type, CONSTRAINT_TYPE_CHILDOF, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_OBJECTSOLVER, - CONSTRAINT_TYPE_FOLLOWTRACK, - CONSTRAINT_TYPE_TRANSFORM)) + CONSTRAINT_TYPE_FOLLOWTRACK)) { return true; } @@ -4734,6 +4733,15 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list) if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION)) return true; } + else if (con->type == CONSTRAINT_TYPE_TRANSFORM) { + /* Transform constraint needs it for rotation at least (r.57309), + * but doing so when translating may also mess things up [#36203] + */ + + if (t->mode == TFM_ROTATION) + return true; + /* ??? (t->mode == TFM_SCALE) ? */ + } } } } -- cgit v1.2.3 From bf04c76ab5ca44ac5d2b191fa7a8b414fcc197b4 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 5 Nov 2013 02:01:39 +0000 Subject: Bugfix [#37168] Outliner refresh error after removing constraints Clear constraints operators were missing the NA_REMOVED flag which the Outliner was checking for before it would perform the necessary updates. --- source/blender/editors/object/object_constraint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 8af9401e30f..d4fac49e973 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1331,7 +1331,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) /* do updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob); return OPERATOR_FINISHED; } @@ -1365,7 +1365,7 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) DAG_relations_tag_update(bmain); /* do updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, NULL); return OPERATOR_FINISHED; } -- cgit v1.2.3 From 1b4afb161d0dc15f17fa4a541072402827dfdc4d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Nov 2013 04:23:46 +0000 Subject: code cleanup: typos --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/editors/sculpt_paint/paint_vertex.c | 4 ++-- source/blender/nodes/composite/nodes/node_composite_image.c | 2 +- source/blender/python/intern/bpy_rna_callback.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 884e7a813a8..731196c2480 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1259,7 +1259,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag, } if (dm->type == DM_TYPE_EDITBMESH) { - /* editmesh draw function checks spesifically for this */ + /* editmesh draw function checks specifically for this */ } else { const int dm_totpoly = dm->getNumPolys(dm); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index db71ca1a93e..c8c38eebea9 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2059,7 +2059,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) BKE_mesh_flush_select_from_polys(me); } - /* weight paint spesific */ + /* weight paint specific */ mesh_octree_table(NULL, NULL, NULL, 'e'); mesh_mirrtopo_table(NULL, 'e'); @@ -2075,7 +2075,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) BKE_paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT); - /* weight paint spesific */ + /* weight paint specific */ mesh_octree_table(ob, NULL, NULL, 's'); ED_vgroup_sync_from_pose(ob); } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index d073abf112a..04a56a9f505 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -201,7 +201,7 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node) * fail and sockets detection will go wrong. * * So we manually construct image user to be sure first - * image from sequence (that one which is set as fileanme + * image from sequence (that one which is set as filename * for image datablock) is used for sockets detection */ load_iuser.ok = 1; diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index 1043f68dbdb..9aefe5a733f 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -203,7 +203,7 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) return NULL; } - /* class spesific callbacks */ + /* class specific callbacks */ if (RNA_struct_is_a(srna, &RNA_Space)) { if (!PyArg_ParseTuple(args, "OOO!ss:Space.draw_handler_add", &cls, &cb_func, /* already assigned, no matter */ -- cgit v1.2.3 From 4a99d30538a70b95a2d6cdbf22434aefe5329a10 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Nov 2013 04:32:51 +0000 Subject: code cleanup: quiet warnings --- intern/rigidbody/CMakeLists.txt | 2 +- source/blender/makesrna/intern/rna_fcurve.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/intern/rigidbody/CMakeLists.txt b/intern/rigidbody/CMakeLists.txt index 3a2edba39bc..5d84c2cf082 100644 --- a/intern/rigidbody/CMakeLists.txt +++ b/intern/rigidbody/CMakeLists.txt @@ -26,7 +26,7 @@ set(INC ) set(INC_SYS - ../../extern/bullet2/src + ${BULLET_INCLUDE_DIRS} ) set(SRC diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 4809291e35e..2036257e5d7 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -485,10 +485,10 @@ static void rna_FModifer_end_frame_set(PointerRNA *ptr, float value) } } -static void rna_FModifier_start_frame_range(PointerRNA *ptr, float *min, float *max, - float *softmin, float *softmax) +static void rna_FModifier_start_frame_range(PointerRNA *UNUSED(ptr), float *min, float *max, + float *UNUSED(softmin), float *UNUSED(softmax)) { - FModifier *fcm = (FModifier *)ptr->data; + // FModifier *fcm = (FModifier *)ptr->data; /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that, * or else it becomes tricky to adjust the range... [#36844] @@ -614,11 +614,11 @@ static void rna_FModifierLimits_maxy_set(PointerRNA *ptr, float value) } } -static void rna_FModifierLimits_minx_range(PointerRNA *ptr, float *min, float *max, +static void rna_FModifierLimits_minx_range(PointerRNA *UNUSED(ptr), float *min, float *max, float *UNUSED(softmin), float *UNUSED(softmax)) { - FModifier *fcm = (FModifier *)ptr->data; - FMod_Limits *data = fcm->data; + // FModifier *fcm = (FModifier *)ptr->data; + // FMod_Limits *data = fcm->data; /* no soft-limits on lower bound - it's too confusing when you can't easily use the slider to set things here */ *min = MINAFRAMEF; @@ -638,11 +638,11 @@ static void rna_FModifierLimits_maxx_range(PointerRNA *ptr, float *min, float *m *max = MAXFRAMEF; } -static void rna_FModifierLimits_miny_range(PointerRNA *ptr, float *min, float *max, - float *softmin, float *softmax) +static void rna_FModifierLimits_miny_range(PointerRNA *UNUSED(ptr), float *min, float *max, + float *UNUSED(softmin), float *UNUSED(softmax)) { - FModifier *fcm = (FModifier *)ptr->data; - FMod_Limits *data = fcm->data; + // FModifier *fcm = (FModifier *)ptr->data; + // FMod_Limits *data = fcm->data; /* no soft-limits on lower bound - it's too confusing when you can't easily use the slider to set things here */ *min = -FLT_MAX; -- cgit v1.2.3 From 9e2beaa1e2149df660594bcf4375a3b125297395 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Nov 2013 06:19:19 +0000 Subject: bge builds again without bullet. --- source/gameengine/Ketsji/KX_Scene.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 2cddb073b41..c3d7d3179b6 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -562,6 +562,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal newobj->SetGraphicController(newctrl); } +#ifdef WITH_BULLET // replicate physics controller if (orgobj->GetPhysicsController()) { @@ -578,6 +579,8 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal if (parent) parent->Release(); } +#endif + return newobj; } @@ -1905,10 +1908,12 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment()); } +#ifdef WITH_BULLET ctrl = gameobj->GetPhysicsController(); if (ctrl) { ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment()); } +#endif /* SG_Node can hold a scene reference */ SG_Node *sg= gameobj->GetSGNode(); -- cgit v1.2.3 From 28bd03d9b596b3383a02ba8368251da7b0ebf2c9 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 5 Nov 2013 08:52:12 +0000 Subject: Code cleanup: * Remove "FCurve/Driver Version fix" from help menu, was used for RNA changes during 2.5x. * Keep utility code in animsys_refactor.py, might still become useful according to Joshua. --- release/scripts/modules/animsys_refactor.py | 668 +-------------------------- release/scripts/startup/bl_operators/anim.py | 11 - release/scripts/startup/bl_ui/space_info.py | 1 - 3 files changed, 1 insertion(+), 679 deletions(-) diff --git a/release/scripts/modules/animsys_refactor.py b/release/scripts/modules/animsys_refactor.py index fd6087b38e6..9730a05c2d2 100644 --- a/release/scripts/modules/animsys_refactor.py +++ b/release/scripts/modules/animsys_refactor.py @@ -22,7 +22,7 @@ This module has utility functions for renaming rna values in fcurves and drivers. -The main function to use is: update_data_paths(...) +Currently unused, but might become useful later again. """ IS_TESTING = False @@ -216,672 +216,6 @@ def update_data_paths(rna_update): print("fcurve (%s): %s -> %s" % (id_data.name, data_path, data_path_new)) -# we could have this data in its own file but no point really -data_2_56_to_2_59 = ( - ("ClothCollisionSettings", "min_distance", "distance_min"), - ("ClothCollisionSettings", "self_min_distance", "self_distance_min"), - ("ClothCollisionSettings", "enable_collision", "use_collision"), - ("ClothCollisionSettings", "enable_self_collision", "use_self_collision"), - ("ClothSettings", "pin_cloth", "use_pin_cloth"), - ("ClothSettings", "stiffness_scaling", "use_stiffness_scale"), - ("CollisionSettings", "random_damping", "damping_random"), - ("CollisionSettings", "random_friction", "friction_random"), - ("CollisionSettings", "inner_thickness", "thickness_inner"), - ("CollisionSettings", "outer_thickness", "thickness_outer"), - ("CollisionSettings", "kill_particles", "use_particle_kill"), - ("Constraint", "proxy_local", "is_proxy_local"), - ("ActionConstraint", "maximum", "max"), - ("ActionConstraint", "minimum", "min"), - ("FollowPathConstraint", "use_fixed_position", "use_fixed_location"), - ("KinematicConstraint", "chain_length", "chain_count"), - ("KinematicConstraint", "pos_lock_x", "lock_location_x"), - ("KinematicConstraint", "pos_lock_y", "lock_location_y"), - ("KinematicConstraint", "pos_lock_z", "lock_location_z"), - ("KinematicConstraint", "rot_lock_x", "lock_rotation_x"), - ("KinematicConstraint", "rot_lock_y", "lock_rotation_y"), - ("KinematicConstraint", "rot_lock_z", "lock_rotation_z"), - ("KinematicConstraint", "axis_reference", "reference_axis"), - ("KinematicConstraint", "use_position", "use_location"), - ("LimitLocationConstraint", "maximum_x", "max_x"), - ("LimitLocationConstraint", "maximum_y", "max_y"), - ("LimitLocationConstraint", "maximum_z", "max_z"), - ("LimitLocationConstraint", "minimum_x", "min_x"), - ("LimitLocationConstraint", "minimum_y", "min_y"), - ("LimitLocationConstraint", "minimum_z", "min_z"), - ("LimitLocationConstraint", "use_maximum_x", "use_max_x"), - ("LimitLocationConstraint", "use_maximum_y", "use_max_y"), - ("LimitLocationConstraint", "use_maximum_z", "use_max_z"), - ("LimitLocationConstraint", "use_minimum_x", "use_min_x"), - ("LimitLocationConstraint", "use_minimum_y", "use_min_y"), - ("LimitLocationConstraint", "use_minimum_z", "use_min_z"), - ("LimitLocationConstraint", "limit_transform", "use_transform_limit"), - ("LimitRotationConstraint", "maximum_x", "max_x"), - ("LimitRotationConstraint", "maximum_y", "max_y"), - ("LimitRotationConstraint", "maximum_z", "max_z"), - ("LimitRotationConstraint", "minimum_x", "min_x"), - ("LimitRotationConstraint", "minimum_y", "min_y"), - ("LimitRotationConstraint", "minimum_z", "min_z"), - ("LimitRotationConstraint", "limit_transform", "use_transform_limit"), - ("LimitScaleConstraint", "maximum_x", "max_x"), - ("LimitScaleConstraint", "maximum_y", "max_y"), - ("LimitScaleConstraint", "maximum_z", "max_z"), - ("LimitScaleConstraint", "minimum_x", "min_x"), - ("LimitScaleConstraint", "minimum_y", "min_y"), - ("LimitScaleConstraint", "minimum_z", "min_z"), - ("LimitScaleConstraint", "use_maximum_x", "use_max_x"), - ("LimitScaleConstraint", "use_maximum_y", "use_max_y"), - ("LimitScaleConstraint", "use_maximum_z", "use_max_z"), - ("LimitScaleConstraint", "use_minimum_x", "use_min_x"), - ("LimitScaleConstraint", "use_minimum_y", "use_min_y"), - ("LimitScaleConstraint", "use_minimum_z", "use_min_z"), - ("LimitScaleConstraint", "limit_transform", "use_transform_limit"), - ("PivotConstraint", "enabled_rotation_range", "rotation_range"), - ("PivotConstraint", "use_relative_position", "use_relative_location"), - ("PythonConstraint", "number_of_targets", "target_count"), - ("SplineIKConstraint", "chain_length", "chain_count"), - ("SplineIKConstraint", "chain_offset", "use_chain_offset"), - ("SplineIKConstraint", "even_divisions", "use_even_divisions"), - ("SplineIKConstraint", "y_stretch", "use_y_stretch"), - ("SplineIKConstraint", "xz_scaling_mode", "xz_scale_mode"), - ("StretchToConstraint", "original_length", "rest_length"), - ("TrackToConstraint", "target_z", "use_target_z"), - ("TransformConstraint", "extrapolate_motion", "use_motion_extrapolate"), - ("FieldSettings", "do_location", "apply_to_location"), - ("FieldSettings", "do_rotation", "apply_to_rotation"), - ("FieldSettings", "maximum_distance", "distance_max"), - ("FieldSettings", "minimum_distance", "distance_min"), - ("FieldSettings", "radial_maximum", "radial_max"), - ("FieldSettings", "radial_minimum", "radial_min"), - ("FieldSettings", "force_2d", "use_2d_force"), - ("FieldSettings", "do_absorption", "use_absorption"), - ("FieldSettings", "global_coordinates", "use_global_coords"), - ("FieldSettings", "guide_path_add", "use_guide_path_add"), - ("FieldSettings", "multiple_springs", "use_multiple_springs"), - ("FieldSettings", "use_coordinates", "use_object_coords"), - ("FieldSettings", "root_coordinates", "use_root_coords"), - ("ControlFluidSettings", "reverse_frames", "use_reverse_frames"), - ("DomainFluidSettings", "real_world_size", "simulation_scale"), - ("DomainFluidSettings", "surface_smoothing", "surface_smooth"), - ("DomainFluidSettings", "reverse_frames", "use_reverse_frames"), - ("DomainFluidSettings", "generate_speed_vectors", "use_speed_vectors"), - ("DomainFluidSettings", "override_time", "use_time_override"), - ("FluidFluidSettings", "export_animated_mesh", "use_animated_mesh"), - ("InflowFluidSettings", "export_animated_mesh", "use_animated_mesh"), - ("InflowFluidSettings", "local_coordinates", "use_local_coords"), - ("ObstacleFluidSettings", "export_animated_mesh", "use_animated_mesh"), - ("OutflowFluidSettings", "export_animated_mesh", "use_animated_mesh"), - ("ParticleFluidSettings", "drops", "use_drops"), - ("ParticleFluidSettings", "floats", "use_floats"), - ("Armature", "drawtype", "draw_type"), - ("Armature", "layer_protection", "layers_protected"), - ("Armature", "auto_ik", "use_auto_ik"), - ("Armature", "delay_deform", "use_deform_delay"), - ("Armature", "deform_envelope", "use_deform_envelopes"), - ("Armature", "deform_quaternion", "use_deform_preserve_volume"), - ("Armature", "deform_vertexgroups", "use_deform_vertex_groups"), - ("Armature", "x_axis_mirror", "use_mirror_x"), - ("Curve", "width", "offset"), - ("Image", "animation_speed", "fps"), - ("Image", "animation_end", "frame_end"), - ("Image", "animation_start", "frame_start"), - ("Image", "animated", "use_animation"), - ("Image", "clamp_x", "use_clamp_x"), - ("Image", "clamp_y", "use_clamp_y"), - ("Image", "premultiply", "use_premultiply"), - ("AreaLamp", "shadow_ray_sampling_method", "shadow_ray_sample_method"), - ("AreaLamp", "only_shadow", "use_only_shadow"), - ("AreaLamp", "shadow_layer", "use_shadow_layer"), - ("AreaLamp", "umbra", "use_umbra"), - ("PointLamp", "shadow_ray_sampling_method", "shadow_ray_sample_method"), - ("PointLamp", "only_shadow", "use_only_shadow"), - ("PointLamp", "shadow_layer", "use_shadow_layer"), - ("PointLamp", "sphere", "use_sphere"), - ("SpotLamp", "shadow_ray_sampling_method", "shadow_ray_sample_method"), - ("SpotLamp", "auto_clip_end", "use_auto_clip_end"), - ("SpotLamp", "auto_clip_start", "use_auto_clip_start"), - ("SpotLamp", "only_shadow", "use_only_shadow"), - ("SpotLamp", "shadow_layer", "use_shadow_layer"), - ("SpotLamp", "sphere", "use_sphere"), - ("SunLamp", "only_shadow", "use_only_shadow"), - ("SunLamp", "shadow_layer", "use_shadow_layer"), - ("Material", "z_offset", "offset_z"), - ("Material", "shadow_casting_alpha", "shadow_cast_alpha"), - ("Material", "cast_approximate", "use_cast_approximate"), - ("Material", "cast_buffer_shadows", "use_cast_buffer_shadows"), - ("Material", "cast_shadows_only", "use_cast_shadows_only"), - ("Material", "face_texture", "use_face_texture"), - ("Material", "face_texture_alpha", "use_face_texture_alpha"), - ("Material", "full_oversampling", "use_full_oversampling"), - ("Material", "light_group_exclusive", "use_light_group_exclusive"), - ("Material", "object_color", "use_object_color"), - ("Material", "only_shadow", "use_only_shadow"), - ("Material", "ray_shadow_bias", "use_ray_shadow_bias"), - ("Material", "traceable", "use_raytrace"), - ("Material", "shadeless", "use_shadeless"), - ("Material", "tangent_shading", "use_tangent_shading"), - ("Material", "transparency", "use_transparency"), - ("Material", "receive_transparent_shadows", "use_transparent_shadows"), - ("Material", "vertex_color_light", "use_vertex_color_light"), - ("Material", "vertex_color_paint", "use_vertex_color_paint"), - ("Mesh", "autosmooth_angle", "auto_smooth_angle"), - ("Mesh", "autosmooth", "use_auto_smooth"), - ("Object", "max_draw_type", "draw_type"), - ("Object", "use_dupli_verts_rotation", "use_dupli_vertices_rotation"), - ("Object", "shape_key_edit_mode", "use_shape_key_edit_mode"), - ("Object", "slow_parent", "use_slow_parent"), - ("Object", "time_offset_add_parent", "use_time_offset_add_parent"), - ("Object", "time_offset_edit", "use_time_offset_edit"), - ("Object", "time_offset_parent", "use_time_offset_parent"), - ("Object", "time_offset_particle", "use_time_offset_particle"), - ("ParticleSettings", "adaptive_pix", "adaptive_pixel"), - ("ParticleSettings", "child_effector", "apply_effector_to_children"), - ("ParticleSettings", "child_guide", "apply_guide_to_children"), - ("ParticleSettings", "billboard_split_offset", "billboard_offset_split"), - ("ParticleSettings", "billboard_random_tilt", "billboard_tilt_random"), - ("ParticleSettings", "child_length_thres", "child_length_threshold"), - ("ParticleSettings", "child_random_size", "child_size_random"), - ("ParticleSettings", "clumppow", "clump_shape"), - ("ParticleSettings", "damp_factor", "damping"), - ("ParticleSettings", "draw_as", "draw_method"), - ("ParticleSettings", "random_factor", "factor_random"), - ("ParticleSettings", "grid_invert", "invert_grid"), - ("ParticleSettings", "random_length", "length_random"), - ("ParticleSettings", "random_lifetime", "lifetime_random"), - ("ParticleSettings", "billboard_lock", "lock_billboard"), - ("ParticleSettings", "boids_2d", "lock_boids_to_surface"), - ("ParticleSettings", "object_aligned_factor", "object_align_factor"), - ("ParticleSettings", "random_phase_factor", "phase_factor_random"), - ("ParticleSettings", "ren_as", "render_type"), - ("ParticleSettings", "rendered_child_nbr", "rendered_child_count"), - ("ParticleSettings", "random_rotation_factor", "rotation_factor_random"), - ("ParticleSettings", "rough1", "roughness_1"), - ("ParticleSettings", "rough1_size", "roughness_1_size"), - ("ParticleSettings", "rough2", "roughness_2"), - ("ParticleSettings", "rough2_size", "roughness_2_size"), - ("ParticleSettings", "rough2_thres", "roughness_2_threshold"), - ("ParticleSettings", "rough_end_shape", "roughness_end_shape"), - ("ParticleSettings", "rough_endpoint", "roughness_endpoint"), - ("ParticleSettings", "random_size", "size_random"), - ("ParticleSettings", "abs_path_time", "use_absolute_path_time"), - ("ParticleSettings", "animate_branching", "use_animate_branching"), - ("ParticleSettings", "branching", "use_branching"), - ("ParticleSettings", "died", "use_dead"), - ("ParticleSettings", "die_on_collision", "use_die_on_collision"), - ("ParticleSettings", "rotation_dynamic", "use_dynamic_rotation"), - ("ParticleSettings", "even_distribution", "use_even_distribution"), - ("ParticleSettings", "rand_group", "use_group_pick_random"), - ("ParticleSettings", "hair_bspline", "use_hair_bspline"), - ("ParticleSettings", "sizemass", "use_multiply_size_mass"), - ("ParticleSettings", "react_multiple", "use_react_multiple"), - ("ParticleSettings", "react_start_end", "use_react_start_end"), - ("ParticleSettings", "render_adaptive", "use_render_adaptive"), - ("ParticleSettings", "self_effect", "use_self_effect"), - ("ParticleSettings", "enable_simplify", "use_simplify"), - ("ParticleSettings", "size_deflect", "use_size_deflect"), - ("ParticleSettings", "render_strand", "use_strand_primitive"), - ("ParticleSettings", "symmetric_branching", "use_symmetric_branching"), - ("ParticleSettings", "velocity_length", "use_velocity_length"), - ("ParticleSettings", "whole_group", "use_whole_group"), - ("CloudsTexture", "noise_size", "noise_scale"), - ("DistortedNoiseTexture", "noise_size", "noise_scale"), - ("EnvironmentMapTexture", "filter_size_minimum", "use_filter_size_min"), - ("EnvironmentMapTexture", "mipmap_gauss", "use_mipmap_gauss"), - ("ImageTexture", "calculate_alpha", "use_calculate_alpha"), - ("ImageTexture", "checker_even", "use_checker_even"), - ("ImageTexture", "checker_odd", "use_checker_odd"), - ("ImageTexture", "filter_size_minimum", "use_filter_size_min"), - ("ImageTexture", "flip_axis", "use_flip_axis"), - ("ImageTexture", "mipmap_gauss", "use_mipmap_gauss"), - ("ImageTexture", "mirror_x", "use_mirror_x"), - ("ImageTexture", "mirror_y", "use_mirror_y"), - ("ImageTexture", "normal_map", "use_normal_map"), - ("MarbleTexture", "noise_size", "noise_scale"), - ("MarbleTexture", "noisebasis2", "noise_basis_2"), - ("MarbleTexture", "noisebasis_2", "noise_basis_2"), - ("MusgraveTexture", "highest_dimension", "dimension_max"), - ("MusgraveTexture", "noise_size", "noise_scale"), - ("StucciTexture", "noise_size", "noise_scale"), - ("VoronoiTexture", "coloring", "color_mode"), - ("VoronoiTexture", "noise_size", "noise_scale"), - ("WoodTexture", "noise_size", "noise_scale"), - ("WoodTexture", "noisebasis2", "noise_basis_2"), - ("WoodTexture", "noisebasis_2", "noise_basis_2"), - ("World", "blend_sky", "use_sky_blend"), - ("World", "paper_sky", "use_sky_paper"), - ("World", "real_sky", "use_sky_real"), - ("ImageUser", "auto_refresh", "use_auto_refresh"), - ("MaterialHalo", "flares_sub", "flare_subflare_count"), - ("MaterialHalo", "flare_subsize", "flare_subflare_size"), - ("MaterialHalo", "line_number", "line_count"), - ("MaterialHalo", "rings", "ring_count"), - ("MaterialHalo", "star_tips", "star_tip_count"), - ("MaterialHalo", "xalpha", "use_extreme_alpha"), - ("MaterialHalo", "flare_mode", "use_flare_mode"), - ("MaterialHalo", "vertex_normal", "use_vertex_normal"), - ("MaterialPhysics", "align_to_normal", "use_normal_align"), - ("MaterialStrand", "min_size", "size_min"), - ("MaterialStrand", "blender_units", "use_blender_units"), - ("MaterialStrand", "surface_diffuse", "use_surface_diffuse"), - ("MaterialStrand", "tangent_shading", "use_tangent_shading"), - ("MaterialSubsurfaceScattering", "error_tolerance", "error_threshold"), - ("MaterialVolume", "depth_cutoff", "depth_threshold"), - ("MaterialVolume", "lighting_mode", "light_method"), - ("MaterialVolume", "step_calculation", "step_method"), - ("MaterialVolume", "external_shadows", "use_external_shadows"), - ("MaterialVolume", "light_cache", "use_light_cache"), - ("ArmatureModifier", "multi_modifier", "use_multi_modifier"), - ("ArrayModifier", "constant_offset_displacement", "constant_offset_displace"), - ("ArrayModifier", "merge_distance", "merge_threshold"), - ("ArrayModifier", "relative_offset_displacement", "relative_offset_displace"), - ("ArrayModifier", "constant_offset", "use_constant_offset"), - ("ArrayModifier", "merge_adjacent_vertices", "use_merge_vertices"), - ("ArrayModifier", "merge_end_vertices", "use_merge_vertices_cap"), - ("ArrayModifier", "add_offset_object", "use_object_offset"), - ("ArrayModifier", "relative_offset", "use_relative_offset"), - ("BevelModifier", "only_vertices", "use_only_vertices"), - ("CastModifier", "from_radius", "use_radius_as_size"), - ("DisplaceModifier", "midlevel", "mid_level"), - ("DisplaceModifier", "texture_coordinates", "texture_coords"), - ("EdgeSplitModifier", "use_sharp", "use_edge_sharp"), - ("ExplodeModifier", "split_edges", "use_edge_split"), - ("MirrorModifier", "merge_limit", "merge_threshold"), - ("MirrorModifier", "mirror_u", "use_mirror_u"), - ("MirrorModifier", "mirror_v", "use_mirror_v"), - ("MirrorModifier", "mirror_vertex_groups", "use_mirror_vertex_groups"), - ("ParticleInstanceModifier", "particle_system_number", "particle_system_index"), - ("ParticleInstanceModifier", "keep_shape", "use_preserve_shape"), - ("ShrinkwrapModifier", "cull_back_faces", "use_cull_back_faces"), - ("ShrinkwrapModifier", "cull_front_faces", "use_cull_front_faces"), - ("ShrinkwrapModifier", "keep_above_surface", "use_keep_above_surface"), - ("SimpleDeformModifier", "lock_x_axis", "lock_x"), - ("SimpleDeformModifier", "lock_y_axis", "lock_y"), - ("SmokeModifier", "smoke_type", "type"), - ("SubsurfModifier", "subsurf_uv", "use_subsurf_uv"), - ("UVProjectModifier", "num_projectors", "projector_count"), - ("UVProjectModifier", "override_image", "use_image_override"), - ("WaveModifier", "texture_coordinates", "texture_coords"), - ("WaveModifier", "x_normal", "use_normal_x"), - ("WaveModifier", "y_normal", "use_normal_y"), - ("WaveModifier", "z_normal", "use_normal_z"), - ("NlaStrip", "blending", "blend_type"), - ("NlaStrip", "animated_influence", "use_animated_influence"), - ("NlaStrip", "animated_time", "use_animated_time"), - ("NlaStrip", "animated_time_cyclic", "use_animated_time_cyclic"), - ("NlaStrip", "auto_blending", "use_auto_blend"), - ("CompositorNodeAlphaOver", "convert_premul", "use_premultiply"), - ("CompositorNodeBlur", "sizex", "size_x"), - ("CompositorNodeBlur", "sizey", "size_y"), - ("CompositorNodeChannelMatte", "algorithm", "limit_method"), - ("CompositorNodeChromaMatte", "acceptance", "tolerance"), - ("CompositorNodeColorBalance", "correction_formula", "correction_method"), - ("CompositorNodeColorSpill", "algorithm", "limit_method"), - ("CompositorNodeColorSpill", "unspill", "use_unspill"), - ("CompositorNodeCrop", "x2", "max_x"), - ("CompositorNodeCrop", "y2", "max_y"), - ("CompositorNodeCrop", "x1", "min_x"), - ("CompositorNodeCrop", "y1", "min_y"), - ("CompositorNodeCrop", "crop_size", "use_crop_size"), - ("CompositorNodeDefocus", "max_blur", "blur_max"), - ("CompositorNodeDefocus", "gamma_correction", "use_gamma_correction"), - ("CompositorNodeGlare", "rotate_45", "use_rotate_45"), - ("CompositorNodeImage", "auto_refresh", "use_auto_refresh"), - ("CompositorNodeLensdist", "projector", "use_projector"), - ("CompositorNodeVecBlur", "max_speed", "speed_max"), - ("CompositorNodeVecBlur", "min_speed", "speed_min"), - ("ShaderNodeMapping", "maximum", "max"), - ("ShaderNodeMapping", "minimum", "min"), - ("ShaderNodeMapping", "clamp_maximum", "use_max"), - ("ShaderNodeMapping", "clamp_minimum", "use_min"), - ("ParticleEdit", "add_keys", "default_key_count"), - ("ParticleEdit", "selection_mode", "select_mode"), - ("ParticleEdit", "auto_velocity", "use_auto_velocity"), - ("ParticleEdit", "add_interpolate", "use_default_interpolate"), - ("ParticleEdit", "emitter_deflect", "use_emitter_deflect"), - ("ParticleEdit", "fade_time", "use_fade_time"), - ("ParticleEdit", "keep_lengths", "use_preserve_length"), - ("ParticleEdit", "keep_root", "use_preserve_root"), - ("ParticleSystem", "vertex_group_clump_negate", "invert_vertex_group_clump"), - ("ParticleSystem", "vertex_group_density_negate", "invert_vertex_group_density"), - ("ParticleSystem", "vertex_group_field_negate", "invert_vertex_group_field"), - ("ParticleSystem", "vertex_group_kink_negate", "invert_vertex_group_kink"), - ("ParticleSystem", "vertex_group_length_negate", "invert_vertex_group_length"), - ("ParticleSystem", "vertex_group_rotation_negate", "invert_vertex_group_rotation"), - ("ParticleSystem", "vertex_group_roughness1_negate", "invert_vertex_group_roughness_1"), - ("ParticleSystem", "vertex_group_roughness2_negate", "invert_vertex_group_roughness_2"), - ("ParticleSystem", "vertex_group_roughness_end_negate", "invert_vertex_group_roughness_end"), - ("ParticleSystem", "vertex_group_size_negate", "invert_vertex_group_size"), - ("ParticleSystem", "vertex_group_tangent_negate", "invert_vertex_group_tangent"), - ("ParticleSystem", "vertex_group_velocity_negate", "invert_vertex_group_velocity"), - ("ParticleSystem", "hair_dynamics", "use_hair_dynamics"), - ("ParticleSystem", "keyed_timing", "use_keyed_timing"), - ("PointDensity", "falloff_softness", "falloff_soft"), - ("PointDensity", "particle_cache", "particle_cache_space"), - ("PointDensity", "turbulence_size", "turbulence_scale"), - ("PointDensity", "turbulence", "use_turbulence"), - ("PointDensity", "vertices_cache", "vertex_cache_space"), - ("PoseBone", "ik_lin_weight", "ik_linear_weight"), - ("PoseBone", "ik_rot_weight", "ik_rotation_weight"), - ("PoseBone", "ik_limit_x", "use_ik_limit_x"), - ("PoseBone", "ik_limit_y", "use_ik_limit_y"), - ("PoseBone", "ik_limit_z", "use_ik_limit_z"), - ("PoseBone", "ik_lin_control", "use_ik_linear_control"), - ("PoseBone", "ik_rot_control", "use_ik_rotation_control"), - ("Bone", "use_hinge", "use_inherit_rotation"), - ("SPHFluidSettings", "spring_k", "spring_force"), - ("SPHFluidSettings", "stiffness_k", "stiffness"), - ("SPHFluidSettings", "stiffness_knear", "stiffness_near"), - ("SceneGameData", "framing_color", "frame_color"), - ("SceneGameData", "framing_type", "frame_type"), - ("SceneGameData", "eye_separation", "stereo_eye_separation"), - ("SceneGameData", "activity_culling", "use_activity_culling"), - ("SceneGameData", "auto_start", "use_auto_start"), - ("SceneGameData", "glsl_extra_textures", "use_glsl_extra_textures"), - ("SceneGameData", "glsl_lights", "use_glsl_lights"), - ("SceneGameData", "glsl_nodes", "use_glsl_nodes"), - ("SceneGameData", "glsl_ramps", "use_glsl_ramps"), - ("SceneGameData", "glsl_shaders", "use_glsl_shaders"), - ("SceneGameData", "glsl_shadows", "use_glsl_shadows"), - ("Sequence", "blend_opacity", "blend_alpha"), - ("Sequence", "blend_mode", "blend_type"), - ("Sequence", "frame_final_length", "frame_final_duration"), - ("Sequence", "use_effect_default_fade", "use_default_fade"), - ("SequenceColorBalance", "inverse_gain", "invert_gain"), - ("SequenceColorBalance", "inverse_gamma", "invert_gamma"), - ("SequenceColorBalance", "inverse_lift", "invert_lift"), - ("EffectSequence", "multiply_colors", "color_multiply"), - ("EffectSequence", "de_interlace", "use_deinterlace"), - ("EffectSequence", "flip_x", "use_flip_x"), - ("EffectSequence", "flip_y", "use_flip_y"), - ("EffectSequence", "convert_float", "use_float"), - ("EffectSequence", "premultiply", "use_premultiply"), - ("EffectSequence", "proxy_custom_directory", "use_proxy_custom_directory"), - ("EffectSequence", "proxy_custom_file", "use_proxy_custom_file"), - ("EffectSequence", "reverse_frames", "use_reverse_frames"), - ("GlowSequence", "blur_distance", "blur_radius"), - ("GlowSequence", "only_boost", "use_only_boost"), - ("SpeedControlSequence", "curve_compress_y", "use_curve_compress_y"), - ("SpeedControlSequence", "curve_velocity", "use_curve_velocity"), - ("SpeedControlSequence", "frame_blending", "use_frame_blend"), - ("TransformSequence", "uniform_scale", "use_uniform_scale"), - ("ImageSequence", "animation_end_offset", "animation_offset_end"), - ("ImageSequence", "animation_start_offset", "animation_offset_start"), - ("ImageSequence", "multiply_colors", "color_multiply"), - ("ImageSequence", "de_interlace", "use_deinterlace"), - ("ImageSequence", "flip_x", "use_flip_x"), - ("ImageSequence", "flip_y", "use_flip_y"), - ("ImageSequence", "convert_float", "use_float"), - ("ImageSequence", "premultiply", "use_premultiply"), - ("ImageSequence", "proxy_custom_directory", "use_proxy_custom_directory"), - ("ImageSequence", "proxy_custom_file", "use_proxy_custom_file"), - ("ImageSequence", "reverse_frames", "use_reverse_frames"), - ("MetaSequence", "animation_end_offset", "animation_offset_end"), - ("MetaSequence", "animation_start_offset", "animation_offset_start"), - ("MetaSequence", "multiply_colors", "color_multiply"), - ("MetaSequence", "de_interlace", "use_deinterlace"), - ("MetaSequence", "flip_x", "use_flip_x"), - ("MetaSequence", "flip_y", "use_flip_y"), - ("MetaSequence", "convert_float", "use_float"), - ("MetaSequence", "premultiply", "use_premultiply"), - ("MetaSequence", "proxy_custom_directory", "use_proxy_custom_directory"), - ("MetaSequence", "proxy_custom_file", "use_proxy_custom_file"), - ("MetaSequence", "reverse_frames", "use_reverse_frames"), - ("MovieSequence", "animation_end_offset", "animation_offset_end"), - ("MovieSequence", "animation_start_offset", "animation_offset_start"), - ("MovieSequence", "multiply_colors", "color_multiply"), - ("MovieSequence", "de_interlace", "use_deinterlace"), - ("MovieSequence", "flip_x", "use_flip_x"), - ("MovieSequence", "flip_y", "use_flip_y"), - ("MovieSequence", "convert_float", "use_float"), - ("MovieSequence", "premultiply", "use_premultiply"), - ("MovieSequence", "proxy_custom_directory", "use_proxy_custom_directory"), - ("MovieSequence", "proxy_custom_file", "use_proxy_custom_file"), - ("MovieSequence", "reverse_frames", "use_reverse_frames"), - ("MulticamSequence", "animation_end_offset", "animation_offset_end"), - ("MulticamSequence", "animation_start_offset", "animation_offset_start"), - ("MulticamSequence", "multiply_colors", "color_multiply"), - ("MulticamSequence", "de_interlace", "use_deinterlace"), - ("MulticamSequence", "flip_x", "use_flip_x"), - ("MulticamSequence", "flip_y", "use_flip_y"), - ("MulticamSequence", "convert_float", "use_float"), - ("MulticamSequence", "premultiply", "use_premultiply"), - ("MulticamSequence", "proxy_custom_directory", "use_proxy_custom_directory"), - ("MulticamSequence", "proxy_custom_file", "use_proxy_custom_file"), - ("MulticamSequence", "reverse_frames", "use_reverse_frames"), - ("SceneSequence", "animation_end_offset", "animation_offset_end"), - ("SceneSequence", "animation_start_offset", "animation_offset_start"), - ("SceneSequence", "multiply_colors", "color_multiply"), - ("SceneSequence", "de_interlace", "use_deinterlace"), - ("SceneSequence", "flip_x", "use_flip_x"), - ("SceneSequence", "flip_y", "use_flip_y"), - ("SceneSequence", "convert_float", "use_float"), - ("SceneSequence", "premultiply", "use_premultiply"), - ("SceneSequence", "proxy_custom_directory", "use_proxy_custom_directory"), - ("SceneSequence", "proxy_custom_file", "use_proxy_custom_file"), - ("SceneSequence", "reverse_frames", "use_reverse_frames"), - ("SoundSequence", "animation_end_offset", "animation_offset_end"), - ("SoundSequence", "animation_start_offset", "animation_offset_start"), - ("SmokeDomainSettings", "smoke_domain_colli", "collision_extents"), - ("SmokeDomainSettings", "smoke_cache_high_comp", "point_cache_compress_high_type"), - ("SmokeDomainSettings", "smoke_cache_comp", "point_cache_compress_type"), - ("SmokeDomainSettings", "maxres", "resolution_max"), - ("SmokeDomainSettings", "smoothemitter", "smooth_emitter"), - ("SmokeDomainSettings", "dissolve_smoke", "use_dissolve_smoke"), - ("SmokeDomainSettings", "dissolve_smoke_log", "use_dissolve_smoke_log"), - ("SmokeDomainSettings", "highres", "use_high_resolution"), - ("SoftBodySettings", "bending", "bend"), - ("SoftBodySettings", "error_limit", "error_threshold"), - ("SoftBodySettings", "lcom", "location_mass_center"), - ("SoftBodySettings", "lrot", "rotation_estimate"), - ("SoftBodySettings", "lscale", "scale_estimate"), - ("SoftBodySettings", "maxstep", "step_max"), - ("SoftBodySettings", "minstep", "step_min"), - ("SoftBodySettings", "diagnose", "use_diagnose"), - ("SoftBodySettings", "edge_collision", "use_edge_collision"), - ("SoftBodySettings", "estimate_matrix", "use_estimate_matrix"), - ("SoftBodySettings", "face_collision", "use_face_collision"), - ("SoftBodySettings", "self_collision", "use_self_collision"), - ("SoftBodySettings", "stiff_quads", "use_stiff_quads"), - ("TexMapping", "maximum", "max"), - ("TexMapping", "minimum", "min"), - ("TexMapping", "has_maximum", "use_max"), - ("TexMapping", "has_minimum", "use_min"), - ("TextCharacterFormat", "bold", "use_bold"), - ("TextCharacterFormat", "italic", "use_italic"), - ("TextCharacterFormat", "underline", "use_underline"), - ("TextureSlot", "rgb_to_intensity", "use_rgb_to_intensity"), - ("TextureSlot", "stencil", "use_stencil"), - ("LampTextureSlot", "texture_coordinates", "texture_coords"), - ("LampTextureSlot", "map_color", "use_map_color"), - ("LampTextureSlot", "map_shadow", "use_map_shadow"), - ("MaterialTextureSlot", "coloremission_factor", "color_emission_factor"), - ("MaterialTextureSlot", "colordiff_factor", "diffuse_color_factor"), - ("MaterialTextureSlot", "x_mapping", "mapping_x"), - ("MaterialTextureSlot", "y_mapping", "mapping_y"), - ("MaterialTextureSlot", "z_mapping", "mapping_z"), - ("MaterialTextureSlot", "colorreflection_factor", "reflection_color_factor"), - ("MaterialTextureSlot", "colorspec_factor", "specular_color_factor"), - ("MaterialTextureSlot", "texture_coordinates", "texture_coords"), - ("MaterialTextureSlot", "colortransmission_factor", "transmission_color_factor"), - ("MaterialTextureSlot", "from_dupli", "use_from_dupli"), - ("MaterialTextureSlot", "from_original", "use_from_original"), - ("MaterialTextureSlot", "map_alpha", "use_map_alpha"), - ("MaterialTextureSlot", "map_ambient", "use_map_ambient"), - ("MaterialTextureSlot", "map_colordiff", "use_map_color_diff"), - ("MaterialTextureSlot", "map_coloremission", "use_map_color_emission"), - ("MaterialTextureSlot", "map_colorreflection", "use_map_color_reflection"), - ("MaterialTextureSlot", "map_colorspec", "use_map_color_spec"), - ("MaterialTextureSlot", "map_colortransmission", "use_map_color_transmission"), - ("MaterialTextureSlot", "map_density", "use_map_density"), - ("MaterialTextureSlot", "map_diffuse", "use_map_diffuse"), - ("MaterialTextureSlot", "map_displacement", "use_map_displacement"), - ("MaterialTextureSlot", "map_emission", "use_map_emission"), - ("MaterialTextureSlot", "map_emit", "use_map_emit"), - ("MaterialTextureSlot", "map_hardness", "use_map_hardness"), - ("MaterialTextureSlot", "map_mirror", "use_map_mirror"), - ("MaterialTextureSlot", "map_normal", "use_map_normal"), - ("MaterialTextureSlot", "map_raymir", "use_map_raymir"), - ("MaterialTextureSlot", "map_reflection", "use_map_reflect"), - ("MaterialTextureSlot", "map_scattering", "use_map_scatter"), - ("MaterialTextureSlot", "map_specular", "use_map_specular"), - ("MaterialTextureSlot", "map_translucency", "use_map_translucency"), - ("MaterialTextureSlot", "map_warp", "use_map_warp"), - ("WorldTextureSlot", "texture_coordinates", "texture_coords"), - ("WorldTextureSlot", "map_blend", "use_map_blend"), - ("WorldTextureSlot", "map_horizon", "use_map_horizon"), - ("WorldTextureSlot", "map_zenith_down", "use_map_zenith_down"), - ("WorldTextureSlot", "map_zenith_up", "use_map_zenith_up"), - ("VoxelData", "still_frame_number", "still_frame"), - ("WorldLighting", "ao_blend_mode", "ao_blend_type"), - ("WorldLighting", "error_tolerance", "error_threshold"), - ("WorldLighting", "use_ambient_occlusion", "use_ambient_occlusian"), - ("WorldLighting", "pixel_cache", "use_cache"), - ("WorldLighting", "use_environment_lighting", "use_environment_light"), - ("WorldLighting", "use_indirect_lighting", "use_indirect_light"), - ("WorldStarsSettings", "color_randomization", "color_random"), - ("WorldStarsSettings", "min_distance", "distance_min"), - ("WorldLighting", "falloff", "use_falloff"), - ("Constraint", "disabled", "is_valid"), - ("ClampToConstraint", "cyclic", "use_cyclic"), - ("ImageTexture", "filter", "filter_type"), - ("ImageTexture", "interpolation", "use_interpolation"), - ("ImageTexture", "mipmap", "use_mipmap"), - ("ImageUser", "frames", "frame_duration"), - ("ImageUser", "offset", "frame_offset"), - ("ImageUser", "cyclic", "use_cyclic"), - ("ArmatureModifier", "invert", "invert_vertex_group"), - ("ArmatureModifier", "quaternion", "use_deform_preserve_volume"), - ("ArrayModifier", "length", "fit_length"), - ("BevelModifier", "angle", "angle_limit"), - ("BuildModifier", "length", "frame_duration"), - ("BuildModifier", "randomize", "use_random_order"), - ("CastModifier", "x", "use_x"), - ("CastModifier", "y", "use_y"), - ("CastModifier", "z", "use_z"), - ("ExplodeModifier", "size", "use_size"), - ("MaskModifier", "invert", "invert_vertex_group"), - ("MeshDeformModifier", "invert", "invert_vertex_group"), - ("MeshDeformModifier", "dynamic", "use_dynamic_bind"), - ("MirrorModifier", "clip", "use_clip"), - ("MirrorModifier", "x", "use_x"), - ("MirrorModifier", "y", "use_y"), - ("MirrorModifier", "z", "use_z"), - ("ParticleInstanceModifier", "children", "use_children"), - ("ParticleInstanceModifier", "normal", "use_normal"), - ("ParticleInstanceModifier", "size", "use_size"), - ("ShrinkwrapModifier", "negative", "use_negative_direction"), - ("ShrinkwrapModifier", "positive", "use_positive_direction"), - ("ShrinkwrapModifier", "x", "use_project_x"), - ("ShrinkwrapModifier", "y", "use_project_y"), - ("ShrinkwrapModifier", "z", "use_project_z"), - ("ShrinkwrapModifier", "mode", "wrap_method"), - ("SimpleDeformModifier", "mode", "deform_method"), - ("SimpleDeformModifier", "relative", "use_relative"), - ("SmoothModifier", "repeat", "iterations"), - ("SmoothModifier", "x", "use_x"), - ("SmoothModifier", "y", "use_y"), - ("SmoothModifier", "z", "use_z"), - ("SolidifyModifier", "invert", "invert_vertex_group"), - ("WaveModifier", "cyclic", "use_cyclic"), - ("WaveModifier", "normals", "use_normal"), - ("WaveModifier", "x", "use_x"), - ("WaveModifier", "y", "use_y"), - ("DampedTrackConstraint", "track", "track_axis"), - ("FloorConstraint", "sticky", "use_sticky"), - ("FollowPathConstraint", "forward", "forward_axis"), - ("FollowPathConstraint", "up", "up_axis"), - ("LockedTrackConstraint", "lock", "lock_axis"), - ("LockedTrackConstraint", "track", "track_axis"), - ("MaintainVolumeConstraint", "axis", "free_axis"), - ("TrackToConstraint", "track", "track_axis"), - ("TrackToConstraint", "up", "up_axis"), - ("GameProperty", "debug", "show_debug"), - ("Image", "tiles", "use_tiles"), - ("Lamp", "diffuse", "use_diffuse"), - ("Lamp", "negative", "use_negative"), - ("Lamp", "layer", "use_own_layer"), - ("Lamp", "specular", "use_specular"), - ("AreaLamp", "dither", "use_dither"), - ("AreaLamp", "jitter", "use_jitter"), - ("SpotLamp", "square", "use_square"), - ("Material", "cubic", "use_cubic"), - ("Material", "shadows", "use_shadows"), - ("ParticleSettings", "amount", "count"), - ("ParticleSettings", "display", "draw_percentage"), - ("ParticleSettings", "velocity", "show_velocity"), - ("ParticleSettings", "trand", "use_emit_random"), - ("ParticleSettings", "parent", "use_parent_particles"), - ("ParticleSettings", "emitter", "use_render_emitter"), - ("ParticleSettings", "viewport", "use_simplify_viewport"), - ("Texture", "brightness", "intensity"), - ("CloudsTexture", "stype", "cloud_type"), - ("EnvironmentMapTexture", "filter", "filter_type"), - ("EnvironmentMapTexture", "mipmap", "use_mipmap"), - ("MarbleTexture", "stype", "marble_type"), - ("StucciTexture", "stype", "stucci_type"), - ("WoodTexture", "stype", "wood_type"), - ("World", "range", "color_range"), - ("World", "lighting", "light_settings"), - ("World", "mist", "mist_settings"), - ("World", "stars", "star_settings"), - ("MaterialHalo", "lines", "use_lines"), - ("MaterialHalo", "ring", "use_ring"), - ("MaterialHalo", "soft", "use_soft"), - ("MaterialHalo", "star", "use_star"), - ("MaterialHalo", "texture", "use_texture"), - ("MaterialPhysics", "damp", "damping"), - ("MaterialRaytraceTransparency", "limit", "depth_max"), - ("NlaStrip", "reversed", "use_reverse"), - ("CompositorNodeBlur", "bokeh", "use_bokeh"), - ("CompositorNodeBlur", "gamma", "use_gamma_correction"), - ("CompositorNodeBlur", "relative", "use_relative"), - ("CompositorNodeChannelMatte", "high", "limit_max"), - ("CompositorNodeChannelMatte", "low", "limit_min"), - ("CompositorNodeChannelMatte", "channel", "matte_channel"), - ("CompositorNodeChromaMatte", "cutoff", "threshold"), - ("CompositorNodeColorMatte", "h", "color_hue"), - ("CompositorNodeColorMatte", "s", "color_saturation"), - ("CompositorNodeColorMatte", "v", "color_value"), - ("CompositorNodeDBlur", "wrap", "use_wrap"), - ("CompositorNodeDefocus", "preview", "use_preview"), - ("CompositorNodeHueSat", "hue", "color_hue"), - ("CompositorNodeHueSat", "sat", "color_saturation"), - ("CompositorNodeHueSat", "val", "color_value"), - ("CompositorNodeImage", "frames", "frame_duration"), - ("CompositorNodeImage", "offset", "frame_offset"), - ("CompositorNodeImage", "start", "frame_start"), - ("CompositorNodeImage", "cyclic", "use_cyclic"), - ("CompositorNodeInvert", "alpha", "invert_alpha"), - ("CompositorNodeInvert", "rgb", "invert_rgb"), - ("CompositorNodeLensdist", "fit", "use_fit"), - ("CompositorNodeLensdist", "jitter", "use_jitter"), - ("CompositorNodeMixRGB", "alpha", "use_alpha"), - ("CompositorNodeRotate", "filter", "filter_type"), - ("CompositorNodeTime", "end", "frame_end"), - ("CompositorNodeTime", "start", "frame_start"), - ("CompositorNodeVecBlur", "curved", "use_curved"), - ("ShaderNodeExtendedMaterial", "diffuse", "use_diffuse"), - ("ShaderNodeExtendedMaterial", "specular", "use_specular"), - ("ShaderNodeMaterial", "diffuse", "use_diffuse"), - ("ShaderNodeMaterial", "specular", "use_specular"), - ("ShaderNodeMixRGB", "alpha", "use_alpha"), - ("TextureNodeCurveTime", "end", "frame_end"), - ("TextureNodeCurveTime", "start", "frame_start"), - ("TextureNodeMixRGB", "alpha", "use_alpha"), - ("TextureSlot", "negate", "invert"), - ("TextureSlot", "size", "scale"), - ("SoftBodySettings", "damp", "damping"), - ("SequenceCrop", "right", "max_x"), - ("SequenceCrop", "top", "max_y"), - ("SequenceCrop", "bottom", "min_x"), - ("SequenceCrop", "left", "min_y"), - ("Sequence", "speed_fader", "speed_factor"), - ("SpeedControlSequence", "global_speed", "multiply_speed"), - ("SpeedControlSequence", "use_curve_velocity", "use_as_speed"), - ("SpeedControlSequence", "use_curve_compress_y", "scale_to_length"), - ("Key", "keys", "key_blocks"), - ) - - if __name__ == "__main__": # Example, should be called externally diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index 6193611504e..3c4b66514de 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -282,14 +282,3 @@ class ClearUselessActions(Operator): % removed) return {'FINISHED'} - -class UpdateAnimData(Operator): - """Update data paths from 2.56 and previous versions, """ \ - """modifying data paths of drivers and fcurves""" - bl_idname = "anim.update_data_paths" - bl_label = "Update Animation Data" - - def execute(self, context): - import animsys_refactor - animsys_refactor.update_data_paths(animsys_refactor.data_2_56_to_2_59) - return {'FINISHED'} diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 6b0c1150f5d..e1b433612e0 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -283,7 +283,6 @@ class INFO_MT_help(Menu): layout.operator("wm.operator_cheat_sheet", icon='TEXT') layout.operator("wm.sysinfo", icon='TEXT') layout.separator() - layout.operator("anim.update_data_paths", text="FCurve/Driver Version fix", icon='HELP') layout.operator("logic.texface_convert", text="TexFace to Material Convert", icon='GAME') layout.separator() -- cgit v1.2.3 From 1808dd082889b3330782a164f2f36db3bc2e3925 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 10:56:52 +0000 Subject: Scons: Fix BGE compile after cleanup --- source/gameengine/GamePlayer/common/SConscript | 1 - 1 file changed, 1 deletion(-) diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript index 85c4b091718..e30c2eb5859 100644 --- a/source/gameengine/GamePlayer/common/SConscript +++ b/source/gameengine/GamePlayer/common/SConscript @@ -33,7 +33,6 @@ source_files = [ 'GPC_Canvas.cpp', 'GPC_KeyboardDevice.cpp', 'GPC_MouseDevice.cpp', - 'GPC_RenderTools.cpp', ] incs = [ -- cgit v1.2.3 From 2cfe64cd1037552dc1a0971c3996dbbe57aad1bb Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 5 Nov 2013 10:57:52 +0000 Subject: Correcting a few typos --- source/blender/blenkernel/intern/anim_sys.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e52aaefd416..bab4e539cf4 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -2074,7 +2074,7 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, Li tmp_nes = *nes; /* evaluate these strips into a temp-buffer (tmp_channels) */ - /* FIXME: modifier evalation here needs some work... */ + /* FIXME: modifier evaluation here needs some work... */ /* first strip */ tmp_nes.strip_mode = NES_TIME_TRANSITION_START; tmp_nes.strip = s1; @@ -2086,7 +2086,7 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, Li nlastrip_evaluate(ptr, &tmp_channels, &tmp_modifiers, &tmp_nes); - /* assumulate temp-buffer and full-buffer, using the 'real' strip */ + /* accumulate temp-buffer and full-buffer, using the 'real' strip */ nlaevalchan_buffers_accumulate(channels, &tmp_channels, nes); /* unlink this strip's modifiers from the parent's modifiers again */ @@ -2334,7 +2334,7 @@ static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, float ctime) /* ***************************************** */ /* Overrides System - Public API */ -/* Clear all overides */ +/* Clear all overrides */ /* Add or get existing Override for given setting */ #if 0 -- cgit v1.2.3 From dd697f8bd40b685de2c3ba87866aaf2785a27308 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 12:48:32 +0000 Subject: OSX: preparing carbon and quicktime dropping, make 64bit and QTKit default, make 10.8sdk default for xcode >= 4.4 --- build_files/scons/config/darwin-config.py | 4 ++-- build_files/scons/tools/btools.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 5a1069618b9..1ded1af9976 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -14,7 +14,7 @@ USE_SDK=True ################### Cocoa & architecture settings ################## ############################################################################# WITH_GHOST_COCOA=True -MACOSX_ARCHITECTURE = 'i386' # valid archs: ppc, i386, ppc64, x86_64 +MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64 cmd = 'uname -p' @@ -97,7 +97,7 @@ else : # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! ) MAC_MIN_VERS = '10.6' MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.7.sdk' + MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk' LCGDIR = '#../lib/darwin-9.x.universal' CC = 'gcc' CXX = 'g++' diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 8f0d3ff590b..7b1737a1e70 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -428,7 +428,7 @@ def read_opts(env, cfg, args): (BoolVariable('WITH_GHOST_SDL', 'Enable building blender against SDL for windowing rather then the native APIs', False)), (BoolVariable('WITH_X11_XINPUT', 'Enable X11 Xinput (tablet support and unicode input)', True)), (BoolVariable('WITH_X11_XF86VMODE', 'Enable X11 video mode switching', True)), - (BoolVariable('USE_QTKIT', 'Use QTKIT if true', False)), + (BoolVariable('USE_QTKIT', 'Use QTKIT if true', True)), ('BF_OPENMP_LIB_STATIC', 'OpenMP static library', ''), (BoolVariable('WITH_BF_QUICKTIME', 'Use QuickTime if true', False)), -- cgit v1.2.3 From 52588bf014352d808ec139ab121b63f3a671fd33 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 12:52:51 +0000 Subject: OSX: preparing carbon and quicktime dropping, make QTKit also default for i386 --- build_files/scons/config/darwin-config.py | 2 +- build_files/scons/tools/btools.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 1ded1af9976..d44b94e42b5 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -49,7 +49,7 @@ if XCODE_SELECT_PATH.endswith("/Contents/Developer"): else: XCODE_BUNDLE=XCODE_SELECT_PATH -if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64': +if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'ppc64': USE_QTKIT=True # Carbon quicktime is not available for 64bit diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 7b1737a1e70..9a5521fff44 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -424,7 +424,7 @@ def read_opts(env, cfg, args): ('BF_OPENMP', 'Base path to OpenMP (used when cross-compiling with older versions of WinGW)', ''), ('BF_OPENMP_INC', 'Path to OpenMP includes (used when cross-compiling with older versions of WinGW)', ''), ('BF_OPENMP_LIBPATH', 'Path to OpenMP libraries (used when cross-compiling with older versions of WinGW)', ''), - (BoolVariable('WITH_GHOST_COCOA', 'Use Cocoa-framework if true', False)), + (BoolVariable('WITH_GHOST_COCOA', 'Use Cocoa-framework if true', True)), (BoolVariable('WITH_GHOST_SDL', 'Enable building blender against SDL for windowing rather then the native APIs', False)), (BoolVariable('WITH_X11_XINPUT', 'Enable X11 Xinput (tablet support and unicode input)', True)), (BoolVariable('WITH_X11_XF86VMODE', 'Enable X11 video mode switching', True)), -- cgit v1.2.3 From 7f5cb54b568cbdef6c96bb552a8dfc44f650e598 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 13:34:05 +0000 Subject: OSX: remove Ghost carbon files and adapt scons --- intern/ghost/SConscript | 4 ---- 1 file changed, 4 deletions(-) diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript index fed8cd7aa3c..7d1f3efbe31 100644 --- a/intern/ghost/SConscript +++ b/intern/ghost/SConscript @@ -55,7 +55,6 @@ incs += ' ' + env['BF_OPENGL_INC'] if env['WITH_GHOST_SDL']: for f in pf: try: - sources.remove('intern' + os.sep + f + 'Carbon.cpp') sources.remove('intern' + os.sep + f + 'Win32.cpp') sources.remove('intern' + os.sep + f + 'X11.cpp') except ValueError: @@ -66,7 +65,6 @@ elif window_system in ('linux', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'f for f in pf: try: sources.remove('intern' + os.sep + f + 'Win32.cpp') - sources.remove('intern' + os.sep + f + 'Carbon.cpp') sources.remove('intern' + os.sep + f + 'SDL.cpp') except ValueError: pass @@ -94,7 +92,6 @@ elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64 for f in pf: try: sources.remove('intern' + os.sep + f + 'X11.cpp') - sources.remove('intern' + os.sep + f + 'Carbon.cpp') sources.remove('intern' + os.sep + f + 'SDL.cpp') except ValueError: pass @@ -108,7 +105,6 @@ elif window_system == 'darwin': try: sources.remove('intern' + os.sep + f + 'Win32.cpp') sources.remove('intern' + os.sep + f + 'X11.cpp') - sources.remove('intern' + os.sep + f + 'Carbon.cpp') sources.remove('intern' + os.sep + f + 'SDL.cpp') except ValueError: pass -- cgit v1.2.3 From 311c5f33ff04c43cffd7da264411bbd3b5e56eb0 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 13:35:49 +0000 Subject: OSX: remove Ghost carbon files finally --- intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp | 175 --- intern/ghost/intern/GHOST_DisplayManagerCarbon.h | 116 -- intern/ghost/intern/GHOST_SystemCarbon.cpp | 1241 -------------------- intern/ghost/intern/GHOST_SystemCarbon.h | 298 ----- intern/ghost/intern/GHOST_SystemPathsCarbon.cpp | 88 -- intern/ghost/intern/GHOST_SystemPathsCarbon.h | 87 -- intern/ghost/intern/GHOST_WindowCarbon.cpp | 751 ------------ intern/ghost/intern/GHOST_WindowCarbon.h | 321 ----- 8 files changed, 3077 deletions(-) delete mode 100644 intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp delete mode 100644 intern/ghost/intern/GHOST_DisplayManagerCarbon.h delete mode 100644 intern/ghost/intern/GHOST_SystemCarbon.cpp delete mode 100644 intern/ghost/intern/GHOST_SystemCarbon.h delete mode 100644 intern/ghost/intern/GHOST_SystemPathsCarbon.cpp delete mode 100644 intern/ghost/intern/GHOST_SystemPathsCarbon.h delete mode 100644 intern/ghost/intern/GHOST_WindowCarbon.cpp delete mode 100644 intern/ghost/intern/GHOST_WindowCarbon.h diff --git a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp b/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp deleted file mode 100644 index 25e9123dae6..00000000000 --- a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file ghost/intern/GHOST_DisplayManagerCarbon.cpp - * \ingroup GHOST - */ - - -/** - * Copyright (C) 2001 NaN Technologies B.V. - * \author Maarten Gribnau - * \date September 21, 2001 - */ - -#include "GHOST_DisplayManagerCarbon.h" -#include "GHOST_Debug.h" - -// We do not support multiple monitors at the moment - - -GHOST_DisplayManagerCarbon::GHOST_DisplayManagerCarbon(void) -{ - if (::CGGetActiveDisplayList(0, NULL, &m_numDisplays) != CGDisplayNoErr) - { - m_numDisplays = 0; - m_displayIDs = NULL; - } - if (m_numDisplays > 0) - { - m_displayIDs = new CGDirectDisplayID[m_numDisplays]; - GHOST_ASSERT((m_displayIDs != NULL), "GHOST_DisplayManagerCarbon::GHOST_DisplayManagerCarbon(): memory allocation failed"); - ::CGGetActiveDisplayList(m_numDisplays, m_displayIDs, &m_numDisplays); - } -} - - -GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplays(GHOST_TUns8& numDisplays) const -{ - numDisplays = (GHOST_TUns8) m_numDisplays; - return GHOST_kSuccess; -} - - -GHOST_TSuccess GHOST_DisplayManagerCarbon::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const -{ - GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::getNumDisplaySettings(): only main display is supported"); - - CFArrayRef displayModes; - displayModes = ::CGDisplayAvailableModes(m_displayIDs[display]); - CFIndex numModes = ::CFArrayGetCount(displayModes); - numSettings = (GHOST_TInt32)numModes; - - return GHOST_kSuccess; -} - - -GHOST_TSuccess GHOST_DisplayManagerCarbon::getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const -{ - GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::getDisplaySetting(): only main display is supported"); - - CFArrayRef displayModes; - CGDirectDisplayID d = m_displayIDs[display]; - displayModes = ::CGDisplayAvailableModes(d); - //CFIndex numModes = ::CFArrayGetCount(displayModes);/*unused*/ - //GHOST_TInt32 numSettings = (GHOST_TInt32)numModes; /*unused*/ - CFDictionaryRef displayModeValues = (CFDictionaryRef) ::CFArrayGetValueAtIndex(displayModes, index); - - setting.xPixels = getValue(displayModeValues, kCGDisplayWidth); - setting.yPixels = getValue(displayModeValues, kCGDisplayHeight); - setting.bpp = getValue(displayModeValues, kCGDisplayBitsPerPixel); - setting.frequency = getValue(displayModeValues, kCGDisplayRefreshRate); - -#ifdef GHOST_DEBUG - printf("display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency); -#endif // GHOST_DEBUG - - return GHOST_kSuccess; -} - - -GHOST_TSuccess GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const -{ - GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::getCurrentDisplaySetting(): only main display is supported"); - - CFDictionaryRef displayModeValues = ::CGDisplayCurrentMode(m_displayIDs[display]); - - setting.xPixels = getValue(displayModeValues, kCGDisplayWidth); - setting.yPixels = getValue(displayModeValues, kCGDisplayHeight); - setting.bpp = getValue(displayModeValues, kCGDisplayBitsPerPixel); - setting.frequency = getValue(displayModeValues, kCGDisplayRefreshRate); - -#ifdef GHOST_DEBUG - printf("current display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency); -#endif // GHOST_DEBUG - - return GHOST_kSuccess; -} - - -GHOST_TSuccess GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting) -{ - GHOST_ASSERT((display == kMainDisplay), "GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): only main display is supported"); - -#ifdef GHOST_DEBUG - printf("GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): requested settings:\n"); - printf(" setting.xPixels=%d\n", setting.xPixels); - printf(" setting.yPixels=%d\n", setting.yPixels); - printf(" setting.bpp=%d\n", setting.bpp); - printf(" setting.frequency=%d\n", setting.frequency); -#endif // GHOST_DEBUG - - CFDictionaryRef displayModeValues = ::CGDisplayBestModeForParametersAndRefreshRate( - m_displayIDs[display], - (size_t)setting.bpp, - (size_t)setting.xPixels, - (size_t)setting.yPixels, - (CGRefreshRate)setting.frequency, - NULL); - -#ifdef GHOST_DEBUG - printf("GHOST_DisplayManagerCarbon::setCurrentDisplaySetting(): switching to:\n"); - printf(" setting.xPixels=%d\n", getValue(displayModeValues, kCGDisplayWidth)); - printf(" setting.yPixels=%d\n", getValue(displayModeValues, kCGDisplayHeight)); - printf(" setting.bpp=%d\n", getValue(displayModeValues, kCGDisplayBitsPerPixel)); - printf(" setting.frequency=%d\n", getValue(displayModeValues, kCGDisplayRefreshRate)); -#endif // GHOST_DEBUG - - CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues); - - return err == CGDisplayNoErr ? GHOST_kSuccess : GHOST_kFailure; -} - - -long GHOST_DisplayManagerCarbon::getValue(CFDictionaryRef values, CFStringRef key) const -{ - CFNumberRef numberValue = (CFNumberRef) CFDictionaryGetValue(values, key); - - if (!numberValue) - { - return -1; - } - - long intValue; - - if (!CFNumberGetValue(numberValue, kCFNumberLongType, &intValue)) - { - return -1; - } - - return intValue; -} diff --git a/intern/ghost/intern/GHOST_DisplayManagerCarbon.h b/intern/ghost/intern/GHOST_DisplayManagerCarbon.h deleted file mode 100644 index 1ac6540b7bd..00000000000 --- a/intern/ghost/intern/GHOST_DisplayManagerCarbon.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file ghost/intern/GHOST_DisplayManagerCarbon.h - * \ingroup GHOST - * Declaration of GHOST_DisplayManagerCarbon class. - */ - -#ifndef __GHOST_DISPLAYMANAGERCARBON_H__ -#define __GHOST_DISPLAYMANAGERCARBON_H__ - -#ifndef __APPLE__ -#error Apple only! -#endif // __APPLE__ - -#include "GHOST_DisplayManager.h" - -#define __CARBONSOUND__ -#include - -/** - * Manages system displays (Mac OSX/Carbon implementation). - * \see GHOST_DisplayManager - * \author Maarten Gribnau - * \date September 21, 2001 - */ -class GHOST_DisplayManagerCarbon : public GHOST_DisplayManager -{ -public: - /** - * Constructor. - */ - GHOST_DisplayManagerCarbon(void); - - /** - * Returns the number of display devices on this system. - * \param numDisplays The number of displays on this system. - * \return Indication of success. - */ - virtual GHOST_TSuccess getNumDisplays(GHOST_TUns8& numDisplays) const; - - /** - * Returns the number of display settings for this display device. - * \param display The index of the display to query with 0 <= display < getNumDisplays(). - * \param setting The number of settings of the display device with this index. - * \return Indication of success. - */ - virtual GHOST_TSuccess getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const; - - /** - * Returns the current setting for this display device. - * \param display The index of the display to query with 0 <= display < getNumDisplays(). - * \param index The setting index to be returned. - * \param setting The setting of the display device with this index. - * \return Indication of success. - */ - virtual GHOST_TSuccess getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const; - - /** - * Returns the current setting for this display device. - * \param display The index of the display to query with 0 <= display < getNumDisplays(). - * \param setting The current setting of the display device with this index. - * \return Indication of success. - */ - virtual GHOST_TSuccess getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const; - - /** - * Changes the current setting for this display device. - * \param display The index of the display to query with 0 <= display < getNumDisplays(). - * \param setting The current setting of the display device with this index. - * \return Indication of success. - */ - virtual GHOST_TSuccess setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting); - -protected: - /** - * Returns a value from a dictionary. - * \param values Dictionary to return value from. - * \param key Key to return value for. - * \return The value for this key. - */ - long getValue(CFDictionaryRef values, CFStringRef key) const; - - /** Cached number of displays. */ - CGDisplayCount m_numDisplays; - /** Cached display id's for each display. */ - CGDirectDisplayID *m_displayIDs; -}; - - -#endif // __GHOST_DISPLAYMANAGERCARBON_H__ - diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp deleted file mode 100644 index 6e72e26beb4..00000000000 --- a/intern/ghost/intern/GHOST_SystemCarbon.cpp +++ /dev/null @@ -1,1241 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file ghost/intern/GHOST_SystemCarbon.cpp - * \ingroup GHOST - */ - - -/** - * Copyright (C) 2001 NaN Technologies B.V. - * \author Maarten Gribnau - * \date May 7, 2001 - */ - -#include -#include -#include "GHOST_SystemCarbon.h" - -#include "GHOST_DisplayManagerCarbon.h" -#include "GHOST_EventKey.h" -#include "GHOST_EventButton.h" -#include "GHOST_EventCursor.h" -#include "GHOST_EventWheel.h" -#ifdef WITH_INPUT_NDOF -#include "GHOST_EventNDOF.h" -#endif - -#include "GHOST_TimerManager.h" -#include "GHOST_TimerTask.h" -#include "GHOST_WindowManager.h" -#include "GHOST_WindowCarbon.h" -#include "GHOST_NDOFManager.h" -#include "AssertMacros.h" - -/* blender class and types events */ -enum { - kEventClassBlender = 'blnd' -}; - -enum { - kEventBlenderNdofAxis = 1, - kEventBlenderNdofButtons = 2 -}; - -const EventTypeSpec kEvents[] = -{ - { kEventClassAppleEvent, kEventAppleEvent }, -#if 0 - { kEventClassApplication, kEventAppActivated }, - { kEventClassApplication, kEventAppDeactivated }, - #endif - { kEventClassKeyboard, kEventRawKeyDown }, - { kEventClassKeyboard, kEventRawKeyRepeat }, - { kEventClassKeyboard, kEventRawKeyUp }, - { kEventClassKeyboard, kEventRawKeyModifiersChanged }, - - { kEventClassMouse, kEventMouseDown }, - { kEventClassMouse, kEventMouseUp }, - { kEventClassMouse, kEventMouseMoved }, - { kEventClassMouse, kEventMouseDragged }, - { kEventClassMouse, kEventMouseWheelMoved }, - - { kEventClassWindow, kEventWindowClickZoomRgn }, /* for new zoom behaviour */ - { kEventClassWindow, kEventWindowZoom }, /* for new zoom behaviour */ - { kEventClassWindow, kEventWindowExpand }, /* for new zoom behaviour */ - { kEventClassWindow, kEventWindowExpandAll }, /* for new zoom behaviour */ - - { kEventClassWindow, kEventWindowClose }, - { kEventClassWindow, kEventWindowActivated }, - { kEventClassWindow, kEventWindowDeactivated }, - { kEventClassWindow, kEventWindowUpdate }, - { kEventClassWindow, kEventWindowBoundsChanged }, - - { kEventClassBlender, kEventBlenderNdofAxis }, - { kEventClassBlender, kEventBlenderNdofButtons } - - - -}; - - - -static GHOST_TButtonMask convertButton(EventMouseButton button) -{ - switch (button) { - case kEventMouseButtonPrimary: - return GHOST_kButtonMaskLeft; - case kEventMouseButtonSecondary: - return GHOST_kButtonMaskRight; - case kEventMouseButtonTertiary: - default: - return GHOST_kButtonMaskMiddle; - } -} - -static GHOST_TKey convertKey(int rawCode) -{ - /* This bit of magic converts the rawCode into a virtual - * Mac key based on the current keyboard mapping, but - * without regard to the modifiers (so we don't get 'a' - * and 'A' for example. - */ - static UInt32 dummy = 0; - Handle transData = (Handle) GetScriptManagerVariable(smKCHRCache); - unsigned char vk = KeyTranslate(transData, rawCode, &dummy); - /* Map numpad based on rawcodes first, otherwise they - * look like non-numpad events. - * Added too: mapping the number keys, for french keyboards etc (ton) - */ - // printf("GHOST: vk: %d %c raw: %d\n", vk, vk, rawCode); - - switch (rawCode) { - case 18: return GHOST_kKey1; - case 19: return GHOST_kKey2; - case 20: return GHOST_kKey3; - case 21: return GHOST_kKey4; - case 23: return GHOST_kKey5; - case 22: return GHOST_kKey6; - case 26: return GHOST_kKey7; - case 28: return GHOST_kKey8; - case 25: return GHOST_kKey9; - case 29: return GHOST_kKey0; - - case 82: return GHOST_kKeyNumpad0; - case 83: return GHOST_kKeyNumpad1; - case 84: return GHOST_kKeyNumpad2; - case 85: return GHOST_kKeyNumpad3; - case 86: return GHOST_kKeyNumpad4; - case 87: return GHOST_kKeyNumpad5; - case 88: return GHOST_kKeyNumpad6; - case 89: return GHOST_kKeyNumpad7; - case 91: return GHOST_kKeyNumpad8; - case 92: return GHOST_kKeyNumpad9; - case 65: return GHOST_kKeyNumpadPeriod; - case 76: return GHOST_kKeyNumpadEnter; - case 69: return GHOST_kKeyNumpadPlus; - case 78: return GHOST_kKeyNumpadMinus; - case 67: return GHOST_kKeyNumpadAsterisk; - case 75: return GHOST_kKeyNumpadSlash; - } - - if ((vk >= 'a') && (vk <= 'z')) { - return (GHOST_TKey) (vk - 'a' + GHOST_kKeyA); - } - else if ((vk >= '0') && (vk <= '9')) { - return (GHOST_TKey) (vk - '0' + GHOST_kKey0); - } - else if (vk == 16) { - switch (rawCode) { - case 122: return GHOST_kKeyF1; - case 120: return GHOST_kKeyF2; - case 99: return GHOST_kKeyF3; - case 118: return GHOST_kKeyF4; - case 96: return GHOST_kKeyF5; - case 97: return GHOST_kKeyF6; - case 98: return GHOST_kKeyF7; - case 100: return GHOST_kKeyF8; - case 101: return GHOST_kKeyF9; - case 109: return GHOST_kKeyF10; - case 103: return GHOST_kKeyF11; - case 111: return GHOST_kKeyF12; // Never get, is used for ejecting the CD! - } - } - else { - switch (vk) { - case kUpArrowCharCode: return GHOST_kKeyUpArrow; - case kDownArrowCharCode: return GHOST_kKeyDownArrow; - case kLeftArrowCharCode: return GHOST_kKeyLeftArrow; - case kRightArrowCharCode: return GHOST_kKeyRightArrow; - - case kReturnCharCode: return GHOST_kKeyEnter; - case kBackspaceCharCode: return GHOST_kKeyBackSpace; - case kDeleteCharCode: return GHOST_kKeyDelete; - case kEscapeCharCode: return GHOST_kKeyEsc; - case kTabCharCode: return GHOST_kKeyTab; - case kSpaceCharCode: return GHOST_kKeySpace; - - case kHomeCharCode: return GHOST_kKeyHome; - case kEndCharCode: return GHOST_kKeyEnd; - case kPageUpCharCode: return GHOST_kKeyUpPage; - case kPageDownCharCode: return GHOST_kKeyDownPage; - - case '-': return GHOST_kKeyMinus; - case '=': return GHOST_kKeyEqual; - case ',': return GHOST_kKeyComma; - case '.': return GHOST_kKeyPeriod; - case '/': return GHOST_kKeySlash; - case ';': return GHOST_kKeySemicolon; - case '\'': return GHOST_kKeyQuote; - case '\\': return GHOST_kKeyBackslash; - case '[': return GHOST_kKeyLeftBracket; - case ']': return GHOST_kKeyRightBracket; - case '`': return GHOST_kKeyAccentGrave; - } - } - - // printf("GHOST: unknown key: %d %d\n", vk, rawCode); - - return GHOST_kKeyUnknown; -} - -/* MacOSX returns a Roman charset with kEventParamKeyMacCharCodes - * as defined here: http://developer.apple.com/documentation/mac/Text/Text-516.html - * I am not sure how international this works... - * For cross-platform convention, we'll use the Latin ascii set instead. - * As defined at: http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html - * - */ -static unsigned char convertRomanToLatin(unsigned char ascii) -{ - - if (ascii < 128) return ascii; - - switch (ascii) { - case 128: return 142; - case 129: return 143; - case 130: return 128; - case 131: return 201; - case 132: return 209; - case 133: return 214; - case 134: return 220; - case 135: return 225; - case 136: return 224; - case 137: return 226; - case 138: return 228; - case 139: return 227; - case 140: return 229; - case 141: return 231; - case 142: return 233; - case 143: return 232; - case 144: return 234; - case 145: return 235; - case 146: return 237; - case 147: return 236; - case 148: return 238; - case 149: return 239; - case 150: return 241; - case 151: return 243; - case 152: return 242; - case 153: return 244; - case 154: return 246; - case 155: return 245; - case 156: return 250; - case 157: return 249; - case 158: return 251; - case 159: return 252; - case 160: return 0; - case 161: return 176; - case 162: return 162; - case 163: return 163; - case 164: return 167; - case 165: return 183; - case 166: return 182; - case 167: return 223; - case 168: return 174; - case 169: return 169; - case 170: return 174; - case 171: return 180; - case 172: return 168; - case 173: return 0; - case 174: return 198; - case 175: return 216; - case 176: return 0; - case 177: return 177; - case 178: return 0; - case 179: return 0; - case 180: return 165; - case 181: return 181; - case 182: return 0; - case 183: return 0; - case 184: return 215; - case 185: return 0; - case 186: return 0; - case 187: return 170; - case 188: return 186; - case 189: return 0; - case 190: return 230; - case 191: return 248; - case 192: return 191; - case 193: return 161; - case 194: return 172; - case 195: return 0; - case 196: return 0; - case 197: return 0; - case 198: return 0; - case 199: return 171; - case 200: return 187; - case 201: return 201; - case 202: return 0; - case 203: return 192; - case 204: return 195; - case 205: return 213; - case 206: return 0; - case 207: return 0; - case 208: return 0; - case 209: return 0; - case 210: return 0; - - case 214: return 247; - - case 229: return 194; - case 230: return 202; - case 231: return 193; - case 232: return 203; - case 233: return 200; - case 234: return 205; - case 235: return 206; - case 236: return 207; - case 237: return 204; - case 238: return 211; - case 239: return 212; - case 240: return 0; - case 241: return 210; - case 242: return 218; - case 243: return 219; - case 244: return 217; - case 245: return 0; - case 246: return 0; - case 247: return 0; - case 248: return 0; - case 249: return 0; - case 250: return 0; - - - default: return 0; - } - -} - - -/***/ - -GHOST_SystemCarbon::GHOST_SystemCarbon() : - m_modifierMask(0) -{ - m_displayManager = new GHOST_DisplayManagerCarbon(); - GHOST_ASSERT(m_displayManager, "GHOST_SystemCarbon::GHOST_SystemCarbon(): m_displayManager==0\n"); - m_displayManager->initialize(); - - UnsignedWide micros; - ::Microseconds(µs); - m_start_time = UnsignedWideToUInt64(micros) / 1000; - m_ignoreWindowSizedMessages = false; -} - -GHOST_SystemCarbon::~GHOST_SystemCarbon() -{ -} - - -GHOST_TUns64 GHOST_SystemCarbon::getMilliSeconds() const -{ - UnsignedWide micros; - ::Microseconds(µs); - UInt64 millis; - millis = UnsignedWideToUInt64(micros); - return (millis / 1000) - m_start_time; -} - -GHOST_TUns8 GHOST_SystemCarbon::getNumDisplays() const -{ - // We do not support multiple monitors at the moment - return 1; -} - - -void GHOST_SystemCarbon::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const -{ - BitMap screenBits; - Rect bnds = GetQDGlobalsScreenBits(&screenBits)->bounds; - width = bnds.right - bnds.left; - height = bnds.bottom - bnds.top; -} - -void GHOST_SystemCarbon::getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const -{ - /* TODO */ - getMainDisplayDimensions(width, height); -} - -GHOST_IWindow *GHOST_SystemCarbon::createWindow( - const STR_String& title, - GHOST_TInt32 left, - GHOST_TInt32 top, - GHOST_TUns32 width, - GHOST_TUns32 height, - GHOST_TWindowState state, - GHOST_TDrawingContextType type, - bool stereoVisual, - const bool exclusive, - const GHOST_TUns16 numOfAASamples, - const GHOST_TEmbedderWindowID parentWindow) -{ - GHOST_IWindow *window = 0; - - window = new GHOST_WindowCarbon(title, left, top, width, height, state, type); - - if (window) { - if (window->getValid()) { - // Store the pointer to the window - GHOST_ASSERT(m_windowManager, "m_windowManager not initialized"); - m_windowManager->addWindow(window); - m_windowManager->setActiveWindow(window); - pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window)); - } - else { - GHOST_PRINT("GHOST_SystemCarbon::createWindow(): window invalid\n"); - delete window; - window = 0; - } - } - else { - GHOST_PRINT("GHOST_SystemCarbon::createWindow(): could not create window\n"); - } - return window; -} - -GHOST_TSuccess GHOST_SystemCarbon::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow **window, const bool stereoVisual) -{ - GHOST_TSuccess success = GHOST_kFailure; - - // need yo make this Carbon all on 10.5 for fullscreen to work correctly - CGCaptureAllDisplays(); - - success = GHOST_System::beginFullScreen(setting, window, stereoVisual); - - if (success != GHOST_kSuccess) { - // fullscreen failed for other reasons, release - CGReleaseAllDisplays(); - } - - return success; -} - -GHOST_TSuccess GHOST_SystemCarbon::endFullScreen(void) -{ - CGReleaseAllDisplays(); - return GHOST_System::endFullScreen(); -} - -/* this is an old style low level event queue. - * As we want to handle our own timers, this is ok. - * the full screen hack should be removed */ -bool GHOST_SystemCarbon::processEvents(bool waitForEvent) -{ - bool anyProcessed = false; - EventRef event; - -// SetMouseCoalescingEnabled(false, NULL); - - do { - GHOST_TimerManager *timerMgr = getTimerManager(); - - if (waitForEvent) { - GHOST_TUns64 next = timerMgr->nextFireTime(); - double timeOut; - - if (next == GHOST_kFireTimeNever) { - timeOut = kEventDurationForever; - } - else { - timeOut = (double)(next - getMilliSeconds()) / 1000.0; - if (timeOut < 0.0) - timeOut = 0.0; - } - - ::ReceiveNextEvent(0, NULL, timeOut, false, &event); - } - - if (timerMgr->fireTimers(getMilliSeconds())) { - anyProcessed = true; - } - - if (getFullScreen()) { - // Check if the full-screen window is dirty - GHOST_IWindow *window = m_windowManager->getFullScreenWindow(); - if (((GHOST_WindowCarbon *)window)->getFullScreenDirty()) { - pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) ); - anyProcessed = true; - } - } - - /* end loop when no more events available */ - while (::ReceiveNextEvent(0, NULL, 0, true, &event) == noErr) { - OSStatus status = ::SendEventToEventTarget(event, ::GetEventDispatcherTarget()); - if (status == noErr) { - anyProcessed = true; - } - else { - UInt32 i = ::GetEventClass(event); - - /* Ignore 'cgs ' class, no documentation on what they - * are, but we get a lot of them - */ - if (i != 'cgs ') { - if (i != 'tblt') { // tablet event. we use the one packaged in the mouse event - ; //printf("Missed - Class: '%.4s', Kind: %d\n", &i, ::GetEventKind(event)); - } - } - } - ::ReleaseEvent(event); - } - } while (waitForEvent && !anyProcessed); - - return anyProcessed; -} - - -GHOST_TSuccess GHOST_SystemCarbon::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const -{ - Point mouseLoc; - // Get the position of the mouse in the active port - ::GetGlobalMouse(&mouseLoc); - // Convert the coordinates to screen coordinates - x = (GHOST_TInt32)mouseLoc.h; - y = (GHOST_TInt32)mouseLoc.v; - return GHOST_kSuccess; -} - - -GHOST_TSuccess GHOST_SystemCarbon::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) -{ - float xf = (float)x, yf = (float)y; - - CGAssociateMouseAndMouseCursorPosition(false); - CGSetLocalEventsSuppressionInterval(0); - CGWarpMouseCursorPosition(CGPointMake(xf, yf)); - CGAssociateMouseAndMouseCursorPosition(true); - -//this doesn't work properly, see game engine mouse-look scripts -// CGWarpMouseCursorPosition(CGPointMake(xf, yf)); - // this call below sends event, but empties other events (like shift) - // CGPostMouseEvent(CGPointMake(xf, yf), TRUE, 1, FALSE, 0); - - return GHOST_kSuccess; -} - - -GHOST_TSuccess GHOST_SystemCarbon::getModifierKeys(GHOST_ModifierKeys& keys) const -{ - UInt32 modifiers = ::GetCurrentKeyModifiers(); - - keys.set(GHOST_kModifierKeyOS, (modifiers & cmdKey) ? true : false); - keys.set(GHOST_kModifierKeyLeftAlt, (modifiers & optionKey) ? true : false); - keys.set(GHOST_kModifierKeyLeftShift, (modifiers & shiftKey) ? true : false); - keys.set(GHOST_kModifierKeyLeftControl, (modifiers & controlKey) ? true : false); - - return GHOST_kSuccess; -} - -/* XXX, incorrect for multibutton mice */ -GHOST_TSuccess GHOST_SystemCarbon::getButtons(GHOST_Buttons& buttons) const -{ - Boolean theOnlyButtonIsDown = ::Button(); - buttons.clear(); - buttons.set(GHOST_kButtonMaskLeft, theOnlyButtonIsDown); - return GHOST_kSuccess; -} - -#define FIRSTFILEBUFLG 512 -static bool g_hasFirstFile = false; -static char g_firstFileBuf[512]; - -extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) -{ - if (g_hasFirstFile) { - strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1); - buf[FIRSTFILEBUFLG - 1] = '\0'; - return 1; - } - else { - return 0; - } -} - -OSErr GHOST_SystemCarbon::sAEHandlerLaunch(const AppleEvent *event, AppleEvent *reply, SInt32 refCon) -{ - //GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon; - - return noErr; -} - -OSErr GHOST_SystemCarbon::sAEHandlerOpenDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon) -{ - //GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon; - AEDescList docs; - SInt32 ndocs; - OSErr err; - - err = AEGetParamDesc(event, keyDirectObject, typeAEList, &docs); - if (err != noErr) return err; - - err = AECountItems(&docs, &ndocs); - if (err == noErr) { - int i; - - for (i = 0; i < ndocs; i++) { - FSSpec fss; - AEKeyword kwd; - DescType actType; - Size actSize; - - err = AEGetNthPtr(&docs, i + 1, typeFSS, &kwd, &actType, &fss, sizeof(fss), &actSize); - if (err != noErr) - break; - - if (i == 0) { - FSRef fsref; - - if (FSpMakeFSRef(&fss, &fsref) != noErr) - break; - if (FSRefMakePath(&fsref, (UInt8 *) g_firstFileBuf, sizeof(g_firstFileBuf)) != noErr) - break; - - g_hasFirstFile = true; - } - } - } - - AEDisposeDesc(&docs); - - return err; -} - -OSErr GHOST_SystemCarbon::sAEHandlerPrintDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon) -{ - //GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) refCon; - - return noErr; -} - -OSErr GHOST_SystemCarbon::sAEHandlerQuit(const AppleEvent *event, AppleEvent *reply, SInt32 refCon) -{ - GHOST_SystemCarbon *sys = (GHOST_SystemCarbon *) refCon; - - sys->pushEvent(new GHOST_Event(sys->getMilliSeconds(), GHOST_kEventQuit, NULL) ); - - return noErr; -} - - -GHOST_TSuccess GHOST_SystemCarbon::init() -{ - - GHOST_TSuccess success = GHOST_System::init(); - if (success) { - /* - * Initialize the cursor to the standard arrow shape (so that we can change it later on). - * This initializes the cursor's visibility counter to 0. - */ - ::InitCursor(); - - MenuRef windMenu; - ::CreateStandardWindowMenu(0, &windMenu); - ::InsertMenu(windMenu, 0); - ::DrawMenuBar(); - - ::InstallApplicationEventHandler(sEventHandlerProc, GetEventTypeCount(kEvents), kEvents, this, &m_handler); - - ::AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, sAEHandlerLaunch, (SInt32) this, false); - ::AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, sAEHandlerOpenDocs, (SInt32) this, false); - ::AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, sAEHandlerPrintDocs, (SInt32) this, false); - ::AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, sAEHandlerQuit, (SInt32) this, false); - - } - return success; -} - - -GHOST_TSuccess GHOST_SystemCarbon::exit() -{ - return GHOST_System::exit(); -} - - -OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event) -{ - WindowRef windowRef; - GHOST_WindowCarbon *window; - OSStatus err = eventNotHandledErr; - - // Check if the event was send to a GHOST window - ::GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &windowRef); - window = (GHOST_WindowCarbon *) ::GetWRefCon(windowRef); - if (!validWindow(window)) { - return err; - } - - //if (!getFullScreen()) { - err = noErr; - switch (::GetEventKind(event)) - { - case kEventWindowClose: - pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) ); - break; - case kEventWindowActivated: - m_windowManager->setActiveWindow(window); - window->loadCursor(window->getCursorVisibility(), window->getCursorShape()); - pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window) ); - break; - case kEventWindowDeactivated: - m_windowManager->setWindowInactive(window); - pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window) ); - break; - case kEventWindowUpdate: - //if (getFullScreen()) GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen update event\n"); - pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) ); - break; - case kEventWindowBoundsChanged: - if (!m_ignoreWindowSizedMessages) - { - window->updateDrawingContext(); - pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) ); - } - break; - default: - err = eventNotHandledErr; - break; - } -// } - //else { - //window = (GHOST_WindowCarbon*) m_windowManager->getFullScreenWindow(); - //GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen window event, " << window << "\n"); - //::RemoveEventFromQueue(::GetMainEventQueue(), event); - //} - - return err; -} - -OSStatus GHOST_SystemCarbon::handleTabletEvent(EventRef event) -{ - GHOST_IWindow *window = m_windowManager->getActiveWindow(); - TabletPointRec tabletPointRecord; - TabletProximityRec tabletProximityRecord; - UInt32 anInt32; - GHOST_TabletData& ct = ((GHOST_WindowCarbon *)window)->GetCarbonTabletData(); - OSStatus err = eventNotHandledErr; - - ct.Pressure = 0; - ct.Xtilt = 0; - ct.Ytilt = 0; - - // is there an embedded tablet event inside this mouse event? - if (noErr == GetEventParameter(event, kEventParamTabletEventType, typeUInt32, NULL, sizeof(UInt32), NULL, (void *)&anInt32)) - { - // yes there is one! - // Embedded tablet events can either be a proximity or pointer event. - if (anInt32 == kEventTabletPoint) - { - //GHOST_PRINT("Embedded pointer event!\n"); - - // Extract the tablet Pointer Event. If there is no Tablet Pointer data - // in this event, then this call will return an error. Just ignore the - // error and go on. This can occur when a proximity event is embedded in - // a mouse event and you did not check the mouse event to see which type - // of tablet event was embedded. - if (noErr == GetEventParameter(event, kEventParamTabletPointRec, - typeTabletPointRec, NULL, - sizeof(TabletPointRec), - NULL, (void *)&tabletPointRecord)) - { - ct.Pressure = tabletPointRecord.pressure / 65535.0f; - ct.Xtilt = tabletPointRecord.tiltX / 32767.0f; /* can be positive or negative */ - ct.Ytilt = tabletPointRecord.tiltY / 32767.0f; /* can be positive or negative */ - } - } - else { - //GHOST_PRINT("Embedded proximity event\n"); - - // Extract the Tablet Proximity record from the event. - if (noErr == GetEventParameter(event, kEventParamTabletProximityRec, - typeTabletProximityRec, NULL, - sizeof(TabletProximityRec), - NULL, (void *)&tabletProximityRecord)) - { - if (tabletProximityRecord.enterProximity) { - //pointer is entering tablet area proximity - - switch (tabletProximityRecord.pointerType) - { - case 1: /* stylus */ - ct.Active = GHOST_kTabletModeStylus; - break; - case 2: /* puck, not supported so far */ - ct.Active = GHOST_kTabletModeNone; - break; - case 3: /* eraser */ - ct.Active = GHOST_kTabletModeEraser; - break; - default: - ct.Active = GHOST_kTabletModeNone; - break; - } - } - else { - // pointer is leaving - return to mouse - ct.Active = GHOST_kTabletModeNone; - } - } - } - err = noErr; - } - return err; -} - -OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event) -{ - OSStatus err = eventNotHandledErr; - GHOST_IWindow *window = m_windowManager->getActiveWindow(); - UInt32 kind = ::GetEventKind(event); - - switch (kind) - { - case kEventMouseDown: - case kEventMouseUp: - // Handle Mac application responsibilities - if ((kind == kEventMouseDown) && handleMouseDown(event)) { - err = noErr; - } - else { - GHOST_TEventType type = (kind == kEventMouseDown) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp; - EventMouseButton button; - - /* Window still gets mouse up after command-H */ - if (m_windowManager->getActiveWindow()) { - // handle any tablet events that may have come with the mouse event (optional) - handleTabletEvent(event); - - ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button); - pushEvent(new GHOST_EventButton(getMilliSeconds(), type, window, convertButton(button))); - err = noErr; - } - } - break; - - case kEventMouseMoved: - case kEventMouseDragged: - { - Point mousePos; - - if (window) { - //handle any tablet events that may have come with the mouse event (optional) - handleTabletEvent(event); - - ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos); - pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, mousePos.h, mousePos.v)); - err = noErr; - } - break; - } - case kEventMouseWheelMoved: - { - OSStatus status; - //UInt32 modifiers; - EventMouseWheelAxis axis; - SInt32 delta; - //status = ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers); - //GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); - status = ::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis); - GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); - if (axis == kEventMouseWheelAxisY) - { - status = ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(delta), NULL, &delta); - GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed"); - /* - * Limit mouse wheel delta to plus and minus one. - */ - delta = delta > 0 ? 1 : -1; - pushEvent(new GHOST_EventWheel(getMilliSeconds(), window, delta)); - err = noErr; - } - } - break; - } - - return err; -} - - -OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event) -{ - OSStatus err = eventNotHandledErr; - GHOST_IWindow *window = m_windowManager->getActiveWindow(); - UInt32 kind = ::GetEventKind(event); - UInt32 modifiers; - UInt32 rawCode; - GHOST_TKey key; - unsigned char ascii; - - /* Can happen, very rarely - seems to only be when command-H makes - * the window go away and we still get an HKey up. - */ - if (!window) { - //::GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &rawCode); - //key = convertKey(rawCode); - return err; - } - - err = noErr; - switch (kind) { - case kEventRawKeyDown: - case kEventRawKeyRepeat: - case kEventRawKeyUp: - ::GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &rawCode); - ::GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &ascii); - - key = convertKey(rawCode); - ascii = convertRomanToLatin(ascii); - - // if (key!=GHOST_kKeyUnknown) { - GHOST_TEventType type; - if (kind == kEventRawKeyDown) { - type = GHOST_kEventKeyDown; - } - else if (kind == kEventRawKeyRepeat) { - type = GHOST_kEventKeyDown; /* XXX, fixme */ - } - else { - type = GHOST_kEventKeyUp; - } - pushEvent(new GHOST_EventKey(getMilliSeconds(), type, window, key, ascii, NULL) ); -// } - break; - - case kEventRawKeyModifiersChanged: - /* ugh */ - ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); - if ((modifiers & shiftKey) != (m_modifierMask & shiftKey)) { - pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & shiftKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) ); - } - if ((modifiers & controlKey) != (m_modifierMask & controlKey)) { - pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & controlKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftControl) ); - } - if ((modifiers & optionKey) != (m_modifierMask & optionKey)) { - pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & optionKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) ); - } - if ((modifiers & cmdKey) != (m_modifierMask & cmdKey)) { - pushEvent(new GHOST_EventKey(getMilliSeconds(), (modifiers & cmdKey) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp, window, GHOST_kKeyOS) ); - } - - m_modifierMask = modifiers; - break; - - default: - err = eventNotHandledErr; - break; - } - - return err; -} - - -bool GHOST_SystemCarbon::handleMouseDown(EventRef event) -{ - WindowPtr window; - short part; - BitMap screenBits; - bool handled = true; - GHOST_WindowCarbon *ghostWindow; - Point mousePos = {0, 0}; - - ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos); - - part = ::FindWindow(mousePos, &window); - ghostWindow = (GHOST_WindowCarbon *) ::GetWRefCon(window); - - switch (part) { - case inMenuBar: - handleMenuCommand(::MenuSelect(mousePos)); - break; - - case inDrag: - /* - * The DragWindow() routine creates a lot of kEventWindowBoundsChanged - * events. By setting m_ignoreWindowSizedMessages these are suppressed. - * \see GHOST_SystemCarbon::handleWindowEvent(EventRef event) - */ - /* even worse: scale window also generates a load of events, and nothing - * is handled (read: client's event proc called) until you release mouse (ton) */ - - GHOST_ASSERT(validWindow(ghostWindow), "GHOST_SystemCarbon::handleMouseDown: invalid window"); - m_ignoreWindowSizedMessages = true; - ::DragWindow(window, mousePos, &GetQDGlobalsScreenBits(&screenBits)->bounds); - m_ignoreWindowSizedMessages = false; - - pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, ghostWindow) ); - - break; - - case inContent: - if (window != ::FrontWindow()) { - ::SelectWindow(window); - /* - * We add a mouse down event on the newly actived window - */ - //GHOST_PRINT("GHOST_SystemCarbon::handleMouseDown(): adding mouse down event, " << ghostWindow << "\n"); - EventMouseButton button; - ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button); - pushEvent(new GHOST_EventButton(getMilliSeconds(), GHOST_kEventButtonDown, ghostWindow, convertButton(button))); - } - else { - handled = false; - } - break; - - case inGoAway: - GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0"); - if (::TrackGoAway(window, mousePos)) - { - // todo: add option-close, because it's in the HIG - // if (event.modifiers & optionKey) { - // Close the clean documents, others will be confirmed one by one. - //} - // else { - pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, ghostWindow)); - //} - } - break; - - case inGrow: - GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0"); - ::ResizeWindow(window, mousePos, NULL, NULL); - break; - - case inZoomIn: - case inZoomOut: - GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0"); - if (::TrackBox(window, mousePos, part)) { - int macState; - - macState = ghostWindow->getMac_windowState(); - if (macState == 0) - ::ZoomWindow(window, part, true); - else - if (macState == 2) { // always ok - ::ZoomWindow(window, part, true); - ghostWindow->setMac_windowState(1); - } - else { // need to force size again - // GHOST_TUns32 scr_x,scr_y; /*unused*/ - Rect outAvailableRect; - - ghostWindow->setMac_windowState(2); - ::GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect); - - //this->getMainDisplayDimensions(scr_x,scr_y); - ::SizeWindow(window, outAvailableRect.right - outAvailableRect.left, outAvailableRect.bottom - outAvailableRect.top - 1, false); - ::MoveWindow(window, outAvailableRect.left, outAvailableRect.top, true); - } - - } - break; - - default: - handled = false; - break; - } - - return handled; -} - - -bool GHOST_SystemCarbon::handleMenuCommand(GHOST_TInt32 menuResult) -{ - short menuID; - short menuItem; - UInt32 command; - bool handled; - OSErr err; - - menuID = HiWord(menuResult); - menuItem = LoWord(menuResult); - - err = ::GetMenuItemCommandID(::GetMenuHandle(menuID), menuItem, &command); - - handled = false; - - if (err || command == 0) { - } - else { - switch (command) { - } - } - - ::HiliteMenu(0); - return handled; -} - - -OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData) -{ - GHOST_SystemCarbon *sys = (GHOST_SystemCarbon *) userData; - OSStatus err = eventNotHandledErr; - GHOST_IWindow *window; -#ifdef WITH_INPUT_NDOF - GHOST_TEventNDOFData data; -#endif - UInt32 kind; - - switch (::GetEventClass(event)) - { - case kEventClassAppleEvent: - EventRecord eventrec; - if (ConvertEventRefToEventRecord(event, &eventrec)) { - err = AEProcessAppleEvent(&eventrec); - } - break; - case kEventClassMouse: - err = sys->handleMouseEvent(event); - break; - case kEventClassWindow: - err = sys->handleWindowEvent(event); - break; - case kEventClassKeyboard: - err = sys->handleKeyEvent(event); - break; - case kEventClassBlender: -#ifdef WITH_INPUT_NDOF - window = sys->m_windowManager->getActiveWindow(); - sys->m_ndofManager->GHOST_NDOFGetDatas(data); - kind = ::GetEventKind(event); - - switch (kind) - { - case 1: - sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFMotion, window, data)); - // printf("motion\n"); - break; - case 2: - sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFButton, window, data)); -// printf("button\n"); - break; - } -#endif - err = noErr; - break; - default: - ; - break; - } - - return err; -} - -GHOST_TUns8 *GHOST_SystemCarbon::getClipboard(bool selection) const -{ - PasteboardRef inPasteboard; - PasteboardItemID itemID; - CFDataRef flavorData; - OSStatus err = noErr; - GHOST_TUns8 *temp_buff; - CFRange range; - OSStatus syncFlags; - - err = PasteboardCreate(kPasteboardClipboard, &inPasteboard); - if (err != noErr) { return NULL; } - - syncFlags = PasteboardSynchronize(inPasteboard); - /* as we always get in a new string, we can safely ignore sync flags if not an error*/ - if (syncFlags < 0) { return NULL; } - - - err = PasteboardGetItemIdentifier(inPasteboard, 1, &itemID); - if (err != noErr) { return NULL; } - - err = PasteboardCopyItemFlavorData(inPasteboard, itemID, CFSTR("public.utf8-plain-text"), &flavorData); - if (err != noErr) { return NULL; } - - range = CFRangeMake(0, CFDataGetLength(flavorData)); - - temp_buff = (GHOST_TUns8 *) malloc(range.length + 1); - - CFDataGetBytes(flavorData, range, (UInt8 *)temp_buff); - - temp_buff[range.length] = '\0'; - - if (temp_buff) { - return temp_buff; - } - else { - return NULL; - } -} - -void GHOST_SystemCarbon::putClipboard(GHOST_TInt8 *buffer, bool selection) const -{ - if (selection) {return; } // for copying the selection, used on X11 - - PasteboardRef inPasteboard; - CFDataRef textData = NULL; - OSStatus err = noErr; /*For error checking*/ - OSStatus syncFlags; - - err = PasteboardCreate(kPasteboardClipboard, &inPasteboard); - if (err != noErr) { return; } - - syncFlags = PasteboardSynchronize(inPasteboard); - /* as we always put in a new string, we can safely ignore sync flags */ - if (syncFlags < 0) { return; } - - err = PasteboardClear(inPasteboard); - if (err != noErr) { return; } - - textData = CFDataCreate(kCFAllocatorDefault, (UInt8 *)buffer, strlen(buffer)); - - if (textData) { - err = PasteboardPutItemFlavor(inPasteboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), textData, 0); - if (err != noErr) { - if (textData) { CFRelease(textData); } - return; - } - } - - if (textData) { - CFRelease(textData); - } -} diff --git a/intern/ghost/intern/GHOST_SystemCarbon.h b/intern/ghost/intern/GHOST_SystemCarbon.h deleted file mode 100644 index 9faf5423205..00000000000 --- a/intern/ghost/intern/GHOST_SystemCarbon.h +++ /dev/null @@ -1,298 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file ghost/intern/GHOST_SystemCarbon.h - * \ingroup GHOST - * Declaration of GHOST_SystemCarbon class. - */ - -#ifndef __GHOST_SYSTEMCARBON_H__ -#define __GHOST_SYSTEMCARBON_H__ - -#ifndef __APPLE__ -#error Apple OSX only! -#endif // __APPLE__ - -#define __CARBONSOUND__ -#include - -#include "GHOST_System.h" - -class GHOST_EventCursor; -class GHOST_EventKey; -class GHOST_EventWindow; - -/** - * OSX/Carbon Implementation of GHOST_System class. - * \see GHOST_System. - * \author Maarten Gribnau - * \date May 21, 2001 - */ -class GHOST_SystemCarbon : public GHOST_System { -public: - /** - * Constructor. - */ - GHOST_SystemCarbon(); - - /** - * Destructor. - */ - ~GHOST_SystemCarbon(); - - /*************************************************************************************** - ** Time(r) functionality - ***************************************************************************************/ - - /** - * Returns the system time. - * Returns the number of milliseconds since the start of the system process. - * Based on ANSI clock() routine. - * \return The number of milliseconds. - */ - virtual GHOST_TUns64 getMilliSeconds() const; - - /*************************************************************************************** - ** Display/window management functionality - ***************************************************************************************/ - - /** - * Returns the number of displays on this system. - * \return The number of displays. - */ - virtual GHOST_TUns8 getNumDisplays() const; - - /** - * Returns the dimensions of the main display on this system. - * \return The dimension of the main display. - */ - virtual void getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const; - - /** - * Returns the combine dimensions of all monitors. - * \return The dimension of the workspace. - */ - virtual void getAllDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const; - - /** - * Create a new window. - * The new window is added to the list of windows managed. - * Never explicitly delete the window, use disposeWindow() instead. - * \param title The name of the window (displayed in the title bar of the window if the OS supports it). - * \param left The coordinate of the left edge of the window. - * \param top The coordinate of the top edge of the window. - * \param width The width the window. - * \param height The height the window. - * \param state The state of the window when opened. - * \param type The type of drawing context installed in this window. - * \param parentWindow Parent (embedder) window - * \return The new window (or 0 if creation failed). - */ - virtual GHOST_IWindow *createWindow( - const STR_String& title, - GHOST_TInt32 left, - GHOST_TInt32 top, - GHOST_TUns32 width, - GHOST_TUns32 height, - GHOST_TWindowState state, - GHOST_TDrawingContextType type, - const bool stereoVisual, - const bool exclusive = false, - const GHOST_TUns16 numOfAASamples = 0, - const GHOST_TEmbedderWindowID parentWindow = 0 - ); - - virtual GHOST_TSuccess beginFullScreen( - const GHOST_DisplaySetting& setting, - GHOST_IWindow **window, - const bool stereoVisual - ); - - virtual GHOST_TSuccess endFullScreen(void); - - /*************************************************************************************** - ** Event management functionality - ***************************************************************************************/ - - /** - * Gets events from the system and stores them in the queue. - * \param waitForEvent Flag to wait for an event (or return immediately). - * \return Indication of the presence of events. - */ - virtual bool processEvents(bool waitForEvent); - - /*************************************************************************************** - ** Cursor management functionality - ***************************************************************************************/ - - /** - * Returns the current location of the cursor (location in screen coordinates) - * \param x The x-coordinate of the cursor. - * \param y The y-coordinate of the cursor. - * \return Indication of success. - */ - virtual GHOST_TSuccess getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const; - - /** - * Updates the location of the cursor (location in screen coordinates). - * \param x The x-coordinate of the cursor. - * \param y The y-coordinate of the cursor. - * \return Indication of success. - */ - virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y); - - /*************************************************************************************** - ** Access to mouse button and keyboard states. - ***************************************************************************************/ - - /** - * Returns the state of all modifier keys. - * \param keys The state of all modifier keys (true == pressed). - * \return Indication of success. - */ - virtual GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys& keys) const; - - /** - * Returns the state of the mouse buttons (ouside the message queue). - * \param buttons The state of the buttons. - * \return Indication of success. - */ - virtual GHOST_TSuccess getButtons(GHOST_Buttons& buttons) const; - - /** - * Returns Clipboard data - * \param selection Indicate which buffer to return - * \return Returns the selected buffer - */ - virtual GHOST_TUns8 *getClipboard(bool selection) const; - - /** - * Puts buffer to system clipboard - * \param buffer The buffer to be copied - * \param selection Indicates which buffer to copy too, only used on X11 - */ - virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const; - - /** - * \see GHOST_ISystem - */ - int toggleConsole(int action) { - return 0; - } - -protected: - /** - * Initializes the system. - * For now, it justs registers the window class (WNDCLASS). - * \return A success value. - */ - virtual GHOST_TSuccess init(); - - /** - * Closes the system down. - * \return A success value. - */ - virtual GHOST_TSuccess exit(); - - - /** - * Handles a tablet event. - * \param event A Mac event. - * \return Indication whether the event was handled. - */ - OSStatus handleTabletEvent(EventRef event); - /** - * Handles a mouse event. - * \param event A Mac event. - * \return Indication whether the event was handled. - */ - OSStatus handleMouseEvent(EventRef event); - - /** - * Handles a key event. - * \param event A Mac event. - * \return Indication whether the event was handled. - */ - OSStatus handleKeyEvent(EventRef event); - - /** - * Handles a window event. - * \param event A Mac event. - * \return Indication whether the event was handled. - */ - OSStatus handleWindowEvent(EventRef event); - - /** - * Handles all basic Mac application stuff for a mouse down event. - * \param event A Mac event. - * \return Indication whether the event was handled. - */ - bool handleMouseDown(EventRef event); - - /** - * Handles a Mac menu command. - * \param menuResult A Mac menu/item identifier. - * \return Indication whether the event was handled. - */ - bool handleMenuCommand(GHOST_TInt32 menuResult); - - /* callback for blender generated events */ - // static OSStatus blendEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData); - - - /** - * Callback for Carbon when it has events. - */ - static OSStatus sEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData); - - /** Apple Event Handlers */ - static OSErr sAEHandlerLaunch(const AppleEvent *event, AppleEvent *reply, SInt32 refCon); - static OSErr sAEHandlerOpenDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon); - static OSErr sAEHandlerPrintDocs(const AppleEvent *event, AppleEvent *reply, SInt32 refCon); - static OSErr sAEHandlerQuit(const AppleEvent *event, AppleEvent *reply, SInt32 refCon); - - /** - * Callback for Mac Timer tasks that expire. - * \param tmTask Pointer to the timer task that expired. - */ - //static void s_timerCallback(TMTaskPtr tmTask); - - /** Event handler reference. */ - EventHandlerRef m_handler; - - /** Start time at initialization. */ - GHOST_TUns64 m_start_time; - - /** State of the modifiers. */ - UInt32 m_modifierMask; - - /** Ignores window size messages (when window is dragged). */ - bool m_ignoreWindowSizedMessages; -}; - -#endif // __GHOST_SYSTEMCARBON_H__ - diff --git a/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp b/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp deleted file mode 100644 index 7d43392a79c..00000000000 --- a/intern/ghost/intern/GHOST_SystemPathsCarbon.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2009 Blender Foundation. - * All rights reserved. - * - * - * Contributor(s): Damien Plisson 2010 - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file ghost/intern/GHOST_SystemPathsCarbon.cpp - * \ingroup GHOST - */ - - -#include -#include -#include "GHOST_SystemPathsCarbon.h" - - -/***/ - -GHOST_SystemPathsCarbon::GHOST_SystemPathsCarbon() -{ -} - -GHOST_SystemPathsCarbon::~GHOST_SystemPathsCarbon() -{ -} - -const GHOST_TUns8 *GHOST_SystemPathsCarbon::getSystemDir(int, const char *versionstr) const -{ - static char systemPath[1024]; - - snprintf(systemPath, sizeof(systemPath), "/Library/Application Support/Blender/%s", versionstr); - - return (GHOST_TUns8*)systemPath; -} - -const GHOST_TUns8 *GHOST_SystemPathsCarbon::getUserDir(int, const char *versionstr) const -{ - static char usrPath[1024]; - char *env = getenv("HOME"); - - if (env) { - snprintf(usrPath, sizeof(usrPath), "%s/Library/Application Support/Blender/%s", env, versionstr); - return (GHOST_TUns8*)usrPath; - } - else - return NULL; -} - -const GHOST_TUns8 *GHOST_SystemPathsCarbon::getBinaryDir() const -{ - CFURLRef bundleURL; - CFStringRef pathStr; - static char path[256]; - CFBundleRef mainBundle = CFBundleGetMainBundle(); - - bundleURL = CFBundleCopyBundleURL(mainBundle); - pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle); - CFStringGetCString(pathStr, path, 255, kCFStringEncodingASCII); - CFRelease(pathStr); - CFRelease(bundleURL); - return (GHOST_TUns8 *)path; -} - -void GHOST_SystemPathsCarbon::addToSystemRecentFiles(const char *filename) const -{ - /* XXXXX TODO: Implementation for Carbon if possible */ - -} diff --git a/intern/ghost/intern/GHOST_SystemPathsCarbon.h b/intern/ghost/intern/GHOST_SystemPathsCarbon.h deleted file mode 100644 index 9d9a3a22564..00000000000 --- a/intern/ghost/intern/GHOST_SystemPathsCarbon.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2010 Blender Foundation. - * All rights reserved. - * - * - * Contributor(s): Damien Plisson 2010 - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file ghost/intern/GHOST_SystemPathsCarbon.h - * \ingroup GHOST - */ - - -#ifndef __GHOST_SYSTEMPATHSCARBON_H__ -#define __GHOST_SYSTEMPATHSCARBON_H__ - -#ifndef __APPLE__ -#error Apple OSX only! -#endif // __APPLE__ - -#include - -#include "GHOST_SystemPaths.h" - -/** - * OSX/Carbon Implementation of GHOST_SystemPaths class. - * \see GHOST_System. - * \author Andrea Weikert - * \date Aug 1, 2010 - */ -class GHOST_SystemPathsCarbon : public GHOST_SystemPaths { -public: - /** - * Constructor. - */ - GHOST_SystemPathsCarbon(); - - /** - * Destructor. - */ - ~GHOST_SystemPathsCarbon(); - - /** - * Determine the base dir in which shared resources are located. It will first try to use - * "unpack and run" path, then look for properly installed path, including versioning. - * \return Unsigned char string pointing to system dir (eg /usr/share/blender/). - */ - virtual const GHOST_TUns8 *getSystemDir(int version, const char *versionstr) const; - - /** - * Determine the base dir in which user configuration is stored, including versioning. - * If needed, it will create the base directory. - * \return Unsigned char string pointing to user dir (eg ~/.blender/). - */ - virtual const GHOST_TUns8 *getUserDir(int version, const char *versionstr) const; - - /** - * Determine the directory of the current binary - * \return Unsigned char string pointing to the binary dir - */ - virtual const GHOST_TUns8 *getBinaryDir() const; - - /** - * Add the file to the operating system most recently used files - */ - void addToSystemRecentFiles(const char *filename) const; -}; - -#endif // __GHOST_SYSTEMPATHSCARBON_H__ diff --git a/intern/ghost/intern/GHOST_WindowCarbon.cpp b/intern/ghost/intern/GHOST_WindowCarbon.cpp deleted file mode 100644 index 36d45b4790c..00000000000 --- a/intern/ghost/intern/GHOST_WindowCarbon.cpp +++ /dev/null @@ -1,751 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file ghost/intern/GHOST_WindowCarbon.cpp - * \ingroup GHOST - */ - - -/** - * Copyright (C) 2001 NaN Technologies B.V. - * \author Maarten Gribnau - * \date May 10, 2001 - */ - -#include "GHOST_WindowCarbon.h" -#include "GHOST_Debug.h" - -AGLContext GHOST_WindowCarbon::s_firstaglCtx = NULL; -#ifdef GHOST_DRAW_CARBON_GUTTER -const GHOST_TInt32 GHOST_WindowCarbon::s_sizeRectSize = 16; -#endif //GHOST_DRAW_CARBON_GUTTER - -static const GLint sPreferredFormatWindow[10] = { - AGL_RGBA, - AGL_DOUBLEBUFFER, - AGL_ACCELERATED, - AGL_DEPTH_SIZE, 32, - AGL_NONE, -}; - -static const GLint sPreferredFormatFullScreen[11] = { - AGL_RGBA, - AGL_DOUBLEBUFFER, - AGL_ACCELERATED, - AGL_FULLSCREEN, - AGL_DEPTH_SIZE, 32, - AGL_NONE, -}; - - - -WindowRef ugly_hack = NULL; - -const EventTypeSpec kWEvents[] = { - { kEventClassWindow, kEventWindowZoom }, /* for new zoom behaviour */ -}; - -static OSStatus myWEventHandlerProc(EventHandlerCallRef handler, EventRef event, void *userData) -{ - WindowRef mywindow; - GHOST_WindowCarbon *ghost_window; - OSStatus err; - int theState; - - if (::GetEventKind(event) == kEventWindowZoom) { - err = ::GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(mywindow), NULL, &mywindow); - ghost_window = (GHOST_WindowCarbon *) GetWRefCon(mywindow); - theState = ghost_window->getMac_windowState(); - if (theState == 1) - ghost_window->setMac_windowState(2); - else if (theState == 2) - ghost_window->setMac_windowState(1); - - } - return eventNotHandledErr; -} - -GHOST_WindowCarbon::GHOST_WindowCarbon( - const STR_String& title, - GHOST_TInt32 left, - GHOST_TInt32 top, - GHOST_TUns32 width, - GHOST_TUns32 height, - GHOST_TWindowState state, - GHOST_TDrawingContextType type, - const bool stereoVisual, - const GHOST_TUns16 numOfAASamples - ) : - GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone), - m_windowRef(0), - m_grafPtr(0), - m_aglCtx(0), - m_customCursor(0), - m_fullScreenDirty(false) -{ - Str255 title255; - OSStatus err; - - //fprintf(stderr," main screen top %i left %i height %i width %i\n", top, left, height, width); - - if (state >= GHOST_kWindowState8Normal) { - if (state == GHOST_kWindowState8Normal) state = GHOST_kWindowStateNormal; - else if (state == GHOST_kWindowState8Maximized) state = GHOST_kWindowStateMaximized; - else if (state == GHOST_kWindowState8Minimized) state = GHOST_kWindowStateMinimized; - else if (state == GHOST_kWindowState8FullScreen) state = GHOST_kWindowStateFullScreen; - - // state = state - 8; this was the simple version of above code, doesnt work in gcc 4.0 - - setMac_windowState(1); - } - else - setMac_windowState(0); - - if (state != GHOST_kWindowStateFullScreen) { - Rect bnds = { top, left, top + height, left + width }; - // Boolean visible = (state == GHOST_kWindowStateNormal) || (state == GHOST_kWindowStateMaximized); /*unused*/ - gen2mac(title, title255); - - err = ::CreateNewWindow(kDocumentWindowClass, - kWindowStandardDocumentAttributes + kWindowLiveResizeAttribute, - &bnds, - &m_windowRef); - - if (err != noErr) { - fprintf(stderr, " error creating window %i \n", (int)err); - } - else { - - ::SetWRefCon(m_windowRef, (SInt32) this); - setTitle(title); - err = InstallWindowEventHandler(m_windowRef, myWEventHandlerProc, GetEventTypeCount(kWEvents), kWEvents, NULL, NULL); - if (err != noErr) { - fprintf(stderr, " error creating handler %i \n", (int)err); - } - else { - // ::TransitionWindow (m_windowRef,kWindowZoomTransitionEffect,kWindowShowTransitionAction,NULL); - ::ShowWindow(m_windowRef); - ::MoveWindow(m_windowRef, left, top, true); - - } - } - if (m_windowRef) { - m_grafPtr = ::GetWindowPort(m_windowRef); - setDrawingContextType(type); - updateDrawingContext(); - activateDrawingContext(); - } - if (ugly_hack == NULL) { - ugly_hack = m_windowRef; - // when started from commandline, window remains in the back... also for play anim - ProcessSerialNumber psn; - GetCurrentProcess(&psn); - SetFrontProcess(&psn); - } - } - else { -#if 0 - Rect bnds = { top, left, top + height, left + width }; - gen2mac("", title255); - m_windowRef = ::NewCWindow( - nil, // Storage - &bnds, // Bounding rectangle of the window - title255, // Title of the window - 0, // Window initially visible - plainDBox, // procID - (WindowRef) - 1L, // Put window before all other windows - 0, // Window has minimize box - (SInt32) this); // Store a pointer to the class in the refCon -#endif - //GHOST_PRINT("GHOST_WindowCarbon::GHOST_WindowCarbon(): creating full-screen OpenGL context\n"); - setDrawingContextType(GHOST_kDrawingContextTypeOpenGL); - installDrawingContext(GHOST_kDrawingContextTypeOpenGL); - updateDrawingContext(); - activateDrawingContext(); - - m_tablet.Active = GHOST_kTabletModeNone; - } -} - - -GHOST_WindowCarbon::~GHOST_WindowCarbon() -{ - if (m_customCursor) delete m_customCursor; - - if (ugly_hack == m_windowRef) ugly_hack = NULL; - - // printf("GHOST_WindowCarbon::~GHOST_WindowCarbon(): removing drawing context\n"); - if (ugly_hack == NULL) setDrawingContextType(GHOST_kDrawingContextTypeNone); - if (m_windowRef) { - ::DisposeWindow(m_windowRef); - m_windowRef = 0; - } -} - -bool GHOST_WindowCarbon::getValid() const -{ - bool valid; - if (!m_fullScreen) { - valid = (m_windowRef != 0) && (m_grafPtr != 0) && ::IsValidWindowPtr(m_windowRef); - } - else { - valid = true; - } - return valid; -} - - -void GHOST_WindowCarbon::setTitle(const STR_String& title) -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setTitle(): window invalid"); - Str255 title255; - gen2mac(title, title255); - ::SetWTitle(m_windowRef, title255); -} - - -void GHOST_WindowCarbon::getTitle(STR_String& title) const -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getTitle(): window invalid"); - Str255 title255; - ::GetWTitle(m_windowRef, title255); - mac2gen(title255, title); -} - - -void GHOST_WindowCarbon::getWindowBounds(GHOST_Rect& bounds) const -{ - OSStatus success; - Rect rect; - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getWindowBounds(): window invalid"); - success = ::GetWindowBounds(m_windowRef, kWindowStructureRgn, &rect); - bounds.m_b = rect.bottom; - bounds.m_l = rect.left; - bounds.m_r = rect.right; - bounds.m_t = rect.top; -} - - -void GHOST_WindowCarbon::getClientBounds(GHOST_Rect& bounds) const -{ - Rect rect; - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getClientBounds(): window invalid"); - //::GetPortBounds(m_grafPtr, &rect); - ::GetWindowBounds(m_windowRef, kWindowContentRgn, &rect); - - bounds.m_b = rect.bottom; - bounds.m_l = rect.left; - bounds.m_r = rect.right; - bounds.m_t = rect.top; - - // Subtract gutter height from bottom -#ifdef GHOST_DRAW_CARBON_GUTTER - if ((bounds.m_b - bounds.m_t) > s_sizeRectSize) - { - bounds.m_b -= s_sizeRectSize; - } - else { - bounds.m_t = bounds.m_b; - } -#endif //GHOST_DRAW_CARBON_GUTTER -} - - -GHOST_TSuccess GHOST_WindowCarbon::setClientWidth(GHOST_TUns32 width) -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientWidth(): window invalid"); - GHOST_Rect cBnds, wBnds; - getClientBounds(cBnds); - if (((GHOST_TUns32)cBnds.getWidth()) != width) { - ::SizeWindow(m_windowRef, width, cBnds.getHeight(), true); - } - return GHOST_kSuccess; -} - - -GHOST_TSuccess GHOST_WindowCarbon::setClientHeight(GHOST_TUns32 height) -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientHeight(): window invalid"); - GHOST_Rect cBnds, wBnds; - getClientBounds(cBnds); -#ifdef GHOST_DRAW_CARBON_GUTTER - if (((GHOST_TUns32)cBnds.getHeight()) != height + s_sizeRectSize) { - ::SizeWindow(m_windowRef, cBnds.getWidth(), height + s_sizeRectSize, true); - } -#else //GHOST_DRAW_CARBON_GUTTER - if (((GHOST_TUns32)cBnds.getHeight()) != height) { - ::SizeWindow(m_windowRef, cBnds.getWidth(), height, true); - } -#endif //GHOST_DRAW_CARBON_GUTTER - return GHOST_kSuccess; -} - - -GHOST_TSuccess GHOST_WindowCarbon::setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setClientSize(): window invalid"); - GHOST_Rect cBnds, wBnds; - getClientBounds(cBnds); -#ifdef GHOST_DRAW_CARBON_GUTTER - if ((((GHOST_TUns32)cBnds.getWidth()) != width) || - (((GHOST_TUns32)cBnds.getHeight()) != height + s_sizeRectSize)) - { - ::SizeWindow(m_windowRef, width, height + s_sizeRectSize, true); - } -#else //GHOST_DRAW_CARBON_GUTTER - if ((((GHOST_TUns32)cBnds.getWidth()) != width) || - (((GHOST_TUns32)cBnds.getHeight()) != height)) { - ::SizeWindow(m_windowRef, width, height, true); - } -#endif //GHOST_DRAW_CARBON_GUTTER - return GHOST_kSuccess; -} - - -GHOST_TWindowState GHOST_WindowCarbon::getState() const -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getState(): window invalid"); - GHOST_TWindowState state; - if (::IsWindowVisible(m_windowRef) == false) { - state = GHOST_kWindowStateMinimized; - } - else if (::IsWindowInStandardState(m_windowRef, nil, nil)) { - state = GHOST_kWindowStateMaximized; - } - else { - state = GHOST_kWindowStateNormal; - } - return state; -} - - -void GHOST_WindowCarbon::screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::screenToClient(): window invalid"); - Point point; - point.h = inX; - point.v = inY; - GrafPtr oldPort; - ::GetPort(&oldPort); - ::SetPort(m_grafPtr); - ::GlobalToLocal(&point); - ::SetPort(oldPort); - outX = point.h; - outY = point.v; -} - - -void GHOST_WindowCarbon::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::clientToScreen(): window invalid"); - Point point; - point.h = inX; - point.v = inY; - GrafPtr oldPort; - ::GetPort(&oldPort); - ::SetPort(m_grafPtr); - ::LocalToGlobal(&point); - ::SetPort(oldPort); - outX = point.h; - outY = point.v; -} - - -GHOST_TSuccess GHOST_WindowCarbon::setState(GHOST_TWindowState state) -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setState(): window invalid"); - switch (state) { - case GHOST_kWindowStateMinimized: - ::HideWindow(m_windowRef); - break; - case GHOST_kWindowStateModified: - SetWindowModified(m_windowRef, 1); - break; - case GHOST_kWindowStateUnModified: - SetWindowModified(m_windowRef, 0); - break; - case GHOST_kWindowStateMaximized: - case GHOST_kWindowStateNormal: - default: - ::ShowWindow(m_windowRef); - break; - } - return GHOST_kSuccess; -} - - -GHOST_TSuccess GHOST_WindowCarbon::setOrder(GHOST_TWindowOrder order) -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setOrder(): window invalid"); - if (order == GHOST_kWindowOrderTop) { - //::BringToFront(m_windowRef); is wrong, front window should be active for input too - ::SelectWindow(m_windowRef); - } - else { - /* doesnt work if you do this with a mouseclick */ - ::SendBehind(m_windowRef, nil); - } - return GHOST_kSuccess; -} - -/*#define WAIT_FOR_VSYNC 1*/ -#ifdef WAIT_FOR_VSYNC -#include -#endif - -GHOST_TSuccess GHOST_WindowCarbon::swapBuffers() -{ -#ifdef WAIT_FOR_VSYNC -/* wait for vsync, to avoid tearing artifacts */ - long VBL = 1; - CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &VBL); -#endif - - GHOST_TSuccess succeeded = GHOST_kSuccess; - if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) { - if (m_aglCtx) { - ::aglSwapBuffers(m_aglCtx); - } - else { - succeeded = GHOST_kFailure; - } - } - return succeeded; -} - -GHOST_TSuccess GHOST_WindowCarbon::updateDrawingContext() -{ - GHOST_TSuccess succeeded = GHOST_kSuccess; - if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) { - if (m_aglCtx) { - ::aglUpdateContext(m_aglCtx); - } - else { - succeeded = GHOST_kFailure; - } - } - return succeeded; -} - -GHOST_TSuccess GHOST_WindowCarbon::activateDrawingContext() -{ - GHOST_TSuccess succeeded = GHOST_kSuccess; - if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) { - if (m_aglCtx) { - ::aglSetCurrentContext(m_aglCtx); -#ifdef GHOST_DRAW_CARBON_GUTTER - // Restrict drawing to non-gutter area - ::aglEnable(m_aglCtx, AGL_BUFFER_RECT); - GHOST_Rect bnds; - getClientBounds(bnds); - GLint b[4] = - { - bnds.m_l, - bnds.m_t + s_sizeRectSize, - bnds.m_r - bnds.m_l, - bnds.m_b - bnds.m_t - }; - GLboolean result = ::aglSetInteger(m_aglCtx, AGL_BUFFER_RECT, b); -#endif //GHOST_DRAW_CARBON_GUTTER - } - else { - succeeded = GHOST_kFailure; - } - } - return succeeded; -} - - -GHOST_TSuccess GHOST_WindowCarbon::installDrawingContext(GHOST_TDrawingContextType type) -{ - GHOST_TSuccess success = GHOST_kFailure; - switch (type) { - case GHOST_kDrawingContextTypeOpenGL: - { - if (!getValid()) break; - - AGLPixelFormat pixelFormat; - if (!m_fullScreen) { - pixelFormat = ::aglChoosePixelFormat(0, 0, sPreferredFormatWindow); - m_aglCtx = ::aglCreateContext(pixelFormat, s_firstaglCtx); - if (!m_aglCtx) break; - if (!s_firstaglCtx) s_firstaglCtx = m_aglCtx; - success = ::aglSetDrawable(m_aglCtx, m_grafPtr) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure; - } - else { - //GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL\n"); - GDHandle device = ::GetMainDevice(); pixelFormat = ::aglChoosePixelFormat(&device, 1, sPreferredFormatFullScreen); - m_aglCtx = ::aglCreateContext(pixelFormat, 0); - if (!m_aglCtx) break; - if (!s_firstaglCtx) s_firstaglCtx = m_aglCtx; - //GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): created OpenGL context\n"); - //::CGGetActiveDisplayList(0, NULL, &m_numDisplays) - success = ::aglSetFullScreen(m_aglCtx, m_fullScreenWidth, m_fullScreenHeight, 75, 0) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure; -#if 0 - if (success == GHOST_kSuccess) { - GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL succeeded\n"); - } - else { - GHOST_PRINT("GHOST_WindowCarbon::installDrawingContext(): init full-screen OpenGL failed\n"); - } -#endif - } - ::aglDestroyPixelFormat(pixelFormat); - } - break; - - case GHOST_kDrawingContextTypeNone: - success = GHOST_kSuccess; - break; - - default: - break; - } - return success; -} - - -GHOST_TSuccess GHOST_WindowCarbon::removeDrawingContext() -{ - GHOST_TSuccess success = GHOST_kFailure; - switch (m_drawingContextType) { - case GHOST_kDrawingContextTypeOpenGL: - if (m_aglCtx) { - aglSetCurrentContext(NULL); - aglSetDrawable(m_aglCtx, NULL); - //aglDestroyContext(m_aglCtx); - if (s_firstaglCtx == m_aglCtx) s_firstaglCtx = NULL; - success = ::aglDestroyContext(m_aglCtx) == GL_TRUE ? GHOST_kSuccess : GHOST_kFailure; - m_aglCtx = 0; - } - break; - case GHOST_kDrawingContextTypeNone: - success = GHOST_kSuccess; - break; - default: - break; - } - return success; -} - - -GHOST_TSuccess GHOST_WindowCarbon::invalidate() -{ - GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::invalidate(): window invalid"); - if (!m_fullScreen) { - Rect rect; - ::GetPortBounds(m_grafPtr, &rect); - ::InvalWindowRect(m_windowRef, &rect); - } - else { - //EventRef event; - //OSStatus status = ::CreateEvent(NULL, kEventClassWindow, kEventWindowUpdate, 0, 0, &event); - //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): created event " << status << " \n"); - //status = ::SetEventParameter(event, kEventParamDirectObject, typeWindowRef, sizeof(WindowRef), this); - //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): set event parameter " << status << " \n"); - //status = ::PostEventToQueue(::GetMainEventQueue(), event, kEventPriorityStandard); - //status = ::SendEventToEventTarget(event, ::GetApplicationEventTarget()); - //GHOST_PRINT("GHOST_WindowCarbon::invalidate(): added event to queue " << status << " \n"); - m_fullScreenDirty = true; - } - return GHOST_kSuccess; -} - - -void GHOST_WindowCarbon::gen2mac(const STR_String& in, Str255 out) const -{ - STR_String tempStr = in; - int num = tempStr.Length(); - if (num > 255) num = 255; - ::memcpy(out + 1, tempStr.Ptr(), num); - out[0] = num; -} - - -void GHOST_WindowCarbon::mac2gen(const Str255 in, STR_String& out) const -{ - char tmp[256]; - ::memcpy(tmp, in + 1, in[0]); - tmp[in[0]] = '\0'; - out = tmp; -} - -void GHOST_WindowCarbon::loadCursor(bool visible, GHOST_TStandardCursor cursor) const -{ - static bool systemCursorVisible = true; - - if (visible != systemCursorVisible) { - if (visible) { - ::ShowCursor(); - systemCursorVisible = true; - } - else { - ::HideCursor(); - systemCursorVisible = false; - } - } - - if (cursor == GHOST_kStandardCursorCustom && m_customCursor) { - ::SetCursor(m_customCursor); - } - else { - int carbon_cursor; - -#define GCMAP(ghostCursor, carbonCursor) case ghostCursor: carbon_cursor = carbonCursor; break - switch (cursor) { - default: - GCMAP(GHOST_kStandardCursorDefault, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorRightArrow, kThemeAliasArrowCursor); - GCMAP(GHOST_kStandardCursorLeftArrow, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorInfo, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorDestroy, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorHelp, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorCycle, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorSpray, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorWait, kThemeWatchCursor); - GCMAP(GHOST_kStandardCursorText, kThemeIBeamCursor); - GCMAP(GHOST_kStandardCursorCrosshair, kThemeCrossCursor); - GCMAP(GHOST_kStandardCursorUpDown, kThemeClosedHandCursor); - GCMAP(GHOST_kStandardCursorLeftRight, kThemeClosedHandCursor); - GCMAP(GHOST_kStandardCursorTopSide, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorBottomSide, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorLeftSide, kThemeResizeLeftCursor); - GCMAP(GHOST_kStandardCursorRightSide, kThemeResizeRightCursor); - GCMAP(GHOST_kStandardCursorTopLeftCorner, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorTopRightCorner, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorBottomRightCorner, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorBottomLeftCorner, kThemeArrowCursor); - GCMAP(GHOST_kStandardCursorCopy, kThemeCopyArrowCursor); - }; -#undef GCMAP - - ::SetThemeCursor(carbon_cursor); - } -} - - -bool GHOST_WindowCarbon::getFullScreenDirty() -{ - return m_fullScreen && m_fullScreenDirty; -} - - -GHOST_TSuccess GHOST_WindowCarbon::setWindowCursorVisibility(bool visible) -{ - if (::FrontWindow() == m_windowRef) { - loadCursor(visible, getCursorShape()); - } - - return GHOST_kSuccess; -} - -GHOST_TSuccess GHOST_WindowCarbon::setWindowCursorShape(GHOST_TStandardCursor shape) -{ - if (m_customCursor) { - delete m_customCursor; - m_customCursor = 0; - } - - if (::FrontWindow() == m_windowRef) { - loadCursor(getCursorVisibility(), shape); - } - - return GHOST_kSuccess; -} - -#if 0 /* UNUSED */ -/** Reverse the bits in a GHOST_TUns8 */ -static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch) -{ - ch = ((ch >> 1) & 0x55) | ((ch << 1) & 0xAA); - ch = ((ch >> 2) & 0x33) | ((ch << 2) & 0xCC); - ch = ((ch >> 4) & 0x0F) | ((ch << 4) & 0xF0); - return ch; -} -#endif - - -/** Reverse the bits in a GHOST_TUns16 */ -static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt) -{ - shrt = ((shrt >> 1) & 0x5555) | ((shrt << 1) & 0xAAAA); - shrt = ((shrt >> 2) & 0x3333) | ((shrt << 2) & 0xCCCC); - shrt = ((shrt >> 4) & 0x0F0F) | ((shrt << 4) & 0xF0F0); - shrt = ((shrt >> 8) & 0x00FF) | ((shrt << 8) & 0xFF00); - return shrt; -} - -GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask, - int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color) -{ - int y; - - if (m_customCursor) { - delete m_customCursor; - m_customCursor = 0; - } - - m_customCursor = new Cursor; - if (!m_customCursor) return GHOST_kFailure; - - for (y = 0; y < 16; y++) { -#if !defined(__LITTLE_ENDIAN__) - m_customCursor->data[y] = uns16ReverseBits((bitmap[2 * y] << 0) | (bitmap[2 * y + 1] << 8)); - m_customCursor->mask[y] = uns16ReverseBits((mask[2 * y] << 0) | (mask[2 * y + 1] << 8)); -#else - m_customCursor->data[y] = uns16ReverseBits((bitmap[2 * y + 1] << 0) | (bitmap[2 * y] << 8)); - m_customCursor->mask[y] = uns16ReverseBits((mask[2 * y + 1] << 0) | (mask[2 * y] << 8)); -#endif - - } - - m_customCursor->hotSpot.h = hotX; - m_customCursor->hotSpot.v = hotY; - - if (::FrontWindow() == m_windowRef) { - loadCursor(getCursorVisibility(), GHOST_kStandardCursorCustom); - } - - return GHOST_kSuccess; -} - -GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], - GHOST_TUns8 mask[16][2], int hotX, int hotY) -{ - return setWindowCustomCursorShape((GHOST_TUns8 *)bitmap, (GHOST_TUns8 *) mask, 16, 16, hotX, hotY, 0, 1); -} - - -void GHOST_WindowCarbon::setMac_windowState(short value) -{ - mac_windowState = value; -} - -short GHOST_WindowCarbon::getMac_windowState() -{ - return mac_windowState; -} diff --git a/intern/ghost/intern/GHOST_WindowCarbon.h b/intern/ghost/intern/GHOST_WindowCarbon.h deleted file mode 100644 index 16f305e93c5..00000000000 --- a/intern/ghost/intern/GHOST_WindowCarbon.h +++ /dev/null @@ -1,321 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file ghost/intern/GHOST_WindowCarbon.h - * \ingroup GHOST - * Declaration of GHOST_WindowCarbon class. - */ - -#ifndef __GHOST_WINDOWCARBON_H__ -#define __GHOST_WINDOWCARBON_H__ - -#ifndef __APPLE__ -#error Apple OSX only! -#endif // __APPLE__ - -#include "GHOST_Window.h" -#include "STR_String.h" - -#define __CARBONSOUND__ -#include - -#include - - -/** - * Window on Mac OSX/Carbon. - * Carbon windows have a size widget in the lower right corner of the window. - * To force it to be visible, the height of the client rectangle is reduced so - * that applications do not draw in that area. GHOST will manage that area - * which is called the gutter. - * When OpenGL contexts are active, GHOST will use AGL_BUFFER_RECT to prevent - * OpenGL drawing outside the reduced client rectangle. - * \author Maarten Gribnau - * \date May 23, 2001 - */ -class GHOST_WindowCarbon : public GHOST_Window { -public: - /** - * Constructor. - * Creates a new window and opens it. - * To check if the window was created properly, use the getValid() method. - * \param title The text shown in the title bar of the window. - * \param left The coordinate of the left edge of the window. - * \param top The coordinate of the top edge of the window. - * \param width The width the window. - * \param height The height the window. - * \param state The state the window is initially opened with. - * \param type The type of drawing context installed in this window. - * \param stereoVisual Stereo visual for quad buffered stereo. - */ - GHOST_WindowCarbon( - const STR_String& title, - GHOST_TInt32 left, - GHOST_TInt32 top, - GHOST_TUns32 width, - GHOST_TUns32 height, - GHOST_TWindowState state, - GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone, - const bool stereoVisual = false, - const GHOST_TUns16 numOfAASamples = 0 - ); - - /** - * Destructor. - * Closes the window and disposes resources allocated. - */ - virtual ~GHOST_WindowCarbon(); - - /** - * Returns indication as to whether the window is valid. - * \return The validity of the window. - */ - virtual bool getValid() const; - - /** - * Sets the title displayed in the title bar. - * \param title The title to display in the title bar. - */ - virtual void setTitle(const STR_String& title); - - /** - * Returns the title displayed in the title bar. - * \param title The title displayed in the title bar. - */ - virtual void getTitle(STR_String& title) const; - - /** - * Returns the window rectangle dimensions. - * The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen. - * \param bounds The bounding rectangle of the window. - */ - virtual void getWindowBounds(GHOST_Rect& bounds) const; - - /** - * Returns the client rectangle dimensions. - * The left and top members of the rectangle are always zero. - * \param bounds The bounding rectangle of the cleient area of the window. - */ - virtual void getClientBounds(GHOST_Rect& bounds) const; - - /** - * Resizes client rectangle width. - * \param width The new width of the client area of the window. - */ - virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width); - - /** - * Resizes client rectangle height. - * \param height The new height of the client area of the window. - */ - virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height); - - /** - * Resizes client rectangle. - * \param width The new width of the client area of the window. - * \param height The new height of the client area of the window. - */ - virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height); - - /** - * Returns the state of the window (normal, minimized, maximized). - * \return The state of the window. - */ - virtual GHOST_TWindowState getState() const; - - /** - * Converts a point in screen coordinates to client rectangle coordinates - * \param inX The x-coordinate on the screen. - * \param inY The y-coordinate on the screen. - * \param outX The x-coordinate in the client rectangle. - * \param outY The y-coordinate in the client rectangle. - */ - virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const; - - /** - * Converts a point in screen coordinates to client rectangle coordinates - * \param inX The x-coordinate in the client rectangle. - * \param inY The y-coordinate in the client rectangle. - * \param outX The x-coordinate on the screen. - * \param outY The y-coordinate on the screen. - */ - virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const; - - /** - * Sets the state of the window (normal, minimized, maximized). - * \param state The state of the window. - * \return Indication of success. - */ - virtual GHOST_TSuccess setState(GHOST_TWindowState state); - - /** - * Sets the order of the window (bottom, top). - * \param order The order of the window. - * \return Indication of success. - */ - virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order); - - /** - * Swaps front and back buffers of a window. - * \return A boolean success indicator. - */ - virtual GHOST_TSuccess swapBuffers(); - - /** - * Updates the drawing context of this window. Needed - * whenever the window is changed. - * \return Indication of success. - */ - GHOST_TSuccess updateDrawingContext(); - - /** - * Activates the drawing context of this window. - * \return A boolean success indicator. - */ - virtual GHOST_TSuccess activateDrawingContext(); - - virtual void loadCursor(bool visible, GHOST_TStandardCursor cursor) const; - - /** - * Returns the dirty state of the window when in full-screen mode. - * \return Whether it is dirty. - */ - virtual bool getFullScreenDirty(); - - /* accessor for fullscreen window */ - virtual void setMac_windowState(short value); - virtual short getMac_windowState(); - - - const GHOST_TabletData *GetTabletData() - { - return &m_tablet; - } - - GHOST_TabletData& GetCarbonTabletData() - { - return m_tablet; - } - - GHOST_TSuccess beginFullScreen() const {return GHOST_kFailure;} - - GHOST_TSuccess endFullScreen() const {return GHOST_kFailure;} - -protected: - /** - * Tries to install a rendering context in this window. - * \param type The type of rendering context installed. - * \return Indication as to whether installation has succeeded. - */ - virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type); - - /** - * Removes the current drawing context. - * \return Indication as to whether removal has succeeded. - */ - virtual GHOST_TSuccess removeDrawingContext(); - - /** - * Invalidates the contents of this window. - * \return Indication of success. - */ - virtual GHOST_TSuccess invalidate(); - - /** - * Sets the cursor visibility on the window using - * native window system calls. - */ - virtual GHOST_TSuccess setWindowCursorVisibility(bool visible); - - /** - * Sets the cursor shape on the window using - * native window system calls. - */ - virtual GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape); - - /** - * Sets the cursor shape on the window using - * native window system calls. - */ - virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask, - int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color); - - virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY); - - /** - * Converts a string object to a Mac Pascal string. - * \param in The string object to be converted. - * \param out The converted string. - */ - virtual void gen2mac(const STR_String& in, Str255 out) const; - - /** - * Converts a Mac Pascal string to a string object. - * \param in The string to be converted. - * \param out The converted string object. - */ - virtual void mac2gen(const Str255 in, STR_String& out) const; - - WindowRef m_windowRef; - CGrafPtr m_grafPtr; - AGLContext m_aglCtx; - - /** The first created OpenGL context (for sharing display lists) */ - static AGLContext s_firstaglCtx; - - Cursor *m_customCursor; - - GHOST_TabletData m_tablet; - - /** When running in full-screen this tells whether to refresh the window. */ - bool m_fullScreenDirty; - - /** specific MacOs X full screen window setting as we use partially system mechanism - * values : 0 not maximizable default - * 1 normal state - * 2 maximized state - * - * this will be reworked when rebuilding GHOST carbon to use new OS X apis - * in order to be unified with GHOST fullscreen/maximised settings - * - * (lukep) - **/ - - short mac_windowState; - - - /** - * The width/height of the size rectangle in the lower right corner of a - * Mac/Carbon window. This is also the height of the gutter area. - */ -#ifdef GHOST_DRAW_CARBON_GUTTER - static const GHOST_TInt32 s_sizeRectSize; -#endif // GHOST_DRAW_CARBON_GUTTER -}; - -#endif // __GHOST_WINDOWCARBON_H__ - -- cgit v1.2.3 From 7ccf1f0b46f4da702e30174ef531afe4b91e7dac Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 13:50:53 +0000 Subject: OSX: more carbon removal cleanups --- intern/ghost/SConscript | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript index 7d1f3efbe31..03868bb8b11 100644 --- a/intern/ghost/SConscript +++ b/intern/ghost/SConscript @@ -96,27 +96,17 @@ elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64 except ValueError: pass elif window_system == 'darwin': - if env['WITH_GHOST_COCOA']: - if env['WITH_BF_QUICKTIME']: - defs.append('WITH_QUICKTIME') - if env['USE_QTKIT']: - defs.append('USE_QTKIT') - for f in pf: - try: - sources.remove('intern' + os.sep + f + 'Win32.cpp') - sources.remove('intern' + os.sep + f + 'X11.cpp') - sources.remove('intern' + os.sep + f + 'SDL.cpp') - except ValueError: - pass - else: - for f in pf: - try: - sources.remove('intern' + os.sep + f + 'Win32.cpp') - sources.remove('intern' + os.sep + f + 'X11.cpp') - sources.remove('intern' + os.sep + f + 'Cocoa.mm') - sources.remove('intern' + os.sep + f + 'SDL.cpp') - except ValueError: - pass + if env['WITH_BF_QUICKTIME']: + defs.append('WITH_QUICKTIME') + if env['USE_QTKIT']: + defs.append('USE_QTKIT') + for f in pf: + try: + sources.remove('intern' + os.sep + f + 'Win32.cpp') + sources.remove('intern' + os.sep + f + 'X11.cpp') + sources.remove('intern' + os.sep + f + 'SDL.cpp') + except ValueError: + pass else: print "Unknown window system specified." @@ -151,7 +141,7 @@ if window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-v if window_system in ('win32-vc', 'win64-vc'): env.BlenderLib ('bf_intern_ghost', sources, Split(incs), defines=defs, libtype=['intern','player'], priority = [40,15]) #, cc_compileflags=env['CCFLAGS'].append('/WX') ) -elif env['WITH_GHOST_COCOA']: # always use default-Apple-gcc for objC language, for gnu-compilers do not support it fully yet +elif window_system == 'darwin': # always use default-Apple-gcc for objC language, for gnu-compilers do not support it fully yet env.BlenderLib ('bf_intern_ghost', sources, Split(incs), defines=defs, libtype=['intern','player'], priority = [40,15], cc_compilerchange='/usr/bin/gcc', cxx_compilerchange='/usr/bin/g++' ) print "GHOST COCOA WILL BE COMPILED WITH APPLE GCC" if env['WITH_BF_3DMOUSE']: -- cgit v1.2.3 From 518c505a156a925868708d4cbc96daf766f5c6e2 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 14:02:33 +0000 Subject: OSX: remove obsolete file and adapt scons --- source/blender/windowmanager/SConscript | 3 - source/blender/windowmanager/intern/wm_apple.c | 137 ------------------------- 2 files changed, 140 deletions(-) delete mode 100644 source/blender/windowmanager/intern/wm_apple.c diff --git a/source/blender/windowmanager/SConscript b/source/blender/windowmanager/SConscript index 0a2f48f0488..00d363e1539 100644 --- a/source/blender/windowmanager/SConscript +++ b/source/blender/windowmanager/SConscript @@ -66,9 +66,6 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', ' incs += ' ' + env['BF_PTHREADS_INC'] incs += ' ../../intern/utfconv' -if env['OURPLATFORM'] != 'darwin' or env['WITH_GHOST_COCOA']: - sources.remove('intern' + os.sep + 'wm_apple.c') - if env['BF_BUILDINFO']: defs.append('WITH_BUILDINFO') diff --git a/source/blender/windowmanager/intern/wm_apple.c b/source/blender/windowmanager/intern/wm_apple.c deleted file mode 100644 index 842fc353699..00000000000 --- a/source/blender/windowmanager/intern/wm_apple.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2007 Blender Foundation. - * All rights reserved. - * - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/windowmanager/intern/wm_apple.c - * \ingroup wm - */ - -/* note, this file builds on apple-carbon only! */ - -#include "BKE_context.h" -#include "BKE_global.h" -#include "WM_api.h" - -#include -#define __CARBONSOUND__ -/* XXX BIG WARNING: carbon.h can not be included in blender code, it conflicts with struct ID */ -#define ID ID_ -#include - -/* To avoid killing small end comps, we want to allow - * blender to start maximized if all the followings are true : - * - Renderer is OpenGL capable - * - Hardware acceleration - * - VRAM > 16 Mo - * - * We will bail out if VRAM is less than 8Mo - */ - -/* bad global, used in wm_window.c to open windows */ -int macPrefState = 0; - -static int checkAppleVideoCard(void) -{ - CGLRendererInfoObj rend; - long theErr; - unsigned long display_mask; - long nrend; - int j; - long value; - long maxvram = 0; /* we get always more than 1 renderer, check one, at least, has 8 Mo */ - - display_mask = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID() ); - - theErr = CGLQueryRendererInfo(display_mask, &rend, &nrend); - if (theErr == 0) { - theErr = CGLDescribeRenderer(rend, 0, kCGLRPRendererCount, &nrend); - if (theErr == 0) { - for (j = 0; j < nrend; j++) { - theErr = CGLDescribeRenderer(rend, j, kCGLRPVideoMemory, &value); - if (value > maxvram) - maxvram = value; - if ((theErr == 0) && (value >= 20000000)) { - theErr = CGLDescribeRenderer(rend, j, kCGLRPAccelerated, &value); - if ((theErr == 0) && (value != 0)) { - theErr = CGLDescribeRenderer(rend, j, kCGLRPCompliant, &value); - if ((theErr == 0) && (value != 0)) { - /*fprintf(stderr, "make it big\n");*/ - CGLDestroyRendererInfo(rend); - macPrefState = 8; - return 1; - } - } - } - } - } - } - if (maxvram < 7500000) { /* put a standard alert and quit*/ - SInt16 junkHit; - char inError[] = "* Not enough VRAM "; - char inText[] = "* blender needs at least 8Mb "; - inError[0] = 16; - inText[0] = 28; - - fprintf(stderr, " vram is %li . not enough, aborting\n", maxvram); - StandardAlert(kAlertStopAlert, (ConstStr255Param) & inError, (ConstStr255Param) & inText, NULL, &junkHit); - abort(); - } - CGLDestroyRendererInfo(rend); - return 0; -} - -static void getMacAvailableBounds(short *top, short *left, short *bottom, short *right) -{ - Rect outAvailableRect; - - GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect); - - *top = outAvailableRect.top; - *left = outAvailableRect.left; - *bottom = outAvailableRect.bottom; - *right = outAvailableRect.right; -} - - -void wm_set_apple_prefsize(int scr_x, int scr_y) -{ - - /* first let us check if we are hardware accelerated and with VRAM > 16 Mo */ - - if (checkAppleVideoCard()) { - short top, left, bottom, right; - - getMacAvailableBounds(&top, &left, &bottom, &right); - WM_init_state_size_set(left + 10, scr_y - bottom + 10, right - left - 20, bottom - 64); - G.windowstate = 0; - - } - else { - - /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */ - WM_init_state_size_set(120, 40, 850, 684); - G.windowstate = 0; - } -} -- cgit v1.2.3 From 8bc46d5be2a64d938f1fb917c9cb55d8bb5f7190 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 14:05:37 +0000 Subject: OSX/cmake: carbon cleanout --- source/blender/windowmanager/CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index b9a5b5ffaae..5f993297840 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -124,14 +124,6 @@ if(WITH_GAMEENGINE) add_definitions(-DWITH_GAMEENGINE) endif() -if(APPLE) - if(NOT WITH_COCOA) - list(APPEND SRC - intern/wm_apple.c - ) - endif() -endif() - if(WITH_BUILDINFO) add_definitions(-DWITH_BUILDINFO) endif() -- cgit v1.2.3 From e83f169da1395c7afcfe706aa498ec672cbfaf12 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 14:09:17 +0000 Subject: OSX/cmake: ghost carbon removal --- intern/ghost/CMakeLists.txt | 66 +++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 44 deletions(-) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 2cc0f476d30..15ee2644ca3 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -131,17 +131,10 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL) # ack, this is still system dependant if(APPLE) - if(WITH_COCOA) - list(APPEND SRC - intern/GHOST_SystemPathsCocoa.mm - intern/GHOST_SystemPathsCocoa.h - ) - else() - list(APPEND SRC - intern/GHOST_SystemPathsCarbon.cpp - intern/GHOST_SystemPathsCarbon.h - ) - endif() + list(APPEND SRC + intern/GHOST_SystemPathsCocoa.mm + intern/GHOST_SystemPathsCocoa.h + ) elseif(UNIX) list(APPEND SRC @@ -172,41 +165,26 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL) endif() elseif(APPLE) - if(WITH_COCOA) - list(APPEND SRC - intern/GHOST_DisplayManagerCocoa.mm - intern/GHOST_SystemCocoa.mm - intern/GHOST_SystemPathsCocoa.mm - intern/GHOST_WindowCocoa.mm - - intern/GHOST_DisplayManagerCocoa.h - intern/GHOST_SystemCocoa.h - intern/GHOST_SystemPathsCocoa.h - intern/GHOST_WindowCocoa.h - ) - - if(WITH_INPUT_NDOF) - list(APPEND SRC - intern/GHOST_NDOFManagerCocoa.mm - intern/GHOST_NDOFManagerCocoa.h - ) - list(APPEND SRC_NDOF3DCONNEXION - intern/GHOST_NDOFManager3Dconnexion.c - intern/GHOST_NDOFManager3Dconnexion.h - ) - endif() + list(APPEND SRC + intern/GHOST_DisplayManagerCocoa.mm + intern/GHOST_SystemCocoa.mm + intern/GHOST_SystemPathsCocoa.mm + intern/GHOST_WindowCocoa.mm + + intern/GHOST_DisplayManagerCocoa.h + intern/GHOST_SystemCocoa.h + intern/GHOST_SystemPathsCocoa.h + intern/GHOST_WindowCocoa.h + ) - else() + if(WITH_INPUT_NDOF) list(APPEND SRC - intern/GHOST_DisplayManagerCarbon.cpp - intern/GHOST_SystemCarbon.cpp - intern/GHOST_SystemPathsCarbon.cpp - intern/GHOST_WindowCarbon.cpp - - intern/GHOST_DisplayManagerCarbon.h - intern/GHOST_SystemCarbon.h - intern/GHOST_SystemPathsCarbon.h - intern/GHOST_WindowCarbon.h + intern/GHOST_NDOFManagerCocoa.mm + intern/GHOST_NDOFManagerCocoa.h + ) + list(APPEND SRC_NDOF3DCONNEXION + intern/GHOST_NDOFManager3Dconnexion.c + intern/GHOST_NDOFManager3Dconnexion.h ) endif() -- cgit v1.2.3 From 4df23896e5acb1bd9785d4bf5f775483d6be93f5 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 14:35:09 +0000 Subject: OSX: removing useless cocoa conditionals as it's solely api now --- intern/ghost/CMakeLists.txt | 2 +- intern/ghost/intern/GHOST_ISystem.cpp | 10 +--------- intern/ghost/intern/GHOST_ISystemPaths.cpp | 8 -------- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 15ee2644ca3..f4faa6ed84e 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -301,6 +301,6 @@ add_definitions(-DGLEW_STATIC) blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}") # workaround for apple clang mangling extern "C" symbols -if(WITH_INPUT_NDOF AND WITH_COCOA) +if(WITH_INPUT_NDOF) blender_add_lib(bf_intern_ghostndof3dconnexion "${SRC_NDOF3DCONNEXION}" "${INC}" "${INC_SYS}") endif() diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp index f6973caad03..009753cb29e 100644 --- a/intern/ghost/intern/GHOST_ISystem.cpp +++ b/intern/ghost/intern/GHOST_ISystem.cpp @@ -46,11 +46,7 @@ # include "GHOST_SystemWin32.h" #else # ifdef __APPLE__ -# ifdef GHOST_COCOA -# include "GHOST_SystemCocoa.h" -# else -# include "GHOST_SystemCarbon.h" -# endif +# include "GHOST_SystemCocoa.h" # else # include "GHOST_SystemX11.h" # endif @@ -72,11 +68,7 @@ GHOST_TSuccess GHOST_ISystem::createSystem() m_system = new GHOST_SystemWin32(); #else # ifdef __APPLE__ -# ifdef GHOST_COCOA m_system = new GHOST_SystemCocoa(); -# else - m_system = new GHOST_SystemCarbon(); -# endif # else m_system = new GHOST_SystemX11(); # endif diff --git a/intern/ghost/intern/GHOST_ISystemPaths.cpp b/intern/ghost/intern/GHOST_ISystemPaths.cpp index ae9a8e49057..581467fb666 100644 --- a/intern/ghost/intern/GHOST_ISystemPaths.cpp +++ b/intern/ghost/intern/GHOST_ISystemPaths.cpp @@ -42,11 +42,7 @@ # include "GHOST_SystemPathsWin32.h" #else # ifdef __APPLE__ -# ifdef GHOST_COCOA # include "GHOST_SystemPathsCocoa.h" -# else -# include "GHOST_SystemPathsCarbon.h" -# endif # else # include "GHOST_SystemPathsX11.h" # endif @@ -64,11 +60,7 @@ GHOST_TSuccess GHOST_ISystemPaths::create() m_systemPaths = new GHOST_SystemPathsWin32(); #else # ifdef __APPLE__ -# ifdef GHOST_COCOA m_systemPaths = new GHOST_SystemPathsCocoa(); -# else - m_systemPaths = new GHOST_SystemPathsCarbon(); -# endif # else m_systemPaths = new GHOST_SystemPathsX11(); # endif -- cgit v1.2.3 From d278b59032c01e3659f6d48ab77597fc02ca7353 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 14:38:18 +0000 Subject: OSX/scons: remove obsolete cocoa conditionals from config --- build_files/scons/config/darwin-config.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index d44b94e42b5..ee35b2c9ceb 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -13,7 +13,7 @@ USE_SDK=True ############################################################################# ################### Cocoa & architecture settings ################## ############################################################################# -WITH_GHOST_COCOA=True + MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64 @@ -359,10 +359,7 @@ CCFLAGS = ['-pipe','-funsigned-char'] CPPFLAGS = list(ARCH_FLAGS) -if WITH_GHOST_COCOA: - PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS -else: - PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS +PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS if WITH_BF_QUICKTIME: if USE_QTKIT: -- cgit v1.2.3 From a7253add34b6a35b65840d8653a86bf5f5c23f25 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 5 Nov 2013 15:37:11 +0000 Subject: Code cleanup: * Remove unused UI code for Info Space items. Was lying around here for some months already. Probably we have to re-think the whole placement of the operator history thing, but thats for later. In the current config there is no room for these buttons though. --- release/scripts/startup/bl_ui/space_info.py | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index e1b433612e0..f7bca1404bf 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -78,35 +78,6 @@ class INFO_HT_header(Header): row.operator("wm.splash", text="", icon='BLENDER', emboss=False) row.label(text=scene.statistics(), translate=False) - # XXX: BEFORE RELEASE, MOVE FILE MENU OUT OF INFO!!! - """ - sinfo = context.space_data - row = layout.row(align=True) - row.prop(sinfo, "show_report_debug", text="Debug") - row.prop(sinfo, "show_report_info", text="Info") - row.prop(sinfo, "show_report_operator", text="Operators") - row.prop(sinfo, "show_report_warning", text="Warnings") - row.prop(sinfo, "show_report_error", text="Errors") - - row = layout.row() - row.enabled = sinfo.show_report_operator - row.operator("info.report_replay") - - row.menu("INFO_MT_report") - """ - - -class INFO_MT_report(Menu): - bl_label = "Report" - - def draw(self, context): - layout = self.layout - - layout.operator("console.select_all_toggle") - layout.operator("console.select_border") - layout.operator("console.report_delete") - layout.operator("console.report_copy") - class INFO_MT_file(Menu): bl_label = "File" -- cgit v1.2.3 From 78d8a1417467a27986b8f63d1aed2f27560a6acd Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 15:37:59 +0000 Subject: OSX: complety remove the cocoa options, definitions and conditionals now --- CMakeLists.txt | 58 ++++++++++------------- SConstruct | 3 -- build_files/scons/tools/btools.py | 2 - source/blender/quicktime/SConscript | 7 +-- source/blender/quicktime/apple/quicktime_export.c | 4 +- source/blender/windowmanager/intern/wm_window.c | 30 +++--------- 6 files changed, 35 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c34fc5acb31..1302fd5bdfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -380,7 +380,6 @@ if(APPLE) add_definitions("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}") endif() - option(WITH_COCOA "Use Cocoa framework instead of deprecated Carbon" ON) option(USE_QTKIT "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF) option(WITH_LIBS10.5 "Use 10.5 libs (needed for 64bit builds)" OFF) if(CMAKE_OSX_ARCHITECTURES MATCHES x86_64) @@ -1612,47 +1611,40 @@ elseif(APPLE) set(PLATFORM_LINKLIBS stdc++) endif() - if(WITH_COCOA) - set(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA") - set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio") - if(USE_QTKIT) - set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT") - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit") - if(CMAKE_OSX_ARCHITECTURES MATCHES i386) - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime") - # libSDL still needs 32bit carbon quicktime - endif() - elseif(WITH_CODEC_QUICKTIME) + set(PLATFORM_CFLAGS "-pipe -funsigned-char") + set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio") + if(USE_QTKIT) + set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT") + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit") + if(CMAKE_OSX_ARCHITECTURES MATCHES i386) set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime") + # libSDL still needs 32bit carbon quicktime endif() + elseif(WITH_CODEC_QUICKTIME) + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime") + endif() - # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED! - # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL - if(WITH_INPUT_NDOF) - # This thread it *should* work and check the framework - campbell - # http://www.cmake.org/pipermail/cmake/2005-December/007740.html - find_library(3DCONNEXION_CLIENT_FRAMEWORK - NAMES 3DconnexionClient - ) - if(NOT 3DCONNEXION_CLIENT_FRAMEWORK) - set(WITH_INPUT_NDOF OFF) - endif() + # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED! + # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL + if(WITH_INPUT_NDOF) + # This thread it *should* work and check the framework - campbell + # http://www.cmake.org/pipermail/cmake/2005-December/007740.html + find_library(3DCONNEXION_CLIENT_FRAMEWORK + NAMES 3DconnexionClient + ) + if(NOT 3DCONNEXION_CLIENT_FRAMEWORK) + set(WITH_INPUT_NDOF OFF) + endif() - if(WITH_INPUT_NDOF) - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework 3DconnexionClient") - set(NDOF_INCLUDE_DIRS /Library/Frameworks/3DconnexionClient.framework/Headers ) - endif() + if(WITH_INPUT_NDOF) + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework 3DconnexionClient") + set(NDOF_INCLUDE_DIRS /Library/Frameworks/3DconnexionClient.framework/Headers ) endif() + endif() if(WITH_JACK) set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework jackmp") endif() - - else() - set(PLATFORM_CFLAGS "-pipe -funsigned-char") - set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime") - set(WITH_INPUT_NDOF OFF) # unsupported - endif() if(WITH_PYTHON_MODULE OR WITH_PYTHON_FRAMEWORK) set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Python")# force cmake to link right framework diff --git a/SConstruct b/SConstruct index 9f9eaa886a3..07227e6bd06 100644 --- a/SConstruct +++ b/SConstruct @@ -342,9 +342,6 @@ if env['WITH_BF_OPENMP'] == 1: else: env.Append(CCFLAGS=['-fopenmp']) -if env['WITH_GHOST_COCOA'] == True: - env.Append(CPPFLAGS=['-DGHOST_COCOA']) - if env['USE_QTKIT'] == True: env.Append(CPPFLAGS=['-DUSE_QTKIT']) diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 9a5521fff44..9ad4315f442 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -138,7 +138,6 @@ def validate_arguments(args, bc): 'WITHOUT_BF_PYTHON_INSTALL', 'WITHOUT_BF_PYTHON_UNPACK', 'WITH_BF_PYTHON_INSTALL_NUMPY', 'WITHOUT_BF_OVERWRITE_INSTALL', 'WITH_BF_OPENMP', 'BF_OPENMP', 'BF_OPENMP_LIBPATH', 'WITH_BF_STATICOPENMP', 'BF_OPENMP_STATIC_STATIC', - 'WITH_GHOST_COCOA', 'WITH_GHOST_SDL', 'WITH_GHOST_XDND', 'WITH_X11_XINPUT', @@ -424,7 +423,6 @@ def read_opts(env, cfg, args): ('BF_OPENMP', 'Base path to OpenMP (used when cross-compiling with older versions of WinGW)', ''), ('BF_OPENMP_INC', 'Path to OpenMP includes (used when cross-compiling with older versions of WinGW)', ''), ('BF_OPENMP_LIBPATH', 'Path to OpenMP libraries (used when cross-compiling with older versions of WinGW)', ''), - (BoolVariable('WITH_GHOST_COCOA', 'Use Cocoa-framework if true', True)), (BoolVariable('WITH_GHOST_SDL', 'Enable building blender against SDL for windowing rather then the native APIs', False)), (BoolVariable('WITH_X11_XINPUT', 'Enable X11 Xinput (tablet support and unicode input)', True)), (BoolVariable('WITH_X11_XF86VMODE', 'Enable X11 video mode switching', True)), diff --git a/source/blender/quicktime/SConscript b/source/blender/quicktime/SConscript index a6debf06226..7d726ed7c7a 100644 --- a/source/blender/quicktime/SConscript +++ b/source/blender/quicktime/SConscript @@ -58,8 +58,5 @@ priorities = [200,235] defs=['WITH_QUICKTIME'] -if env['WITH_GHOST_COCOA']: - defs.append('GHOST_COCOA') - env.BlenderLib ('bf_quicktime', sources=source_files, includes=incs, defines=defs, libtype=types, priority=priorities, cc_compilerchange='/usr/bin/gcc', cxx_compilerchange='/usr/bin/g++') # always use default-Apple-gcc for objC language, gnu-compilers do not support it fully yet -else: - env.BlenderLib ('bf_quicktime', sources=source_files, includes=incs, defines=defs, libtype=types, priority=priorities) +env.BlenderLib ('bf_quicktime', sources=source_files, includes=incs, defines=defs, libtype=types, priority=priorities, cc_compilerchange='/usr/bin/gcc', cxx_compilerchange='/usr/bin/g++') # always use default-Apple-gcc for objC language, gnu-compilers do not support it fully yet + diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c index 52ef21e4f39..67be8b169c6 100644 --- a/source/blender/quicktime/apple/quicktime_export.c +++ b/source/blender/quicktime/apple/quicktime_export.c @@ -890,7 +890,7 @@ static int ED_operator_setqtcodec(bContext *C) return G.have_quicktime != FALSE; } -#if defined(__APPLE__) && defined(GHOST_COCOA) +#if defined(__APPLE__) /* Need to set up a Cocoa NSAutoReleasePool to avoid memory leak * And it must be done in an objC file, so use a GHOST_SystemCocoa.mm function for that */ extern int cocoa_request_qtcodec_settings_exec(bContext *C, wmOperator *op); @@ -910,7 +910,7 @@ void SCENE_OT_render_data_set_quicktime_codec(wmOperatorType *ot) ot->idname = "SCENE_OT_render_data_set_quicktime_codec"; /* api callbacks */ -#if defined(__APPLE__) && defined(GHOST_COCOA) +#if defined(__APPLE__) ot->exec = cocoa_request_qtcodec_settings_exec; #else ot->exec = request_qtcodec_settings_exec; diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 9e89c17e024..5f344340643 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -133,10 +133,6 @@ static void wm_window_check_position(rcti *rect) wm_get_screensize(&width, &height); -#if defined(__APPLE__) && !defined(GHOST_COCOA) - height -= 70; -#endif - if (rect->xmin < 0) { rect->xmax -= rect->xmin; rect->xmin = 0; @@ -338,12 +334,6 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) * in case of OS application terminate request (e.g. OS Shortcut Alt+F4, Cmd+Q, (...), or session end) */ GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8) !wm->file_saved); -#if defined(__APPLE__) && !defined(GHOST_COCOA) - if (wm->file_saved) - GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateUnModified); - else - GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateModified); -#endif } } @@ -428,20 +418,12 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) if (wm_init_state.size_x == 0) { wm_get_screensize(&wm_init_state.size_x, &wm_init_state.size_y); -#if defined(__APPLE__) && !defined(GHOST_COCOA) - /* Cocoa provides functions to get correct max window size */ - { - extern void wm_set_apple_prefsize(int, int); /* wm_apple.c */ - - wm_set_apple_prefsize(wm_init_state.size_x, wm_init_state.size_y); - } -#else - /* note!, this isnt quite correct, active screen maybe offset 1000s if PX, - * we'd need a wm_get_screensize like function that gives offset, - * in practice the window manager will likely move to the correct monitor */ - wm_init_state.start_x = 0; - wm_init_state.start_y = 0; -#endif + /* note!, this isnt quite correct, active screen maybe offset 1000s if PX, + * we'd need a wm_get_screensize like function that gives offset, + * in practice the window manager will likely move to the correct monitor */ + wm_init_state.start_x = 0; + wm_init_state.start_y = 0; + #if !defined(__APPLE__) && !defined(WIN32) /* X11 */ /* X11, start maximized but use default sane size */ -- cgit v1.2.3 From 37f45454d3be45ccdc18d4138b85f6017b771525 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 15:48:26 +0000 Subject: Fix linking for non-apple ndof --- intern/ghost/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index f4faa6ed84e..beca24fc5e9 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -301,6 +301,6 @@ add_definitions(-DGLEW_STATIC) blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}") # workaround for apple clang mangling extern "C" symbols -if(WITH_INPUT_NDOF) +if(WITH_INPUT_NDOF AND APPLE) blender_add_lib(bf_intern_ghostndof3dconnexion "${SRC_NDOF3DCONNEXION}" "${INC}" "${INC_SYS}") endif() -- cgit v1.2.3 From c215faf9f4c02774a430ea9b960fede7a1ed209c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 5 Nov 2013 15:53:55 +0000 Subject: Fix [#37319] Forcefield on translated, unselected lamp draws in origin. drawlamp() was not resetting OGL matrix to its org value! Thanks to Philipp Oeser for initial investigation, and Brecht for review. :) --- source/blender/editors/space_view3d/drawobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index d9dc549f207..c4c246be711 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1356,6 +1356,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } /* and back to viewspace */ + glPushMatrix(); glLoadMatrixf(rv3d->viewmat); copy_v3_v3(vec, ob->obmat[3]); @@ -1391,6 +1392,8 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* restore for drawing extra stuff */ glColor3ubv(ob_wire_col); } + /* and finally back to org object space! */ + glPopMatrix(); } static void draw_limit_line(float sta, float end, const short dflag, unsigned int col) @@ -6876,7 +6879,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short case OB_LAMP: if (!render_override) { drawlamp(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); - if (dtx || (base->flag & SELECT)) glMultMatrixf(ob->obmat); } break; case OB_CAMERA: -- cgit v1.2.3 From 25b1280c504c0a80010de7c74ef65c887a8d9cf8 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 16:00:23 +0000 Subject: OSX: buildbot cleanups after carbon removal --- build_files/buildbot/config/user-config-mac-i386.py | 10 +++------- build_files/buildbot/config/user-config-mac-x86_64.py | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/build_files/buildbot/config/user-config-mac-i386.py b/build_files/buildbot/config/user-config-mac-i386.py index ad0fbcc78da..c86bc284d0b 100644 --- a/build_files/buildbot/config/user-config-mac-i386.py +++ b/build_files/buildbot/config/user-config-mac-i386.py @@ -13,7 +13,7 @@ USE_SDK=True ############################################################################# ################### Cocoa & architecture settings ################## ############################################################################# -WITH_GHOST_COCOA=True + MACOSX_ARCHITECTURE = 'i386' # valid archs: ppc, i386, ppc64, x86_64 @@ -43,8 +43,7 @@ cmd = 'xcodebuild -showsdks' cmd_sdk=commands.getoutput(cmd) MACOSX_SDK_CHECK=cmd_sdk -if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64': - USE_QTKIT=True # Carbon quicktime is not available for 64bit +USE_QTKIT=True # Carbon quicktime is not available for 64bit # Default target OSX settings per architecture @@ -352,10 +351,7 @@ CCFLAGS = ['-pipe','-funsigned-char'] CPPFLAGS = list(ARCH_FLAGS) -if WITH_GHOST_COCOA: - PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS -else: - PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS +PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS if WITH_BF_QUICKTIME: if USE_QTKIT: diff --git a/build_files/buildbot/config/user-config-mac-x86_64.py b/build_files/buildbot/config/user-config-mac-x86_64.py index fb0a084cf4d..e51259ad5af 100644 --- a/build_files/buildbot/config/user-config-mac-x86_64.py +++ b/build_files/buildbot/config/user-config-mac-x86_64.py @@ -13,7 +13,7 @@ USE_SDK=True ############################################################################# ################### Cocoa & architecture settings ################## ############################################################################# -WITH_GHOST_COCOA=True + MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64 @@ -43,8 +43,7 @@ cmd = 'xcodebuild -showsdks' cmd_sdk=commands.getoutput(cmd) MACOSX_SDK_CHECK=cmd_sdk -if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64': - USE_QTKIT=True # Carbon quicktime is not available for 64bit +USE_QTKIT=True # Carbon quicktime is not available for 64bit # Default target OSX settings per architecture @@ -352,10 +351,7 @@ CCFLAGS = ['-pipe','-funsigned-char'] CPPFLAGS = list(ARCH_FLAGS) -if WITH_GHOST_COCOA: - PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS -else: - PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Carbon','-framework','AGL','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS +PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS if WITH_BF_QUICKTIME: if USE_QTKIT: -- cgit v1.2.3 From 6c4b06a46d919c96bb31c2de30ba8368cbbf788c Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 16:04:32 +0000 Subject: OSX: also remove USE_QTKIT option from configs, leave env var for later use ( always True ) --- build_files/buildbot/config/user-config-mac-i386.py | 3 --- build_files/buildbot/config/user-config-mac-x86_64.py | 3 --- build_files/scons/config/darwin-config.py | 4 ---- 3 files changed, 10 deletions(-) diff --git a/build_files/buildbot/config/user-config-mac-i386.py b/build_files/buildbot/config/user-config-mac-i386.py index c86bc284d0b..1629ad0d67c 100644 --- a/build_files/buildbot/config/user-config-mac-i386.py +++ b/build_files/buildbot/config/user-config-mac-i386.py @@ -43,9 +43,6 @@ cmd = 'xcodebuild -showsdks' cmd_sdk=commands.getoutput(cmd) MACOSX_SDK_CHECK=cmd_sdk -USE_QTKIT=True # Carbon quicktime is not available for 64bit - - # Default target OSX settings per architecture # Can be customized diff --git a/build_files/buildbot/config/user-config-mac-x86_64.py b/build_files/buildbot/config/user-config-mac-x86_64.py index e51259ad5af..fe4154dd2da 100644 --- a/build_files/buildbot/config/user-config-mac-x86_64.py +++ b/build_files/buildbot/config/user-config-mac-x86_64.py @@ -43,9 +43,6 @@ cmd = 'xcodebuild -showsdks' cmd_sdk=commands.getoutput(cmd) MACOSX_SDK_CHECK=cmd_sdk -USE_QTKIT=True # Carbon quicktime is not available for 64bit - - # Default target OSX settings per architecture # Can be customized diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index ee35b2c9ceb..f81658afe6a 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -49,10 +49,6 @@ if XCODE_SELECT_PATH.endswith("/Contents/Developer"): else: XCODE_BUNDLE=XCODE_SELECT_PATH -if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'ppc64': - USE_QTKIT=True # Carbon quicktime is not available for 64bit - - # Default target OSX settings per architecture # Can be customized -- cgit v1.2.3 From c8e2b54ce251ce3c67f3e2443118655835ddd8df Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 5 Nov 2013 16:20:06 +0000 Subject: Fix [#37324] Crash, calling Warp operator in Outliner Warp needs a valid 3DView region... --- source/blender/editors/transform/transform_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 4b5ae8963d5..8f31e49bfe9 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -706,7 +706,7 @@ static void TRANSFORM_OT_warp(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_screenactive; + ot->poll = ED_operator_region_view3d_active; RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); -- cgit v1.2.3 From 538a6ed57a0b0576617b1f5546bbc9f936338ab5 Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Tue, 5 Nov 2013 16:24:00 +0000 Subject: Rewrote a lot of knife tool. Now allows cut-through to make new vertices in the middle of faces. This also fixes knife bugs: #36678, #35945, #35943, #35387, #35045, #35002. --- source/blender/editors/mesh/editmesh_knife.c | 1761 +++++++++----------------- 1 file changed, 596 insertions(+), 1165 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index adb03ab837b..f961b6aefe9 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -76,6 +76,7 @@ #define KNIFE_FLT_EPS 0.00001f #define KNIFE_FLT_EPS_SQUARED (KNIFE_FLT_EPS * KNIFE_FLT_EPS) +#define KNIFE_FLT_EPSBIG 0.001f typedef struct KnifeColors { unsigned char line[3]; @@ -111,16 +112,20 @@ typedef struct KnifeEdge { bool draw; } KnifeEdge; -typedef struct BMEdgeHit { - KnifeEdge *kfe; +typedef struct KnifeLineHit { float hit[3], cagehit[3]; - float realhit[3]; /* used in midpoint mode */ float schit[2]; float l; /* lambda along cut line */ float perc; /* lambda along hit line */ - KnifeVert *v; /* set if snapped to a vert */ + float m; /* depth front-to-back */ + + /* Exactly one of kfe, v, or f should be non-NULL, + * saying whether cut line crosses and edge, + * is snapped to a vert, or is in the middle of some face. */ + KnifeEdge *kfe; + KnifeVert *v; BMFace *f; -} BMEdgeHit; +} KnifeLineHit; typedef struct KnifePosData { float co[3]; @@ -152,8 +157,8 @@ typedef struct KnifeTool_OpData { GHash *origvertmap; GHash *origedgemap; - GHash *kedgefacemap; + GHash *facetrimap; BMBVHTree *bmbvh; @@ -164,7 +169,7 @@ typedef struct KnifeTool_OpData { float ethresh; /* used for drag-cutting */ - BMEdgeHit *linehits; + KnifeLineHit *linehits; int totlinehit; /* Data for mouse-position-derived data (cur) and previous click (prev) */ @@ -215,13 +220,11 @@ typedef struct KnifeTool_OpData { static ListBase *knife_get_face_kedges(KnifeTool_OpData *kcd, BMFace *f); -#if 0 -static void knife_input_ray_cast(KnifeTool_OpData *kcd, const float mval[2], - float r_origin[3], float r_ray[3]); -#endif static void knife_input_ray_segment(KnifeTool_OpData *kcd, const float mval[2], const float ofs, float r_origin[3], float r_dest[3]); +static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f); + static void knife_update_header(bContext *C, KnifeTool_OpData *kcd) { #define HEADER_LENGTH 256 @@ -238,13 +241,6 @@ static void knife_update_header(bContext *C, KnifeTool_OpData *kcd) ED_area_headerprint(CTX_wm_area(C), header); } -#if 0 -BLI_INLINE int round_ftoi(float x) -{ - return x > 0.0f ? (int)(x + 0.5f) : (int)(x - 0.5f); -} -#endif - static void knife_project_v2(const KnifeTool_OpData *kcd, const float co[3], float sco[2]) { ED_view3d_project_float_v2_m4(kcd->ar, co, sco, (float (*)[4])kcd->projmat); @@ -290,6 +286,12 @@ static Ref *find_ref(ListBase *lb, void *ref) return NULL; } +static void knife_append_list_no_dup(KnifeTool_OpData *kcd, ListBase *lst, void *elem) +{ + if (!find_ref(lst, elem)) + knife_append_list(kcd, lst, elem); +} + static KnifeEdge *new_knife_edge(KnifeTool_OpData *kcd) { kcd->totkedge++; @@ -387,6 +389,45 @@ static KnifeEdge *get_bm_knife_edge(KnifeTool_OpData *kcd, BMEdge *e) return kfe; } +/* Record the index in kcd->em->looptris of first looptri triple for a given face, + * given an index for some triple in that array. + * This assumes that all of the triangles for a given face are contiguous + * in that array (as they are by the current tesselation routines). + * Actually store index + 1 in the hash, because 0 looks like "no entry" + * to hash lookup routine; will reverse this in the get routine. + * Doing this lazily rather than all at once for all faces. + */ +static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index) +{ + int i; + + if (BLI_ghash_lookup(kcd->facetrimap, f)) + return; + + BLI_assert(index >= 0 && index < kcd->em->tottri); + BLI_assert(kcd->em->looptris[index][0]->f == f); + for (i = index - 1; i >= 0; i--) { + if (kcd->em->looptris[i][0]->f != f) { + i++; + break; + } + } + if (i == -1) + i++; + + BLI_ghash_insert(kcd->facetrimap, f, SET_INT_IN_POINTER(i + 1)); +} + +/* This should only be called for faces that have had a lowest face tri set by previous function */ +static int get_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f) +{ + int ans; + + ans = GET_INT_FROM_POINTER(BLI_ghash_lookup(kcd->facetrimap, f)); + BLI_assert(ans != 0); + return ans - 1; +} + /* User has just clicked for first time or first time after a restart (E key). * Copy the current position data into prev. */ static void knife_start_cut(KnifeTool_OpData *kcd) @@ -430,12 +471,6 @@ static ListBase *knife_get_face_kedges(KnifeTool_OpData *kcd, BMFace *f) return lst; } -/* finds the proper face to restrict face fill to */ -static void knife_find_basef(KnifeEdge *kfe) -{ - kfe->basef = knife_find_common_face(&kfe->v1->faces, &kfe->v2->faces); -} - static void knife_edge_append_face(KnifeTool_OpData *kcd, KnifeEdge *kfe, BMFace *f) { knife_append_list(kcd, knife_get_face_kedges(kcd, f), kfe); @@ -493,466 +528,263 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd, KnifeEdge *kfe, float return newkfe->v2; } -/* Make a single KnifeEdge for cut from kcd->prev to kcd->curr. - * and move cur data to prev. */ -static void knife_add_single_cut(KnifeTool_OpData *kcd) +/* primary key: lambda along cut + * secondary key: lambda along depth + * tertiary key: pointer comparisons of verts if both snapped to verts + */ +static int linehit_compare(const void *vlh1, const void *vlh2) { - KnifeEdge *kfe, *kfe2 = NULL, *kfe3 = NULL; - - if ((kcd->prev.vert && kcd->prev.vert == kcd->curr.vert) || - (kcd->prev.edge && kcd->prev.edge == kcd->curr.edge)) - { - kcd->prev = kcd->curr; - return; - } + const KnifeLineHit *lh1 = vlh1; + const KnifeLineHit *lh2 = vlh2; - kfe = new_knife_edge(kcd); - kfe->draw = true; - - if (kcd->prev.vert) { - kfe->v1 = kcd->prev.vert; - } - else if (kcd->prev.edge) { - kfe->v1 = knife_split_edge(kcd, kcd->prev.edge, kcd->prev.co, &kfe2); - } - else { - kfe->v1 = new_knife_vert(kcd, kcd->prev.co, kcd->prev.co); - kfe->v1->draw = kfe->draw = !kcd->prev.is_space; - kfe->v1->in_space = kcd->prev.is_space; - kfe->draw = !kcd->prev.is_space; - kfe->v1->is_face = true; - if (kfe->v1->draw && kcd->prev.bmface) - knife_append_list(kcd, &kfe->v1->faces, kcd->prev.bmface); - } - - if (kcd->curr.vert) { - kfe->v2 = kcd->curr.vert; - } - else if (kcd->curr.edge) { - kfe->v2 = knife_split_edge(kcd, kcd->curr.edge, kcd->curr.co, &kfe3); - kcd->curr.vert = kfe->v2; - } + if (lh1->l < lh2->l) return -1; + else if (lh1->l > lh2->l) return 1; else { - kfe->v2 = new_knife_vert(kcd, kcd->curr.co, kcd->curr.co); - kfe->v2->draw = !kcd->curr.is_space; - kfe->v2->is_face = true; - kfe->v2->in_space = kcd->curr.is_space; - if (kfe->v2->draw && kcd->curr.bmface) - knife_append_list(kcd, &kfe->v2->faces, kcd->curr.bmface); - - if (kcd->curr.is_space) - kfe->draw = false; - - kcd->curr.vert = kfe->v2; - } - - knife_find_basef(kfe); - - knife_add_to_vert_edges(kcd, kfe); - - if (kfe->basef && !find_ref(&kfe->faces, kfe->basef)) - knife_edge_append_face(kcd, kfe, kfe->basef); - - /* sanity check to make sure we're in the right edge/face lists */ - if (kcd->curr.bmface) { - if (!find_ref(&kfe->faces, kcd->curr.bmface)) { - knife_edge_append_face(kcd, kfe, kcd->curr.bmface); - } - - if (kcd->prev.bmface && kcd->prev.bmface != kcd->curr.bmface) { - if (!find_ref(&kfe->faces, kcd->prev.bmface)) { - knife_edge_append_face(kcd, kfe, kcd->prev.bmface); - } + if (lh1->m < lh2->m) return -1; + else if (lh1->m > lh2->m) return 1; + else { + if (lh1->v < lh2->v) return -1; + else if (lh1->v > lh2->v) return 1; + else return 0; } } - - /* set up for next cut */ - kcd->prev = kcd->curr; } -static int verge_linehit(const void *vlh1, const void *vlh2) -{ - const BMEdgeHit *lh1 = vlh1, *lh2 = vlh2; - - if (lh1->l < lh2->l) return -1; - else if (lh1->l > lh2->l) return 1; - else if (lh1->v && lh2->v) { - /* want like verts to sort together; just compare pointers */ - if (lh1->v < lh2->v) return -1; - else if (lh1->v > lh2->v) return 1; - else return 0; - } - else return 0; -} - -/* If there's a linehit connected (same face) as testi in range [firsti, lasti], return the first such, else -1. - * It also counts as connected if both linehits are snapped to the same vertex. - * If testi is out of range, look for connection to f instead, if f is non-NULL */ -static int find_connected_linehit(KnifeTool_OpData *kcd, int testi, BMFace *f, int firsti, int lasti) -{ - int i; - ListBase *testfaces, *ifaces; - BMFace *testface, *iface; - BMEdgeHit *lh; - bool shareface; - - if (testi >= 0 && testi < kcd->totlinehit) { - testface = NULL; - testfaces = NULL; - lh = &kcd->linehits[testi]; - if (lh->v) - testfaces = &lh->v->faces; - else if (lh->kfe) - testfaces = &lh->kfe->faces; - else if (lh->f) { - testfaces = NULL; - testface = lh->f; - } - } - else { - testface = f; - testfaces = NULL; - } - for (i = firsti; i <= lasti; i++) { - shareface = false; - lh = &kcd->linehits[i]; - iface = NULL; - ifaces = NULL; - if (lh->v) - ifaces = &lh->v->faces; - else if (lh->kfe) - ifaces = &lh->kfe->faces; - else if (lh->f) { - ifaces = NULL; - iface = lh->f; - } - if (testfaces) { - if (ifaces) - shareface = (knife_find_common_face(testfaces, ifaces) != NULL); - else if (iface) - shareface = (find_ref(testfaces, iface) != NULL); - } - else if (ifaces) { - if (testface) - shareface = (find_ref(ifaces, testface) != NULL); - } - else if (testface && iface) { - shareface = (testface == iface); - } - if (shareface) - return i; - } - return -1; -} - -/* Sort in order of distance along cut line. - * Remove any successive linehits that are snapped to the same vertex. - * If joinfaces, treat hits at same distance as follows: try to find - * ordering so that preceding and succeeding hits will share a face. +/* + * Sort linehits by distance along cut line, and secondarily from + * front to back (from eye), and tertiarily by snap vertex, + * and remove any duplicates. */ -static void knife_sort_linehits(KnifeTool_OpData *kcd, bool joinfaces) +static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) { - int i, j, k, nexti, nsame; + KnifeLineHit *linehits, *lhi, *lhj; + int i, j, n; - qsort(kcd->linehits, kcd->totlinehit, sizeof(BMEdgeHit), verge_linehit); + n = kcd->totlinehit; + linehits = kcd->linehits; + if (n == 0) + return; - /* Remove duplicated linehits snapped to same vertex */ - i = j = 0; /* loop copies from j to i */ - while (j < kcd->totlinehit) { - nsame = 0; - if (kcd->linehits[j].v) { - for (k = j + 1; k < kcd->totlinehit; k++) { - if (kcd->linehits[k].v != kcd->linehits[j].v) + qsort(linehits, n, sizeof(KnifeLineHit), linehit_compare); + + /* Remove any edge hits that are preceded or followed + * by a vertex hit that is very near. Mark such edge hits using + * l == -1 and then do another pass to actually remove. + * Also remove all but one of a series of vertex hits for the same vertex. */ + for (i = 0; i < n; i++) { + lhi = &linehits[i]; + if (lhi->v) { + for (j = i - 1; j >= 0; j--) { + lhj = &linehits[j]; + if (!lhj->kfe || + fabsf(lhi->l - lhj->l) > KNIFE_FLT_EPSBIG || + fabsf(lhi->m - lhj->m) > KNIFE_FLT_EPSBIG) + { break; - nsame++; + } + lhj->l = -1.0f; + } + for (j = i + 1; j < n; j++) { + lhj = &linehits[j]; + if (fabsf(lhi->l - lhj->l) > KNIFE_FLT_EPSBIG || + fabsf(lhi->m - lhj->m) > KNIFE_FLT_EPSBIG) + { + break; + } + if (lhj->kfe || lhi->v == lhj->v) { + lhj->l = -1.0f; + } } } - if (i != j) - kcd->linehits[i] = kcd->linehits[j]; - i++; - j += 1 + nsame; } - kcd->totlinehit = i; - if (!joinfaces) - return; - - /* for ranges of equal "l", swap if neccesary to make predecessor and - * successor faces connected to the linehits at either end of the range */ - for (i = 0; i < kcd->totlinehit - 1; i = nexti) { - for (j = i + 1; j < kcd->totlinehit; j++) { - if (fabsf(kcd->linehits[j].l - kcd->linehits[i].l) > KNIFE_FLT_EPS) - break; + /* delete-in-place loop: copying from pos j to pos i+1 */ + i = 0; + j = 1; + while (j < n) { + lhi = &linehits[i]; + lhj = &linehits[j]; + if (lhj->l == -1.0f) { + j++; /* skip copying this one */ } - nexti = j; - j--; - nsame = j - i; - if (nsame > 0) { - /* find something connected to predecessor of equal range */ - k = find_connected_linehit(kcd, i - 1, kcd->prev.bmface, i, j); - if (k != -1) { - if (k != i) { - SWAP(BMEdgeHit, kcd->linehits[i], kcd->linehits[k]); - } - i++; - nsame--; + else { + /* copy unless a no-op */ + if (lhi->l == -1.0f) { + /* could happen if linehits[0] is being deleted */ + memcpy(&linehits[i], &linehits[j], sizeof(KnifeLineHit)); } - if (nsame > 0) { - /* find something connected to successor of equal range */ - k = find_connected_linehit(kcd, j + 1, kcd->curr.bmface, i, j); - if (k != -1 && k != j) { - SWAP(BMEdgeHit, kcd->linehits[j], kcd->linehits[k]); - } + else { + if (i + 1 != j) + memcpy(&linehits[i + 1], &linehits[j], sizeof(KnifeLineHit)); + i++; } - /* rest of same range doesn't matter because we won't connect them */ + j++; } } + kcd->totlinehit = i + 1; } -static void knife_add_single_cut_through(KnifeTool_OpData *kcd, KnifeVert *v1, KnifeVert *v2, BMFace *f) +/* Add hit to list of hits in facehits[f], where facehits is a map, if not already there */ +static void add_hit_to_facehits(KnifeTool_OpData *kcd, GHash *facehits, BMFace *f, KnifeLineHit *hit) { - KnifeEdge *kfenew; - - kfenew = new_knife_edge(kcd); - kfenew->basef = f; - kfenew->v1 = v1; - kfenew->v2 = v2; - kfenew->draw = true; + ListBase *lst = BLI_ghash_lookup(facehits, f); - knife_add_to_vert_edges(kcd, kfenew); - - if (!find_ref(&kfenew->faces, f)) - knife_edge_append_face(kcd, kfenew, f); + if (!lst) { + lst = knife_empty_list(kcd); + BLI_ghash_insert(facehits, f, lst); + } + knife_append_list_no_dup(kcd, lst, hit); } -#if 0 -static void knife_get_vert_faces(KnifeTool_OpData *kcd, KnifeVert *kfv, BMFace *facef, ListBase *lst) +static void knife_add_single_cut(KnifeTool_OpData *kcd, KnifeLineHit *lh1, KnifeLineHit *lh2, BMFace *f) { - BMIter bmiter; - BMFace *f; - Ref *r; + KnifeEdge *kfe, *kfe2; - if (kfv->is_face && facef) { - knife_append_list(kcd, lst, facef); - } - else if (kfv->v) { - BM_ITER_ELEM (f, &bmiter, kfv->v, BM_FACES_OF_VERT) { - knife_append_list(kcd, lst, f); - } - } - else { - for (r = kfv->faces.first; r; r = r->next) { - knife_append_list(kcd, lst, r->ref); - } + if ((lh1->v && lh1->v == lh2->v) || + (lh1->kfe && lh1->kfe == lh2->kfe)) + { + return; } -} -static void knife_get_edge_faces(KnifeTool_OpData *kcd, KnifeEdge *kfe, ListBase *lst) -{ - BMIter bmiter; - BMFace *f; - - if (kfe->e) { - BM_ITER_ELEM (f, &bmiter, kfe->e, BM_FACES_OF_EDGE) { - knife_append_list(kcd, lst, f); + /* Check if edge actually lies within face (might not, if this face is concave) */ + if (lh1->v && lh2->v) { + if (!knife_verts_edge_in_face(lh1->v, lh2->v, f)) { + return; } } -} -#endif - -static void copy_hit_from_posdata(BMEdgeHit *lh, KnifePosData *pos, float lambda) -{ - lh->kfe = pos->edge; - lh->v = pos->vert; - lh->f = pos->bmface; - copy_v3_v3(lh->hit, pos->co); - copy_v3_v3(lh->cagehit, pos->cage); - copy_v3_v3(lh->realhit, pos->co); - lh->l = lambda; - /* perc and schit not used by callers of this function */ -} -/* BMESH_TODO: add more functionality to cut-through: - * - cutting "in face" (e.g., holes) should cut in all faces, not just visible one - * - perhaps improve O(n^2) algorithm used here */ -static void knife_cut_through(KnifeTool_OpData *kcd) -{ - BMEdgeHit *lh, *lh2, *linehits; - BMFace *f; - KnifeEdge *kfe, *kfe2; - KnifeVert *v1, *v2, *lastv; - ListBase *faces1, *faces2; - KnifeEdge **splitkfe; - bool needprev, needcurr; - int i, j, n; + kfe = new_knife_edge(kcd); + kfe->draw = true; + kfe->basef = f; - if (!kcd->totlinehit) { - /* if no linehits then no interesting back face stuff to do */ - knife_add_single_cut(kcd); - return; + if (lh1->v) { + kfe->v1 = lh1->v; + } + else if (lh1->kfe) { + kfe->v1 = knife_split_edge(kcd, lh1->kfe, lh1->cagehit, &kfe2); + lh1->v = kfe->v1; /* record the KnifeVert for this hit */ + } + else { + BLI_assert(lh1->f); + kfe->v1 = new_knife_vert(kcd, lh1->hit, lh1->cagehit); + kfe->v1->draw = true; + kfe->v1->is_face = true; + knife_append_list(kcd, &kfe->v1->faces, lh1->f); + lh1->v = kfe->v1; /* record the KnifeVert for this hit */ } - /* sort eliminates hits on same vertices */ - knife_sort_linehits(kcd, false); - - /* code is cleaner if make prev and curr into hits (if they are on edges or verts) */ - n = kcd->totlinehit; - needprev = ((kcd->prev.vert && kcd->prev.vert != kcd->linehits[0].v) || kcd->prev.edge); - needcurr = ((kcd->curr.vert && kcd->curr.vert != kcd->linehits[n - 1].v) || kcd->curr.edge); - n += needprev + needcurr; - linehits = MEM_callocN(n * sizeof(BMEdgeHit), "knife_cut_through"); - i = 0; - if (needprev) { - copy_hit_from_posdata(&linehits[0], &kcd->prev, 0.0f); - i++; + if (lh2->v) { + kfe->v2 = lh2->v; + } + else if (lh2->kfe) { + kfe->v2 = knife_split_edge(kcd, lh2->kfe, lh2->cagehit, &kfe2); + lh2->v = kfe->v2; /* future uses of lh2 won't split again */ + } + else { + BLI_assert(lh2->f); + kfe->v2 = new_knife_vert(kcd, lh2->hit, lh2->cagehit); + kfe->v2->draw = true; + kfe->v2->is_face = true; + knife_append_list(kcd, &kfe->v2->faces, lh2->f); + lh2->v = kfe->v2; /* record the KnifeVert for this hit */ } - memcpy(linehits + i, kcd->linehits, kcd->totlinehit * sizeof(BMEdgeHit)); - i += kcd->totlinehit; - if (needcurr) - copy_hit_from_posdata(&linehits[i], &kcd->curr, 1.0f); + knife_add_to_vert_edges(kcd, kfe); - splitkfe = MEM_callocN(n * sizeof(KnifeEdge *), "knife_cut_through"); + /* TODO: check if this is ever needed */ + if (kfe->basef && !find_ref(&kfe->faces, kfe->basef)) + knife_edge_append_face(kcd, kfe, kfe->basef); - lastv = NULL; - for (i = 0, lh = linehits; i < n; i++, lh++) { - kfe = lh->kfe; - v1 = NULL; +} - /* get faces incident on hit lh */ - if (lh->v) { - v1 = lh->v; - faces1 = &v1->faces; - } - else if (kfe) { - faces1 = &kfe->faces; - } +/* Given a list of KnifeLineHits for one face, sorted by l + * and then by m, make the required KnifeVerts and + * KnifeEdges. + */ +static void knife_cut_face(KnifeTool_OpData *kcd, BMFace *f, ListBase *hits) +{ + Ref *r; + KnifeLineHit *lh, *prevlh; + int n; - /* For each following hit, connect if lh1 an lh2 share a face */ - for (j = i + 1, lh2 = lh + 1; j < n; j++, lh2++) { - kfe2 = lh2->kfe; - v2 = NULL; - if (lh2->v) { - v2 = lh2->v; - faces2 = &v2->faces; - } - else if (kfe2) { - faces2 = &kfe2->faces; - } + (void) kcd; - f = knife_find_common_face(faces1, faces2); - if (f) { - if (!v1) - v1 = splitkfe[i] ? kfe->v1 : knife_split_edge(kcd, kfe, lh->hit, &splitkfe[i]); - if (!v2) - v2 = splitkfe[j] ? kfe2->v1 : knife_split_edge(kcd, kfe2, lh2->hit, &splitkfe[j]); - knife_add_single_cut_through(kcd, v1, v2, f); - lastv = v2; - } - } - } + n = BLI_countlist(hits); + if (n < 2) + return; - MEM_freeN(splitkfe); - MEM_freeN(linehits); - MEM_freeN(kcd->linehits); - kcd->linehits = NULL; - kcd->totlinehit = 0; + prevlh = NULL; + for (r = hits->first; r; r = r->next) { + lh = (KnifeLineHit *)r->ref; + if (prevlh) + knife_add_single_cut(kcd, prevlh, lh, f); + prevlh = lh; + } - /* set up for next cut */ - kcd->curr.vert = lastv; - kcd->prev = kcd->curr; } /* User has just left-clicked after the first time. * Add all knife cuts implied by line from prev to curr. - * If that line crossed edges then kcd->linehits will be non-NULL. */ + * If that line crossed edges then kcd->linehits will be non-NULL. + * Make all of the KnifeVerts and KnifeEdges implied by this cut. + */ static void knife_add_cut(KnifeTool_OpData *kcd) { - KnifePosData savcur = kcd->curr; + int i; + KnifeLineHit *lh; + GHash *facehits; + BMFace *f; + Ref *r; + GHashIterator giter; + ListBase *lst; - if (kcd->cut_through) { - knife_cut_through(kcd); + prepare_linehits_for_cut(kcd); + if (kcd->totlinehit == 0) { + kcd->prev = kcd->curr; + return; } - else if (kcd->linehits) { - BMEdgeHit *lh, *lastlh, *firstlh; - int i; - - knife_sort_linehits(kcd, true); - lh = kcd->linehits; - lastlh = firstlh = NULL; - for (i = 0; i < kcd->totlinehit; i++, (lastlh = lh), lh++) { - BMFace *f = lastlh ? lastlh->f : lh->f; - - if (lastlh && len_squared_v3v3(lastlh->hit, lh->hit) == 0.0f) { - if (!firstlh) - firstlh = lastlh; - continue; - } - else if (lastlh && firstlh) { - if (firstlh->v || lastlh->v) { - KnifeVert *kfv = firstlh->v ? firstlh->v : lastlh->v; - - kcd->prev.vert = kfv; - copy_v3_v3(kcd->prev.co, firstlh->hit); - copy_v3_v3(kcd->prev.cage, firstlh->cagehit); - kcd->prev.edge = NULL; - kcd->prev.bmface = f; - /* TODO: should we set prev.in_space = 0 ? */ - } - lastlh = firstlh = NULL; - } - - if (len_squared_v3v3(kcd->prev.cage, lh->realhit) < KNIFE_FLT_EPS_SQUARED) - continue; - if (len_squared_v3v3(kcd->curr.cage, lh->realhit) < KNIFE_FLT_EPS_SQUARED) - continue; - - /* first linehit may be down face parallel to view */ - if (!lastlh && !lh->v && fabsf(lh->l) < KNIFE_FLT_EPS) - continue; - - if (kcd->prev.is_space) { - kcd->prev.is_space = 0; - copy_v3_v3(kcd->prev.co, lh->hit); - copy_v3_v3(kcd->prev.cage, lh->cagehit); - kcd->prev.vert = lh->v; - kcd->prev.edge = lh->kfe; - kcd->prev.bmface = lh->f; - continue; - } - - kcd->curr.is_space = 0; - kcd->curr.edge = lh->kfe; - kcd->curr.bmface = lh->f; - kcd->curr.vert = lh->v; - copy_v3_v3(kcd->curr.co, lh->hit); - copy_v3_v3(kcd->curr.cage, lh->cagehit); - - /* don't draw edges down faces parallel to view */ - if (lastlh && fabsf(lastlh->l - lh->l) < KNIFE_FLT_EPS) { - kcd->prev = kcd->curr; - continue; - } - - knife_add_single_cut(kcd); + /* make facehits: map face -> list of linehits touching it */ + facehits = BLI_ghash_ptr_new("knife facehits"); + for (i = 0; i < kcd->totlinehit; i++) { + lh = &kcd->linehits[i]; + if (lh->f) { + add_hit_to_facehits(kcd, facehits, lh->f, lh); } - - if (savcur.is_space) { - kcd->prev = savcur; + if (lh->v) { + for (r = lh->v->faces.first; r; r = r->next) { + add_hit_to_facehits(kcd, facehits, r->ref, lh); + } } - else { - kcd->curr = savcur; - knife_add_single_cut(kcd); + if (lh->kfe) { + for (r = lh->kfe->faces.first; r; r = r->next) { + add_hit_to_facehits(kcd, facehits, r->ref, lh); + } } + } - MEM_freeN(kcd->linehits); - kcd->linehits = NULL; - kcd->totlinehit = 0; + /* Note: as following loop progresses, the 'v' fields of + * the linehits will be filled in (as edges are split or + * in-face verts are made), so it may be true that both + * the v and the kfe or f fields will be non-NULL. */ + GHASH_ITER (giter, facehits) { + f = (BMFace *)BLI_ghashIterator_getKey(&giter); + lst = (ListBase *)BLI_ghashIterator_getValue(&giter); + knife_cut_face(kcd, f, lst); } - else { - knife_add_single_cut(kcd); + + /* set up for next cut */ + kcd->prev = kcd->curr; + if (kcd->prev.bmface) { + /* was "in face" but now we have a KnifeVert it is snapped to */ + kcd->prev.bmface = NULL; + kcd->prev.vert = kcd->linehits[kcd->totlinehit - 1].v; } + + BLI_ghash_free(facehits, NULL, NULL); + MEM_freeN(kcd->linehits); + kcd->linehits = NULL; + kcd->totlinehit = 0; } static void knife_finish_cut(KnifeTool_OpData *UNUSED(kcd)) @@ -1101,6 +933,24 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) glLineWidth(1.0); } + if (kcd->prev.vert) { + glColor3ubv(kcd->colors.point); + glPointSize(11); + + glBegin(GL_POINTS); + glVertex3fv(kcd->prev.cage); + glEnd(); + } + + if (kcd->prev.bmface) { + glColor3ubv(kcd->colors.curpoint); + glPointSize(9); + + glBegin(GL_POINTS); + glVertex3fv(kcd->prev.cage); + glEnd(); + } + if (kcd->curr.edge) { glColor3ubv(kcd->colors.edge); glLineWidth(2.0); @@ -1131,10 +981,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) } if (kcd->totlinehit > 0) { - const float vthresh4 = kcd->vthresh / 4.0f; - const float vthresh4_sq = vthresh4 * vthresh4; - - BMEdgeHit *lh; + KnifeLineHit *lh; int i; glEnable(GL_BLEND); @@ -1146,22 +993,8 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) glBegin(GL_POINTS); lh = kcd->linehits; for (i = 0; i < kcd->totlinehit; i++, lh++) { - float sv1[2], sv2[2]; - - knife_project_v2(kcd, lh->kfe->v1->cageco, sv1); - knife_project_v2(kcd, lh->kfe->v2->cageco, sv2); - knife_project_v2(kcd, lh->cagehit, lh->schit); - - if (len_squared_v2v2(lh->schit, sv1) < vthresh4_sq) { - copy_v3_v3(lh->cagehit, lh->kfe->v1->cageco); + if (lh->v) glVertex3fv(lh->cagehit); - lh->v = lh->kfe->v1; - } - else if (len_squared_v2v2(lh->schit, sv2) < vthresh4_sq) { - copy_v3_v3(lh->cagehit, lh->kfe->v2->cageco); - glVertex3fv(lh->cagehit); - lh->v = lh->kfe->v2; - } } glEnd(); @@ -1171,7 +1004,8 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) glBegin(GL_POINTS); lh = kcd->linehits; for (i = 0; i < kcd->totlinehit; i++, lh++) { - glVertex3fv(lh->cagehit); + if (!lh->v) + glVertex3fv(lh->cagehit); } glEnd(); glDisable(GL_BLEND); @@ -1224,274 +1058,72 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } -static float len_v3_tri_side_max(const float v1[3], const float v2[3], const float v3[3]) -{ - const float s1 = len_squared_v3v3(v1, v2); - const float s2 = len_squared_v3v3(v2, v3); - const float s3 = len_squared_v3v3(v3, v1); - - return sqrtf(max_fff(s1, s2, s3)); -} - -/** - * given a tri, return 3 planes aligned with the tri's normal. - * - * If the triangle were extruded along its normal, - * the planes calculated would be the 3 sides around the extrusion. - */ -static void plane_from_tri_clip3_v3( - float tri_plane_clip[3][4], - const float v0[3], const float v1[3], const float v2[3]) -{ - float tri_norm[3]; - float tvec[3], cross[3]; - - normal_tri_v3(tri_norm, v0, v1, v2); - - sub_v3_v3v3(tvec, v0, v1); - cross_v3_v3v3(cross, tvec, tri_norm); - plane_from_point_normal_v3(tri_plane_clip[0], v0, cross); - - sub_v3_v3v3(tvec, v1, v2); - cross_v3_v3v3(cross, tvec, tri_norm); - plane_from_point_normal_v3(tri_plane_clip[1], v1, cross); - - sub_v3_v3v3(tvec, v2, v0); - cross_v3_v3v3(cross, tvec, tri_norm); - plane_from_point_normal_v3(tri_plane_clip[2], v2, cross); -} - -/** - * Given a line that is planar with a tri, clip the segment by that tri. - * - * This is needed so we end up with both points in the triangle. - */ -static bool isect_line_tri_coplanar_v3( - const float p1[3], const float p2[3], - const float v0[3], const float v1[3], const float v2[3], - float r_isects[2][3], - - /* avoid re-calculating every time */ - float tri_plane[4], float tri_plane_clip[3][4]) -{ - float p1_tmp[3] = {UNPACK3(p1)}; - float p2_tmp[3] = {UNPACK3(p2)}; - - (void)v0, (void)v1, (void)v2; - - /* first check if the points are planar with the tri */ - if ((fabsf(dist_squared_to_plane_v3(p1, tri_plane)) < KNIFE_FLT_EPS_SQUARED) && - (fabsf(dist_squared_to_plane_v3(p2, tri_plane)) < KNIFE_FLT_EPS_SQUARED) && - /* clip the segment by planes around the triangle so we can be sure the points - * aren't outside the triangle */ - (clip_segment_v3_plane_n(p1_tmp, p2_tmp, tri_plane_clip, 3))) - { - copy_v3_v3(r_isects[0], p1_tmp); - copy_v3_v3(r_isects[1], p2_tmp); - - return true; - } - else { - return false; - } -} - -static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, - const float v1[3], const float v2[3], const float v3[3], - SmallHash *ehash, bglMats *mats, int *count) -{ - BVHTree *tree2 = BLI_bvhtree_new(3, FLT_EPSILON * 4, 8, 8), *tree = BKE_bmbvh_tree_get(bmtree); - BMEdgeHit *edges = NULL; - BLI_array_declare(edges); - BVHTreeOverlap *results, *result; - BMLoop **ls; - float cos[9], tri_norm[3], tri_plane[4], isects[2][3], lambda; - float tri_plane_clip[3][4]; - unsigned int tot = 0; - int i, j, n_isects; - - - /* for comparing distances, error of intersection depends on triangle scale. - * need to scale down before squaring for accurate comparison */ - const float depsilon = (FLT_EPSILON / 2.0f) * len_v3_tri_side_max(v1, v2, v3); - const float depsilon_sq = depsilon * depsilon; - - copy_v3_v3(cos + 0, v1); - copy_v3_v3(cos + 3, v2); - copy_v3_v3(cos + 6, v3); - - /* avoid re-calculation in #isect_line_tri_coplanar_v3 */ - normal_tri_v3(tri_norm, v1, v2, v3); - plane_from_point_normal_v3(tri_plane, v1, tri_norm); - plane_from_tri_clip3_v3(tri_plane_clip, v1, v2, v3); - - BLI_bvhtree_insert(tree2, 0, cos, 3); - BLI_bvhtree_balance(tree2); - - result = results = BLI_bvhtree_overlap(tree, tree2, &tot); - - for (i = 0; i < tot; i++, result++) { - BMLoop *l1; - BMFace *f_hit; - ListBase *lst; - Ref *ref; - - ls = (BMLoop **)kcd->em->looptris[result->indexA]; - - l1 = ls[0]; - lst = knife_get_face_kedges(kcd, l1->f); - - for (ref = lst->first; ref; ref = ref->next) { - KnifeEdge *kfe = ref->ref; - - if (BLI_smallhash_haskey(ehash, (uintptr_t)kfe)) { - continue; /* We already found a hit on this knife edge */ - } - - n_isects = 0; - - if (isect_line_tri_coplanar_v3(kfe->v1->cageco, kfe->v2->cageco, v1, v2, v3, - isects, - /* cached values */ - tri_plane, tri_plane_clip)) - { - /* both kfe ends are in cutting triangle */ - n_isects = 2; - } - else if (isect_line_tri_epsilon_v3(kfe->v1->cageco, kfe->v2->cageco, v1, v2, v3, - &lambda, NULL, depsilon)) - { - /* kfe intersects cutting triangle lambda of the way along kfe */ - interp_v3_v3v3(isects[0], kfe->v1->cageco, kfe->v2->cageco, lambda); - n_isects = 1; - } - - for (j = 0; j < n_isects; j++) { - float p[3]; - - copy_v3_v3(p, isects[j]); - if (kcd->curr.vert && len_squared_v3v3(kcd->curr.vert->cageco, p) < depsilon_sq) { - continue; - } - if (kcd->prev.vert && len_squared_v3v3(kcd->prev.vert->cageco, p) < depsilon_sq) { - continue; - } - if (len_squared_v3v3(kcd->prev.cage, p) < depsilon_sq || - len_squared_v3v3(kcd->curr.cage, p) < depsilon_sq) - { - continue; - } - if ((kcd->vc.rv3d->rflag & RV3D_CLIPPING) && - ED_view3d_clipping_test(kcd->vc.rv3d, p, true)) - { - continue; - } - - if (kcd->cut_through) { - f_hit = NULL; - } - else { - /* check if this point is visible in the viewport */ - float p1[3], no[3], view[3], sp[2]; - float lambda1; - - /* screen projection */ - knife_project_v2(kcd, p, sp); - ED_view3d_unproject(mats, view, sp[0], sp[1], 0.0f); - mul_m4_v3(kcd->ob->imat, view); - - /* if face isn't planer, p may be behind the current tesselated tri, - * so move it onto that and then a little towards eye */ - if (isect_line_tri_v3(p, view, ls[0]->v->co, ls[1]->v->co, ls[2]->v->co, &lambda1, NULL)) { - interp_v3_v3v3(p1, p, view, lambda1); - } - else { - copy_v3_v3(p1, p); - } - sub_v3_v3(view, p1); - normalize_v3(view); - - copy_v3_v3(no, view); - mul_v3_fl(no, 0.003); - - /* go towards view a bit */ - add_v3_v3(p1, no); - - /* ray cast */ - f_hit = BKE_bmbvh_ray_cast(bmtree, p1, no, KNIFE_FLT_EPS, NULL, NULL, NULL); - } - - /* ok, if visible add the new point */ - if (!f_hit && !BLI_smallhash_haskey(ehash, (uintptr_t)kfe)) { - BMEdgeHit hit; - - if (len_squared_v3v3(p, kcd->curr.co) < depsilon_sq || - len_squared_v3v3(p, kcd->prev.co) < depsilon_sq) - { - continue; - } - - hit.kfe = kfe; - hit.v = NULL; - hit.l = 0.0f; - - knife_find_basef(kfe); - hit.f = kfe->basef; - hit.perc = len_v3v3(p, kfe->v1->cageco) / len_v3v3(kfe->v1->cageco, kfe->v2->cageco); - copy_v3_v3(hit.cagehit, p); - - interp_v3_v3v3(p, kfe->v1->co, kfe->v2->co, hit.perc); - copy_v3_v3(hit.realhit, p); - - if (kcd->snap_midpoints) { - float perc = hit.perc; - - /* select the closest from the edge endpoints or the midpoint */ - if (perc < 0.25f) { - perc = 0.0f; - } - else if (perc < 0.75f) { - perc = 0.5f; - } - else { - perc = 1.0f; - } +/* Find intersection of v1-v2 with face f. + * Only take intersections that are at least face_tol (in screen space) away + * from other intersection elements. + * If v1-v2 is coplanar with f, call that "no intersection though + * it really means "infinite number of intersections". + * In such a case we should have gotten hits on edges or verts of the face. */ +static bool knife_ray_intersect_face(KnifeTool_OpData *kcd, + const float s[2], + const float v1[2], const float v2[2], + BMFace *f, + const float face_tol, + float intersectp[3]) +{ + int tottri, tri_i; + float lv1[3], lv2[3], lv3[3], raydir[3]; + float tri_norm[3], tri_plane[4]; + float se1[2], se2[2]; + float d, lambda; + BMLoop **tri; + ListBase *lst; + Ref *ref; + KnifeEdge *kfe; - interp_v3_v3v3(hit.hit, kfe->v1->co, kfe->v2->co, perc); - interp_v3_v3v3(hit.cagehit, kfe->v1->cageco, kfe->v2->cageco, perc); - } - else if (hit.perc < KNIFE_FLT_EPS || hit.perc > 1.0f - KNIFE_FLT_EPS) { - /* snap to vert */ - hit.v = (hit.perc < KNIFE_FLT_EPS) ? kfe->v1 : kfe->v2; - copy_v3_v3(hit.hit, hit.v->co); - copy_v3_v3(hit.cagehit, hit.v->co); - } - else { - copy_v3_v3(hit.hit, p); - } - knife_project_v2(kcd, hit.cagehit, hit.schit); + sub_v3_v3v3(raydir, v2, v1); + normalize_v3(raydir); + tri_i = get_lowest_face_tri(kcd, f); + tottri = kcd->em->tottri; + BLI_assert(tri_i >= 0 && tri_i < tottri); - BLI_array_append(edges, hit); - BLI_smallhash_insert(ehash, (uintptr_t)kfe, NULL); + for (; tri_i < tottri; tri_i++) { + tri = kcd->em->looptris[tri_i]; + if (tri[0]->f != f) + break; + copy_v3_v3(lv1, kcd->cagecos[BM_elem_index_get(tri[0]->v)]); + copy_v3_v3(lv2, kcd->cagecos[BM_elem_index_get(tri[1]->v)]); + copy_v3_v3(lv3, kcd->cagecos[BM_elem_index_get(tri[2]->v)]); + /* using epsilon test in case ray is directly through an internal + * tesselation edge and might not hit either tesselation tri with + * an exact test; + * we will exclude hits near real edges by a later test */ + if (isect_ray_tri_epsilon_v3(v1, raydir, lv1, lv2, lv3, &lambda, NULL, KNIFE_FLT_EPS)) { + /* check if line coplanar with tri */ + normal_tri_v3(tri_norm, lv1, lv2, lv3); + plane_from_point_normal_v3(tri_plane, lv1, tri_norm); + if ((fabsf(dist_squared_to_plane_v3(v1, tri_plane)) < KNIFE_FLT_EPS) && + (fabsf(dist_squared_to_plane_v3(v2, tri_plane)) < KNIFE_FLT_EPS)) + { + return false; + } + copy_v3_v3(intersectp, v1); + madd_v3_v3fl(intersectp, raydir, lambda); + /* Now check that far enough away from verts and edges */ + lst = knife_get_face_kedges(kcd, f); + for (ref = lst->first; ref; ref = ref->next) { + kfe = ref->ref; + knife_project_v2(kcd, kfe->v1->cageco, se1); + knife_project_v2(kcd, kfe->v2->cageco, se2); + d = dist_to_line_segment_v2(s, se1, se2); + if (d < face_tol) { + return false; } } + return true; } } - - if (results) - MEM_freeN(results); - - BLI_bvhtree_free(tree2); - *count = BLI_array_count(edges); - - return edges; -} - -static void knife_bgl_get_mats(KnifeTool_OpData *UNUSED(kcd), bglMats *mats) -{ - bgl_get_mats(mats); - //copy_m4_m4(mats->modelview, kcd->vc.rv3d->viewmat); - //copy_m4_m4(mats->projection, kcd->vc.rv3d->winmat); + return false; } /* Calculate maximum excursion from (0,0,0) of mesh */ @@ -1510,6 +1142,43 @@ static void calc_ortho_extent(KnifeTool_OpData *kcd) kcd->ortho_extent = max_xyz; } +/* Check if p is visible (not clipped, not occluded by another face). + * s in screen projection of p. */ +static bool point_is_visible(KnifeTool_OpData *kcd, const float p[3], const float s[2], bglMats *mats) +{ + float p1[3], no[3], view[3]; + BMFace *f_hit; + + /* If not cutting through, make sure no face is in front of p */ + if (!kcd->cut_through) { + /* TODO: I think there's a simpler way to get the required raycast ray */ + ED_view3d_unproject(mats, view, s[0], s[1], 0.0f); + mul_m4_v3(kcd->ob->imat, view); + + /* make p1 a little towards view, so ray doesn't hit p's face. */ + copy_v3_v3(p1, p); + sub_v3_v3(view, p1); + normalize_v3(view); + copy_v3_v3(no, view); + mul_v3_fl(no, 3.0f * KNIFE_FLT_EPSBIG); + add_v3_v3(p1, no); + + /* see if there's a face hit between p1 and the view */ + f_hit = BKE_bmbvh_ray_cast(kcd->bmbvh, p1, no, KNIFE_FLT_EPS, NULL, NULL, NULL); + if (f_hit) + return false; + } + + /* If box clipping on, make sure p is not clipped */ + if (kcd->vc.rv3d->rflag & RV3D_CLIPPING && + ED_view3d_clipping_test(kcd->vc.rv3d, p, true)) + { + return false; + } + + return true; +} + /* Clip the line (v1, v2) to planes perpendicular to it and distances d from * the closest point on the line to the origin */ static void clip_to_ortho_planes(float v1[3], float v2[3], float d) @@ -1522,16 +1191,49 @@ static void clip_to_ortho_planes(float v1[3], float v2[3], float d) dist_ensure_v3_v3fl(v2, closest, d); } +static void set_linehit_depth(KnifeTool_OpData *kcd, KnifeLineHit *lh) +{ + float vnear[3], vfar[3]; + + ED_view3d_win_to_segment(kcd->ar, kcd->vc.v3d, lh->schit, vnear, vfar, true); + mul_m4_v3(kcd->ob->imat, vnear); + if (kcd->is_ortho) { + if (kcd->ortho_extent == 0.0f) + calc_ortho_extent(kcd); + clip_to_ortho_planes(vnear, vfar, kcd->ortho_extent + 10.0f); + } + lh->m = len_v3v3(vnear, lh->cagehit); +} + /* Finds visible (or all, if cutting through) edges that intersects the current screen drag line */ static void knife_find_line_hits(KnifeTool_OpData *kcd) { bglMats mats; - BMEdgeHit *e1, *e2; - SmallHash hash, *ehash = &hash; - float v1[3], v2[3], v3[3], v4[4], s1[2], s2[2]; - int i, c1, c2; + SmallHash faces, kfes, kfvs; + float v1[3], v2[3], v3[3], v4[3], s1[2], s2[2]; + BVHTree *planetree, *tree; + BVHTreeOverlap *results, *result; + BMLoop **ls; + BMFace *f; + KnifeEdge *kfe; + KnifeVert *v; + ListBase *lst; + Ref *ref; + KnifeLineHit *linehits = NULL; + BLI_array_declare(linehits); + SmallHashIter hiter; + KnifeLineHit hit; + void *val; + float plane_cos[12]; + float s[2], se1[2], se2[2], sint[2]; + float p[3], p2[3], r1[3], r2[3]; + float d, d1, d2, lambda; + float vert_tol, vert_tol_sq, line_tol, face_tol; + int isect_kind; + unsigned int tot; + int i; - knife_bgl_get_mats(kcd, &mats); + bgl_get_mats(&mats); if (kcd->linehits) { MEM_freeN(kcd->linehits); @@ -1568,7 +1270,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) /* numeric error, 'v1' -> 'v2', 'v2' -> 'v4' can end up being ~2000 units apart in otho mode * (from ED_view3d_win_to_segment_clip() above) - * this gives precision error in 'knife_edge_tri_isect', rather then solving properly + * this gives precision error; rather then solving properly * (which may involve using doubles everywhere!), * limit the distance between these points */ if (kcd->is_ortho) { @@ -1578,70 +1280,176 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) clip_to_ortho_planes(v2, v4, kcd->ortho_extent + 10.0f); } - BLI_smallhash_init(ehash); + /* First use bvh tree to find faces, knife edges, and knife verts that might + * intersect the cut plane with rays v1-v3 and v2-v4. + * This deduplicates the candidates before doing more expensive intersection tests. */ + BLI_smallhash_init(&faces); + BLI_smallhash_init(&kfes); + BLI_smallhash_init(&kfvs); + + tree = BKE_bmbvh_tree_get(kcd->bmbvh); + planetree = BLI_bvhtree_new(4, FLT_EPSILON * 4, 8, 8); + copy_v3_v3(plane_cos + 0, v1); + copy_v3_v3(plane_cos + 3, v2); + copy_v3_v3(plane_cos + 6, v3); + copy_v3_v3(plane_cos + 9, v4); + BLI_bvhtree_insert(planetree, 0, plane_cos, 4); + BLI_bvhtree_balance(planetree); + + results = BLI_bvhtree_overlap(tree, planetree, &tot); + if (!results) { + BLI_smallhash_release(&faces); + BLI_smallhash_release(&kfes); + BLI_smallhash_release(&kfvs); + BLI_bvhtree_free(planetree); + return; + } + + for (i = 0, result = results; i < tot; i++, result++) { + ls = (BMLoop **)kcd->em->looptris[result->indexA]; + f = ls[0]->f; + set_lowest_face_tri(kcd, f, result->indexA); + /* for faces, store index of lowest hit looptri in hash */ + if (BLI_smallhash_haskey(&faces, (uintptr_t)f)) { + continue; + } + /* don't care what the value is except that it is non-NULL, for iterator */ + BLI_smallhash_insert(&faces, (uintptr_t)f, f); - /* test two triangles of sceen line's plane */ - e1 = knife_edge_tri_isect(kcd, kcd->bmbvh, v1, v2, v3, ehash, &mats, &c1); - e2 = knife_edge_tri_isect(kcd, kcd->bmbvh, v2, v3, v4, ehash, &mats, &c2); - if (c1 && c2) { - e1 = MEM_reallocN(e1, sizeof(BMEdgeHit) * (c1 + c2)); - memcpy(e1 + c1, e2, sizeof(BMEdgeHit) * c2); - MEM_freeN(e2); + lst = knife_get_face_kedges(kcd, f); + for (ref = lst->first; ref; ref = ref->next) { + kfe = ref->ref; + if (BLI_smallhash_haskey(&kfes, (uintptr_t)kfe)) + continue; + BLI_smallhash_insert(&kfes, (uintptr_t)kfe, kfe); + v = kfe->v1; + if (!BLI_smallhash_haskey(&kfvs, (uintptr_t)v)) + BLI_smallhash_insert(&kfvs, (uintptr_t)v, v); + v = kfe->v2; + if (!BLI_smallhash_haskey(&kfvs, (uintptr_t)v)) + BLI_smallhash_insert(&kfvs, (uintptr_t)v, v); + } + } + + /* Now go through the candidates and find intersections */ + /* These tolerances, in screen space, are for intermediate hits, as ends are already snapped to screen */ + vert_tol = KNIFE_FLT_EPS * 2000.0f; + line_tol = KNIFE_FLT_EPS * 2000.0f; + vert_tol_sq = vert_tol * vert_tol; + face_tol = max_ff(vert_tol, line_tol); + /* Assume these tolerances swamp floating point rounding errors in calculations below */ + + /* first look for vertex hits */ + for (val = BLI_smallhash_iternew(&kfvs, &hiter, (uintptr_t *)&v); val; + val = BLI_smallhash_iternext(&hiter, (uintptr_t *)&v)) + { + knife_project_v2(kcd, v->cageco, s); + d = dist_squared_to_line_segment_v2(s, s1, s2); + if (d <= vert_tol_sq) { + if (point_is_visible(kcd, v->cageco, s, &mats)) { + memset(&hit, 0, sizeof(hit)); + hit.v = v; + copy_v3_v3(hit.hit, v->cageco); + copy_v3_v3(hit.cagehit, v->cageco); + copy_v2_v2(hit.schit, s); + set_linehit_depth(kcd, &hit); + BLI_array_append(linehits, hit); + } + } + } + /* now edge hits; don't add if a vertex at end of edge should have hit */ + for (val = BLI_smallhash_iternew(&kfes, &hiter, (uintptr_t *)&kfe); val; + val = BLI_smallhash_iternext(&hiter, (uintptr_t *)&kfe)) + { + knife_project_v2(kcd, kfe->v1->cageco, se1); + knife_project_v2(kcd, kfe->v2->cageco, se2); + isect_kind = isect_seg_seg_v2_point(s1, s2, se1, se2, sint); + if (isect_kind == -1) { + /* isect_seg_seg_v2 doesn't do tolerance test around ends of s1-s2 */ + closest_to_line_segment_v2(sint, s1, se1, se2); + if (len_squared_v2v2(sint, s1) <= vert_tol_sq) + isect_kind = 1; + else { + closest_to_line_segment_v2(sint, s2, se1, se2); + if (len_squared_v2v2(sint, s2) <= vert_tol_sq) + isect_kind = 1; + } + } + if (isect_kind == 1) { + d1 = len_v2v2(sint, se1); + d2 = len_v2v2(se2, se1); + if (!(d1 <= vert_tol || d2 <= vert_tol || fabsf(d1 - d2) <= vert_tol)) { + lambda = d1 / d2; + /* Can't just interpolate between ends of kfe because + * that doesn't work with perspective transformation. + * Need to find 3d intersection of ray through sint */ + knife_input_ray_segment(kcd, sint, 1.0f, r1, r2); + isect_kind = isect_line_line_v3(kfe->v1->cageco, kfe->v2->cageco, r1, r2, p, p2); + if (isect_kind >= 1 && point_is_visible(kcd, p, sint, &mats)) { + memset(&hit, 0, sizeof(hit)); + hit.kfe = kfe; + copy_v3_v3(hit.hit, p); + copy_v3_v3(hit.cagehit, p); + copy_v2_v2(hit.schit, sint); + hit.perc = lambda; + set_linehit_depth(kcd, &hit); + BLI_array_append(linehits, hit); + } + } + } } - else if (c2) { - e1 = e2; + /* now face hits; don't add if a vertex or edge in face should have hit */ + for (val = BLI_smallhash_iternew(&faces, &hiter, (uintptr_t *)&f); val; + val = BLI_smallhash_iternext(&hiter, (uintptr_t *)&f)) + { + if (knife_ray_intersect_face(kcd, s1, v1, v3, f, face_tol, p)) { + if (point_is_visible(kcd, p, s1, &mats)) { + memset(&hit, 0, sizeof(hit)); + hit.f = f; + copy_v3_v3(hit.hit, p); + copy_v3_v3(hit.cagehit, p); + copy_v2_v2(hit.schit, s1); + set_linehit_depth(kcd, &hit); + BLI_array_append(linehits, hit); + } + } + if (knife_ray_intersect_face(kcd, s2, v2, v4, f, face_tol, p)) { + if (point_is_visible(kcd, p, s2, &mats)) { + memset(&hit, 0, sizeof(hit)); + hit.f = f; + copy_v3_v3(hit.hit, p); + copy_v3_v3(hit.cagehit, p); + copy_v2_v2(hit.schit, s2); + set_linehit_depth(kcd, &hit); + BLI_array_append(linehits, hit); + } + } } - kcd->linehits = e1; - kcd->totlinehit = c1 + c2; + kcd->linehits = linehits; + kcd->totlinehit = BLI_array_count(linehits); /* find position along screen line, used for sorting */ for (i = 0; i < kcd->totlinehit; i++) { - BMEdgeHit *lh = e1 + i; + KnifeLineHit *lh = kcd->linehits + i; lh->l = len_v2v2(lh->schit, s1) / len_v2v2(s2, s1); } - BLI_smallhash_release(ehash); -} - -/* this works but gives numeric problems [#33400] */ -#if 0 -static void knife_input_ray_cast(KnifeTool_OpData *kcd, const float mval[2], - float r_origin[3], float r_ray[3]) -{ - bglMats mats; - float imat[3][3]; - - knife_bgl_get_mats(kcd, &mats); - - /* unproject to find view ray */ - ED_view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f); - - if (kcd->is_ortho) { - negate_v3_v3(r_ray, kcd->vc.rv3d->viewinv[2]); - } - else { - sub_v3_v3v3(r_ray, r_origin, kcd->vc.rv3d->viewinv[3]); - } - normalize_v3(r_ray); - - /* transform into object space */ - invert_m4_m4(kcd->ob->imat, kcd->ob->obmat); - copy_m3_m4(imat, kcd->ob->obmat); - invert_m3(imat); - - mul_m4_v3(kcd->ob->imat, r_origin); - mul_m3_v3(imat, r_ray); + BLI_smallhash_release(&faces); + BLI_smallhash_release(&kfes); + BLI_smallhash_release(&kfvs); + BLI_bvhtree_free(planetree); + if (results) + MEM_freeN(results); } -#endif static void knife_input_ray_segment(KnifeTool_OpData *kcd, const float mval[2], const float ofs, float r_origin[3], float r_origin_ofs[3]) { bglMats mats; - knife_bgl_get_mats(kcd, &mats); + bgl_get_mats(&mats); /* unproject to find view ray */ ED_view3d_unproject(&mats, r_origin, mval[0], mval[1], 0.0f); @@ -1757,7 +1565,8 @@ static float knife_snap_size(KnifeTool_OpData *kcd, float maxsize) } /* p is closest point on edge to the mouse cursor */ -static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], float cagep[3], BMFace **fptr, bool *is_space) +static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], float cagep[3], + BMFace **fptr, bool *is_space) { BMFace *f; float co[3], cageco[3], sco[2]; @@ -1867,7 +1676,7 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo /* set p to co, in case we don't find anything, means a face cut */ copy_v3_v3(p, co); - copy_v3_v3(cagep, p); + copy_v3_v3(cagep, cageco); kcd->curr.bmface = f; if (f) { @@ -1989,20 +1798,22 @@ static int knife_update_active(KnifeTool_OpData *kcd) kcd->curr.vert = knife_find_closest_vert(kcd, kcd->curr.co, kcd->curr.cage, &kcd->curr.bmface, &kcd->curr.is_space); if (!kcd->curr.vert) { - kcd->curr.edge = knife_find_closest_edge(kcd, kcd->curr.co, kcd->curr.cage, &kcd->curr.bmface, &kcd->curr.is_space); + kcd->curr.edge = knife_find_closest_edge(kcd, kcd->curr.co, kcd->curr.cage, + &kcd->curr.bmface, &kcd->curr.is_space); } /* if no hits are found this would normally default to (0, 0, 0) so instead * get a point at the mouse ray closest to the previous point. * Note that drawing lines in `free-space` isn't properly supported * but theres no guarantee (0, 0, 0) has any geometry either - campbell */ - if (kcd->curr.vert == NULL && kcd->curr.edge == NULL) { + if (kcd->curr.vert == NULL && kcd->curr.edge == NULL && kcd->curr.bmface == NULL) { float origin[3]; float origin_ofs[3]; knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs); closest_to_line_v3(kcd->curr.cage, kcd->prev.cage, origin_ofs, origin); + copy_v3_v3(kcd->curr.co, kcd->curr.cage); } if (kcd->mode == MODE_DRAGGING) { @@ -2011,380 +1822,11 @@ static int knife_update_active(KnifeTool_OpData *kcd) return 1; } -#define SCANFILL_CUTS 0 -#if SCANFILL_CUTS - -#define MARK 4 -#define DEL 8 -#define VERT_ON_EDGE 16 -#define VERT_ORIG 32 -#define FACE_FLIP 64 -#define BOUNDARY 128 -#define FACE_NEW 256 - -typedef struct facenet_entry { - struct facenet_entry *next, *prev; - KnifeEdge *kfe; -} facenet_entry; - -static void rnd_offset_co(RNG *rng, float co[3], float scale) -{ - int i; - - for (i = 0; i < 3; i++) { - co[i] += (BLI_rng_get_float(rng) - 0.5) * scale; - } -} - -static void remerge_faces(KnifeTool_OpData *kcd) -{ - BMesh *bm = kcd->em->bm; - SmallHash svisit, *visit = &svisit; - BMIter iter; - BMFace *f; - BMFace **stack = NULL; - BLI_array_declare(stack); - BMFace **faces = NULL; - BLI_array_declare(faces); - BMOperator bmop; - int idx; - - BMO_op_initf(bm, &bmop, "beautify_fill faces=%ff edges=%Fe", FACE_NEW, BOUNDARY); - - BMO_op_exec(bm, &bmop); - BMO_slot_buffer_flag_enable(bm, &bmop, "geom.out", BM_FACE, FACE_NEW); - - BMO_op_finish(bm, &bmop); - - BLI_smallhash_init(visit); - BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - BMIter eiter; - BMEdge *e; - BMFace *f2; - - if (!BMO_elem_flag_test(bm, f, FACE_NEW)) - continue; - - if (BLI_smallhash_haskey(visit, (uintptr_t)f)) - continue; - - BLI_array_empty(stack); - BLI_array_empty(faces); - BLI_array_append(stack, f); - BLI_smallhash_insert(visit, (uintptr_t)f, NULL); - - do { - f2 = BLI_array_pop(stack); - - BLI_array_append(faces, f2); - - BM_ITER_ELEM (e, &eiter, f2, BM_EDGES_OF_FACE) { - BMIter fiter; - BMFace *f3; - - if (BMO_elem_flag_test(bm, e, BOUNDARY)) - continue; - - BM_ITER_ELEM (f3, &fiter, e, BM_FACES_OF_EDGE) { - if (!BMO_elem_flag_test(bm, f3, FACE_NEW)) - continue; - if (BLI_smallhash_haskey(visit, (uintptr_t)f3)) - continue; - - BLI_smallhash_insert(visit, (uintptr_t)f3, NULL); - BLI_array_append(stack, f3); - } - } - } while (BLI_array_count(stack) > 0); - - if (BLI_array_count(faces) > 0) { - idx = BM_elem_index_get(faces[0]); - - f2 = BM_faces_join(bm, faces, BLI_array_count(faces), true); - if (f2) { - BMO_elem_flag_enable(bm, f2, FACE_NEW); - BM_elem_index_set(f2, idx); /* set_dirty! *//* BMESH_TODO, check if this is valid or not */ - } - } - } - /* BMESH_TODO, check if the code above validates the indices */ - /* bm->elem_index_dirty &= ~BM_FACE; */ - bm->elem_index_dirty |= BM_FACE; - - BLI_smallhash_release(visit); - - BLI_array_free(stack); - BLI_array_free(faces); -} - -/* use edgenet to fill faces. this is a bit annoying and convoluted.*/ -static void knifenet_fill_faces(KnifeTool_OpData *kcd) -{ - ScanFillContext sf_ctx; - BMesh *bm = kcd->em->bm; - BMIter bmiter; - BLI_mempool_iter iter; - BMFace *f; - BMEdge *e; - KnifeVert *kfv; - KnifeEdge *kfe; - facenet_entry *entry; - ListBase *face_nets = MEM_callocN(sizeof(ListBase) * bm->totface, "face_nets"); - BMFace **faces = MEM_callocN(sizeof(BMFace *) * bm->totface, "faces knife"); - MemArena *arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "knifenet_fill_faces"); - SmallHash shash; - RNG *rng; - int i, j, k = 0, totface = bm->totface; - - BMO_push(bm, NULL); - bmesh_edit_begin(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH); - - /* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */ - i = 0; - BM_ITER_MESH (f, &bmiter, bm, BM_FACES_OF_MESH) { - BM_elem_index_set(f, i); /* set_inline */ - faces[i] = f; - i++; - } - bm->elem_index_dirty &= ~BM_FACE; - - BM_ITER_MESH (e, &bmiter, bm, BM_EDGES_OF_MESH) { - BMO_elem_flag_enable(bm, e, BOUNDARY); - } - - /* turn knife verts into real verts, as necessary */ - BLI_mempool_iternew(kcd->kverts, &iter); - for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) { - if (!kfv->v) { - /* shouldn't we be at least copying the normal? - if not some comment here should explain why - campbell */ - kfv->v = BM_vert_create(bm, kfv->co, NULL, BM_CREATE_NOP); - kfv->flag = 1; - BMO_elem_flag_enable(bm, kfv->v, DEL); - } - else { - kfv->flag = 0; - BMO_elem_flag_enable(bm, kfv->v, VERT_ORIG); - } - - BMO_elem_flag_enable(bm, kfv->v, MARK); - } - - /* we want to only do changed faces. first, go over new edges and add to - * face net lists.*/ - i = j = k = 0; - BLI_mempool_iternew(kcd->kedges, &iter); - for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) { - Ref *ref; - if (!kfe->v1 || !kfe->v2 || kfe->v1->inspace || kfe->v2->inspace) - continue; - - i++; - - if (kfe->e && kfe->v1->v == kfe->e->v1 && kfe->v2->v == kfe->e->v2) { - kfe->e_old = kfe->e; - continue; - } - - j++; - - if (kfe->e) { - kfe->e_old = kfe->e; - - BMO_elem_flag_enable(bm, kfe->e, DEL); - BMO_elem_flag_disable(bm, kfe->e, BOUNDARY); - kfe->e = NULL; - } - - kfe->e = BM_edge_create(bm, kfe->v1->v, kfe->v2->v, NULL, BM_CREATE_NO_DOUBLE); - BMO_elem_flag_enable(bm, kfe->e, BOUNDARY); - - for (ref = kfe->faces.first; ref; ref = ref->next) { - f = ref->ref; - - entry = BLI_memarena_alloc(arena, sizeof(*entry)); - entry->kfe = kfe; - BLI_addtail(face_nets + BM_elem_index_get(f), entry); - } - } - - /* go over original edges, and add to faces with new geometry */ - BLI_mempool_iternew(kcd->kedges, &iter); - for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) { - Ref *ref; - - if (!kfe->v1 || !kfe->v2 || kfe->v1->inspace || kfe->v2->inspace) - continue; - if (!(kfe->e_old && kfe->v1->v == kfe->e_old->v1 && kfe->v2->v == kfe->e_old->v2)) - continue; - - k++; - - BMO_elem_flag_enable(bm, kfe->e, BOUNDARY); - kfe->e_old = kfe->e; - - for (ref = kfe->faces.first; ref; ref = ref->next) { - f = ref->ref; - - if (face_nets[BM_elem_index_get(f)].first) { - entry = BLI_memarena_alloc(arena, sizeof(*entry)); - entry->kfe = kfe; - BLI_addtail(face_nets + BM_elem_index_get(f), entry); - } - } - } - - rng = BLI_rng_new(0); - - for (i = 0; i < totface; i++) { - SmallHash *hash = &shash; - ScanFillFace *sf_tri; - ScanFillVert *sf_vert, *sf_vert_last; - int j; - float rndscale = (KNIFE_FLT_EPS / 4.0f); - - f = faces[i]; - BLI_smallhash_init(hash); - - if (face_nets[i].first) - BMO_elem_flag_enable(bm, f, DEL); - - BLI_scanfill_begin(&sf_ctx); - - for (entry = face_nets[i].first; entry; entry = entry->next) { - if (!BLI_smallhash_haskey(hash, (uintptr_t)entry->kfe->v1)) { - sf_vert = BLI_scanfill_vert_add(&sf_ctx, entry->kfe->v1->v->co); - sf_vert->poly_nr = 0; - rnd_offset_co(rng, sf_vert->co, rndscale); - sf_vert->tmp.p = entry->kfe->v1->v; - BLI_smallhash_insert(hash, (uintptr_t)entry->kfe->v1, sf_vert); - } - - if (!BLI_smallhash_haskey(hash, (uintptr_t)entry->kfe->v2)) { - sf_vert = BLI_scanfill_vert_add(&sf_ctx, entry->kfe->v2->v->co); - sf_vert->poly_nr = 0; - rnd_offset_co(rng, sf_vert->co, rndscale); - sf_vert->tmp.p = entry->kfe->v2->v; - BLI_smallhash_insert(hash, (uintptr_t)entry->kfe->v2, sf_vert); - } - } - - for (j = 0, entry = face_nets[i].first; entry; entry = entry->next, j++) { - sf_vert_last = BLI_smallhash_lookup(hash, (uintptr_t)entry->kfe->v1); - sf_vert = BLI_smallhash_lookup(hash, (uintptr_t)entry->kfe->v2); - - sf_vert->poly_nr++; - sf_vert_last->poly_nr++; - } - - for (j = 0, entry = face_nets[i].first; entry; entry = entry->next, j++) { - sf_vert_last = BLI_smallhash_lookup(hash, (uintptr_t)entry->kfe->v1); - sf_vert = BLI_smallhash_lookup(hash, (uintptr_t)entry->kfe->v2); - - if (sf_vert->poly_nr > 1 && sf_vert_last->poly_nr > 1) { - ScanFillEdge *sf_edge; - sf_edge = BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert); - if (entry->kfe->e_old) - sf_edge->f = SF_EDGE_BOUNDARY; /* mark as original boundary edge */ - - BMO_elem_flag_disable(bm, entry->kfe->e->v1, DEL); - BMO_elem_flag_disable(bm, entry->kfe->e->v2, DEL); - } - else { - if (sf_vert_last->poly_nr < 2) - BLI_remlink(&sf_ctx.fillvertbase, sf_vert_last); - if (sf_vert->poly_nr < 2) - BLI_remlink(&sf_ctx.fillvertbase, sf_vert); - } - } - - BLI_scanfill_calc(&sf_ctx, 0); - - for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) { - BMVert *v1 = sf_tri->v3->tmp.p, *v2 = sf_tri->v2->tmp.p, *v3 = sf_tri->v1->tmp.p; - BMFace *f2; - BMLoop *l_iter; - BMVert *verts[3] = {v1, v2, v3}; - - if (v1 == v2 || v2 == v3 || v1 == v3) - continue; - if (BM_face_exists(bm, verts, 3, &f2)) - continue; - - f2 = BM_face_create_quad_tri(bm, - v1, v2, v3, NULL, - NULL, false); - - BMO_elem_flag_enable(bm, f2, FACE_NEW); - - l_iter = BM_FACE_FIRST_LOOP(f2); - do { - BMO_elem_flag_disable(bm, l_iter->e, DEL); - } while ((l_iter = l_iter->next) != BM_FACE_FIRST_LOOP(f2)); - - BMO_elem_flag_disable(bm, f2, DEL); - BM_elem_index_set(f2, i); /* set_dirty! *//* note, not 100% sure this is dirty? need to check */ - - BM_face_normal_update(f2); - if (dot_v3v3(f->no, f2->no) < 0.0f) { - BM_face_normal_flip(bm, f2); - } - } - - BLI_scanfill_end(&sf_ctx); - BLI_smallhash_release(hash); - } - bm->elem_index_dirty |= BM_FACE; - - /* interpolate customdata */ - BM_ITER_MESH (f, &bmiter, bm, BM_FACES_OF_MESH) { - BMLoop *l1; - BMFace *f2; - BMIter liter1; - - if (!BMO_elem_flag_test(bm, f, FACE_NEW)) - continue; - - f2 = faces[BM_elem_index_get(f)]; - if (BM_elem_index_get(f) < 0 || BM_elem_index_get(f) >= totface) { - fprintf(stderr, "%s: face index out of range! (bmesh internal error)\n", __func__); - } - - BM_elem_attrs_copy(bm, bm, f2, f); - - BM_ITER_ELEM (l1, &liter1, f, BM_LOOPS_OF_FACE) { - BM_loop_interp_from_face(bm, l1, f2, true, true); - } - } - - /* merge triangles back into faces */ - remerge_faces(kcd); - - /* delete left over faces */ - BMO_op_callf(bm, BMO_FLAG_DEFAULTS, "delete geom=%ff context=%i", DEL, DEL_ONLYFACES); - BMO_op_callf(bm, BMO_FLAG_DEFAULTS, "delete geom=%fe context=%i", DEL, DEL_EDGES); - BMO_op_callf(bm, BMO_FLAG_DEFAULTS, "delete geom=%fv context=%i", DEL, DEL_VERTS); - - if (face_nets) - MEM_freeN(face_nets); - if (faces) - MEM_freeN(faces); - BLI_memarena_free(arena); - BLI_rng_free(rng); - - BMO_error_clear(bm); /* remerge_faces sometimes raises errors, so make sure to clear them */ - - bmesh_edit_end(bm, BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH); - BMO_pop(bm); -} - -#else /* use direct (non-scanfill) method for cuts */ - /* sort list of kverts by fraction along edge e */ static void sort_by_frac_along(ListBase *lst, BMEdge *e) { /* note, since we know the point is along the edge, sort from distance to v1co */ const float *v1co = e->v1->co; -// const float *v2co = e->v2->co; Ref *cur = NULL, *prev = NULL, *next = NULL; if (lst->first == lst->last) @@ -2392,11 +1834,7 @@ static void sort_by_frac_along(ListBase *lst, BMEdge *e) for (cur = ((Ref *)lst->first)->next; cur; cur = next) { KnifeVert *vcur = cur->ref; -#if 0 - const float vcur_fac = line_point_factor_v3(vcur->co, v1co, v2co); -#else const float vcur_fac = len_squared_v3v3(v1co, vcur->co); -#endif next = cur->next; prev = cur->prev; @@ -2405,13 +1843,8 @@ static void sort_by_frac_along(ListBase *lst, BMEdge *e) while (prev) { KnifeVert *vprev = prev->ref; -#if 0 - if (line_point_factor_v3(vprev->co, v1co, v2co) <= vcur_fac) - break; -#else if (len_squared_v3v3(v1co, vprev->co) <= vcur_fac) break; -#endif prev = prev->prev; } @@ -2745,34 +2178,30 @@ static bool find_hole_chains(KnifeTool_OpData *kcd, ListBase *hole, BMFace *f, L } } -static bool knife_edge_in_face(KnifeTool_OpData *UNUSED(kcd), KnifeEdge *kfe, BMFace *f) +static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f) { - /* BMesh *bm = kcd->em->bm; */ /* UNUSED */ - BMVert *v1, *v2; BMLoop *l1, *l2, *l; float mid[3]; BMIter iter; int v1inside, v2inside; - if (!f) + if (!f || !v1 || !v2) return false; - v1 = kfe->v1->v; - v2 = kfe->v2->v; l1 = NULL; l2 = NULL; /* find out if v1 and v2, if set, are part of the face */ BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) { - if (v1 && l->v == v1) + if (v1->v && l->v == v1->v) l1 = l; - if (v2 && l->v == v2) + if (v2->v && l->v == v2->v) l2 = l; } /* BM_face_point_inside_test uses best-axis projection so this isn't most accurate test... */ - v1inside = l1 ? 0 : BM_face_point_inside_test(f, kfe->v1->co); - v2inside = l2 ? 0 : BM_face_point_inside_test(f, kfe->v2->co); + v1inside = l1 ? 0 : BM_face_point_inside_test(f, v1->co); + v2inside = l2 ? 0 : BM_face_point_inside_test(f, v2->co); if ((l1 && v2inside) || (l2 && v1inside) || (v1inside && v2inside)) return true; if (l1 && l2) { @@ -2780,12 +2209,17 @@ static bool knife_edge_in_face(KnifeTool_OpData *UNUSED(kcd), KnifeEdge *kfe, BM * BM_face_legal_splits does visibility and self-intersection tests, * but it is expensive and maybe a bit buggy, so use a simple * "is the midpoint in the face" test */ - mid_v3_v3v3(mid, kfe->v1->co, kfe->v2->co); + mid_v3_v3v3(mid, v1->co, v2->co); return BM_face_point_inside_test(f, mid); } return false; } +static bool knife_edge_in_face(KnifeEdge *kfe, BMFace *f) +{ + return knife_verts_edge_in_face(kfe->v1, kfe->v2, f); +} + /* Split face f with KnifeEdges on chain. f remains as one side, the face formed is put in *newface. * The new face will be on the left side of the chain as viewed from the normal-out side of f. */ static void knife_make_chain_cut(KnifeTool_OpData *kcd, BMFace *f, ListBase *chain, BMFace **r_f_new) @@ -2877,7 +2311,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe for (ref = kfedges->first; ref; ref = refnext) { kfe = ref->ref; refnext = ref->next; - if (knife_edge_in_face(kcd, kfe, fnew)) { + if (knife_edge_in_face(kfe, fnew)) { BLI_remlink(kfedges, ref); kfe->basef = fnew; knife_append_list(kcd, fnew_kfedges, kfe); @@ -2907,14 +2341,14 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe return; } kfe = ((Ref *)sidechain->first)->ref; - if (knife_edge_in_face(kcd, kfe, f)) { + if (knife_edge_in_face(kfe, f)) { knife_make_chain_cut(kcd, f, sidechain, &fnew2); if (fnew2 == NULL) { return; } fhole = f; } - else if (knife_edge_in_face(kcd, kfe, fnew)) { + else if (knife_edge_in_face(kfe, fnew)) { knife_make_chain_cut(kcd, fnew, sidechain, &fnew2); if (fnew2 == NULL) { return; @@ -2933,12 +2367,12 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe for (ref = kfedges->first; ref; ref = refnext) { kfe = ref->ref; refnext = ref->next; - if (knife_edge_in_face(kcd, kfe, fnew)) { + if (knife_edge_in_face(kfe, fnew)) { BLI_remlink(kfedges, ref); kfe->basef = fnew; knife_append_list(kcd, fnew_kfedges, kfe); } - else if (knife_edge_in_face(kcd, kfe, fnew2)) { + else if (knife_edge_in_face(kfe, fnew2)) { BLI_remlink(kfedges, ref); kfe->basef = fnew2; knife_append_list(kcd, fnew2_kfedges, kfe); @@ -3044,16 +2478,11 @@ static void knife_make_cuts(KnifeTool_OpData *kcd) BLI_smallhash_release(fhash); BLI_smallhash_release(ehash); } -#endif /* called on tool confirmation */ static void knifetool_finish_ex(KnifeTool_OpData *kcd) { -#if SCANFILL_CUTS - knifenet_fill_faces(kcd); -#else knife_make_cuts(kcd); -#endif EDBM_selectmode_flush(kcd->em); EDBM_mesh_normals_update(kcd->em); @@ -3096,6 +2525,7 @@ static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd) BLI_ghash_free(kcd->origedgemap, NULL, NULL); BLI_ghash_free(kcd->origvertmap, NULL, NULL); BLI_ghash_free(kcd->kedgefacemap, NULL, NULL); + BLI_ghash_free(kcd->facetrimap, NULL, NULL); BKE_bmbvh_free(kcd->bmbvh); BLI_memarena_free(kcd->arena); @@ -3155,9 +2585,9 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd, kcd->cagecos = (const float (*)[3])BKE_editmesh_vertexCos_get(kcd->em, scene, NULL); kcd->bmbvh = BKE_bmbvh_new(kcd->em, - BMBVH_RETURN_ORIG | - (only_select ? BMBVH_RESPECT_SELECT : BMBVH_RESPECT_HIDDEN), - kcd->cagecos, false); + BMBVH_RETURN_ORIG | + (only_select ? BMBVH_RESPECT_SELECT : BMBVH_RESPECT_HIDDEN), + kcd->cagecos, false); kcd->arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 15), "knife"); kcd->vthresh = KMAXDIST - 1; @@ -3175,7 +2605,8 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd, kcd->origedgemap = BLI_ghash_ptr_new("knife origedgemap"); kcd->origvertmap = BLI_ghash_ptr_new("knife origvertmap"); - kcd->kedgefacemap = BLI_ghash_ptr_new("knife origvertmap"); + kcd->kedgefacemap = BLI_ghash_ptr_new("knife kedgefacemap"); + kcd->facetrimap = BLI_ghash_ptr_new("knife facetrimap"); /* cut all the way through the mesh if use_occlude_geometry button not pushed */ kcd->is_interactive = is_interactive; @@ -3475,7 +2906,7 @@ static void edvm_mesh_knife_face_point(BMFace *f, float r_cent[3]) int j; float const *best_co[3] = {NULL}; - float best_area = -1.0f; + float best_area = -1.0f; bool ok = false; tottri = BM_face_calc_tessellation(f, loops, index); -- cgit v1.2.3 From eabc16ab5294b4df81101e3ceaab1508d7396104 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 17:35:47 +0000 Subject: Since we dropped carbon api, this workaround seems not longer to be necessary, pls. keep an eye --- source/blender/editors/space_file/fsmenu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 0227230fb68..62cf4889797 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -55,9 +55,7 @@ #endif #ifdef __APPLE__ -/* XXX BIG WARNING: carbon.h can not be included in blender code, it conflicts with struct ID */ -# define ID ID_ -# include +#include #endif /* __APPLE__ */ #ifdef __linux__ -- cgit v1.2.3 From 9e3a993392eeb8de05d7b8d7840f98549eeaf292 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 17:49:27 +0000 Subject: OSX/GHOST: starting file by file removal of outdated code, such as VERSION_MIN_REQUIRED <= 1040 --- intern/ghost/intern/GHOST_SystemCocoa.mm | 252 +++---------------------------- 1 file changed, 20 insertions(+), 232 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index ab1d547ea5e..c60ded15d6c 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -57,156 +57,6 @@ #include "AssertMacros.h" #pragma mark KeyMap, mouse converters -#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040 -/* Keycodes not defined in Tiger */ -/* - * Summary: - * Virtual keycodes - * - * Discussion: - * These constants are the virtual keycodes defined originally in - * Inside Mac Volume V, pg. V-191. They identify physical keys on a - * keyboard. Those constants with "ANSI" in the name are labeled - * according to the key position on an ANSI-standard US keyboard. - * For example, kVK_ANSI_A indicates the virtual keycode for the key - * with the letter 'A' in the US keyboard layout. Other keyboard - * layouts may have the 'A' key label on a different physical key; - * in this case, pressing 'A' will generate a different virtual - * keycode. - */ -enum { - kVK_ANSI_A = 0x00, - kVK_ANSI_S = 0x01, - kVK_ANSI_D = 0x02, - kVK_ANSI_F = 0x03, - kVK_ANSI_H = 0x04, - kVK_ANSI_G = 0x05, - kVK_ANSI_Z = 0x06, - kVK_ANSI_X = 0x07, - kVK_ANSI_C = 0x08, - kVK_ANSI_V = 0x09, - kVK_ANSI_B = 0x0B, - kVK_ANSI_Q = 0x0C, - kVK_ANSI_W = 0x0D, - kVK_ANSI_E = 0x0E, - kVK_ANSI_R = 0x0F, - kVK_ANSI_Y = 0x10, - kVK_ANSI_T = 0x11, - kVK_ANSI_1 = 0x12, - kVK_ANSI_2 = 0x13, - kVK_ANSI_3 = 0x14, - kVK_ANSI_4 = 0x15, - kVK_ANSI_6 = 0x16, - kVK_ANSI_5 = 0x17, - kVK_ANSI_Equal = 0x18, - kVK_ANSI_9 = 0x19, - kVK_ANSI_7 = 0x1A, - kVK_ANSI_Minus = 0x1B, - kVK_ANSI_8 = 0x1C, - kVK_ANSI_0 = 0x1D, - kVK_ANSI_RightBracket = 0x1E, - kVK_ANSI_O = 0x1F, - kVK_ANSI_U = 0x20, - kVK_ANSI_LeftBracket = 0x21, - kVK_ANSI_I = 0x22, - kVK_ANSI_P = 0x23, - kVK_ANSI_L = 0x25, - kVK_ANSI_J = 0x26, - kVK_ANSI_Quote = 0x27, - kVK_ANSI_K = 0x28, - kVK_ANSI_Semicolon = 0x29, - kVK_ANSI_Backslash = 0x2A, - kVK_ANSI_Comma = 0x2B, - kVK_ANSI_Slash = 0x2C, - kVK_ANSI_N = 0x2D, - kVK_ANSI_M = 0x2E, - kVK_ANSI_Period = 0x2F, - kVK_ANSI_Grave = 0x32, - kVK_ANSI_KeypadDecimal = 0x41, - kVK_ANSI_KeypadMultiply = 0x43, - kVK_ANSI_KeypadPlus = 0x45, - kVK_ANSI_KeypadClear = 0x47, - kVK_ANSI_KeypadDivide = 0x4B, - kVK_ANSI_KeypadEnter = 0x4C, - kVK_ANSI_KeypadMinus = 0x4E, - kVK_ANSI_KeypadEquals = 0x51, - kVK_ANSI_Keypad0 = 0x52, - kVK_ANSI_Keypad1 = 0x53, - kVK_ANSI_Keypad2 = 0x54, - kVK_ANSI_Keypad3 = 0x55, - kVK_ANSI_Keypad4 = 0x56, - kVK_ANSI_Keypad5 = 0x57, - kVK_ANSI_Keypad6 = 0x58, - kVK_ANSI_Keypad7 = 0x59, - kVK_ANSI_Keypad8 = 0x5B, - kVK_ANSI_Keypad9 = 0x5C -}; - -/* keycodes for keys that are independent of keyboard layout*/ -enum { - kVK_Return = 0x24, - kVK_Tab = 0x30, - kVK_Space = 0x31, - kVK_Delete = 0x33, - kVK_Escape = 0x35, - kVK_Command = 0x37, - kVK_Shift = 0x38, - kVK_CapsLock = 0x39, - kVK_Option = 0x3A, - kVK_Control = 0x3B, - kVK_RightShift = 0x3C, - kVK_RightOption = 0x3D, - kVK_RightControl = 0x3E, - kVK_Function = 0x3F, - kVK_F17 = 0x40, - kVK_VolumeUp = 0x48, - kVK_VolumeDown = 0x49, - kVK_Mute = 0x4A, - kVK_F18 = 0x4F, - kVK_F19 = 0x50, - kVK_F20 = 0x5A, - kVK_F5 = 0x60, - kVK_F6 = 0x61, - kVK_F7 = 0x62, - kVK_F3 = 0x63, - kVK_F8 = 0x64, - kVK_F9 = 0x65, - kVK_F11 = 0x67, - kVK_F13 = 0x69, - kVK_F16 = 0x6A, - kVK_F14 = 0x6B, - kVK_F10 = 0x6D, - kVK_F12 = 0x6F, - kVK_F15 = 0x71, - kVK_Help = 0x72, - kVK_Home = 0x73, - kVK_PageUp = 0x74, - kVK_ForwardDelete = 0x75, - kVK_F4 = 0x76, - kVK_End = 0x77, - kVK_F2 = 0x78, - kVK_PageDown = 0x79, - kVK_F1 = 0x7A, - kVK_LeftArrow = 0x7B, - kVK_RightArrow = 0x7C, - kVK_DownArrow = 0x7D, - kVK_UpArrow = 0x7E -}; - -/* ISO keyboards only*/ -enum { - kVK_ISO_Section = 0x0A -}; - -/* JIS keyboards only*/ -enum { - kVK_JIS_Yen = 0x5D, - kVK_JIS_Underscore = 0x5E, - kVK_JIS_KeypadComma = 0x5F, - kVK_JIS_Eisu = 0x66, - kVK_JIS_Kana = 0x68 -}; -#endif static GHOST_TButtonMask convertButton(int button) { @@ -361,47 +211,28 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction) return (GHOST_TKey) (recvChar - 'a' + GHOST_kKeyA); } else { -#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040 - KeyboardLayoutRef keyLayout; - UCKeyboardLayout *uchrData; - - KLGetCurrentKeyboardLayout(&keyLayout); - KLGetKeyboardLayoutProperty(keyLayout, kKLuchrData, (const void **) - &uchrData); - /*get actual character value of the "remappable" keys in int'l keyboards, - if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger), - then fallback on using the received charactersIgnoringModifiers */ - if (uchrData) - { - UInt32 deadKeyState=0; - UniCharCount actualStrLength=0; - - UCKeyTranslate(uchrData, rawCode, keyAction, 0, - LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar); - - } -#else - /* Leopard and Snow Leopard 64bit compatible API*/ - CFDataRef uchrHandle; /*the keyboard layout*/ - TISInputSourceRef kbdTISHandle; + + /* Leopard and Snow Leopard 64bit compatible API*/ + CFDataRef uchrHandle; /*the keyboard layout*/ + TISInputSourceRef kbdTISHandle; + + kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource(); + uchrHandle = (CFDataRef)TISGetInputSourceProperty(kbdTISHandle,kTISPropertyUnicodeKeyLayoutData); + CFRelease(kbdTISHandle); + + /*get actual character value of the "remappable" keys in int'l keyboards, + if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger), + then fallback on using the received charactersIgnoringModifiers */ + if (uchrHandle) + { + UInt32 deadKeyState=0; + UniCharCount actualStrLength=0; - kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource(); - uchrHandle = (CFDataRef)TISGetInputSourceProperty(kbdTISHandle,kTISPropertyUnicodeKeyLayoutData); - CFRelease(kbdTISHandle); + UCKeyTranslate((UCKeyboardLayout*)CFDataGetBytePtr(uchrHandle), rawCode, keyAction, 0, + LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar); - /*get actual character value of the "remappable" keys in int'l keyboards, - if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger), - then fallback on using the received charactersIgnoringModifiers */ - if (uchrHandle) - { - UInt32 deadKeyState=0; - UniCharCount actualStrLength=0; - - UCKeyTranslate((UCKeyboardLayout*)CFDataGetBytePtr(uchrHandle), rawCode, keyAction, 0, - LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar); - - } -#endif + } + switch (recvChar) { case '-': return GHOST_kKeyMinus; case '=': return GHOST_kKeyEqual; @@ -424,26 +255,6 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction) #pragma mark defines for 10.6 api not documented in 10.5 -#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040 -enum { - /* The following event types are available on some hardware on 10.5.2 and later */ - NSEventTypeGesture = 29, - NSEventTypeMagnify = 30, - NSEventTypeSwipe = 31, - NSEventTypeRotate = 18, - NSEventTypeBeginGesture = 19, - NSEventTypeEndGesture = 20 -}; - -@interface NSEvent(GestureEvents) -- (float)magnification; // change in magnification. -#else -@interface NSEvent(GestureEvents) -- (CGFloat)magnification; // change in magnification on 10.5.2 or later. -@end - -#endif - #pragma mark Utility functions @@ -464,29 +275,6 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) } } -#if defined(WITH_QUICKTIME) && !defined(USE_QTKIT) -//Need to place this quicktime function in an ObjC file -//It is used to avoid memory leak when raising the quicktime "compression settings" standard dialog -extern "C" { - struct bContext; - struct wmOperator; - extern int fromcocoa_request_qtcodec_settings(bContext *C, wmOperator *op); - - -int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op) -{ - int result; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - result = fromcocoa_request_qtcodec_settings(C, op); - - [pool drain]; - return result; -} -}; -#endif - - #pragma mark Cocoa objects /** -- cgit v1.2.3 From 864920ee41e9abc5ce7c699292ccc54ab28fa86a Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 18:17:02 +0000 Subject: OSX/scons: make 10.5 our lowest env and remove older conditionals --- build_files/scons/config/darwin-config.py | 82 ++++++++++--------------------- 1 file changed, 25 insertions(+), 57 deletions(-) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index f81658afe6a..f6c4c942e81 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -22,11 +22,7 @@ MAC_PROC=commands.getoutput(cmd) cmd = 'uname -r' cmd_res=commands.getoutput(cmd) -if cmd_res[:1]=='7': - MAC_CUR_VER='10.3' -elif cmd_res[:1]=='8': - MAC_CUR_VER='10.4' -elif cmd_res[:1]=='9': +if cmd_res[:1]=='9': MAC_CUR_VER='10.5' elif cmd_res[:2]=='10': MAC_CUR_VER='10.6' @@ -52,51 +48,30 @@ else: # Default target OSX settings per architecture # Can be customized -if MACOSX_ARCHITECTURE == 'ppc' and MAC_CUR_VER == '10.4': -# all releases are now made for 10.5 ! -# MAC_MIN_VERS = '10.3' -# MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk' -# LCGDIR = '#../lib/darwin-6.1-powerpc' -# CC = 'gcc-3.3' -# CXX = 'g++-3.3' - MAC_MIN_VERS = '10.4' - MACOSX_DEPLOYMENT_TARGET = '10.4' - MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk' - LCGDIR = '#../lib/darwin-8.0.0-powerpc' - CC = 'gcc-4.0' - CXX = 'g++-4.0' -elif MACOSX_ARCHITECTURE == 'i386' and MAC_CUR_VER == '10.4': - MAC_MIN_VERS = '10.4' - MACOSX_DEPLOYMENT_TARGET = '10.4' - MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk' - LCGDIR = '#../lib/darwin-8.x.i386' - CC = 'gcc-4.0' - CXX = 'g++-4.0' -else : - if 'Mac OS X 10.5' in MACOSX_SDK_CHECK: - # OSX 10.5/6 with Xcode 3.x - MAC_MIN_VERS = '10.5' - MACOSX_DEPLOYMENT_TARGET = '10.5' - MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' - elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK: - # OSX 10.6/7 with Xcode 4.x - MAC_MIN_VERS = '10.6' - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' - else: - # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! ) - MAC_MIN_VERS = '10.6' - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc' - CXX = 'g++' +if 'Mac OS X 10.5' in MACOSX_SDK_CHECK: + # OSX 10.5/6 with Xcode 3.x + MAC_MIN_VERS = '10.5' + MACOSX_DEPLOYMENT_TARGET = '10.5' + MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' + LCGDIR = '#../lib/darwin-9.x.universal' + CC = 'gcc-4.2' + CXX = 'g++-4.2' +elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK: + # OSX 10.6/7 with Xcode 4.x + MAC_MIN_VERS = '10.6' + MACOSX_DEPLOYMENT_TARGET = '10.6' + MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk' + LCGDIR = '#../lib/darwin-9.x.universal' + CC = 'gcc-4.2' + CXX = 'g++-4.2' +else: + # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! ) + MAC_MIN_VERS = '10.6' + MACOSX_DEPLOYMENT_TARGET = '10.6' + MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk' + LCGDIR = '#../lib/darwin-9.x.universal' + CC = 'gcc' + CXX = 'g++' LIBDIR = '${LCGDIR}' @@ -367,19 +342,12 @@ if not WITH_OSX_STATICPYTHON: PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python'] -#note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4 #for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore) if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk") or MACOSX_SDK.endswith("10.9.sdk"): LLIBS = ['stdc++'] else: LLIBS = ['stdc++', 'SystemStubs'] -# some flags shuffling for different OS versions -if MAC_MIN_VERS == '10.3': - CCFLAGS = ['-fuse-cxa-atexit'] + CCFLAGS - PLATFORM_LINKFLAGS = ['-fuse-cxa-atexit'] + PLATFORM_LINKFLAGS - LLIBS.append('crt3.o') - if USE_SDK: SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE] PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS -- cgit v1.2.3 From 6477062b6b2487400880f6947e155bf442400441 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 18:25:43 +0000 Subject: OSX/scons: buildbot cleanup following darwin-config --- .../buildbot/config/user-config-mac-i386.py | 88 ++++++++-------------- .../buildbot/config/user-config-mac-x86_64.py | 88 ++++++++-------------- 2 files changed, 62 insertions(+), 114 deletions(-) diff --git a/build_files/buildbot/config/user-config-mac-i386.py b/build_files/buildbot/config/user-config-mac-i386.py index 1629ad0d67c..cdc3eded5ee 100644 --- a/build_files/buildbot/config/user-config-mac-i386.py +++ b/build_files/buildbot/config/user-config-mac-i386.py @@ -22,11 +22,7 @@ MAC_PROC=commands.getoutput(cmd) cmd = 'uname -r' cmd_res=commands.getoutput(cmd) -if cmd_res[:1]=='7': - MAC_CUR_VER='10.3' -elif cmd_res[:1]=='8': - MAC_CUR_VER='10.4' -elif cmd_res[:1]=='9': +if cmd_res[:1]=='9': MAC_CUR_VER='10.5' elif cmd_res[:2]=='10': MAC_CUR_VER='10.6' @@ -42,55 +38,40 @@ XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version cmd = 'xcodebuild -showsdks' cmd_sdk=commands.getoutput(cmd) MACOSX_SDK_CHECK=cmd_sdk +cmd = 'xcode-select --print-path' +XCODE_SELECT_PATH=commands.getoutput(cmd) +if XCODE_SELECT_PATH.endswith("/Contents/Developer"): + XCODE_BUNDLE=XCODE_SELECT_PATH[:-19] +else: + XCODE_BUNDLE=XCODE_SELECT_PATH # Default target OSX settings per architecture # Can be customized -if MACOSX_ARCHITECTURE == 'ppc' and MAC_CUR_VER == '10.4': -# all releases are now made for 10.5 ! -# MAC_MIN_VERS = '10.3' -# MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk' -# LCGDIR = '#../lib/darwin-6.1-powerpc' -# CC = 'gcc-3.3' -# CXX = 'g++-3.3' - MAC_MIN_VERS = '10.4' - MACOSX_DEPLOYMENT_TARGET = '10.4' - MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk' - LCGDIR = '#../lib/darwin-8.0.0-powerpc' - CC = 'gcc-4.0' - CXX = 'g++-4.0' -elif MACOSX_ARCHITECTURE == 'i386' and MAC_CUR_VER == '10.4': - MAC_MIN_VERS = '10.4' - MACOSX_DEPLOYMENT_TARGET = '10.4' - MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk' - LCGDIR = '#../lib/darwin-8.x.i386' - CC = 'gcc-4.0' - CXX = 'g++-4.0' -else : - if 'Mac OS X 10.5' in MACOSX_SDK_CHECK: - # OSX 10.5/6 with Xcode 3.x - MAC_MIN_VERS = '10.5' - MACOSX_DEPLOYMENT_TARGET = '10.5' - MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' - elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK: - # OSX 10.6/7 with Xcode 4.x - MAC_MIN_VERS = '10.6' - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' - else: - # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! ) - MAC_MIN_VERS = '10.6' - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.7.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc' - CXX = 'g++' +if 'Mac OS X 10.5' in MACOSX_SDK_CHECK: + # OSX 10.5/6 with Xcode 3.x + MAC_MIN_VERS = '10.5' + MACOSX_DEPLOYMENT_TARGET = '10.5' + MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' + LCGDIR = '#../lib/darwin-9.x.universal' + CC = 'gcc-4.2' + CXX = 'g++-4.2' +elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK: + # OSX 10.6/7 with Xcode 4.x + MAC_MIN_VERS = '10.6' + MACOSX_DEPLOYMENT_TARGET = '10.6' + MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk' + LCGDIR = '#../lib/darwin-9.x.universal' + CC = 'gcc-4.2' + CXX = 'g++-4.2' +else: + # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! ) + MAC_MIN_VERS = '10.6' + MACOSX_DEPLOYMENT_TARGET = '10.6' + MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk' + LCGDIR = '#../lib/darwin-9.x.universal' + CC = 'gcc' + CXX = 'g++' LIBDIR = '${LCGDIR}' @@ -360,19 +341,12 @@ if not WITH_OSX_STATICPYTHON: PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python'] -#note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4 #for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore) if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk") or MACOSX_SDK.endswith("10.9.sdk"): LLIBS = ['stdc++'] else: LLIBS = ['stdc++', 'SystemStubs'] -# some flags shuffling for different OS versions -if MAC_MIN_VERS == '10.3': - CCFLAGS = ['-fuse-cxa-atexit'] + CCFLAGS - PLATFORM_LINKFLAGS = ['-fuse-cxa-atexit'] + PLATFORM_LINKFLAGS - LLIBS.append('crt3.o') - if USE_SDK: SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE] PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS diff --git a/build_files/buildbot/config/user-config-mac-x86_64.py b/build_files/buildbot/config/user-config-mac-x86_64.py index fe4154dd2da..024d01c78a2 100644 --- a/build_files/buildbot/config/user-config-mac-x86_64.py +++ b/build_files/buildbot/config/user-config-mac-x86_64.py @@ -22,11 +22,7 @@ MAC_PROC=commands.getoutput(cmd) cmd = 'uname -r' cmd_res=commands.getoutput(cmd) -if cmd_res[:1]=='7': - MAC_CUR_VER='10.3' -elif cmd_res[:1]=='8': - MAC_CUR_VER='10.4' -elif cmd_res[:1]=='9': +if cmd_res[:1]=='9': MAC_CUR_VER='10.5' elif cmd_res[:2]=='10': MAC_CUR_VER='10.6' @@ -42,55 +38,40 @@ XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version cmd = 'xcodebuild -showsdks' cmd_sdk=commands.getoutput(cmd) MACOSX_SDK_CHECK=cmd_sdk +cmd = 'xcode-select --print-path' +XCODE_SELECT_PATH=commands.getoutput(cmd) +if XCODE_SELECT_PATH.endswith("/Contents/Developer"): + XCODE_BUNDLE=XCODE_SELECT_PATH[:-19] +else: + XCODE_BUNDLE=XCODE_SELECT_PATH # Default target OSX settings per architecture # Can be customized -if MACOSX_ARCHITECTURE == 'ppc' and MAC_CUR_VER == '10.4': -# all releases are now made for 10.5 ! -# MAC_MIN_VERS = '10.3' -# MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk' -# LCGDIR = '#../lib/darwin-6.1-powerpc' -# CC = 'gcc-3.3' -# CXX = 'g++-3.3' - MAC_MIN_VERS = '10.4' - MACOSX_DEPLOYMENT_TARGET = '10.4' - MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk' - LCGDIR = '#../lib/darwin-8.0.0-powerpc' - CC = 'gcc-4.0' - CXX = 'g++-4.0' -elif MACOSX_ARCHITECTURE == 'i386' and MAC_CUR_VER == '10.4': - MAC_MIN_VERS = '10.4' - MACOSX_DEPLOYMENT_TARGET = '10.4' - MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk' - LCGDIR = '#../lib/darwin-8.x.i386' - CC = 'gcc-4.0' - CXX = 'g++-4.0' -else : - if 'Mac OS X 10.5' in MACOSX_SDK_CHECK: - # OSX 10.5/6 with Xcode 3.x - MAC_MIN_VERS = '10.5' - MACOSX_DEPLOYMENT_TARGET = '10.5' - MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' - elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK: - # OSX 10.6/7 with Xcode 4.x - MAC_MIN_VERS = '10.6' - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' - else: - # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! ) - MAC_MIN_VERS = '10.6' - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.7.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc' - CXX = 'g++' +if 'Mac OS X 10.5' in MACOSX_SDK_CHECK: + # OSX 10.5/6 with Xcode 3.x + MAC_MIN_VERS = '10.5' + MACOSX_DEPLOYMENT_TARGET = '10.5' + MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' + LCGDIR = '#../lib/darwin-9.x.universal' + CC = 'gcc-4.2' + CXX = 'g++-4.2' +elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK: + # OSX 10.6/7 with Xcode 4.x + MAC_MIN_VERS = '10.6' + MACOSX_DEPLOYMENT_TARGET = '10.6' + MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk' + LCGDIR = '#../lib/darwin-9.x.universal' + CC = 'gcc-4.2' + CXX = 'g++-4.2' +else: + # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! ) + MAC_MIN_VERS = '10.6' + MACOSX_DEPLOYMENT_TARGET = '10.6' + MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk' + LCGDIR = '#../lib/darwin-9.x.universal' + CC = 'gcc' + CXX = 'g++' LIBDIR = '${LCGDIR}' @@ -360,19 +341,12 @@ if not WITH_OSX_STATICPYTHON: PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python'] -#note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4 #for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore) if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk") or MACOSX_SDK.endswith("10.9.sdk"): LLIBS = ['stdc++'] else: LLIBS = ['stdc++', 'SystemStubs'] -# some flags shuffling for different OS versions -if MAC_MIN_VERS == '10.3': - CCFLAGS = ['-fuse-cxa-atexit'] + CCFLAGS - PLATFORM_LINKFLAGS = ['-fuse-cxa-atexit'] + PLATFORM_LINKFLAGS - LLIBS.append('crt3.o') - if USE_SDK: SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE] PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS -- cgit v1.2.3 From f3a137c1b97a85344a6a03221afadcd2eacae61a Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 5 Nov 2013 18:28:43 +0000 Subject: Fix #37312, Backdrop value offset is not refreshed. Backdrop operators need to push notifiers to redraw the node editor buttons. --- source/blender/editors/space_node/node_view.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index 5ea6f8b0caf..ff441d63479 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -220,6 +220,7 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e CLAMP(snode->yof, nvm->ymin, nvm->ymax); ED_region_tag_redraw(ar); + WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL); break; @@ -304,6 +305,7 @@ static int backimage_zoom_exec(bContext *C, wmOperator *op) snode->zoom *= fac; ED_region_tag_redraw(ar); + WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -361,6 +363,7 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op)) snode->yof = 0; ED_region_tag_redraw(ar); + WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } -- cgit v1.2.3 From e3a5f0501ea67e5aa62c948be948f82cc6ac73e2 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 18:57:45 +0000 Subject: Fix cmake/player compile by adding the xtra osx lib, check if this breaks other OS --- source/blenderplayer/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 67009bf2c8b..4c345a0e782 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -92,6 +92,7 @@ endif() ge_player_common bf_intern_string bf_intern_ghost + bf_intern_ghostndof3dconnexion bf_rna bf_blenkernel bf_intern_rigidbody -- cgit v1.2.3 From dba787f5297a12a3c1bd658d84c6ba10e2a14d75 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Tue, 5 Nov 2013 20:30:09 +0000 Subject: OSX/player: Remove some very old code ( 11 years+ ), was commented anyway --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 31 ------------------------ 1 file changed, 31 deletions(-) diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 385fa0a42d8..14b5bca1101 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -40,11 +40,6 @@ #endif /* __alpha__ */ #endif /* __linux__ */ -#ifdef __APPLE__ -// Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh) -//#include -//#include -#endif // __APPLE__ #include "KX_KetsjiEngine.h" #include "KX_PythonInit.h" #include "KX_PythonMain.h" @@ -426,27 +421,6 @@ int main(int argc, char** argv) #endif /* __linux__ */ BLI_init_program_path(argv[0]); BLI_init_temporary_dir(NULL); -#ifdef __APPLE__ - // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh) - /* - IBNibRef nibRef; - WindowRef window; - OSStatus err; - - // Create a Nib reference passing the name of the nib file (without the .nib extension) - // CreateNibReference only searches into the application bundle. - err = ::CreateNibReference(CFSTR("main"), &nibRef); - if (err) return -1; - - // Once the nib reference is created, set the menu bar. "MainMenu" is the name of the menu bar - // object. This name is set in InterfaceBuilder when the nib is created. - err = ::SetMenuBarFromNib(nibRef, CFSTR("MenuBar")); - if (err) return -1; - - // We don't need the nib reference anymore. - ::DisposeNibReference(nibRef); - */ -#endif // __APPLE__ // We don't use threads directly in the BGE, but we need to call this so things like // freeing up GPU_Textures works correctly. @@ -775,11 +749,6 @@ int main(int argc, char** argv) if (scr_saver_mode != SCREEN_SAVER_MODE_CONFIGURATION) #endif { -#ifdef __APPLE__ - //SYS_WriteCommandLineInt(syshandle, "show_framerate", 1); - //SYS_WriteCommandLineInt(syshandle, "nomipmap", 1); - //fullScreen = false; // Can't use full screen -#endif if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) { GPU_set_mipmap(0); -- cgit v1.2.3 From 53dccd94a46cc68347a2e787bd6f8930463cd9a9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Nov 2013 21:47:35 +0000 Subject: patch [#37305] Quick Hack: Armature Mirror Select from Terry Struven (tlstruven), with some modifications. --- release/scripts/startup/bl_ui/space_view3d.py | 1 + source/blender/editors/armature/armature_intern.h | 1 + source/blender/editors/armature/armature_ops.c | 4 ++ source/blender/editors/armature/armature_select.c | 64 ++++++++++++++++++++--- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index fd1f7f5c4bf..3a3d3df06d8 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -758,6 +758,7 @@ class VIEW3D_MT_select_edit_armature(Menu): layout.operator("armature.select_all").action = 'TOGGLE' layout.operator("armature.select_all", text="Inverse").action = 'INVERT' + layout.operator("armature.select_mirror", text="Mirror").extend = False layout.separator() diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 3080ab33538..83800e598ba 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -62,6 +62,7 @@ void ARMATURE_OT_parent_set(struct wmOperatorType *ot); void ARMATURE_OT_parent_clear(struct wmOperatorType *ot); void ARMATURE_OT_select_all(struct wmOperatorType *ot); +void ARMATURE_OT_select_mirror(struct wmOperatorType *ot); void ARMATURE_OT_select_more(struct wmOperatorType *ot); void ARMATURE_OT_select_less(struct wmOperatorType *ot); void ARMATURE_OT_select_hierarchy(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 3322b115da9..040b6f33f3b 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -58,6 +58,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(ARMATURE_OT_parent_clear); WM_operatortype_append(ARMATURE_OT_select_all); + WM_operatortype_append(ARMATURE_OT_select_mirror); WM_operatortype_append(ARMATURE_OT_select_more); WM_operatortype_append(ARMATURE_OT_select_less); WM_operatortype_append(ARMATURE_OT_select_hierarchy); @@ -239,6 +240,9 @@ void ED_keymap_armature(wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + + kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 69a42b84624..4c956ca65d4 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -54,6 +54,10 @@ #include "armature_intern.h" +/* utility macros fro storing a temp int in the bone (selection flag) */ +#define EBONE_PREV_FLAG_GET(ebone) ((void)0, (GET_INT_FROM_POINTER((ebone)->temp))) +#define EBONE_PREV_FLAG_SET(ebone, val) ((ebone)->temp = SET_INT_IN_POINTER(val)) + /* **************** PoseMode & EditMode Selection Buffer Queries *************************** */ /* only for opengl selection indices */ @@ -634,9 +638,6 @@ void ARMATURE_OT_select_all(wmOperatorType *ot) /**************** Select more/less **************/ -#define EBONE_PREV_FLAG_GET(ebone) ((void)0, (GET_INT_FROM_POINTER(ebone->temp))) -#define EBONE_PREV_FLAG_SET(ebone, val) (ebone->temp = SET_INT_IN_POINTER(val)) - static void armature_select_more(bArmature *arm, EditBone *ebone) { if ((EBONE_PREV_FLAG_GET(ebone) & (BONE_ROOTSEL | BONE_TIPSEL)) != 0) { @@ -720,9 +721,6 @@ static void armature_select_more_less(Object *ob, bool more) ED_armature_sync_selection(arm->edbo); } -#undef EBONE_PREV_FLAG_GET -#undef EBONE_PREV_FLAG_SET - static int armature_de_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { Object *obedit = CTX_data_edit_object(C); @@ -1050,3 +1048,57 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } +/****************** Mirror Select ****************/ + +static int armature_select_mirror_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = obedit->data; + EditBone *ebone; + const bool extend = RNA_boolean_get(op->ptr, "extend"); + + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + const int flag = ED_armature_ebone_selectflag_get(ebone); + EBONE_PREV_FLAG_SET(ebone, flag); + } + + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + if (EBONE_SELECTABLE(arm, ebone)) { + EditBone *ebone_mirror; + int flag_new = extend ? EBONE_PREV_FLAG_GET(ebone) : 0; + + if ((ebone_mirror = ED_armature_bone_get_mirrored(arm->edbo, ebone)) && + (EBONE_VISIBLE(arm, ebone_mirror))) + { + const int flag_mirror = EBONE_PREV_FLAG_GET(ebone_mirror); + flag_new |= flag_mirror; + } + + ED_armature_ebone_selectflag_set(ebone, flag_new); + } + } + + ED_armature_sync_selection(arm->edbo); + + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); + + return OPERATOR_FINISHED; +} + +void ARMATURE_OT_select_mirror(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Mirror Select"; + ot->idname = "ARMATURE_OT_select_mirror"; + ot->description = "Mirror the bone selection"; + + /* api callbacks */ + ot->exec = armature_select_mirror_exec; + ot->poll = ED_operator_editarmature; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); +} -- cgit v1.2.3 From 7874447e4a75d77eddacb0b0186ea1e9f2c76596 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Nov 2013 21:59:30 +0000 Subject: code cleanup: typo and warning when openmp's disabled. --- source/blender/editors/armature/armature_edit.c | 2 +- source/blender/editors/include/ED_armature.h | 2 +- source/blender/editors/sculpt_paint/paint_mask.c | 5 +++-- source/blender/editors/space_outliner/outliner_draw.c | 2 +- source/gameengine/Ketsji/KX_Scene.cpp | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 4c90a37e720..29eebe86afa 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -484,7 +484,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) /* the number of joints determines how we fill: * 1) between joint and cursor (joint=head, cursor=tail) - * 2) between the two joints (order is dependent on active-bone/hierachy) + * 2) between the two joints (order is dependent on active-bone/hierarchy) * 3+) error (a smarter method involving finding chains needs to be worked out */ count = BLI_countlist(&points); diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index e7489e1bc72..bb4640949c1 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -106,7 +106,7 @@ typedef struct EditBone { (((ebone)->flag & BONE_SELECTED) && !((ebone)->flag & BONE_EDITMODE_LOCKED)) \ ) -/* used in bone_select_hierachy() */ +/* used in armature_select_hierarchy_exec() */ #define BONE_SELECT_PARENT 0 #define BONE_SELECT_CHILD 1 diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 87e267b1072..980223e24c0 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -277,8 +277,9 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) Object *ob; ViewContext vc; LassoMaskData data; +#ifdef _OPENMP Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - +#endif struct MultiresModifierData *mmd; DerivedMesh *dm; PBVH *pbvh; @@ -322,7 +323,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) sculpt_undo_push_begin("Mask lasso fill"); - #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) +#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (i = 0; i < totnode; i++) { PBVHVertexIter vi; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index fda8c19d21b..5168c3c873a 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1624,7 +1624,7 @@ void draw_outliner(const bContext *C) /* set matrix for 2d-view controls */ UI_view2d_view_ortho(v2d); - /* draw outliner stuff (background, hierachy lines and names) */ + /* draw outliner stuff (background, hierarchy lines and names) */ outliner_back(ar); block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); outliner_draw_tree((bContext *)C, block, scene, ar, soops, &te_edit); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index c3d7d3179b6..5a956ffc048 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -630,7 +630,7 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) newsensorobj = (SCA_IObject*)(*h_obj); if (!newsensorobj) { - // no, then the sensor points outside the hierachy, keep it the same + // no, then the sensor points outside the hierarchy, keep it the same if (m_objectlist->SearchValue(oldsensorobj)) // only replicate links that points to active objects m_logicmgr->RegisterToSensor(cont,oldsensor); @@ -670,7 +670,7 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) if (!newactuatorobj) { - // no, then the sensor points outside the hierachy, keep it the same + // no, then the sensor points outside the hierarchy, keep it the same if (m_objectlist->SearchValue(oldactuatorobj)) // only replicate links that points to active objects m_logicmgr->RegisterToActuator(cont,oldactuator); -- cgit v1.2.3 From 299812f28d32950a9bbf4612a3a5fef46054e7fb Mon Sep 17 00:00:00 2001 From: Kevin Mackay Date: Tue, 5 Nov 2013 23:37:09 +0000 Subject: Made active point and active spline behaviour more predictable on curves/surfaces: * deselect all no longer leaves an active point * the most recently added spline becomes the active one * on successful duplicate/delete the active point and active spline are reset --- source/blender/blenkernel/intern/curve.c | 1 + source/blender/editors/curve/editcurve.c | 56 ++++++++++++++-------------- source/blender/editors/curve/editcurve_add.c | 2 + 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index ca9f97b754c..4524b3ac7ac 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -230,6 +230,7 @@ Curve *BKE_curve_copy(Curve *cu) cun->editnurb = NULL; cun->editfont = NULL; cun->selboxes = NULL; + cun->lastsel = NULL; #if 0 // XXX old animation system /* single user ipo too */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index bd91740521d..f576440fe92 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1279,6 +1279,8 @@ void CU_deselect_all(Object *obedit) if (editnurb) { Nurb *nu; int a; + ((Curve *)obedit->data)->lastsel = NULL; + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { BezTriple *bezt; @@ -1902,7 +1904,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, int a, b, c, starta, enda, diffa, cyclicu, cyclicv, newu, newv; char *usel; - cu->lastsel = NULL; while (nu) { cyclicu = cyclicv = 0; if (nu->type == CU_BEZIER) { @@ -1927,7 +1928,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, newnu = BKE_nurb_copy(nu, newu, 1); BLI_addtail(newnurb, newnu); - set_actNurb(obedit, newnu); memcpy(newnu->bezt, &nu->bezt[starta], diffa * sizeof(BezTriple)); if (newu != diffa) { memcpy(&newnu->bezt[diffa], nu->bezt, cyclicu * sizeof(BezTriple)); @@ -1976,7 +1976,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, newnu = BKE_nurb_copy(nu, newu, 1); BLI_addtail(newnurb, newnu); - set_actNurb(obedit, newnu); memcpy(newnu->bp, &nu->bp[starta], diffa * sizeof(BPoint)); if (newu != diffa) { memcpy(&newnu->bp[diffa], nu->bp, cyclicu * sizeof(BPoint)); @@ -1995,8 +1994,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, if (cyclicu != 0) { newnu = BKE_nurb_copy(nu, cyclicu, 1); BLI_addtail(newnurb, newnu); - set_actNurb(obedit, newnu); - memcpy(newnu->bp, nu->bp, cyclicu * sizeof(BPoint)); newnu->flagu &= ~CU_NURB_CYCLIC; @@ -2093,7 +2090,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, memcpy(&newnu->bp[b * newu], &nu->bp[b * nu->pntsu + a], newu * sizeof(BPoint)); } } - set_actNurb(obedit, newnu); BLI_addtail(newnurb, newnu); if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC; @@ -2110,7 +2106,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, for (b = 0; b < newv; b++) { memcpy(&newnu->bp[b * newu], &nu->bp[b * nu->pntsu], newu * sizeof(BPoint)); } - set_actNurb(obedit, newnu); BLI_addtail(newnurb, newnu); if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC; @@ -2127,32 +2122,35 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, nu = nu->prev; } - for (nu = newnurb->first; nu; nu = nu->next) { - if (nu->type == CU_BEZIER) { - if (split) { - /* recalc first and last */ - BKE_nurb_handle_calc_simple(nu, &nu->bezt[0]); - BKE_nurb_handle_calc_simple(nu, &nu->bezt[nu->pntsu - 1]); - } - } - else { - /* knots done after duplicate as pntsu may change */ - nu->knotsu = nu->knotsv = NULL; - BKE_nurb_order_clamp_u(nu); - BKE_nurb_knot_calc_u(nu); + if (newnurb->first != NULL) { + cu->lastsel = NULL; + cu->actnu = -1; - if (obedit->type == OB_SURF) { - for (a = 0, bp = nu->bp; a < nu->pntsu * nu->pntsv; a++, bp++) { - bp->f1 &= ~SURF_SEEN; + for (nu = newnurb->first; nu; nu = nu->next) { + if (nu->type == CU_BEZIER) { + if (split) { + /* recalc first and last */ + BKE_nurb_handle_calc_simple(nu, &nu->bezt[0]); + BKE_nurb_handle_calc_simple(nu, &nu->bezt[nu->pntsu - 1]); } + } + else { + /* knots done after duplicate as pntsu may change */ + nu->knotsu = nu->knotsv = NULL; + BKE_nurb_order_clamp_u(nu); + BKE_nurb_knot_calc_u(nu); - BKE_nurb_order_clamp_v(nu); - BKE_nurb_knot_calc_v(nu); + if (obedit->type == OB_SURF) { + for (a = 0, bp = nu->bp; a < nu->pntsu * nu->pntsv; a++, bp++) { + bp->f1 &= ~SURF_SEEN; + } + + BKE_nurb_order_clamp_v(nu); + BKE_nurb_knot_calc_v(nu); + } } } } - - /* actnu changed */ } /**************** switch direction operator ***************/ @@ -6367,6 +6365,7 @@ static int curve_delete_segments(Object *obedit, const bool split) static int curve_delete_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); + Curve *cu = (Curve *)obedit->data; eCurveElem_Types type = RNA_enum_get(op->ptr, "type"); int retval; @@ -6375,6 +6374,9 @@ static int curve_delete_exec(bContext *C, wmOperator *op) else BLI_assert(0); if (retval == OPERATOR_FINISHED) { + cu->lastsel = NULL; + cu->actnu = -1; + if (ED_curve_updateAnimPaths(obedit->data)) WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index 9b858a2c4e9..6804aa3584f 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -458,6 +458,8 @@ Nurb *add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4], int type if (nu) { /* should always be set */ nu->flag |= CU_SMOOTH; + cu->actnu = BLI_countlist(editnurb); + cu->lastsel = NULL; BKE_nurb_test2D(nu); } -- cgit v1.2.3 From 99c5e713970859640a9e46c2afeeff9d5235f624 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 6 Nov 2013 01:45:15 +0000 Subject: Quicktime: remove backend with the old quicktime API, and keep the QTKit backend. This means that if you have WITH_BF_QUICKTIME or WITH_CODEC_QUICKTIME enabled, it will always use QTKit. The old backend was only used on 32 bit OS X builds, now 32 and 64 bit builds will give consistent input/output. On Windows or Linux quicktime isn't being used. --- CMakeLists.txt | 26 +- SConstruct | 3 - .../buildbot/config/user-config-mac-i386.py | 6 +- .../buildbot/config/user-config-mac-x86_64.py | 6 +- build_files/scons/config/darwin-config.py | 6 +- build_files/scons/config/freebsd8-config.py | 5 - build_files/scons/config/linux-config.py | 4 - build_files/scons/config/linuxcross-config.py | 4 - build_files/scons/config/win32-mingw-config.py | 4 - build_files/scons/config/win32-vc-config.py | 6 - build_files/scons/config/win64-mingw-config.py | 2 - build_files/scons/tools/btools.py | 2 - intern/ghost/SConscript | 3 - release/scripts/startup/bl_ui/properties_render.py | 5 +- source/blender/editors/object/object_add.c | 3 + source/blender/editors/render/SConscript | 3 - source/blender/editors/render/render_ops.c | 8 - source/blender/makesrna/intern/rna_scene.c | 12 +- source/blender/quicktime/CMakeLists.txt | 22 +- source/blender/quicktime/SConscript | 6 +- source/blender/quicktime/apple/quicktime_export.c | 927 --------------------- source/blender/quicktime/apple/quicktime_import.c | 833 ------------------ source/blender/quicktime/quicktime_export.h | 9 +- source/blender/quicktime/quicktime_import.h | 12 - 24 files changed, 21 insertions(+), 1896 deletions(-) delete mode 100644 source/blender/quicktime/apple/quicktime_export.c delete mode 100644 source/blender/quicktime/apple/quicktime_import.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 1302fd5bdfa..f9ba78eab53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,7 +218,7 @@ option(WITH_CODEC_AVI "Enable Blenders own AVI file support (raw/jpeg) option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" OFF) option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF) -if(APPLE OR (WIN32 AND NOT UNIX)) +if(APPLE) option(WITH_CODEC_QUICKTIME "Enable Quicktime Support" OFF) endif() @@ -380,11 +380,7 @@ if(APPLE) add_definitions("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}") endif() - option(USE_QTKIT "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF) option(WITH_LIBS10.5 "Use 10.5 libs (needed for 64bit builds)" OFF) - if(CMAKE_OSX_ARCHITECTURES MATCHES x86_64) - set(USE_QTKIT ON CACHE BOOL "ON" FORCE) # no Quicktime in 64bit - endif() endif() @@ -491,14 +487,6 @@ if(WITH_GHOST_SDL OR WITH_HEADLESS) set(WITH_X11_XINPUT OFF) endif() -if(MINGW) - if(WITH_CODEC_QUICKTIME) - message(FATAL_ERROR "MINGW requires WITH_CODEC_QUICKTIME to be OFF " - "because it is currently unsupported, remove this " - "line if youre a developer who wants to add support.") - endif() -endif() - TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG) TEST_STDBOOL_SUPPORT() @@ -1029,13 +1017,6 @@ elseif(WIN32) set(SDL_LIBPATH ${SDL}/lib) endif() - if(WITH_CODEC_QUICKTIME) - set(QUICKTIME ${LIBDIR}/QTDevWin) - set(QUICKTIME_INCLUDE_DIRS ${QUICKTIME}/CIncludes) - set(QUICKTIME_LIBRARIES qtmlClient) - set(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries) - endif() - if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD) add_definitions(-D__SSE__ -D__MMX__) endif() @@ -1613,15 +1594,12 @@ elseif(APPLE) set(PLATFORM_CFLAGS "-pipe -funsigned-char") set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio") - if(USE_QTKIT) - set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT") + if(WITH_CODEC_QUICKTIME) set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit") if(CMAKE_OSX_ARCHITECTURES MATCHES i386) set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime") # libSDL still needs 32bit carbon quicktime endif() - elseif(WITH_CODEC_QUICKTIME) - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime") endif() # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED! diff --git a/SConstruct b/SConstruct index 07227e6bd06..4ef56db46d4 100644 --- a/SConstruct +++ b/SConstruct @@ -342,9 +342,6 @@ if env['WITH_BF_OPENMP'] == 1: else: env.Append(CCFLAGS=['-fopenmp']) -if env['USE_QTKIT'] == True: - env.Append(CPPFLAGS=['-DUSE_QTKIT']) - #check for additional debug libnames if env.has_key('BF_DEBUG_LIBS'): diff --git a/build_files/buildbot/config/user-config-mac-i386.py b/build_files/buildbot/config/user-config-mac-i386.py index cdc3eded5ee..7242289e109 100644 --- a/build_files/buildbot/config/user-config-mac-i386.py +++ b/build_files/buildbot/config/user-config-mac-i386.py @@ -45,6 +45,7 @@ if XCODE_SELECT_PATH.endswith("/Contents/Developer"): else: XCODE_BUNDLE=XCODE_SELECT_PATH + # Default target OSX settings per architecture # Can be customized @@ -332,10 +333,7 @@ CPPFLAGS = list(ARCH_FLAGS) PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS if WITH_BF_QUICKTIME: - if USE_QTKIT: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit'] - else: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime'] + PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit'] if not WITH_OSX_STATICPYTHON: PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python'] diff --git a/build_files/buildbot/config/user-config-mac-x86_64.py b/build_files/buildbot/config/user-config-mac-x86_64.py index 024d01c78a2..4324ecbe2b4 100644 --- a/build_files/buildbot/config/user-config-mac-x86_64.py +++ b/build_files/buildbot/config/user-config-mac-x86_64.py @@ -45,6 +45,7 @@ if XCODE_SELECT_PATH.endswith("/Contents/Developer"): else: XCODE_BUNDLE=XCODE_SELECT_PATH + # Default target OSX settings per architecture # Can be customized @@ -332,10 +333,7 @@ CPPFLAGS = list(ARCH_FLAGS) PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS if WITH_BF_QUICKTIME: - if USE_QTKIT: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit'] - else: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime'] + PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit'] if not WITH_OSX_STATICPYTHON: PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python'] diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index f6c4c942e81..142b1ad04a1 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -45,6 +45,7 @@ if XCODE_SELECT_PATH.endswith("/Contents/Developer"): else: XCODE_BUNDLE=XCODE_SELECT_PATH + # Default target OSX settings per architecture # Can be customized @@ -333,10 +334,7 @@ CPPFLAGS = list(ARCH_FLAGS) PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS if WITH_BF_QUICKTIME: - if USE_QTKIT: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit'] - else: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QuickTime'] + PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit'] if not WITH_OSX_STATICPYTHON: PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python'] diff --git a/build_files/scons/config/freebsd8-config.py b/build_files/scons/config/freebsd8-config.py index e94f61f7819..b7c6fed45c2 100644 --- a/build_files/scons/config/freebsd8-config.py +++ b/build_files/scons/config/freebsd8-config.py @@ -90,11 +90,6 @@ BF_FREETYPE = '/usr/local' BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2' BF_FREETYPE_LIB = 'freetype' -### XXX Find what this actually wants; it doesn't want libquicktime. -WITH_BF_QUICKTIME = False -BF_QUICKTIME = '/usr/local' -BF_QUICKTIME_INC = '${BF_QUICKTIME}/include' - WITH_BF_ICONV = True BF_ICONV = LIBDIR + "/iconv" BF_ICONV_INC = '${BF_ICONV}/include' diff --git a/build_files/scons/config/linux-config.py b/build_files/scons/config/linux-config.py index 93fa6137bb0..743131ab32e 100644 --- a/build_files/scons/config/linux-config.py +++ b/build_files/scons/config/linux-config.py @@ -100,10 +100,6 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2' BF_FREETYPE_LIB = 'freetype' #BF_FREETYPE_LIB_STATIC = '${BF_FREETYPE}/lib/libfreetype.a' -WITH_BF_QUICKTIME = False -BF_QUICKTIME = '/usr/local' -BF_QUICKTIME_INC = '${BF_QUICKTIME}/include' - WITH_BF_ICONV = False BF_ICONV = "/usr" BF_ICONV_INC = '${BF_ICONV}/include' diff --git a/build_files/scons/config/linuxcross-config.py b/build_files/scons/config/linuxcross-config.py index 5b958420f37..36b29a309af 100644 --- a/build_files/scons/config/linuxcross-config.py +++ b/build_files/scons/config/linuxcross-config.py @@ -101,10 +101,6 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2' BF_FREETYPE_LIB = 'freetype' BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib' -WITH_BF_QUICKTIME = False -BF_QUICKTIME = '/usr/local' -BF_QUICKTIME_INC = '${BF_QUICKTIME}/include' - WITH_BF_ICONV = False BF_ICONV = LIBDIR + "/gcc/iconv" BF_ICONV_INC = '${BF_ICONV}/include' diff --git a/build_files/scons/config/win32-mingw-config.py b/build_files/scons/config/win32-mingw-config.py index d71feb8d2e9..213efcbb2df 100644 --- a/build_files/scons/config/win32-mingw-config.py +++ b/build_files/scons/config/win32-mingw-config.py @@ -112,10 +112,6 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2' BF_FREETYPE_LIB = 'freetype' BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib' -WITH_BF_QUICKTIME = False -BF_QUICKTIME = '/usr/local' -BF_QUICKTIME_INC = '${BF_QUICKTIME}/include' - WITH_BF_ICONV = False BF_ICONV = LIBDIR + "/iconv" BF_ICONV_INC = '${BF_ICONV}/include' diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index f1597a66538..4eb6416ad59 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -133,12 +133,6 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2' BF_FREETYPE_LIB = 'freetype2ST' BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib' -WITH_BF_QUICKTIME = False -BF_QUICKTIME = LIBDIR + '/QTDevWin' -BF_QUICKTIME_INC = '${BF_QUICKTIME}/CIncludes' -BF_QUICKTIME_LIB = 'qtmlClient' -BF_QUICKTIME_LIBPATH = '${BF_QUICKTIME}/Libraries' - WITH_BF_OPENJPEG = True BF_OPENJPEG = '#extern/libopenjpeg' BF_OPENJPEG_LIB = '' diff --git a/build_files/scons/config/win64-mingw-config.py b/build_files/scons/config/win64-mingw-config.py index e82b6e8a73f..bb55354d591 100644 --- a/build_files/scons/config/win64-mingw-config.py +++ b/build_files/scons/config/win64-mingw-config.py @@ -111,8 +111,6 @@ BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2/' BF_FREETYPE_LIB = 'freetype' BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib' -WITH_BF_QUICKTIME = False - WITH_BF_ICONV = False BF_ICONV = LIBDIR + "/iconv" BF_ICONV_INC = '${BF_ICONV}/include' diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 9ad4315f442..65cbcf4e1ec 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -143,7 +143,6 @@ def validate_arguments(args, bc): 'WITH_X11_XINPUT', 'WITH_X11_XF86VMODE', 'BF_GHOST_DEBUG', - 'USE_QTKIT', 'BF_FANCY', 'BF_QUIET', 'BF_LINE_OVERWRITE', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG', @@ -426,7 +425,6 @@ def read_opts(env, cfg, args): (BoolVariable('WITH_GHOST_SDL', 'Enable building blender against SDL for windowing rather then the native APIs', False)), (BoolVariable('WITH_X11_XINPUT', 'Enable X11 Xinput (tablet support and unicode input)', True)), (BoolVariable('WITH_X11_XF86VMODE', 'Enable X11 video mode switching', True)), - (BoolVariable('USE_QTKIT', 'Use QTKIT if true', True)), ('BF_OPENMP_LIB_STATIC', 'OpenMP static library', ''), (BoolVariable('WITH_BF_QUICKTIME', 'Use QuickTime if true', False)), diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript index 03868bb8b11..df4efe60a11 100644 --- a/intern/ghost/SConscript +++ b/intern/ghost/SConscript @@ -98,8 +98,6 @@ elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64 elif window_system == 'darwin': if env['WITH_BF_QUICKTIME']: defs.append('WITH_QUICKTIME') - if env['USE_QTKIT']: - defs.append('USE_QTKIT') for f in pf: try: sources.remove('intern' + os.sep + f + 'Win32.cpp') @@ -107,7 +105,6 @@ elif window_system == 'darwin': sources.remove('intern' + os.sep + f + 'SDL.cpp') except ValueError: pass - else: print "Unknown window system specified." Exit() diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 288f95ca4b0..7b09fd6ab16 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -395,10 +395,7 @@ class RENDER_PT_output(RenderButtonsPanel, Panel): layout.template_image_settings(image_settings, color_management=False) - if file_format == 'QUICKTIME_CARBON': - layout.operator("scene.render_data_set_quicktime_codec") - - elif file_format == 'QUICKTIME_QTKIT': + if file_format == 'QUICKTIME': quicktime = rd.quicktime split = layout.split() diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 0a390da2ae4..9dd686326bb 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1617,6 +1617,9 @@ static int convert_exec(bContext *C, wmOperator *op) for (nu = cu->nurb.first; nu; nu = nu->next) nu->charidx = 0; + cu->flag &= ~CU_3D; + BKE_curve_curve_dimension_update(cu); + if (target == OB_MESH) { curvetomesh(scene, newob); diff --git a/source/blender/editors/render/SConscript b/source/blender/editors/render/SConscript index 7406d42f416..41576f9b485 100644 --- a/source/blender/editors/render/SConscript +++ b/source/blender/editors/render/SConscript @@ -61,9 +61,6 @@ if env['WITH_BF_QUICKTIME']: incs += ' ../../quicktime' env.Append(CFLAGS=['-DWITH_QUICKTIME']) -if env['USE_QTKIT']: - env.Append(CFLAGS=['-DUSE_QTKIT']) - if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c index 7c52b7d0d39..3401577ee55 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -37,10 +37,6 @@ #include "render_intern.h" // own include -#if (defined(WITH_QUICKTIME) && !defined(USE_QTKIT)) -#include "quicktime_export.h" -#endif - /***************************** render ***********************************/ void ED_operatortypes_render(void) @@ -81,10 +77,6 @@ void ED_operatortypes_render(void) WM_operatortype_append(SCENE_OT_freestyle_modifier_copy); #endif -#if (defined(WITH_QUICKTIME) && !defined(USE_QTKIT)) - WM_operatortype_append(SCENE_OT_render_data_set_quicktime_codec); -#endif - WM_operatortype_append(TEXTURE_OT_slot_copy); WM_operatortype_append(TEXTURE_OT_slot_paste); WM_operatortype_append(TEXTURE_OT_slot_move); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index ef3ee07e211..fb0a26621f4 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -261,11 +261,7 @@ EnumPropertyItem image_type_items[] = { {R_IMF_IMTYPE_THEORA, "THEORA", ICON_FILE_MOVIE, "Ogg Theora", "Output video in Ogg format"}, #endif #ifdef WITH_QUICKTIME -# ifdef USE_QTKIT - {R_IMF_IMTYPE_QUICKTIME, "QUICKTIME_QTKIT", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"}, -# else - {R_IMF_IMTYPE_QUICKTIME, "QUICKTIME_CARBON", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"}, -# endif + {R_IMF_IMTYPE_QUICKTIME, "QUICKTIME", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"}, #endif #ifdef WITH_FFMPEG {R_IMF_IMTYPE_XVID, "XVID", ICON_FILE_MOVIE, "Xvid", "Output video in Xvid format"}, @@ -955,7 +951,6 @@ static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_codecType_itemf(bCon return item; } -#ifdef USE_QTKIT static int rna_RenderSettings_qtcodecsettings_audiocodecType_get(PointerRNA *ptr) { QuicktimeCodecSettings *settings = (QuicktimeCodecSettings *)ptr->data; @@ -994,7 +989,6 @@ static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_audiocodecType_itemf return item; } #endif -#endif #ifdef WITH_FFMPEG static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, int value) @@ -3954,7 +3948,6 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; -#ifdef USE_QTKIT static EnumPropertyItem quicktime_audio_samplerate_items[] = { {22050, "22050", 0, "22kHz", ""}, {44100, "44100", 0, "44.1kHz", ""}, @@ -3984,7 +3977,6 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna) {320000, "320000", 0, "320kbps", ""}, {0, NULL, 0, NULL, NULL} }; -#endif /* QuickTime */ srna = RNA_def_struct(brna, "QuickTimeSettings", NULL); @@ -4006,7 +3998,6 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Spatial quality", "Intra-frame spatial quality level"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); -#ifdef USE_QTKIT prop = RNA_def_property(srna, "audiocodec_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "audiocodecType"); RNA_def_property_enum_items(prop, quicktime_codec_type_items); @@ -4043,7 +4034,6 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, quicktime_audio_bitrate_items); RNA_def_property_ui_text(prop, "Bitrate", "Compressed audio bitrate"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); -#endif } #endif diff --git a/source/blender/quicktime/CMakeLists.txt b/source/blender/quicktime/CMakeLists.txt index 0c5c4d8a9f1..b0a8c92e559 100644 --- a/source/blender/quicktime/CMakeLists.txt +++ b/source/blender/quicktime/CMakeLists.txt @@ -41,23 +41,13 @@ set(INC_SYS ${QUICKTIME_INCLUDE_DIRS} ) -if(USE_QTKIT) - set(SRC - apple/qtkit_import.m - apple/qtkit_export.m +set(SRC + apple/qtkit_import.m + apple/qtkit_export.m - quicktime_export.h - quicktime_import.h - ) -else() - set(SRC - apple/quicktime_import.c - apple/quicktime_export.c - - quicktime_export.h - quicktime_import.h - ) -endif() + quicktime_export.h + quicktime_import.h +) add_definitions(-DWITH_QUICKTIME) diff --git a/source/blender/quicktime/SConscript b/source/blender/quicktime/SConscript index 7d726ed7c7a..1fc2bc96b21 100644 --- a/source/blender/quicktime/SConscript +++ b/source/blender/quicktime/SConscript @@ -28,12 +28,8 @@ Import ('env') -if env['USE_QTKIT']: - source_files = ['apple/qtkit_import.m', +source_files = ['apple/qtkit_import.m', 'apple/qtkit_export.m'] -else: - source_files = ['apple/quicktime_import.c', - 'apple/quicktime_export.c'] incs = ['.', diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c deleted file mode 100644 index 67be8b169c6..00000000000 --- a/source/blender/quicktime/apple/quicktime_export.c +++ /dev/null @@ -1,927 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * - * The Original Code is written by Rob Haarsma (phase) - * - * Contributor(s): Stefan Gartner (sgefant) - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/quicktime/apple/quicktime_export.c - * \ingroup quicktime - * - * Code to create QuickTime Movies with Blender - */ - - -#ifdef WITH_QUICKTIME -#if defined(_WIN32) || defined(__APPLE__) -#ifndef USE_QTKIT - -#include "DNA_scene_types.h" -#include "DNA_windowmanager_types.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "BKE_context.h" -#include "BKE_global.h" -#include "BKE_main.h" -#include "BKE_report.h" -#include "BKE_scene.h" - -#include "BLI_blenlib.h" - -#include "BLI_sys_types.h" - -#include "IMB_imbuf.h" -#include "IMB_imbuf_types.h" - -#include "MEM_guardedalloc.h" - -#include "quicktime_import.h" -#include "quicktime_export.h" - -#ifdef _WIN32 -#include -#include -#include -#include -#include -#include - -#endif /* _WIN32 */ - -#ifdef __APPLE__ -/* evil */ -#ifndef __AIFF__ -#define __AIFF__ -#endif -#include -#include -#include /* open() */ -#include /* close() */ -#include /* file permissions */ -#endif /* __APPLE__ */ - -#define kMyCreatorType FOUR_CHAR_CODE('TVOD') -#define kTrackStart 0 -#define kMediaStart 0 - -static void QT_StartAddVideoSamplesToMedia(const Rect *trackFrame, int rectx, int recty, struct ReportList *reports); -static void QT_DoAddVideoSamplesToMedia(int frame, int *pixels, int rectx, int recty, struct ReportList *reports); -static void QT_EndAddVideoSamplesToMedia(void); -static void QT_CreateMyVideoTrack(int rectx, int recty, struct ReportList *reports); -static void QT_EndCreateMyVideoTrack(struct ReportList *reports); -static void check_renderbutton_framerate(struct RenderData *rd, struct ReportList *reports); -static int get_qtcodec_settings(struct RenderData *rd, struct ReportList *reports); - -typedef struct QuicktimeExport { - - FSSpec theSpec; - short resRefNum; - Str255 qtfilename; - - Media theMedia; - Movie theMovie; - Track theTrack; - - GWorldPtr theGWorld; - PixMapHandle thePixMap; - ImageDescription **anImageDescription; - - ImBuf *ibuf; /* imagedata for Quicktime's Gworld */ - ImBuf *ibuf2; /* copy of renderdata, to be Y-flipped */ - -} QuicktimeExport; - -typedef struct QuicktimeComponentData { - - ComponentInstance theComponent; - SCTemporalSettings gTemporalSettings; - SCSpatialSettings gSpatialSettings; - SCDataRateSettings aDataRateSetting; - TimeValue duration; - long kVideoTimeScale; - -} QuicktimeComponentData; - -static struct QuicktimeExport *qtexport; -static struct QuicktimeComponentData *qtdata; - -static int sframe; - -/* RNA functions */ - -static QuicktimeCodecTypeDesc qtVideoCodecList[] = { - {kRawCodecType, 1, "Uncompressed"}, - {kJPEGCodecType, 2, "JPEG"}, - {kMotionJPEGACodecType, 3, "M-JPEG A"}, - {kMotionJPEGBCodecType, 4, "M-JPEG B"}, - {kDVCPALCodecType, 5, "DV PAL"}, - {kDVCNTSCCodecType, 6, "DV/DVCPRO NTSC"}, - {kDVCPROHD720pCodecType, 7, "DVCPRO HD 720p"}, - {kDVCPROHD1080i50CodecType, 8, "DVCPRO HD 1080i50"}, - {kDVCPROHD1080i60CodecType, 9, "DVCPRO HD 1080i60"}, - {kMPEG4VisualCodecType, 10, "MPEG4"}, - {kH263CodecType, 11, "H.263"}, - {kH264CodecType, 12, "H.264"}, - {0, 0, NULL} -}; - -static int qtVideoCodecCount = 12; - -int quicktime_get_num_videocodecs() -{ - return qtVideoCodecCount; -} - -QuicktimeCodecTypeDesc *quicktime_get_videocodecType_desc(int indexValue) -{ - if ((indexValue >= 0) && (indexValue < qtVideoCodecCount)) - return &qtVideoCodecList[indexValue]; - else - return NULL; -} - -int quicktime_rnatmpvalue_from_videocodectype(int codecType) -{ - int i; - for (i = 0; i < qtVideoCodecCount; i++) { - if (qtVideoCodecList[i].codecType == codecType) - return qtVideoCodecList[i].rnatmpvalue; - } - - return 0; -} - -int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue) -{ - int i; - for (i = 0; i < qtVideoCodecCount; i++) { - if (qtVideoCodecList[i].rnatmpvalue == rnatmpvalue) - return qtVideoCodecList[i].codecType; - } - - return 0; -} - - - -static void CheckError(OSErr err, char *msg, ReportList *reports) -{ - if (err != noErr) { - BKE_reportf(reports, RPT_ERROR, "%s: %d", msg, err); - } -} - - -static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports) -{ - QTAtomContainer myContainer = NULL; - ComponentResult myErr = noErr; - Ptr myPtr; - long mySize = 0; - - CodecInfo ci; - - QuicktimeCodecData *qcd = rd->qtcodecdata; - - /* check if current scene already has qtcodec settings, and clear them */ - if (qcd) { - free_qtcodecdata(qcd); - } - else { - qcd = rd->qtcodecdata = MEM_callocN(sizeof(QuicktimeCodecData), "QuicktimeCodecData"); - } - - /* obtain all current codec settings */ - SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); - SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - - /* retreive codecdata from quicktime in a atomcontainer */ - myErr = SCGetSettingsAsAtomContainer(qtdata->theComponent, &myContainer); - if (myErr != noErr) { - BKE_report(reports, RPT_ERROR, "Quicktime: SCGetSettingsAsAtomContainer failed"); - goto bail; - } - - /* get the size of the atomcontainer */ - mySize = GetHandleSize((Handle)myContainer); - - /* lock and convert the atomcontainer to a *valid* pointer */ - QTLockContainer(myContainer); - myPtr = *(Handle)myContainer; - - /* copy the Quicktime data into the blender qtcodecdata struct */ - if (myPtr) { - qcd->cdParms = MEM_mallocN(mySize, "qt.cdParms"); - memcpy(qcd->cdParms, myPtr, mySize); - qcd->cdSize = mySize; - - GetCodecInfo(&ci, qtdata->gSpatialSettings.codecType, 0); - } - else { - BKE_report(reports, RPT_ERROR, "Quicktime: QT_SaveCodecSettingsToScene failed"); - } - - QTUnlockContainer(myContainer); - -bail: - if (myContainer != NULL) - QTDisposeAtomContainer(myContainer); - - return((OSErr)myErr); -} - - -static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports) -{ - Handle myHandle = NULL; - ComponentResult myErr = noErr; - - QuicktimeCodecData *qcd = rd->qtcodecdata; - - /* if there is codecdata in the blendfile, convert it to a Quicktime handle */ - if (qcd) { - myHandle = NewHandle(qcd->cdSize); - PtrToHand(qcd->cdParms, &myHandle, qcd->cdSize); - } - - /* restore codecsettings to the quicktime component */ - if (qcd->cdParms && qcd->cdSize) { - myErr = SCSetSettingsFromAtomContainer((GraphicsExportComponent)qtdata->theComponent, (QTAtomContainer)myHandle); - if (myErr != noErr) { - BKE_report(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed"); - goto bail; - } - - /* update runtime codecsettings for use with the codec dialog */ - SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); - SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - - - /* Fill the render QuicktimeCodecSettigns struct */ - rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality; - /* Do not override scene frame rate (qtdata->gTemporalSettings.framerate) */ - rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate; - - rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType; - rd->qtcodecsettings.codec = (int)qtdata->gSpatialSettings.codec; - rd->qtcodecsettings.colorDepth = qtdata->gSpatialSettings.depth; - rd->qtcodecsettings.codecSpatialQuality = (qtdata->gSpatialSettings.spatialQuality * 100) / codecLosslessQuality; - - rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate; - rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality; - rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality; - /* Frame duration is already known (qtdata->aDataRateSetting.frameDuration) */ - - } - else { - BKE_report(reports, RPT_ERROR, "Quicktime: QT_GetCodecSettingsFromScene failed"); - } -bail: - if (myHandle != NULL) - DisposeHandle(myHandle); - - return((OSErr)myErr); -} - - -static OSErr QT_AddUserDataTextToMovie(Movie theMovie, char *theText, OSType theType) -{ - UserData myUserData = NULL; - Handle myHandle = NULL; - long myLength = strlen(theText); - OSErr myErr = noErr; - - /* get the movie's user data list */ - myUserData = GetMovieUserData(theMovie); - if (myUserData == NULL) - return(paramErr); - - /* copy the specified text into a new handle */ - myHandle = NewHandleClear(myLength); - if (myHandle == NULL) - return(MemError()); - - BlockMoveData(theText, *myHandle, myLength); - - /* add the data to the movie's user data */ - myErr = AddUserDataText(myUserData, myHandle, theType, 1, (short)GetScriptManagerVariable(smRegionCode)); - - /* clean up */ - DisposeHandle(myHandle); - return(myErr); -} - - -static void QT_CreateMyVideoTrack(int rectx, int recty, ReportList *reports) -{ - OSErr err = noErr; - Rect trackFrame; -// MatrixRecord myMatrix; - - trackFrame.top = 0; - trackFrame.left = 0; - trackFrame.bottom = recty; - trackFrame.right = rectx; - - qtexport->theTrack = NewMovieTrack(qtexport->theMovie, - FixRatio(trackFrame.right, 1), - FixRatio(trackFrame.bottom, 1), - 0); - CheckError(GetMoviesError(), "NewMovieTrack error", reports); - - // SetIdentityMatrix(&myMatrix); - // ScaleMatrix(&myMatrix, fixed1, Long2Fix(-1), 0, 0); - // TranslateMatrix(&myMatrix, 0, Long2Fix(trackFrame.bottom)); - // SetMovieMatrix(qtexport->theMovie, &myMatrix); - - qtexport->theMedia = NewTrackMedia(qtexport->theTrack, - VideoMediaType, - qtdata->kVideoTimeScale, - nil, - 0); - CheckError(GetMoviesError(), "NewTrackMedia error", reports); - - err = BeginMediaEdits(qtexport->theMedia); - CheckError(err, "BeginMediaEdits error", reports); - - QT_StartAddVideoSamplesToMedia(&trackFrame, rectx, recty, reports); -} - - -static void QT_EndCreateMyVideoTrack(ReportList *reports) -{ - OSErr err = noErr; - - QT_EndAddVideoSamplesToMedia(); - - err = EndMediaEdits(qtexport->theMedia); - CheckError(err, "EndMediaEdits error", reports); - - err = InsertMediaIntoTrack(qtexport->theTrack, - kTrackStart, /* track start time */ - kMediaStart, /* media start time */ - GetMediaDuration(qtexport->theMedia), - fixed1); - CheckError(err, "InsertMediaIntoTrack error", reports); -} - - -static void QT_StartAddVideoSamplesToMedia(const Rect *trackFrame, int rectx, int recty, ReportList *reports) -{ - SCTemporalSettings gTemporalSettings; - OSErr err = noErr; - - qtexport->ibuf = IMB_allocImBuf(rectx, recty, 32, IB_rect); - qtexport->ibuf2 = IMB_allocImBuf(rectx, recty, 32, IB_rect); - - err = NewGWorldFromPtr(&qtexport->theGWorld, - k32ARGBPixelFormat, - trackFrame, - NULL, NULL, 0, - (Ptr)qtexport->ibuf->rect, - rectx * 4); - CheckError(err, "NewGWorldFromPtr error", reports); - - qtexport->thePixMap = GetGWorldPixMap(qtexport->theGWorld); - LockPixels(qtexport->thePixMap); - - SCDefaultPixMapSettings(qtdata->theComponent, qtexport->thePixMap, true); - - /* workaround for crash with H.264, which requires an upgrade to - * the new callback based api for proper encoding, but that's not - * really compatible with rendering out frames sequentially */ - gTemporalSettings = qtdata->gTemporalSettings; - if (qtdata->gSpatialSettings.codecType == kH264CodecType) { - if (gTemporalSettings.temporalQuality != codecMinQuality) { - BKE_report(reports, RPT_WARNING, "Only minimum quality compression supported for Quicktime H.264"); - gTemporalSettings.temporalQuality = codecMinQuality; - } - } - - SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &gTemporalSettings); - SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); - SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - - err = SCCompressSequenceBegin(qtdata->theComponent, qtexport->thePixMap, NULL, &qtexport->anImageDescription); - CheckError(err, "SCCompressSequenceBegin error", reports); -} - - -static void QT_DoAddVideoSamplesToMedia(int frame, int *pixels, int rectx, int recty, ReportList *reports) -{ - OSErr err = noErr; - Rect imageRect; - - int index; - int boxsize; - unsigned char *from, *to; - - short syncFlag; - long dataSize; - Handle compressedData; - Ptr myPtr; - - - /* copy and flip renderdata */ - memcpy(qtexport->ibuf2->rect, pixels, 4 * rectx * recty); - IMB_flipy(qtexport->ibuf2); - - /* get pointers to parse bitmapdata */ - myPtr = GetPixBaseAddr(qtexport->thePixMap); - imageRect = (**qtexport->thePixMap).bounds; - - from = (unsigned char *) qtexport->ibuf2->rect; - to = (unsigned char *) myPtr; - - /* parse RGBA bitmap into Quicktime's ARGB GWorld */ - boxsize = rectx * recty; - for (index = 0; index < boxsize; index++) { - to[0] = from[3]; - to[1] = from[0]; - to[2] = from[1]; - to[3] = from[2]; - to += 4, from += 4; - } - - err = SCCompressSequenceFrame(qtdata->theComponent, - qtexport->thePixMap, - &imageRect, - &compressedData, - &dataSize, - &syncFlag); - CheckError(err, "SCCompressSequenceFrame error", reports); - - err = AddMediaSample(qtexport->theMedia, - compressedData, - 0, - dataSize, - qtdata->duration, - (SampleDescriptionHandle)qtexport->anImageDescription, - 1, - syncFlag, - NULL); - CheckError(err, "AddMediaSample error", reports); -} - - -static void QT_EndAddVideoSamplesToMedia(void) -{ - SCCompressSequenceEnd(qtdata->theComponent); - - UnlockPixels(qtexport->thePixMap); - if (qtexport->theGWorld) - DisposeGWorld(qtexport->theGWorld); - - if (qtexport->ibuf) - IMB_freeImBuf(qtexport->ibuf); - - if (qtexport->ibuf2) - IMB_freeImBuf(qtexport->ibuf2); -} - - -void filepath_qt(char *string, RenderData *rd) -{ - char txt[64]; - - if (string == 0) return; - - strcpy(string, rd->pic); - BLI_path_abs(string, G.main->name); - - BLI_make_existing_file(string); - - if (BLI_strcasecmp(string + strlen(string) - 4, ".mov")) { - sprintf(txt, "%04d-%04d.mov", (rd->sfra), (rd->efra)); - strcat(string, txt); - } -} - - -int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, ReportList *reports) -{ - OSErr err = noErr; - - char name[2048]; - char theFullPath[255]; - -#ifdef __APPLE__ - int myFile; - FSRef myRef; -#else - char *qtname; -#endif - int success = 1; - - if (qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport"); - - if (qtdata) { - if (qtdata->theComponent) CloseComponent(qtdata->theComponent); - free_qtcomponentdata(); - } - - qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeCodecDataExt"); - - if (rd->qtcodecdata == NULL || rd->qtcodecdata->cdParms == NULL) { - get_qtcodec_settings(rd, reports); - } - else { - qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); - - QT_GetCodecSettingsFromScene(rd, reports); - check_renderbutton_framerate(rd, reports); - } - - sframe = (rd->sfra); - - filepath_qt(name, rd); - -#ifdef __APPLE__ - EnterMoviesOnThread(0); - strcpy(theFullPath, name); - - /* hack: create an empty file to make FSPathMakeRef() happy */ - myFile = open(theFullPath, O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRUSR | S_IWUSR); - if (myFile < 0) { - BKE_report(reports, RPT_ERROR, "Error while creating movie file!"); - /* do something? */ - } - close(myFile); - err = FSPathMakeRef((const UInt8 *)theFullPath, &myRef, 0); - CheckError(err, "FsPathMakeRef error", reports); - err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &qtexport->theSpec, NULL); - CheckError(err, "FsGetCatalogInfoRef error", reports); -#endif -#ifdef _WIN32 - qtname = get_valid_qtname(name); - strcpy(theFullPath, qtname); - strcpy(name, qtname); - MEM_freeN(qtname); - - CopyCStringToPascal(theFullPath, qtexport->qtfilename); - err = FSMakeFSSpec(0, 0L, qtexport->qtfilename, &qtexport->theSpec); -#endif - - err = CreateMovieFile(&qtexport->theSpec, - kMyCreatorType, - smCurrentScript, - createMovieFileDeleteCurFile | createMovieFileDontCreateResFile, - &qtexport->resRefNum, - &qtexport->theMovie); - CheckError(err, "CreateMovieFile error", reports); - - if (err != noErr) { - BKE_reportf(reports, RPT_ERROR, "Unable to create Quicktime movie: %s", name); - success = 0; -#ifdef __APPLE__ - ExitMoviesOnThread(); -#endif - } - else { - /* printf("Created QuickTime movie: %s\n", name); */ - - QT_CreateMyVideoTrack(rectx, recty, reports); - } - - return success; -} - - -int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty, ReportList *reports) -{ - QT_DoAddVideoSamplesToMedia(frame, pixels, rectx, recty, reports); - return 1; -} - - -void end_qt(void) -{ - OSErr err = noErr; - short resId = movieInDataForkResID; - - if (qtexport->theMovie) { - QT_EndCreateMyVideoTrack(NULL); - - err = AddMovieResource(qtexport->theMovie, qtexport->resRefNum, &resId, qtexport->qtfilename); - CheckError(err, "AddMovieResource error", NULL); - - err = QT_AddUserDataTextToMovie(qtexport->theMovie, "Made with Blender", kUserDataTextInformation); - CheckError(err, "AddUserDataTextToMovie error", NULL); - - err = UpdateMovieResource(qtexport->theMovie, qtexport->resRefNum, resId, qtexport->qtfilename); - CheckError(err, "UpdateMovieResource error", NULL); - - if (qtexport->resRefNum) CloseMovieFile(qtexport->resRefNum); - - DisposeMovie(qtexport->theMovie); - - /* printf("Finished QuickTime movie.\n"); */ - } - -#ifdef __APPLE__ - ExitMoviesOnThread(); -#endif - - if (qtexport) { - MEM_freeN(qtexport); - qtexport = NULL; - } -} - - -void free_qtcomponentdata(void) -{ - if (qtdata) { - if (qtdata->theComponent) CloseComponent(qtdata->theComponent); - MEM_freeN(qtdata); - qtdata = NULL; - } -} - - -static void check_renderbutton_framerate(RenderData *rd, ReportList *reports) -{ - /* to keep float framerates consistent between the codec dialog and frs/sec button. */ - OSErr err; - - err = SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - CheckError(err, "SCGetInfo fr error", reports); - - if ( (rd->frs_sec == 24 || rd->frs_sec == 30 || rd->frs_sec == 60) && - (qtdata->gTemporalSettings.frameRate == 1571553 || - qtdata->gTemporalSettings.frameRate == 1964113 || - qtdata->gTemporalSettings.frameRate == 3928227)) - { - /* do nothing */ - } - else { - if (rd->frs_sec_base > 0) - qtdata->gTemporalSettings.frameRate = - ((float)(rd->frs_sec << 16) / rd->frs_sec_base); - } - - err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - CheckError(err, "SCSetInfo error", reports); - - if (qtdata->gTemporalSettings.frameRate == 1571553) { /* 23.98 fps */ - qtdata->kVideoTimeScale = 24000; - qtdata->duration = 1001; - } - else if (qtdata->gTemporalSettings.frameRate == 1964113) { /* 29.97 fps */ - qtdata->kVideoTimeScale = 30000; - qtdata->duration = 1001; - } - else if (qtdata->gTemporalSettings.frameRate == 3928227) { /* 59.94 fps */ - qtdata->kVideoTimeScale = 60000; - qtdata->duration = 1001; - } - else { - qtdata->kVideoTimeScale = (qtdata->gTemporalSettings.frameRate >> 16) * 100; - qtdata->duration = 100; - } -} - -void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf) -{ - if (imf->imtype == R_IMF_IMTYPE_QUICKTIME) { - if ((rd->qtcodecsettings.codecType == 0) || - (rd->qtcodecsettings.codecSpatialQuality < 0) || - (rd->qtcodecsettings.codecSpatialQuality > 100)) - { - rd->qtcodecsettings.codecType = kJPEGCodecType; - rd->qtcodecsettings.codec = (int)anyCodec; - rd->qtcodecsettings.codecSpatialQuality = (codecHighQuality * 100) / codecLosslessQuality; - rd->qtcodecsettings.codecTemporalQuality = (codecHighQuality * 100) / codecLosslessQuality; - rd->qtcodecsettings.keyFrameRate = 25; - rd->qtcodecsettings.bitRate = 5000000; /* 5 Mbps */ - } - } -} - -int get_qtcodec_settings(RenderData *rd, ReportList *reports) -{ - OSErr err = noErr; - /* erase any existing codecsetting */ - if (qtdata) { - if (qtdata->theComponent) CloseComponent(qtdata->theComponent); - free_qtcomponentdata(); - } - - /* allocate new */ - qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeComponentData"); - qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); - - /* get previous selected codecsetting, from qtatom or detailed settings */ - if (rd->qtcodecdata && rd->qtcodecdata->cdParms) { - QT_GetCodecSettingsFromScene(rd, reports); - } - else { - SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); - SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - - qtdata->gSpatialSettings.codecType = rd->qtcodecsettings.codecType; - qtdata->gSpatialSettings.codec = (CodecComponent)rd->qtcodecsettings.codec; - qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) / 100; - qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) / 100; - qtdata->gTemporalSettings.keyFrameRate = rd->qtcodecsettings.keyFrameRate; - qtdata->aDataRateSetting.dataRate = rd->qtcodecsettings.bitRate; - qtdata->gSpatialSettings.depth = rd->qtcodecsettings.colorDepth; - qtdata->aDataRateSetting.minSpatialQuality = (rd->qtcodecsettings.minSpatialQuality * codecLosslessQuality) / 100; - qtdata->aDataRateSetting.minTemporalQuality = (rd->qtcodecsettings.minTemporalQuality * codecLosslessQuality) / 100; - - qtdata->aDataRateSetting.frameDuration = rd->frs_sec; - SetMovieTimeScale(qtexport->theMovie, rd->frs_sec_base * 1000); - - - err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - CheckError(err, "SCSetInfo1 error", reports); - err = SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); - CheckError(err, "SCSetInfo2 error", reports); - err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - CheckError(err, "SCSetInfo3 error", reports); - } - - check_renderbutton_framerate(rd, reports); - - return err; -} - -static int request_qtcodec_settings_exec(bContext *C, wmOperator *op) -{ - OSErr err = noErr; - Scene *scene = CTX_data_scene(C); - RenderData *rd = &scene->r; - - /* erase any existing codecsetting */ - if (qtdata) { - if (qtdata->theComponent) CloseComponent(qtdata->theComponent); - free_qtcomponentdata(); - } - - /* allocate new */ - qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeComponentData"); - qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); - - /* get previous selected codecsetting, from qtatom or detailed settings */ - if (rd->qtcodecdata && rd->qtcodecdata->cdParms) { - QT_GetCodecSettingsFromScene(rd, op->reports); - } - else { - SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); - SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - - qtdata->gSpatialSettings.codecType = rd->qtcodecsettings.codecType; - qtdata->gSpatialSettings.codec = (CodecComponent)rd->qtcodecsettings.codec; - qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) / 100; - qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) / 100; - qtdata->gTemporalSettings.keyFrameRate = rd->qtcodecsettings.keyFrameRate; - qtdata->gTemporalSettings.frameRate = ((float)(rd->frs_sec << 16) / rd->frs_sec_base); - qtdata->aDataRateSetting.dataRate = rd->qtcodecsettings.bitRate; - qtdata->gSpatialSettings.depth = rd->qtcodecsettings.colorDepth; - qtdata->aDataRateSetting.minSpatialQuality = (rd->qtcodecsettings.minSpatialQuality * codecLosslessQuality) / 100; - qtdata->aDataRateSetting.minTemporalQuality = (rd->qtcodecsettings.minTemporalQuality * codecLosslessQuality) / 100; - - qtdata->aDataRateSetting.frameDuration = rd->frs_sec; - - err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - CheckError(err, "SCSetInfo1 error", op->reports); - err = SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); - CheckError(err, "SCSetInfo2 error", op->reports); - err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - CheckError(err, "SCSetInfo3 error", op->reports); - } - /* put up the dialog box - it needs to be called from the main thread */ - err = SCRequestSequenceSettings(qtdata->theComponent); - - if (err == scUserCancelled) { - return OPERATOR_FINISHED; - } - - /* update runtime codecsettings for use with the codec dialog */ - SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); - SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - - - /* Fill the render QuicktimeCodecSettings struct */ - rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality; - /* Do not override scene frame rate (qtdata->gTemporalSettings.framerate) */ - rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate; - - rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType; - rd->qtcodecsettings.codec = (int)qtdata->gSpatialSettings.codec; - rd->qtcodecsettings.colorDepth = qtdata->gSpatialSettings.depth; - rd->qtcodecsettings.codecSpatialQuality = (qtdata->gSpatialSettings.spatialQuality * 100) / codecLosslessQuality; - - rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate; - rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality; - rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality; - /* Frame duration is already known (qtdata->aDataRateSetting.frameDuration) */ - - QT_SaveCodecSettingsToScene(rd, op->reports); - - /* framerate jugglin' */ - if (qtdata->gTemporalSettings.frameRate == 1571553) { /* 23.98 fps */ - qtdata->kVideoTimeScale = 24000; - qtdata->duration = 1001; - - rd->frs_sec = 24; - rd->frs_sec_base = 1.001; - } - else if (qtdata->gTemporalSettings.frameRate == 1964113) { /* 29.97 fps */ - qtdata->kVideoTimeScale = 30000; - qtdata->duration = 1001; - - rd->frs_sec = 30; - rd->frs_sec_base = 1.001; - } - else if (qtdata->gTemporalSettings.frameRate == 3928227) { /* 59.94 fps */ - qtdata->kVideoTimeScale = 60000; - qtdata->duration = 1001; - - rd->frs_sec = 60; - rd->frs_sec_base = 1.001; - } - else { - double fps = qtdata->gTemporalSettings.frameRate; - - qtdata->kVideoTimeScale = 60000; - qtdata->duration = qtdata->kVideoTimeScale / (qtdata->gTemporalSettings.frameRate / 65536); - - if ((qtdata->gTemporalSettings.frameRate & 0xffff) == 0) { - rd->frs_sec = fps / 65536; - rd->frs_sec_base = 1.0; - } - else { - /* we do our very best... */ - rd->frs_sec = fps / 65536; - rd->frs_sec_base = 1.0; - } - } - - return OPERATOR_FINISHED; -} - -static int ED_operator_setqtcodec(bContext *C) -{ - return G.have_quicktime != FALSE; -} - -#if defined(__APPLE__) -/* Need to set up a Cocoa NSAutoReleasePool to avoid memory leak - * And it must be done in an objC file, so use a GHOST_SystemCocoa.mm function for that */ -extern int cocoa_request_qtcodec_settings_exec(bContext *C, wmOperator *op); - -int fromcocoa_request_qtcodec_settings(bContext *C, wmOperator *op) -{ - return request_qtcodec_settings_exec(C, op); -} -#endif - - -void SCENE_OT_render_data_set_quicktime_codec(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Change Codec"; - ot->description = "Change Quicktime codec Settings"; - ot->idname = "SCENE_OT_render_data_set_quicktime_codec"; - - /* api callbacks */ -#if defined(__APPLE__) - ot->exec = cocoa_request_qtcodec_settings_exec; -#else - ot->exec = request_qtcodec_settings_exec; -#endif - ot->poll = ED_operator_setqtcodec; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - -#endif /* USE_QTKIT */ -#endif /* _WIN32 || __APPLE__ */ -#endif /* WITH_QUICKTIME */ - diff --git a/source/blender/quicktime/apple/quicktime_import.c b/source/blender/quicktime/apple/quicktime_import.c deleted file mode 100644 index 511b62d856a..00000000000 --- a/source/blender/quicktime/apple/quicktime_import.c +++ /dev/null @@ -1,833 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * - * The Original Code is written by Rob Haarsma (phase) - * - * Contributor(s): Stefan Gartner (sgefant) - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/quicktime/apple/quicktime_import.c - * \ingroup quicktime - * - * Code to use Quicktime to load images/movies as texture. - */ - -#ifdef WITH_QUICKTIME - -#if defined(_WIN32) || defined(__APPLE__) -#ifndef USE_QTKIT - -#include "MEM_guardedalloc.h" -#include "IMB_anim.h" -#include "BLI_sys_types.h" -#include "BKE_global.h" -#include "BLI_dynstr.h" -#include "BLI_path_util.h" - -#ifdef __APPLE__ -#include -#include -#endif - -#ifdef _WIN32 -#include -#include -#include -#include -#include -#endif /* _WIN32 */ - - -#include "quicktime_import.h" -#include "quicktime_export.h" - -#define RECT_WIDTH(r) (r.right - r.left) -#define RECT_HEIGHT(r) (r.bottom - r.top) - -#define QTIME_DEBUG 0 - -typedef struct _QuicktimeMovie { - - GWorldPtr offscreenGWorld; - PixMapHandle offscreenPixMap; - Movie movie; - Rect movieBounds; - short movieRefNum; - short movieResId; - int movWidth, movHeight; - - - int framecount; - - - ImBuf *ibuf; - - - TimeValue *frameIndex; - Media theMedia; - Track theTrack; - long trackIndex; - short depth; - - int have_gw; /* ugly */ -} QuicktimeMovie; - - - -void quicktime_init(void) -{ - OSErr nerr; -#ifdef _WIN32 - QTLoadLibrary("QTCF.dll"); - nerr = InitializeQTML(0); - if (nerr != noErr) { - G.have_quicktime = FALSE; - } - else - G.have_quicktime = TRUE; -#endif /* _WIN32 */ - - /* Initialize QuickTime */ -#if defined(_WIN32) || defined(__APPLE__) - nerr = EnterMovies(); - if (nerr != noErr) - G.have_quicktime = FALSE; - else -#endif /* _WIN32 || __APPLE__ */ -#ifdef __linux__ - /* inititalize quicktime codec registry */ - lqt_registry_init(); -#endif - G.have_quicktime = TRUE; -} - - -void quicktime_exit(void) -{ -#if defined(_WIN32) || defined(__APPLE__) -#ifdef WITH_QUICKTIME - if (G.have_quicktime) { - free_qtcomponentdata(); - ExitMovies(); -#ifdef _WIN32 - TerminateQTML(); -#endif /* _WIN32 */ - } -#endif /* WITH_QUICKTIME */ -#endif /* _WIN32 || __APPLE__ */ -} - - -#ifdef _WIN32 -char *get_valid_qtname(char *name) -{ - TCHAR Buffer[MAX_PATH]; - DWORD dwRet; - char *qtname; - DynStr *ds = BLI_dynstr_new(); - - dwRet = GetCurrentDirectory(MAX_PATH, Buffer); - - if (name[1] != ':') { - char drive[2]; - - if (name[0] == '/' || name[0] == '\\') { - drive[0] = Buffer[0]; - drive[1] = '\0'; - - BLI_dynstr_append(ds, drive); - BLI_dynstr_append(ds, ":"); - BLI_dynstr_append(ds, name); - } - else { - BLI_dynstr_append(ds, Buffer); - BLI_dynstr_append(ds, "/"); - BLI_dynstr_append(ds, name); - } - } - else { - BLI_dynstr_append(ds, name); - } - - qtname = BLI_dynstr_get_cstring(ds); - BLI_dynstr_free(ds); - - return qtname; -} -#endif /* _WIN32 */ - - -int anim_is_quicktime(const char *name) -{ - FSSpec theFSSpec; - char theFullPath[255]; - - Boolean isMovieFile = false; - AliasHandle myAlias = NULL; - Component myImporter = NULL; -#ifdef __APPLE__ - FInfo myFinderInfo; - FSRef myRef; -#else - char *qtname; - Str255 dst; -#endif - OSErr err = noErr; - - // don't let quicktime movie import handle these - if (BLI_testextensie(name, ".swf") || - BLI_testextensie(name, ".txt") || - BLI_testextensie(name, ".mpg") || - BLI_testextensie(name, ".avi") || /* wouldn't be appropriate ;) */ - BLI_testextensie(name, ".tga") || - BLI_testextensie(name, ".png") || - BLI_testextensie(name, ".bmp") || - BLI_testextensie(name, ".jpg") || - BLI_testextensie(name, ".tif") || - BLI_testextensie(name, ".exr") || - BLI_testextensie(name, ".wav") || - BLI_testextensie(name, ".zip") || - BLI_testextensie(name, ".mp3")) - { - return 0; - } - - if (QTIME_DEBUG) printf("qt: checking as movie: %s\n", name); - -#ifdef __APPLE__ - strcpy(theFullPath, name); - - err = FSPathMakeRef(theFullPath, &myRef, 0); - err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL); -#else - qtname = get_valid_qtname(name); - strcpy(theFullPath, qtname); - MEM_freeN(qtname); - - CopyCStringToPascal(theFullPath, dst); - err = FSMakeFSSpec(0, 0L, dst, &theFSSpec); -#endif - -#ifdef __APPLE__ - // see whether the file type is MovieFileType; to do this, get the Finder information - err = FSpGetFInfo(&theFSSpec, &myFinderInfo); - if (err == noErr) { - if (myFinderInfo.fdType == kQTFileTypeMovie) { - return(true); - } - } -#endif - -/* on mac os x this results in using quicktime for other formats as well - * not sure whether this is intended - */ - // if it isn't a movie file, see whether the file can be imported as a movie - err = QTNewAlias(&theFSSpec, &myAlias, true); - if (err == noErr) { - if (myAlias != NULL) { - err = GetMovieImporterForDataRef(rAliasType, (Handle)myAlias, kGetMovieImporterDontConsiderGraphicsImporters, &myImporter); - DisposeHandle((Handle)myAlias); - } - } - - if ((err == noErr) && (myImporter != NULL)) { /* this file is a movie file */ - isMovieFile = true; - } - - return(isMovieFile); -} - - -void free_anim_quicktime(struct anim *anim) -{ - if (anim == NULL) return; - if (anim->qtime == NULL) return; - - UnlockPixels(anim->qtime->offscreenPixMap); - - if (anim->qtime->have_gw) - DisposeGWorld(anim->qtime->offscreenGWorld); - if (anim->qtime->ibuf) - IMB_freeImBuf(anim->qtime->ibuf); - - DisposeMovie(anim->qtime->movie); - CloseMovieFile(anim->qtime->movieRefNum); - - if (anim->qtime->frameIndex) MEM_freeN(anim->qtime->frameIndex); - if (anim->qtime) MEM_freeN(anim->qtime); - - anim->qtime = NULL; - - anim->duration = 0; -} - - -static OSErr QT_get_frameIndexes(struct anim *anim) -{ - int i; - OSErr anErr = noErr; - OSType media = VideoMediaType; - TimeValue nextTime = 0; - TimeValue startPoint; - TimeValue tmpstartPoint; - long sampleCount = 0; - - startPoint = -1; - - GetMovieNextInterestingTime(anim->qtime->movie, nextTimeMediaSample + nextTimeEdgeOK, (TimeValue)1, &media, 0, - 1, &startPoint, NULL); - - tmpstartPoint = startPoint; - - anim->qtime->framecount = 0; - - sampleCount = GetMediaSampleCount(anim->qtime->theMedia); - anErr = GetMoviesError(); - if (anErr != noErr) return anErr; - - anim->qtime->framecount = sampleCount; - - anim->qtime->frameIndex = (TimeValue *) MEM_callocN(sizeof(TimeValue) * anim->qtime->framecount, "qtframeindex"); - - //rewind - GetMovieNextInterestingTime(anim->qtime->movie, nextTimeMediaSample, 1, &media, (TimeValue)1, 0, &tmpstartPoint, NULL); - - anim->qtime->frameIndex[0] = startPoint; - for (i = 1; i < anim->qtime->framecount; i++) { - nextTime = 0; - GetMovieNextInterestingTime(anim->qtime->movie, nextTimeMediaSample, 1, &media, startPoint, 0, &nextTime, NULL); - startPoint = nextTime; - anim->qtime->frameIndex[i] = nextTime; - } - - anErr = GetMoviesError(); - return anErr; -} - - -ImBuf *qtime_fetchibuf(struct anim *anim, int position) -{ - PixMapHandle myPixMap = NULL; - Ptr myPtr; - - register int index; - register int boxsize; - - register uint32_t *readPos; - register uint32_t *changePos; - - ImBuf *ibuf = NULL; - unsigned int *rect; -#ifdef __APPLE__ - unsigned char *from, *to; -#endif -#ifdef _WIN32 - unsigned char *crect; -#endif - - if (anim == NULL) { - return (NULL); - } - - ibuf = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect); - rect = ibuf->rect; - - SetMovieTimeValue(anim->qtime->movie, anim->qtime->frameIndex[position]); - UpdateMovie(anim->qtime->movie); - MoviesTask(anim->qtime->movie, 0); - - - myPixMap = GetGWorldPixMap(anim->qtime->offscreenGWorld); - myPtr = GetPixBaseAddr(myPixMap); - - if (myPtr == NULL) { - printf("Error reading frame from Quicktime"); - IMB_freeImBuf(ibuf); - return NULL; - } - - boxsize = anim->x * anim->y; - readPos = (uint32_t *) myPtr; - changePos = (uint32_t *) rect; //textureIMBuf *THE* data pointerrr - -#ifdef __APPLE__ - // Swap alpha byte to the end, so ARGB become RGBA; - from = (unsigned char *)readPos; - to = (unsigned char *)changePos; - - for (index = 0; index < boxsize; index++, from += 4, to += 4) { - to[3] = from[0]; - to[0] = from[1]; - to[1] = from[2]; - to[2] = from[3]; - } -#endif - -#ifdef _WIN32 - for (index = 0; index < boxsize; index++, changePos++, readPos++) - *(changePos) = *(readPos); - - if (anim->qtime->depth < 32) { - //add alpha to ibuf - boxsize = anim->x * anim->y * 4; - crect = (unsigned char *) rect; - for (index = 0; index < boxsize; index += 4, crect += 4) { - crect[3] = 0xFF; - } - } -#endif - - IMB_flipy(ibuf); - return ibuf; -} - - -// following two functions only here to get movie pixeldepth - -static int GetFirstVideoMedia(struct anim *anim) -{ - long numTracks; - OSType mediaType; - - numTracks = GetMovieTrackCount(anim->qtime->movie); - - for (anim->qtime->trackIndex = 1; anim->qtime->trackIndex <= numTracks; (anim->qtime->trackIndex)++) { - anim->qtime->theTrack = GetMovieIndTrack(anim->qtime->movie, anim->qtime->trackIndex); - - if (anim->qtime->theTrack) - anim->qtime->theMedia = GetTrackMedia(anim->qtime->theTrack); - - if (anim->qtime->theMedia) - GetMediaHandlerDescription(anim->qtime->theMedia, &mediaType, nil, nil); - if (mediaType == VideoMediaType) return 1; - } - - anim->qtime->trackIndex = 0; // trackIndex can't be 0 - return 0; // went through all tracks and no video -} - -static short GetFirstVideoTrackPixelDepth(struct anim *anim) -{ - SampleDescriptionHandle imageDescH = (SampleDescriptionHandle)NewHandle(sizeof(Handle)); -// long trackIndex = 0; /*unused*/ - - if (!GetFirstVideoMedia(anim)) - return -1; - - if (!anim->qtime->trackIndex || !anim->qtime->theMedia) return -1; // we need both - GetMediaSampleDescription(anim->qtime->theMedia, anim->qtime->trackIndex, imageDescH); - - return (*(ImageDescriptionHandle)imageDescH)->depth; -} - - -int startquicktime(struct anim *anim) -{ - FSSpec theFSSpec; - - OSErr err = noErr; - char theFullPath[255]; -#ifdef __APPLE__ - FSRef myRef; -#else - char *qtname; - Str255 dst; -#endif - short depth = 0; - - anim->qtime = MEM_callocN(sizeof(QuicktimeMovie), "animqt"); - anim->qtime->have_gw = FALSE; - - if (anim->qtime == NULL) { - if (QTIME_DEBUG) printf("Can't alloc qtime: %s\n", anim->name); - return -1; - } - - if (QTIME_DEBUG) printf("qt: attempting to load as movie %s\n", anim->name); - -#ifdef __APPLE__ - strcpy(theFullPath, anim->name); - - err = FSPathMakeRef(theFullPath, &myRef, 0); - err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL); -#else - qtname = get_valid_qtname(anim->name); - strcpy(theFullPath, qtname); - MEM_freeN(qtname); - - CopyCStringToPascal(theFullPath, dst); - FSMakeFSSpec(0, 0L, dst, &theFSSpec); -#endif - - err = OpenMovieFile(&theFSSpec, &anim->qtime->movieRefNum, fsRdPerm); - - if (err == noErr) { - if (QTIME_DEBUG) printf("qt: movie opened\n"); - err = NewMovieFromFile(&anim->qtime->movie, - anim->qtime->movieRefNum, - &anim->qtime->movieResId, NULL, newMovieActive, NULL); - } - - if (err) { - if (QTIME_DEBUG) printf("qt: bad movie %s\n", anim->name); - if (anim->qtime->movie) { - DisposeMovie(anim->qtime->movie); - MEM_freeN(anim->qtime); - if (QTIME_DEBUG) printf("qt: can't load %s\n", anim->name); - return -1; - } - } - - GetMovieBox(anim->qtime->movie, &anim->qtime->movieBounds); - anim->x = anim->qtime->movWidth = RECT_WIDTH(anim->qtime->movieBounds); - anim->y = anim->qtime->movHeight = RECT_HEIGHT(anim->qtime->movieBounds); - if (QTIME_DEBUG) printf("qt: got bounds %s\n", anim->name); - - if (anim->x == 0 && anim->y == 0) { - if (QTIME_DEBUG) printf("qt: error, no dimensions\n"); - free_anim_quicktime(anim); - return -1; - } - - anim->qtime->ibuf = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect); - -#ifdef _WIN32 - err = NewGWorldFromPtr(&anim->qtime->offscreenGWorld, - k32RGBAPixelFormat, - &anim->qtime->movieBounds, - NULL, NULL, 0, - (unsigned char *)anim->qtime->ibuf->rect, - anim->x * 4); -#else - err = NewGWorldFromPtr(&anim->qtime->offscreenGWorld, - k32ARGBPixelFormat, - &anim->qtime->movieBounds, - NULL, NULL, 0, - (unsigned char *)anim->qtime->ibuf->rect, - anim->x * 4); -#endif /* _WIN32 */ - - if (err == noErr) { - anim->qtime->have_gw = TRUE; - - SetMovieGWorld(anim->qtime->movie, - anim->qtime->offscreenGWorld, - GetGWorldDevice(anim->qtime->offscreenGWorld)); - SetMoviePlayHints(anim->qtime->movie, hintsHighQuality, hintsHighQuality); - - // sets Media and Track! - depth = GetFirstVideoTrackPixelDepth(anim); - - QT_get_frameIndexes(anim); - } - - anim->qtime->offscreenPixMap = GetGWorldPixMap(anim->qtime->offscreenGWorld); - LockPixels(anim->qtime->offscreenPixMap); - - //fill blender's anim struct - anim->qtime->depth = depth; - - anim->duration = anim->qtime->framecount; - anim->params = 0; - - anim->interlacing = 0; - anim->orientation = 0; - anim->framesize = anim->x * anim->y * 4; - - anim->curposition = 0; - - if (QTIME_DEBUG) printf("qt: load %s %dx%dx%d frames %d\n", anim->name, anim->qtime->movWidth, - anim->qtime->movHeight, anim->qtime->depth, anim->qtime->framecount); - - return 0; -} - -int imb_is_a_quicktime(char *name) -{ - GraphicsImportComponent theImporter = NULL; - - FSSpec theFSSpec; -#ifdef _WIN32 - Str255 dst; /*unused*/ -#endif - char theFullPath[255]; - -// Boolean isMovieFile = false; /*unused*/ -// AliasHandle myAlias = NULL; /*unused*/ -// Component myImporter = NULL; /*unused*/ -#ifdef __APPLE__ -// FInfo myFinderInfo; /*unused*/ - FSRef myRef; -#endif - OSErr err = noErr; - - if (!G.have_quicktime) return 0; - - if (QTIME_DEBUG) printf("qt: checking as image %s\n", name); - - // don't let quicktime image import handle these - if (BLI_testextensie(name, ".swf") || - BLI_testextensie(name, ".txt") || - BLI_testextensie(name, ".mpg") || - BLI_testextensie(name, ".wav") || - BLI_testextensie(name, ".mov") || // not as image, doesn't work - BLI_testextensie(name, ".avi") || - BLI_testextensie(name, ".mp3")) - { - return 0; - } - - strcpy(theFullPath, name); -#ifdef __APPLE__ - err = FSPathMakeRef(theFullPath, &myRef, 0); - err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL); -#else - CopyCStringToPascal(theFullPath, dst); - err = FSMakeFSSpec(0, 0L, dst, &theFSSpec); -#endif - - GetGraphicsImporterForFile(&theFSSpec, &theImporter); - - if (theImporter != NULL) { - if (QTIME_DEBUG) printf("qt: %s valid\n", name); - CloseComponent(theImporter); - return 1; - } - - return 0; -} - -ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags) -{ - Rect myRect; - OSErr err = noErr; - GraphicsImportComponent gImporter = NULL; - - ImageDescriptionHandle desc; - - ComponentInstance dataHandler; - PointerDataRef dataref; - - int x, y, depth; - int have_gw = FALSE; - ImBuf *ibuf = NULL; -// ImBuf *imbuf = NULL; /*unused*/ - GWorldPtr offGWorld; - PixMapHandle myPixMap = NULL; - -#ifdef __APPLE__ - Ptr myPtr; - - register int index; - register int boxsize; - - register uint32_t *readPos; - register uint32_t *changePos; - - ImBuf *wbuf = NULL; - unsigned int *rect; - unsigned char *from, *to; -#endif - - if (mem == NULL || !G.have_quicktime) - goto bail; - - if (QTIME_DEBUG) printf("qt: attempt to load mem as image\n"); - - dataref = (PointerDataRef)NewHandle(sizeof(PointerDataRefRecord)); - (**dataref).data = mem; - (**dataref).dataLength = size; - - err = OpenADataHandler((Handle)dataref, - PointerDataHandlerSubType, - nil, - (OSType)0, - nil, - kDataHCanRead, - &dataHandler); - if (err != noErr) { - if (QTIME_DEBUG) printf("no datahandler\n"); - goto bail; - } - - err = GetGraphicsImporterForDataRef((Handle)dataref, PointerDataHandlerSubType, &gImporter); - if (err != noErr) { - if (QTIME_DEBUG) printf("no graphimport\n"); - goto bail; - } - - err = GraphicsImportGetNaturalBounds(gImporter, &myRect); - if (err != noErr) { - if (QTIME_DEBUG) printf("no bounds\n"); - goto bail; - } - - err = GraphicsImportGetImageDescription(gImporter, &desc); - if (err != noErr) { - if (QTIME_DEBUG) printf("no imagedescription\n"); - goto bail; - } - - x = RECT_WIDTH(myRect); - y = RECT_HEIGHT(myRect); - depth = (**desc).depth; - - if (flags & IB_test) { - ibuf = IMB_allocImBuf(x, y, depth, 0); - ibuf->ftype = QUICKTIME; - DisposeHandle((Handle)dataref); - if (gImporter != NULL) CloseComponent(gImporter); - return ibuf; - } - -#ifdef __APPLE__ - ibuf = IMB_allocImBuf(x, y, 32, IB_rect); - wbuf = IMB_allocImBuf(x, y, 32, IB_rect); - - err = NewGWorldFromPtr(&offGWorld, - k32ARGBPixelFormat, - &myRect, NULL, NULL, 0, - (unsigned char *)wbuf->rect, x * 4); -#else - - ibuf = IMB_allocImBuf(x, y, 32, IB_rect); - - err = NewGWorldFromPtr(&offGWorld, - k32RGBAPixelFormat, - &myRect, NULL, NULL, 0, - (unsigned char *)ibuf->rect, x * 4); -#endif - - if (err != noErr) { - if (QTIME_DEBUG) printf("no newgworld\n"); - goto bail; - } - else { - have_gw = TRUE; - } - - GraphicsImportSetGWorld(gImporter, offGWorld, NULL); - GraphicsImportDraw(gImporter); - -#ifdef __APPLE__ - rect = ibuf->rect; - - myPixMap = GetGWorldPixMap(offGWorld); - LockPixels(myPixMap); - myPtr = GetPixBaseAddr(myPixMap); - - if (myPtr == NULL) { - printf("Error reading frame from Quicktime"); - IMB_freeImBuf(ibuf); - return NULL; - } - - boxsize = x * y; - readPos = (uint32_t *) myPtr; - changePos = (uint32_t *) rect; - - // Swap alpha byte to the end, so ARGB become RGBA; - from = (unsigned char *)readPos; - to = (unsigned char *)changePos; - - for (index = 0; index < boxsize; index++, from += 4, to += 4) { - to[3] = from[0]; - to[0] = from[1]; - to[1] = from[2]; - to[2] = from[3]; - } -#endif - -bail: - - DisposeHandle((Handle)dataref); - UnlockPixels(myPixMap); - if (have_gw) DisposeGWorld(offGWorld); - -#ifdef __APPLE__ - if (wbuf) { - IMB_freeImBuf(wbuf); - wbuf = NULL; - } -#endif - - if (gImporter != NULL) CloseComponent(gImporter); - - if (err != noErr) { - if (QTIME_DEBUG) printf("quicktime import unsuccesfull\n"); - if (ibuf) { - IMB_freeImBuf(ibuf); - ibuf = NULL; - } - } - - if (ibuf) { - -#ifdef _WIN32 -// add non transparent alpha layer, so images without alpha show up in the sequence editor -// exception for GIF images since these can be transparent without being 32 bit -// (might also be nescessary for OSX) - int i; - int box = x * y; - unsigned char *arect = (unsigned char *) ibuf->rect; - - if (depth < 32 && (**desc).cType != kGIFCodecType) { - for (i = 0; i < box; i++, arect += 4) - arect[3] = 0xFF; - } -#endif - - IMB_flipy(ibuf); - ibuf->ftype = QUICKTIME; - } - return ibuf; -} - -#endif /* USE_QTKIT */ -#endif /* _WIN32 || __APPLE__ */ - -#endif /* WITH_QUICKTIME */ - - -#if 0 - -struct ImageDescription { - long idSize; - CodecType cType; - long resvd1; - short resvd2; - short dataRefIndex; - short version; - short revisionLevel; - long vendor; - CodecQ temporalQuality; - CodecQ spatialQuality; - short width; - short height; - Fixed hRes; - Fixed vRes; - long dataSize; - short frameCount; - Str31 name; - short depth; - short clutID; -}; - -#endif // 0 diff --git a/source/blender/quicktime/quicktime_export.h b/source/blender/quicktime/quicktime_export.h index 55323c05278..35e424b9081 100644 --- a/source/blender/quicktime/quicktime_export.h +++ b/source/blender/quicktime/quicktime_export.h @@ -69,25 +69,18 @@ QuicktimeCodecTypeDesc *quicktime_get_videocodecType_desc(int indexValue); int quicktime_rnatmpvalue_from_videocodectype(int codecType); int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue); -#ifdef USE_QTKIT /*Audio codec type*/ int quicktime_get_num_audiocodecs(void); QuicktimeCodecTypeDesc *quicktime_get_audiocodecType_desc(int indexValue); int quicktime_rnatmpvalue_from_audiocodectype(int codecType); int quicktime_audiocodecType_from_rnatmpvalue(int rnatmpvalue); -#endif - -#ifndef USE_QTKIT -void SCENE_OT_render_data_set_quicktime_codec(struct wmOperatorType *ot); //Operator to raise quicktime standard dialog to request codec settings -#endif - void free_qtcomponentdata(void); void makeqtstring(struct RenderData *rd, char *string); //for playanim.c -#if (defined(USE_QTKIT) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 && __LP64__) +#if (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 && __LP64__) //Include the quicktime codec types constants that are missing in QTKitDefines.h enum { kRawCodecType = 'raw ', diff --git a/source/blender/quicktime/quicktime_import.h b/source/blender/quicktime/quicktime_import.h index 4ec435db982..e45720496cc 100644 --- a/source/blender/quicktime/quicktime_import.h +++ b/source/blender/quicktime/quicktime_import.h @@ -42,18 +42,6 @@ #include "../imbuf/IMB_imbuf.h" #include "../imbuf/IMB_imbuf_types.h" -#ifndef USE_QTKIT -# ifndef __MOVIES__ -# ifdef _WIN32 -# include -# elif defined(__APPLE__) -# define __CARBONSOUND__ -# import -# include -# endif -# endif /* __MOVIES__ */ -#endif /* USE_QTKIT */ - #ifdef _WIN32 # ifndef __FIXMATH__ # include -- cgit v1.2.3 From 17994825f069e6b2c013de466f36fadfe9018579 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 6 Nov 2013 08:27:18 +0000 Subject: Fix #37251: Snap not working correctly in metaball edit mode. It wasn't enabled in snapping code from the beginning it seems, but from quick tests snapping for mballs works just fine. Maybe we could drop out check for edit object type now? --- source/blender/editors/transform/transform_snap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 48b92dfac7c..354164ce36f 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -117,7 +117,7 @@ int BIF_snappingSupported(Object *obedit) { int status = 0; - if (obedit == NULL || ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) /* only support object mesh, armature, curves */ + if (obedit == NULL || ELEM5(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) /* only support object mesh, armature, curves */ { status = 1; } @@ -440,7 +440,7 @@ static void initSnappingMode(TransInfo *t) /* Edit mode */ if (t->tsnap.applySnap != NULL && // A snapping function actually exist - (obedit != NULL && ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) ) // Temporary limited to edit mode meshes, armature, curves + (obedit != NULL && ELEM5(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) ) // Temporary limited to edit mode meshes, armature, curves, mballs { /* Exclude editmesh if using proportional edit */ if ((obedit->type == OB_MESH) && (t->flag & T_PROP_EDIT)) { -- cgit v1.2.3 From 50ac2ee8dea2df1f95ef700e271e4111adb1ef48 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 6 Nov 2013 10:59:05 +0000 Subject: Grease Pencil: User-Pref for setting the default colour of newly created layers --- release/scripts/startup/bl_ui/space_userpref.py | 6 +++++- source/blender/blenkernel/intern/gpencil.c | 3 ++- source/blender/editors/interface/resources.c | 10 +++++++++- source/blender/makesdna/DNA_userdef_types.h | 1 + source/blender/makesrna/intern/rna_userdef.c | 8 +++++++- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 1e9c9e7ff7e..697c070ffad 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -268,12 +268,16 @@ class USERPREF_PT_edit(Panel): col = row.column() col.label(text="Grease Pencil:") + col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius") + col.separator() col.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance") col.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance") - col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius") + col.separator() col.prop(edit, "use_grease_pencil_smooth_stroke", text="Smooth Stroke") col.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke") col.separator() + col.prop(edit, "grease_pencil_default_color", text="Default Color") + col.separator() col.separator() col.separator() col.label(text="Playback:") diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 4d17bd286b4..42e146301a2 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "BLI_math_vector.h" #include "BLF_translation.h" @@ -182,7 +183,7 @@ bGPDlayer *gpencil_layer_addnew(bGPdata *gpd, const char *name, int setactive) BLI_addtail(&gpd->layers, gpl); /* set basic settings */ - gpl->color[3] = 0.9f; + copy_v4_v4(gpl->color, U.gpencil_new_layer_col); gpl->thickness = 3; /* auto-name */ diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index ace35f0276e..55b353b1031 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1406,6 +1406,7 @@ void init_userdef_do_versions(void) } if (U.pad_rot_angle == 0) U.pad_rot_angle = 15; + /* graph editor - unselected F-Curve visibility */ if (U.fcu_inactive_alpha == 0) { U.fcu_inactive_alpha = 0.25f; @@ -2224,7 +2225,14 @@ void init_userdef_do_versions(void) rgba_char_args_test_set(btheme->tima.uv_shadow, 112, 112, 112, 255); } } - + + if (U.versionfile < 270) { + /* grease pencil - new layer color */ + if (U.gpencil_new_layer_col[3] < 0.1f) { + /* defaults to black, but must at least be visible! */ + U.gpencil_new_layer_col[3] = 0.9f; + } + } if (U.pixelsize == 0.0f) U.pixelsize = 1.0f; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 1621f7c6cb6..ae01536eebe 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -474,6 +474,7 @@ typedef struct UserDef { struct ColorBand coba_weight; /* from texture.h */ float sculpt_paint_overlay_col[3]; + float gpencil_new_layer_col[3]; /* default color for newly created Grease Pencil layers */ short tweak_threshold; short pad3; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 5221e8de7ce..0e45d6d4aea 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3266,7 +3266,13 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "gp_eraser"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Grease Pencil Eraser Radius", "Radius of eraser 'brush'"); - + + + prop = RNA_def_property(srna, "grease_pencil_default_color", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "gpencil_new_layer_col"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Grease Pencil Default Color", "Color of new Grease Pencil layers"); + /* sculpt and paint */ prop = RNA_def_property(srna, "sculpt_paint_overlay_color", PROP_FLOAT, PROP_COLOR_GAMMA); -- cgit v1.2.3 From b9aa637b83e79d09781a351a956a60b545a7cec9 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 6 Nov 2013 12:44:49 +0000 Subject: Removed the DNA storage for LGG lift and inverse gamma in the color balance node. These values were always calculated at execution time, so there is no need to keep them around in DNA data and no forward compatibility break either. Only reason they were stored in DNA before is that the old compositor had no other means of keeping precomputed values around for every pixel than storing the DNA node data, with new compositor this is no longer necessary (values are stored in operations). --- .../blender/compositor/nodes/COM_ColorBalanceNode.cpp | 18 ++++++++---------- source/blender/makesdna/DNA_node_types.h | 4 ---- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp index 5578fdae54e..68829940da5 100644 --- a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp +++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp @@ -43,18 +43,16 @@ void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorCon NodeOperation *operation; if (node->custom1 == 0) { ColorBalanceLGGOperation *operationLGG = new ColorBalanceLGGOperation(); - { - int c; - - for (c = 0; c < 3; c++) { - n->lift_lgg[c] = 2.0f - n->lift[c]; - n->gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f; - } + + float lift_lgg[3], gamma_inv[3]; + for (int c = 0; c < 3; c++) { + lift_lgg[c] = 2.0f - n->lift[c]; + gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f; } - + operationLGG->setGain(n->gain); - operationLGG->setLift(n->lift_lgg); - operationLGG->setGammaInv(n->gamma_inv); + operationLGG->setLift(lift_lgg); + operationLGG->setGammaInv(gamma_inv); operation = operationLGG; } else { diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 451dd20daa6..4ce4f6010b6 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -686,10 +686,6 @@ typedef struct NodeColorBalance { float lift[3]; float gamma[3]; float gain[3]; - - /* temp storage for inverted lift */ - float lift_lgg[3]; - float gamma_inv[3]; } NodeColorBalance; typedef struct NodeColorspill { -- cgit v1.2.3 From b91e841f8fa1af0d378870c614880d1b06cc9143 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 6 Nov 2013 12:44:51 +0000 Subject: Fix #37333: Bad default value in Color Balance. Use independent offset/power/slope variables for the CDL mode in color balance node. This avoids stupid default values in particular for offset, which would be 1 when just using the lift value for it. --- source/blender/compositor/nodes/COM_ColorBalanceNode.cpp | 6 +++--- .../operations/COM_ColorBalanceASCCDLOperation.cpp | 6 +++--- .../compositor/operations/COM_ColorBalanceASCCDLOperation.h | 12 ++++++------ source/blender/makesdna/DNA_node_types.h | 4 ++-- source/blender/makesrna/intern/rna_nodetree.c | 6 +++--- .../nodes/composite/nodes/node_composite_colorbalance.c | 4 ++++ 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp index 68829940da5..2b396fb9861 100644 --- a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp +++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp @@ -57,9 +57,9 @@ void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorCon } else { ColorBalanceASCCDLOperation *operationCDL = new ColorBalanceASCCDLOperation(); - operationCDL->setGain(n->gain); - operationCDL->setLift(n->lift); - operationCDL->setGamma(n->gamma); + operationCDL->setOffset(n->offset); + operationCDL->setPower(n->power); + operationCDL->setSlope(n->slope); operation = operationCDL; } diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp index aa4d0932c92..1456aaf6a55 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp @@ -61,9 +61,9 @@ void ColorBalanceASCCDLOperation::executePixel(float output[4], float x, float y fac = min(1.0f, fac); const float mfac = 1.0f - fac; - output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]); - output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]); - output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]); + output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_offset[0], this->m_power[0], this->m_slope[0]); + output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_offset[1], this->m_power[1], this->m_slope[1]); + output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_offset[2], this->m_power[2], this->m_slope[2]); output[3] = inputColor[3]; } diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h index 17fb5f67be9..ee0b89f7f70 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h @@ -36,9 +36,9 @@ protected: SocketReader *m_inputValueOperation; SocketReader *m_inputColorOperation; - float m_gain[3]; - float m_lift[3]; - float m_gamma[3]; + float m_offset[3]; + float m_power[3]; + float m_slope[3]; public: /** @@ -61,8 +61,8 @@ public: */ void deinitExecution(); - void setGain(float gain[3]) { copy_v3_v3(this->m_gain, gain); } - void setLift(float lift[3]) { copy_v3_v3(this->m_lift, lift); } - void setGamma(float gamma[3]) { copy_v3_v3(this->m_gamma, gamma); } + void setOffset(float offset[3]) { copy_v3_v3(this->m_offset, offset); } + void setPower(float power[3]) { copy_v3_v3(this->m_power, power); } + void setSlope(float slope[3]) { copy_v3_v3(this->m_slope, slope); } }; #endif diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 4ce4f6010b6..a4510dd23fd 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -677,12 +677,12 @@ typedef struct NodeLensDist { } NodeLensDist; typedef struct NodeColorBalance { - /* for processing */ + /* ASC CDL parameters */ float slope[3]; float offset[3]; float power[3]; - /* for ui representation */ + /* LGG parameters */ float lift[3]; float gamma[3]; float gain[3]; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 1f154460ef0..87136a6a07b 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -5256,14 +5256,14 @@ static void def_cmp_colorbalance(StructRNA *srna) prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "lift"); + RNA_def_property_float_sdna(prop, NULL, "offset"); RNA_def_property_array(prop, 3); RNA_def_property_ui_range(prop, 0, 1, 0.1, 3); RNA_def_property_ui_text(prop, "Offset", "Correction for Shadows"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "power", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "gamma"); + RNA_def_property_float_sdna(prop, NULL, "power"); RNA_def_property_array(prop, 3); RNA_def_property_float_array_default(prop, default_1); RNA_def_property_range(prop, 0.f, FLT_MAX); @@ -5272,7 +5272,7 @@ static void def_cmp_colorbalance(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "slope", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "gain"); + RNA_def_property_float_sdna(prop, NULL, "slope"); RNA_def_property_array(prop, 3); RNA_def_property_float_array_default(prop, default_1); RNA_def_property_range(prop, 0.f, FLT_MAX); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index 9ae744439bc..08019311d4b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -53,6 +53,10 @@ static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode *nod n->lift[0] = n->lift[1] = n->lift[2] = 1.0f; n->gamma[0] = n->gamma[1] = n->gamma[2] = 1.0f; n->gain[0] = n->gain[1] = n->gain[2] = 1.0f; + + n->slope[0] = n->slope[1] = n->slope[2] = 1.0f; + n->offset[0] = n->offset[1] = n->offset[2] = 0.0f; + n->power[0] = n->power[1] = n->power[2] = 1.0f; } void register_node_type_cmp_colorbalance(void) -- cgit v1.2.3 From b8f22a0565c7b4a1b0b1eb2e8fbdaa3ebbd1a99e Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 6 Nov 2013 12:44:54 +0000 Subject: Syncing methods for Color Balance node LGG and ASC-CDL modes. The settings for either mode are converted into equivalent settings of the other. This keeps the result of both modes roughly the same and mimics the previous behavior when settings were shared by both modes (but not equivalent). NOTE: Due to the use of additional sRGB conversion in the LGG mode the result is not entirely accurate, this should perhaps be fixed. Settings for each mode are kept in their own color values nevertheless, this avoids potential problems with float precision. --- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenkernel/BKE_node.h | 3 +++ source/blender/blenloader/intern/readfile.c | 27 +++++++++++++++++++ source/blender/makesrna/intern/rna_nodetree.c | 24 ++++++++++++----- .../composite/nodes/node_composite_colorbalance.c | 30 ++++++++++++++++++++++ 5 files changed, 79 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 5b32e7229d5..f2d9c0efc13 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 269 -#define BLENDER_SUBVERSION 1 +#define BLENDER_SUBVERSION 2 /* 262 was the last editmesh release but it has compatibility code for bmesh data */ #define BLENDER_MINVERSION 262 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 15c14c7a707..05824ae6950 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -944,6 +944,9 @@ void ntreeCompositOutputFileSetLayer(struct bNode *node, struct bNodeSocket *soc void ntreeCompositOutputFileUniquePath(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim); void ntreeCompositOutputFileUniqueLayer(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim); +void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *ntree, bNode *node); +void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *ntree, bNode *node); + /* ************** TEXTURE NODES *************** */ struct TexResult; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 17ae0b103ca..aaf646b70bd 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9783,6 +9783,33 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (!MAIN_VERSION_ATLEAST(main, 269, 2)) { + /* Initialize CDL settings for Color Balance nodes */ + FOREACH_NODETREE(main, ntree, id) { + if (ntree->type == NTREE_COMPOSIT) { + bNode *node; + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_COLORBALANCE) { + NodeColorBalance *n = node->storage; + if (node->custom1 == 0) { + /* LGG mode stays the same, just init CDL settings */ + ntreeCompositColorBalanceSyncFromLGG(ntree, node); + } + else if (node->custom1 == 1) { + /* CDL previously used same variables as LGG, copy them over + * and then sync LGG for comparable results in both modes. + */ + copy_v3_v3(n->offset, n->lift); + copy_v3_v3(n->power, n->gamma); + copy_v3_v3(n->slope, n->gain); + ntreeCompositColorBalanceSyncFromCDL(ntree, node); + } + } + } + } + } FOREACH_NODETREE_END + } + { Scene *scene; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 87136a6a07b..2b9c2bd4e9a 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2693,6 +2693,18 @@ static PointerRNA rna_NodeOutputFile_slot_file_get(CollectionPropertyIterator *i return ptr; } +static void rna_NodeColorBalance_update_lgg(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + ntreeCompositColorBalanceSyncFromLGG(ptr->id.data, ptr->data); + rna_Node_update(bmain, scene, ptr); +} + +static void rna_NodeColorBalance_update_cdl(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + ntreeCompositColorBalanceSyncFromCDL(ptr->id.data, ptr->data); + rna_Node_update(bmain, scene, ptr); +} + /* ******** Node Socket Types ******** */ static PointerRNA rna_NodeOutputFile_slot_layer_get(CollectionPropertyIterator *iter) @@ -5236,7 +5248,7 @@ static void def_cmp_colorbalance(StructRNA *srna) RNA_def_property_float_array_default(prop, default_1); RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); RNA_def_property_ui_text(prop, "Lift", "Correction for Shadows"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg"); prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "gamma"); @@ -5244,7 +5256,7 @@ static void def_cmp_colorbalance(StructRNA *srna) RNA_def_property_float_array_default(prop, default_1); RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); RNA_def_property_ui_text(prop, "Gamma", "Correction for Midtones"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg"); prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "gain"); @@ -5252,7 +5264,7 @@ static void def_cmp_colorbalance(StructRNA *srna) RNA_def_property_float_array_default(prop, default_1); RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); RNA_def_property_ui_text(prop, "Gain", "Correction for Highlights"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg"); prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -5260,7 +5272,7 @@ static void def_cmp_colorbalance(StructRNA *srna) RNA_def_property_array(prop, 3); RNA_def_property_ui_range(prop, 0, 1, 0.1, 3); RNA_def_property_ui_text(prop, "Offset", "Correction for Shadows"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl"); prop = RNA_def_property(srna, "power", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "power"); @@ -5269,7 +5281,7 @@ static void def_cmp_colorbalance(StructRNA *srna) RNA_def_property_range(prop, 0.f, FLT_MAX); RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); RNA_def_property_ui_text(prop, "Power", "Correction for Midtones"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl"); prop = RNA_def_property(srna, "slope", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "slope"); @@ -5278,7 +5290,7 @@ static void def_cmp_colorbalance(StructRNA *srna) RNA_def_property_range(prop, 0.f, FLT_MAX); RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); RNA_def_property_ui_text(prop, "Slope", "Correction for Highlights"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl"); } static void def_cmp_huecorrect(StructRNA *srna) diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index 08019311d4b..81ebc7c4c3b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -46,6 +46,36 @@ static bNodeSocketTemplate cmp_node_colorbalance_out[] = { {-1, 0, ""} }; +/* Sync functions update formula parameters for other modes, such that the result is comparable. + * Note that the results are not exactly the same due to differences in color handling (sRGB conversion happens for LGG), + * but this keeps settings comparable. + */ + +void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *UNUSED(ntree), bNode *node) +{ + NodeColorBalance *n = node->storage; + int c; + + for (c = 0; c < 3; ++c) { + n->slope[c] = (2.0f - n->lift[c]) * n->gain[c]; + n->offset[c] = (n->lift[c] - 1.0f) * n->gain[c]; + n->power[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f; + } +} + +void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *UNUSED(ntree), bNode *node) +{ + NodeColorBalance *n = node->storage; + int c; + + for (c = 0; c < 3; ++c) { + float d = n->slope[c] + n->offset[c]; + n->lift[c] = (d != 0.0f ? n->slope[c] + 2.0f*n->offset[c] / d : 0.0f); + n->gain[c] = d; + n->gamma[c] = (n->power[c] != 0.0f) ? 1.0f / n->power[c] : 1000000.0f; + } +} + static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode *node) { NodeColorBalance *n = node->storage = MEM_callocN(sizeof(NodeColorBalance), "node colorbalance"); -- cgit v1.2.3 From 5f084aced0a92c25e1326967b4a33030858825fb Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Wed, 6 Nov 2013 12:52:09 +0000 Subject: OSX/scons: simplification for getting the system version ( major, minor ), use sw_vers -productVersion instead of uname -r, we must not redine it then from darwin version -> osx version --- build_files/buildbot/config/user-config-mac-i386.py | 15 ++------------- build_files/buildbot/config/user-config-mac-x86_64.py | 15 ++------------- build_files/scons/config/darwin-config.py | 15 ++------------- 3 files changed, 6 insertions(+), 39 deletions(-) diff --git a/build_files/buildbot/config/user-config-mac-i386.py b/build_files/buildbot/config/user-config-mac-i386.py index 7242289e109..e0074785a01 100644 --- a/build_files/buildbot/config/user-config-mac-i386.py +++ b/build_files/buildbot/config/user-config-mac-i386.py @@ -19,19 +19,8 @@ MACOSX_ARCHITECTURE = 'i386' # valid archs: ppc, i386, ppc64, x86_64 cmd = 'uname -p' MAC_PROC=commands.getoutput(cmd) -cmd = 'uname -r' -cmd_res=commands.getoutput(cmd) - -if cmd_res[:1]=='9': - MAC_CUR_VER='10.5' -elif cmd_res[:2]=='10': - MAC_CUR_VER='10.6' -elif cmd_res[:2]=='11': - MAC_CUR_VER='10.7' -elif cmd_res[:2]=='12': - MAC_CUR_VER='10.8' -elif cmd_res[:2]=='13': - MAC_CUR_VER='10.9' +cmd = 'sw_vers -productVersion' +MAC_CUR_VER=cmd_res=commands.getoutput(cmd) cmd = 'xcodebuild -version' cmd_xcode=commands.getoutput(cmd) XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version diff --git a/build_files/buildbot/config/user-config-mac-x86_64.py b/build_files/buildbot/config/user-config-mac-x86_64.py index 4324ecbe2b4..0fbd30e4aa1 100644 --- a/build_files/buildbot/config/user-config-mac-x86_64.py +++ b/build_files/buildbot/config/user-config-mac-x86_64.py @@ -19,19 +19,8 @@ MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64 cmd = 'uname -p' MAC_PROC=commands.getoutput(cmd) -cmd = 'uname -r' -cmd_res=commands.getoutput(cmd) - -if cmd_res[:1]=='9': - MAC_CUR_VER='10.5' -elif cmd_res[:2]=='10': - MAC_CUR_VER='10.6' -elif cmd_res[:2]=='11': - MAC_CUR_VER='10.7' -elif cmd_res[:2]=='12': - MAC_CUR_VER='10.8' -elif cmd_res[:2]=='13': - MAC_CUR_VER='10.9' +cmd = 'sw_vers -productVersion' +MAC_CUR_VER=cmd_res=commands.getoutput(cmd) cmd = 'xcodebuild -version' cmd_xcode=commands.getoutput(cmd) XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 142b1ad04a1..75e37a59723 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -19,19 +19,8 @@ MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64 cmd = 'uname -p' MAC_PROC=commands.getoutput(cmd) -cmd = 'uname -r' -cmd_res=commands.getoutput(cmd) - -if cmd_res[:1]=='9': - MAC_CUR_VER='10.5' -elif cmd_res[:2]=='10': - MAC_CUR_VER='10.6' -elif cmd_res[:2]=='11': - MAC_CUR_VER='10.7' -elif cmd_res[:2]=='12': - MAC_CUR_VER='10.8' -elif cmd_res[:2]=='13': - MAC_CUR_VER='10.9' +cmd = 'sw_vers -productVersion' +MAC_CUR_VER=cmd_res=commands.getoutput(cmd) cmd = 'xcodebuild -version' cmd_xcode=commands.getoutput(cmd) XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version -- cgit v1.2.3 From 96aaea414baf6e84bab527fb35c303f2a913cc7e Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Wed, 6 Nov 2013 13:56:11 +0000 Subject: OSX/scons: more cleanup of redundant vars, preparation to remove local vars to not need to cp whole config as user-config later --- build_files/scons/config/darwin-config.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 75e37a59723..cbe9d7db1d7 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -40,29 +40,22 @@ else: if 'Mac OS X 10.5' in MACOSX_SDK_CHECK: # OSX 10.5/6 with Xcode 3.x - MAC_MIN_VERS = '10.5' MACOSX_DEPLOYMENT_TARGET = '10.5' MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK: # OSX 10.6/7 with Xcode 4.x - MAC_MIN_VERS = '10.6' MACOSX_DEPLOYMENT_TARGET = '10.6' MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' else: - # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! ) - MAC_MIN_VERS = '10.6' + # OSX 10.7/8/9 with Xcode 4.4 and higher (no 10.6sdk! ) MACOSX_DEPLOYMENT_TARGET = '10.6' MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc' - CXX = 'g++' +MAC_MIN_VERS = MACOSX_DEPLOYMENT_TARGET +# gcc always defaults to the system standard compiler linked by a shim or symlink +CC = 'gcc' +CXX = 'g++' +LCGDIR = '#../lib/darwin-9.x.universal' LIBDIR = '${LCGDIR}' if XCODE_CUR_VER >= '4.3': ## since version 4.3, XCode and developer dir are bundled ## -- cgit v1.2.3 From 3e6c3698882475698a879d8eff99f094874017b6 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Wed, 6 Nov 2013 14:03:51 +0000 Subject: OSX/scons: remove local MAC_MIN_VERS var and use the always identical MACOSX_DEPLOYMENT_TARGET instead --- build_files/scons/config/darwin-config.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index cbe9d7db1d7..572bb7026cc 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -51,7 +51,6 @@ else: MACOSX_DEPLOYMENT_TARGET = '10.6' MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk' -MAC_MIN_VERS = MACOSX_DEPLOYMENT_TARGET # gcc always defaults to the system standard compiler linked by a shim or symlink CC = 'gcc' CXX = 'g++' @@ -329,8 +328,8 @@ else: LLIBS = ['stdc++', 'SystemStubs'] if USE_SDK: - SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE] - PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS + SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MACOSX_DEPLOYMENT_TARGET,'-arch',MACOSX_ARCHITECTURE] + PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MACOSX_DEPLOYMENT_TARGET,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS CCFLAGS=SDK_FLAGS+CCFLAGS CXXFLAGS=SDK_FLAGS+CXXFLAGS -- cgit v1.2.3 From 3143536b08708bbbf1d8dfdfff705ad5d5afedfb Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Wed, 6 Nov 2013 15:27:19 +0000 Subject: Fix knife bug exposed by valgrind. Was reading cage coordinate from those of existing BMVerts even for newly created verts that don't have cage coordinates there. --- source/blender/editors/mesh/editmesh_knife.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index f961b6aefe9..32d17f6c599 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -348,12 +348,17 @@ static KnifeVert *new_knife_vert(KnifeTool_OpData *kcd, const float co[3], const static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v) { KnifeVert *kfv = BLI_ghash_lookup(kcd->origvertmap, v); + const float *cageco; if (!kfv) { BMIter bmiter; BMFace *f; - kfv = new_knife_vert(kcd, v->co, kcd->cagecos[BM_elem_index_get(v)]); + if (BM_elem_index_get(v) >= 0) + cageco = kcd->cagecos[BM_elem_index_get(v)]; + else + cageco = v->co; + kfv = new_knife_vert(kcd, v->co, cageco); kfv->v = v; BLI_ghash_insert(kcd->origvertmap, v, kfv); BM_ITER_ELEM (f, &bmiter, v, BM_FACES_OF_VERT) { -- cgit v1.2.3 From 5557332488d03671fdff284c1471668c8da42231 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Wed, 6 Nov 2013 15:37:14 +0000 Subject: OSX/scons: remove another outdated conditional --- build_files/scons/config/darwin-config.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 572bb7026cc..6a00261a8fa 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -101,14 +101,7 @@ else: BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config-${BF_PYTHON_VERSION}m' WITH_BF_OPENAL = True -#different lib must be used following version of gcc -# for gcc 3.3 -#BF_OPENAL = LIBDIR + '/openal' -# for gcc 3.4 and ulterior -if MAC_PROC == 'powerpc': - BF_OPENAL = '#../lib/darwin-8.0.0-powerpc/openal' -else : - BF_OPENAL = LIBDIR + '/openal' +BF_OPENAL = LIBDIR + '/openal' WITH_BF_STATICOPENAL = False BF_OPENAL_INC = '${BF_OPENAL}/include' # only headers from libdir needed for proper use of framework !!!! -- cgit v1.2.3 From c81c0859ee0d3a1b6b3dab739dd9acc62772aa10 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Wed, 6 Nov 2013 15:42:01 +0000 Subject: OSX/scons: remove obsolete compile flags and silence warnings same time --- build_files/scons/config/darwin-config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 6a00261a8fa..563009cad7d 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -330,7 +330,7 @@ if USE_SDK: if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64': REL_CFLAGS = [] REL_CXXFLAGS = [] - REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3','-mfpmath=sse'] + REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3'] else: CCFLAGS += ['-fno-strict-aliasing'] REL_CFLAGS = [] @@ -339,7 +339,7 @@ else: # Intel 64bit Macs are Core2Duo and up if MACOSX_ARCHITECTURE == 'x86_64': - REL_CCFLAGS += ['-march=core2','-mssse3','-with-tune=core2','-enable-threads'] + REL_CCFLAGS += ['-march=core2','-mssse3'] CC_WARN = ['-Wall'] C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes'] -- cgit v1.2.3 From 480d4317ded845dd69d167c909807290bddd77ab Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Wed, 6 Nov 2013 15:46:57 +0000 Subject: OSX/scons: remove obsolete compile flag --- build_files/scons/config/darwin-config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 563009cad7d..84665548d96 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -339,7 +339,7 @@ else: # Intel 64bit Macs are Core2Duo and up if MACOSX_ARCHITECTURE == 'x86_64': - REL_CCFLAGS += ['-march=core2','-mssse3'] + REL_CCFLAGS += ['-mssse3'] CC_WARN = ['-Wall'] C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes'] -- cgit v1.2.3 From 73986000902c34020f581a6ef7395a9259b7f6c2 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 6 Nov 2013 17:46:32 +0000 Subject: True grid snapping for nodes: This snaps nodes to the actual background grid instead of using incremental offset (which is not useful for nodes). Increment snapping has been disabled for nodes to avoid confusion, grid snap is now the default as it seems to be the most wanted and easy to use mode. Absolute grid snapping happens in a somewhat generic function 'applyGridAbsolute', which could also be used for objects and other transforms later on. It is conceptually similar to the 'project' snapping option, in that it calculates a delta vector for each element on top of the overall transform, which places each node on the grid. Node transform now uses the top-left node corner for TransformData->loc. The transform center is still the average of node centers, so that scaling and rotation works nicely. snapGrid*** functions have been renamed to snapGridIncrement*** to distinguish better between incremental and absolute grid snapping. --- release/scripts/startup/bl_ui/space_node.py | 2 +- source/blender/blenkernel/intern/scene.c | 2 + source/blender/blenloader/intern/readfile.c | 6 ++ source/blender/editors/include/ED_node.h | 3 + source/blender/editors/space_node/node_draw.c | 9 ++- source/blender/editors/transform/transform.c | 49 ++++++------- source/blender/editors/transform/transform.h | 5 +- .../editors/transform/transform_constraints.c | 2 +- .../editors/transform/transform_conversions.c | 28 +++----- source/blender/editors/transform/transform_snap.c | 80 +++++++++++++++++++--- source/blender/makesdna/DNA_scene_types.h | 1 + source/blender/makesrna/intern/rna_scene.c | 2 +- 12 files changed, 132 insertions(+), 57 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 1721eacd8ac..b9aa3feb607 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -105,7 +105,7 @@ class NODE_HT_header(Header): row = layout.row(align=True) row.prop(toolsettings, "use_snap", text="") row.prop(toolsettings, "snap_node_element", text="", icon_only=True) - if toolsettings.snap_node_element != 'INCREMENT': + if toolsettings.snap_node_element != 'GRID': row.prop(toolsettings, "snap_target", text="") row = layout.row(align=True) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 9356536557a..05e1ec82392 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -504,6 +504,8 @@ Scene *BKE_scene_add(Main *bmain, const char *name) sce->toolsettings->normalsize = 0.1; sce->toolsettings->autokey_mode = U.autokey_mode; + sce->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID; + sce->toolsettings->skgen_resolution = 100; sce->toolsettings->skgen_threshold_internal = 0.01f; sce->toolsettings->skgen_threshold_external = 0.01f; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index aaf646b70bd..48c61c7db6b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9818,6 +9818,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) scene->gm.matmode = GAME_MAT_MULTITEX; } } + + /* 'Increment' mode disabled for nodes, use true grid snapping instead */ + for (scene = main->scene.first; scene; scene = scene->id.next) { + if (scene->toolsettings->snap_node_mode == SCE_SNAP_MODE_INCREMENT) + scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID; + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 2f16d84aed0..de83df9cc05 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -54,6 +54,8 @@ typedef enum { NODE_RIGHT = 8 } NodeBorder; +#define NODE_GRID_STEPS 5 + /* space_node.c */ int ED_node_tree_path_length(struct SpaceNode *snode); void ED_node_tree_path_get(struct SpaceNode *snode, char *value); @@ -81,6 +83,7 @@ void ED_node_tree_update(const struct bContext *C); void ED_node_tag_update_id(struct ID *id); void ED_node_tag_update_nodetree(struct Main *bmain, struct bNodeTree *ntree); void ED_node_sort(struct bNodeTree *ntree); +float ED_node_grid_size(void); /* node_relationships.c */ void ED_node_link_intersect_test(struct ScrArea *sa, int test); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 65eb75f8523..e031e056cd3 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -72,6 +72,11 @@ /* XXX interface.h */ extern void ui_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select); +float ED_node_grid_size(void) +{ + return U.widget_unit; +} + void ED_node_tree_update(const bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); @@ -1325,7 +1330,7 @@ void drawnodespace(const bContext *C, ARegion *ar) snode_setup_v2d(snode, ar, center); /* grid, uses theme color based on node path depth */ - UI_view2d_multi_grid_draw(v2d, (depth > 0 ? TH_NODE_GROUP : TH_BACK), U.widget_unit, 5, 2); + UI_view2d_multi_grid_draw(v2d, (depth > 0 ? TH_NODE_GROUP : TH_BACK), ED_node_grid_size(), NODE_GRID_STEPS, 2); /* backdrop */ draw_nodespace_back_pix(C, ar, snode, path->parent_key); @@ -1350,7 +1355,7 @@ void drawnodespace(const bContext *C, ARegion *ar) } else { /* default grid */ - UI_view2d_multi_grid_draw(v2d, TH_BACK, U.widget_unit, 5, 2); + UI_view2d_multi_grid_draw(v2d, TH_BACK, ED_node_grid_size(), NODE_GRID_STEPS, 2); /* backdrop */ draw_nodespace_back_pix(C, ar, snode, NODE_INSTANCE_KEY_NONE); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ab2732d4e8c..2caf04e3143 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -82,6 +82,7 @@ #include "ED_mesh.h" #include "ED_clip.h" #include "ED_mask.h" +#include "ED_node.h" #include "WM_types.h" #include "WM_api.h" @@ -2778,7 +2779,7 @@ static void Warp(TransInfo *t, const int UNUSED(mval[2])) const float radius_snap = 0.1f; const float snap_hack = (t->snap[1] * data->warp_init_dist) / radius_snap; values.scale *= snap_hack; - snapGrid(t, values.vector); + snapGridIncrement(t, values.vector); values.scale /= snap_hack; } #endif @@ -2950,7 +2951,7 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2])) value = t->values[0]; - snapGrid(t, &value); + snapGridIncrement(t, &value); applyNumInput(&t->num, &value); @@ -3238,7 +3239,7 @@ static void applyResize(TransInfo *t, const int mval[2]) size[0] = size[1] = size[2] = ratio; - snapGrid(t, size); + snapGridIncrement(t, size); if (hasNumInput(&t->num)) { applyNumInput(&t->num, size); @@ -3340,7 +3341,7 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) ratio = t->values[0]; size[0] = size[1] = size[2] = ratio; - snapGrid(t, size); + snapGridIncrement(t, size); if (hasNumInput(&t->num)) { applyNumInput(&t->num, size); @@ -3438,7 +3439,7 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) ratio = t->values[0]; - snapGrid(t, &ratio); + snapGridIncrement(t, &ratio); applyNumInput(&t->num, &ratio); @@ -3789,7 +3790,7 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2])) final = t->values[0]; - snapGrid(t, &final); + snapGridIncrement(t, &final); if ((t->con.mode & CON_APPLY) && t->con.applyRot) { t->con.applyRot(t, NULL, t->axis, NULL); @@ -3902,7 +3903,7 @@ static void applyTrackball(TransInfo *t, const int UNUSED(mval[2])) phi[0] = t->values[0]; phi[1] = t->values[1]; - snapGrid(t, phi); + snapGridIncrement(t, phi); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN * 2]; @@ -3981,8 +3982,8 @@ static void initTranslation(TransInfo *t) } else if (t->spacetype == SPACE_NODE) { t->snap[0] = 0.0f; - t->snap[1] = 125.0f; - t->snap[2] = 25.0f; + t->snap[1] = ED_node_grid_size() * NODE_GRID_STEPS; + t->snap[2] = ED_node_grid_size(); } else { t->snap[0] = 0.0f; @@ -4162,7 +4163,7 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2])) headerTranslation(t, pvec, str); } else { - snapGrid(t, t->values); + snapGridIncrement(t, t->values); applyNumInput(&t->num, t->values); if (hasNumInput(&t->num)) { removeAspectRatio(t, t->values); @@ -4234,7 +4235,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) distance = -t->values[0]; - snapGrid(t, &distance); + snapGridIncrement(t, &distance); applyNumInput(&t->num, &distance); @@ -4327,7 +4328,7 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2])) final = t->values[0]; - snapGrid(t, &final); + snapGridIncrement(t, &final); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; @@ -4402,7 +4403,7 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) ratio = t->values[0]; - snapGrid(t, &ratio); + snapGridIncrement(t, &ratio); applyNumInput(&t->num, &ratio); @@ -4475,7 +4476,7 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) ratio = t->values[0]; - snapGrid(t, &ratio); + snapGridIncrement(t, &ratio); applyNumInput(&t->num, &ratio); @@ -4566,7 +4567,7 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) distance = t->values[0]; - snapGrid(t, &distance); + snapGridIncrement(t, &distance); applyNumInput(&t->num, &distance); @@ -4658,7 +4659,7 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2])) weight -= 1.0f; if (weight > 1.0f) weight = 1.0f; - snapGrid(t, &weight); + snapGridIncrement(t, &weight); applyNumInput(&t->num, &weight); @@ -4735,7 +4736,7 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2])) crease -= 1.0f; if (crease > 1.0f) crease = 1.0f; - snapGrid(t, &crease); + snapGridIncrement(t, &crease); applyNumInput(&t->num, &crease); @@ -4868,7 +4869,7 @@ static void applyBoneSize(TransInfo *t, const int mval[2]) size[0] = size[1] = size[2] = ratio; - snapGrid(t, size); + snapGridIncrement(t, size); if (hasNumInput(&t->num)) { applyNumInput(&t->num, size); @@ -4935,7 +4936,7 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) ratio = t->values[0]; - snapGrid(t, &ratio); + snapGridIncrement(t, &ratio); applyNumInput(&t->num, &ratio); @@ -6066,7 +6067,7 @@ static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2])) final = t->values[0]; - snapGrid(t, &final); + snapGridIncrement(t, &final); /* only do this so out of range values are not displayed */ CLAMP(final, -1.0f, 1.0f); @@ -6574,7 +6575,7 @@ static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2])) final = t->values[0]; - snapGrid(t, &final); + snapGridIncrement(t, &final); /* only do this so out of range values are not displayed */ if (is_constrained) { @@ -6643,7 +6644,7 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2])) final = t->values[0]; - snapGrid(t, &final); + snapGridIncrement(t, &final); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; @@ -6716,7 +6717,7 @@ static void applyBakeTime(TransInfo *t, const int mval[2]) time = (float)(t->center2d[0] - mval[0]) * fac; } - snapGrid(t, &time); + snapGridIncrement(t, &time); applyNumInput(&t->num, &time); @@ -6983,7 +6984,7 @@ static void applySeqSlide(TransInfo *t, const int UNUSED(mval[2])) copy_v3_v3(t->values, tvec); } else { - snapGrid(t, t->values); + snapGridIncrement(t, t->values); applyNumInput(&t->num, t->values); } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 73b8c47eb63..ab5f034c836 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -566,14 +566,15 @@ typedef enum { SMALL_GEARS = 2 } GearsType; -void snapGrid(TransInfo *t, float *val); -void snapGridAction(TransInfo *t, float *val, GearsType action); +void snapGridIncrement(TransInfo *t, float *val); +void snapGridIncrementAction(TransInfo *t, float *val, GearsType action); bool activeSnap(TransInfo *t); bool validSnap(TransInfo *t); void initSnapping(struct TransInfo *t, struct wmOperator *op); void applyProject(TransInfo *t); +void applyGridAbsolute(TransInfo *t); void applySnapping(TransInfo *t, float *vec); void resetSnapping(TransInfo *t); eRedrawFlag handleSnapping(TransInfo *t, const struct wmEvent *event); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 4497723185f..8df289ff917 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -135,7 +135,7 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) mul_m3_v3(t->con.imtx, vec); - snapGrid(t, vec); + snapGridIncrement(t, vec); if (t->num.flag & T_NULL_ONE) { if (!(t->con.mode & CON_AXIS0)) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index cfc78a0e0ef..5332e843ea1 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2381,16 +2381,16 @@ void flushTransNodes(TransInfo *t) int a; TransData *td; TransData2D *td2d; - + + applyGridAbsolute(t); + /* flush to 2d vector from internally used 3d vector */ for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) { bNode *node = td->extra; - float vec[2]; /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */ - add_v2_v2v2(vec, td2d->loc, td2d->ih1); - node->locx = vec[0] / UI_DPI_FAC; - node->locy = vec[1] / UI_DPI_FAC; + node->locx = td2d->loc[0] / UI_DPI_FAC; + node->locy = td2d->loc[1] / UI_DPI_FAC; } /* handle intersection with noodles */ @@ -5962,12 +5962,9 @@ static void createTransObject(bContext *C, TransInfo *t) /* transcribe given node into TransData2D for Transforming */ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) { - /* hold original location */ - float locxy[2] = {BLI_rctf_cent_x(&node->totr), - BLI_rctf_cent_y(&node->totr)}; - float nodeloc[2]; - - copy_v2_v2(td2d->loc, locxy); + /* use top-left corner as the transform origin for nodes */ + td2d->loc[0] = node->totr.xmin; + td2d->loc[1] = node->totr.ymax; td2d->loc[2] = 0.0f; td2d->loc2d = td2d->loc; /* current location */ @@ -5976,8 +5973,8 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) td->loc = td2d->loc; copy_v3_v3(td->iloc, td->loc); /* use node center instead of origin (top-left corner) */ - td->center[0] = locxy[0]; - td->center[1] = locxy[1]; + td->center[0] = BLI_rctf_cent_x(&node->totr); + td->center[1] = BLI_rctf_cent_y(&node->totr); td->center[2] = 0.0f; memset(td->axismtx, 0, sizeof(td->axismtx)); @@ -5991,11 +5988,6 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) unit_m3(td->mtx); unit_m3(td->smtx); - /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */ - nodeloc[0] = UI_DPI_FAC * node->locx; - nodeloc[1] = UI_DPI_FAC * node->locy; - sub_v2_v2v2(td2d->ih1, nodeloc, locxy); - td->extra = node; } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 354164ce36f..5ace7e3a738 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -344,6 +344,70 @@ void applyProject(TransInfo *t) } } +void applyGridAbsolute(TransInfo *t) +{ + float grid_size = 0.0f; + GearsType grid_action; + TransData *td; + float imat[4][4]; + int i; + + if (!(activeSnap(t) && (t->tsnap.mode == SCE_SNAP_MODE_GRID))) + return; + + grid_action = BIG_GEARS; + if (t->modifiers & MOD_PRECISION) + grid_action = SMALL_GEARS; + + switch (grid_action) { + case NO_GEARS: grid_size = t->snap[0]; break; + case BIG_GEARS: grid_size = t->snap[1]; break; + case SMALL_GEARS: grid_size = t->snap[2]; break; + } + /* early exit on unusable grid size */ + if (grid_size == 0.0f) + return; + + if (t->flag & (T_EDIT | T_POSE)) { + Object *ob = t->obedit ? t->obedit : t->poseobj; + invert_m4_m4(imat, ob->obmat); + } + + for (i = 0, td = t->data; i < t->total; i++, td++) { + float iloc[3], loc[3], tvec[3]; + + if (td->flag & TD_NOACTION) + break; + + if (td->flag & TD_SKIP) + continue; + + if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) + continue; + + copy_v3_v3(iloc, td->loc); + if (t->flag & (T_EDIT | T_POSE)) { + Object *ob = t->obedit ? t->obedit : t->poseobj; + mul_m4_v3(ob->obmat, iloc); + } + else if (t->flag & T_OBJECT) { + td->ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + BKE_object_handle_update(t->scene, td->ob); + copy_v3_v3(iloc, td->ob->obmat[3]); + } + + mul_v3_v3fl(loc, iloc, 1.0f/grid_size); + loc[0] = floorf(loc[0]); + loc[1] = floorf(loc[1]); + loc[2] = floorf(loc[2]); + mul_v3_fl(loc, grid_size); + + sub_v3_v3v3(tvec, loc, iloc); + mul_m3_v3(td->smtx, tvec); + add_v3_v3(td->loc, tvec); + } +} + void applySnapping(TransInfo *t, float *vec) { /* project is not applied this way */ @@ -818,7 +882,7 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]) static void UNUSED_FUNCTION(CalcSnapGrid) (TransInfo *t, float *UNUSED(vec)) { - snapGridAction(t, t->tsnap.snapPoint, BIG_GEARS); + snapGridIncrementAction(t, t->tsnap.snapPoint, BIG_GEARS); } static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) @@ -2169,10 +2233,10 @@ bool snapNodesContext(bContext *C, const int mval[2], float *r_dist_px, float r_ /*================================================================*/ -static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], GearsType action); +static void applyGridIncrement(TransInfo *t, float *val, int max_index, float fac[3], GearsType action); -void snapGridAction(TransInfo *t, float *val, GearsType action) +void snapGridIncrementAction(TransInfo *t, float *val, GearsType action) { float fac[3]; @@ -2180,11 +2244,11 @@ void snapGridAction(TransInfo *t, float *val, GearsType action) fac[BIG_GEARS] = t->snap[1]; fac[SMALL_GEARS] = t->snap[2]; - applyGrid(t, val, t->idx_max, fac, action); + applyGridIncrement(t, val, t->idx_max, fac, action); } -void snapGrid(TransInfo *t, float *val) +void snapGridIncrement(TransInfo *t, float *val) { GearsType action; @@ -2198,17 +2262,17 @@ void snapGrid(TransInfo *t, float *val) action = SMALL_GEARS; } - snapGridAction(t, val, action); + snapGridIncrementAction(t, val, action); } -static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], GearsType action) +static void applyGridIncrement(TransInfo *t, float *val, int max_index, float fac[3], GearsType action) { int i; float asp[3] = {1.0f, 1.0f, 1.0f}; // TODO: Remove hard coded limit here (3) if (max_index > 2) { - printf("applyGrid: invalid index %d, clamping\n", max_index); + printf("applyGridIncrement: invalid index %d, clamping\n", max_index); max_index = 2; } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 1ddc7d6ee06..ca328423072 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1457,6 +1457,7 @@ typedef struct Scene { #define SCE_SNAP_MODE_NODE_X 5 #define SCE_SNAP_MODE_NODE_Y 6 #define SCE_SNAP_MODE_NODE_XY 7 +#define SCE_SNAP_MODE_GRID 8 /* toolsettings->selectmode */ #define SCE_SELECT_VERTEX 1 /* for mesh */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index fb0a26621f4..d31a29623a1 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -145,7 +145,7 @@ EnumPropertyItem snap_element_items[] = { }; EnumPropertyItem snap_node_element_items[] = { - {SCE_SNAP_MODE_INCREMENT, "INCREMENT", ICON_SNAP_INCREMENT, "Increment", "Snap to increments of grid"}, + {SCE_SNAP_MODE_GRID, "GRID", ICON_SNAP_INCREMENT, "Grid", "Snap to grid"}, {SCE_SNAP_MODE_NODE_X, "NODE_X", ICON_SNAP_EDGE, "Node X", "Snap to left/right node border"}, {SCE_SNAP_MODE_NODE_Y, "NODE_Y", ICON_SNAP_EDGE, "Node Y", "Snap to top/bottom node border"}, {SCE_SNAP_MODE_NODE_XY, "NODE_XY", ICON_SNAP_EDGE, "Node X / Y", "Snap to any node border"}, -- cgit v1.2.3 From 549ed3d37873e242f12eb6d38ba481f4ed99e115 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 6 Nov 2013 18:56:51 +0000 Subject: Removed the "Show Cyclic Dependencies" operator for nodes. This operator is an old relic implemented for showing cyclic node connections as red links. This is not necessary any more, the operator simply called the generic node tree update function, which is happening anyway after all relevant node operators (if it doesn't that has to be considered a bug). It has been suggested to better use the C key for circle select, this remains to be discussed. --- release/scripts/startup/bl_ui/space_node.py | 1 - source/blender/editors/space_node/node_intern.h | 1 - source/blender/editors/space_node/node_ops.c | 3 --- .../editors/space_node/node_relationships.c | 28 ---------------------- 4 files changed, 33 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index b9aa3feb607..f9e32256566 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -233,7 +233,6 @@ class NODE_MT_node(Menu): layout.separator() - layout.operator("node.show_cyclic_dependencies") layout.operator("node.read_renderlayers") layout.operator("node.read_fullsamplelayers") diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 176b81f9503..5e244b862f6 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -169,7 +169,6 @@ void NODE_OT_join(struct wmOperatorType *ot); void NODE_OT_attach(struct wmOperatorType *ot); void NODE_OT_detach(struct wmOperatorType *ot); -void NODE_OT_show_cyclic_dependencies(struct wmOperatorType *ot); void NODE_OT_link_viewer(struct wmOperatorType *ot); /* node_edit.c */ diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index f0d3deb24df..1d631d5c9e5 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -70,7 +70,6 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_preview_toggle); WM_operatortype_append(NODE_OT_options_toggle); WM_operatortype_append(NODE_OT_hide_socket_toggle); - WM_operatortype_append(NODE_OT_show_cyclic_dependencies); WM_operatortype_append(NODE_OT_node_copy_color); WM_operatortype_append(NODE_OT_duplicate); @@ -272,8 +271,6 @@ void node_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "NODE_OT_preview_toggle", HKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NODE_OT_hide_socket_toggle", HKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "NODE_OT_show_cyclic_dependencies", CKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 8c4050766af..a8c619a15fb 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -876,34 +876,6 @@ void NODE_OT_links_detach(wmOperatorType *ot) } -/* ****************** Show Cyclic Dependencies Operator ******************* */ - -static int node_show_cycles_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceNode *snode = CTX_wm_space_node(C); - - /* this is just a wrapper around this call... */ - ntreeUpdateTree(CTX_data_main(C), snode->nodetree); - snode_notify(C, snode); - - return OPERATOR_FINISHED; -} - -void NODE_OT_show_cyclic_dependencies(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Show Cyclic Dependencies"; - ot->description = "Sort the nodes and show the cyclic dependencies between the nodes"; - ot->idname = "NODE_OT_show_cyclic_dependencies"; - - /* callbacks */ - ot->exec = node_show_cycles_exec; - ot->poll = ED_operator_node_active; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - /* ****************** Set Parent ******************* */ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) -- cgit v1.2.3 From 61c411068b4b6c593a3bb05b073b26e0d0227995 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 6 Nov 2013 19:21:42 +0000 Subject: Patch #37274: Circle select for node editor, by Henrik Aarnio (hjaarnio). Circle select was missing from node editor, and C key was assigned to now defunct "show cyclic dependencies". This patch remaps the key and adds circle select operator. Functions to check intersection between rctf/rcti and a circle were also added to rct.c for code cleanliness and consistency. --- release/scripts/startup/bl_ui/space_node.py | 1 + source/blender/blenlib/BLI_rect.h | 2 + source/blender/blenlib/intern/rct.c | 26 ++++++++++ source/blender/editors/space_node/node_intern.h | 1 + source/blender/editors/space_node/node_ops.c | 3 ++ source/blender/editors/space_node/node_select.c | 57 ++++++++++++++++++++++ source/blender/windowmanager/intern/wm_operators.c | 1 + 7 files changed, 91 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index f9e32256566..8d577bb22c5 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -169,6 +169,7 @@ class NODE_MT_select(Menu): layout = self.layout layout.operator("node.select_border") + layout.operator("node.select_circle") layout.separator() layout.operator("node.select_all").action = 'TOGGLE' diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index f8b9088fe3d..0fee9264191 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -74,6 +74,8 @@ bool BLI_rctf_isect_pt(const struct rctf *rect, const float x, const float y); bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2]); bool BLI_rcti_isect_segment(const struct rcti *rect, const int s1[2], const int s2[2]); bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2]); +bool BLI_rcti_isect_circle(const struct rcti *rect, const float xy[2], const float radius); +bool BLI_rctf_isect_circle(const struct rctf *rect, const float xy[2], const float radius); bool BLI_rcti_inside_rcti(rcti *rct_a, const rcti *rct_b); bool BLI_rctf_inside_rctf(rctf *rct_a, const rctf *rct_b); void BLI_rcti_union(struct rcti *rcti1, const struct rcti *rcti2); diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 02525e25dda..d36cd3cb394 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -216,6 +216,32 @@ bool BLI_rctf_isect_segment(const rctf *rect, const float s1[2], const float s2[ } } +bool BLI_rcti_isect_circle(const rcti *rect, const float xy[2], const float radius) +{ + float dx, dy; + + if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) dx = 0; + else dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax); + + if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) dy = 0; + else dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax); + + return dx * dx + dy * dy <= radius * radius; +} + +bool BLI_rctf_isect_circle(const rctf *rect, const float xy[2], const float radius) +{ + float dx, dy; + + if (xy[0] >= rect->xmin && xy[0] <= rect->xmax) dx = 0; + else dx = (xy[0] < rect->xmin) ? (rect->xmin - xy[0]) : (xy[0] - rect->xmax); + + if (xy[1] >= rect->ymin && xy[1] <= rect->ymax) dy = 0; + else dy = (xy[1] < rect->ymin) ? (rect->ymin - xy[1]) : (xy[1] - rect->ymax); + + return dx * dx + dy * dy <= radius * radius; +} + void BLI_rctf_union(rctf *rct1, const rctf *rct2) { if (rct1->xmin > rct2->xmin) rct1->xmin = rct2->xmin; diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 5e244b862f6..f598a13bea9 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -116,6 +116,7 @@ void NODE_OT_select_all(struct wmOperatorType *ot); void NODE_OT_select_linked_to(struct wmOperatorType *ot); void NODE_OT_select_linked_from(struct wmOperatorType *ot); void NODE_OT_select_border(struct wmOperatorType *ot); +void NODE_OT_select_circle(struct wmOperatorType *ot); void NODE_OT_select_lasso(struct wmOperatorType *ot); void NODE_OT_select_same_type(struct wmOperatorType *ot); void NODE_OT_select_same_type_step(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 1d631d5c9e5..edd422b8148 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -56,6 +56,7 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_select_linked_to); WM_operatortype_append(NODE_OT_select_linked_from); WM_operatortype_append(NODE_OT_select_border); + WM_operatortype_append(NODE_OT_select_circle); WM_operatortype_append(NODE_OT_select_lasso); WM_operatortype_append(NODE_OT_select_same_type); WM_operatortype_append(NODE_OT_select_same_type_step); @@ -232,6 +233,8 @@ void node_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "deselect", TRUE); + WM_keymap_add_item(keymap, "NODE_OT_select_circle", CKEY, KM_PRESS, 0, 0); + /* each of these falls through if not handled... */ kmi = WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "detach", FALSE); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 958a3433337..2e3e747618b 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -514,6 +514,63 @@ void NODE_OT_select_border(wmOperatorType *ot) RNA_def_boolean(ot->srna, "tweak", 0, "Tweak", "Only activate when mouse is not over a node - useful for tweak gesture"); } +/* ****** Circle Select ****** */ + +static int node_circleselect_exec(bContext *C, wmOperator *op) +{ + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + bNode *node; + + int x, y, radius, gesture_mode; + float offset[2]; + + float zoom = (float)(BLI_rcti_size_x(&ar->winrct)) / (float)(BLI_rctf_size_x(&ar->v2d.cur)); + + gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + + /* get operator properties */ + x = RNA_int_get(op->ptr, "x"); + y = RNA_int_get(op->ptr, "y"); + radius = RNA_int_get(op->ptr, "radius"); + + UI_view2d_region_to_view(&ar->v2d, x, y, &offset[0], &offset[1]); + + for (node = snode->edittree->nodes.first; node; node = node->next) { + if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) { + nodeSetSelected(node, (gesture_mode == GESTURE_MODAL_SELECT)); + } + } + + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); + + return OPERATOR_FINISHED; +} + +void NODE_OT_select_circle(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Circle Select"; + ot->idname = "NODE_OT_select_circle"; + ot->description = "Use circle selection to select nodes"; + + /* api callbacks */ + ot->invoke = WM_gesture_circle_invoke; + ot->exec = node_circleselect_exec; + ot->modal = WM_gesture_circle_modal; + + ot->poll = ED_operator_node_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* rna */ + RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); + RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); + RNA_def_int(ot->srna, "radius", 0, INT_MIN, INT_MAX, "Radius", "", INT_MIN, INT_MAX); + RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX); +} + /* ****** Lasso Select ****** */ static int do_lasso_select_node(bContext *C, const int mcords[][2], short moves, short select) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 2cd5190cdaf..eb42f44b696 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -4271,6 +4271,7 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_assign(keymap, "UV_OT_circle_select"); WM_modalkeymap_assign(keymap, "CLIP_OT_select_circle"); WM_modalkeymap_assign(keymap, "MASK_OT_select_circle"); + WM_modalkeymap_assign(keymap, "NODE_OT_select_circle"); } -- cgit v1.2.3 From 5cd28bbe8071e4e83fe0baafe8e04360f65c1778 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 6 Nov 2013 19:40:37 +0000 Subject: BGE: Fix for #37335 "Moving the camera with a key (after the recent BGE cleanup commits) now crashes the game" reported by Ace Dragon. CcdPhysicsEnvironment->GetCharacterController(); was missing a NULL check. --- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 10be1876e41..71ed6af2f99 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -2288,7 +2288,7 @@ PHY_IVehicle* CcdPhysicsEnvironment::GetVehicleConstraint(int constraintId) PHY_ICharacter* CcdPhysicsEnvironment::GetCharacterController(KX_GameObject *ob) { CcdPhysicsController* controller = (CcdPhysicsController*)ob->GetPhysicsController(); - return dynamic_cast(controller->GetCharacterController()); + return (controller) ? dynamic_cast(controller->GetCharacterController()) : NULL; } -- cgit v1.2.3 From ad34a5cc1b344abc152f14183e2a3436b1737e50 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 6 Nov 2013 20:56:18 +0000 Subject: Fix [#34675] *AFTER 2.69* Info view shows duplicate operators with incorrect values of args Refactored a bit WM api to generate operator's pystring, now it can also handle correctly macro operators. Thanks to Campbell for the review! --- .../blender/editors/interface/interface_handlers.c | 2 +- .../blender/editors/interface/interface_layout.c | 2 +- .../blender/editors/interface/interface_regions.c | 2 +- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_access.c | 4 +- source/blender/python/intern/bpy_operator.c | 2 +- source/blender/windowmanager/WM_api.h | 4 +- .../blender/windowmanager/intern/wm_event_system.c | 6 +- source/blender/windowmanager/intern/wm_operators.c | 71 ++++++++++++++++------ source/blenderplayer/bad_level_call_stubs/stubs.c | 3 +- 10 files changed, 68 insertions(+), 29 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 8a0b3a500b5..903a5e72499 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1534,7 +1534,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char *str; opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ - str = WM_operator_pystring(C, but->optype, opptr, 0); + str = WM_operator_pystring_ex(C, NULL, false, but->optype, opptr); WM_clipboard_text_set(str, 0); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b453a3b8363..89c244009e5 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2931,7 +2931,7 @@ static void ui_intro_button(DynStr *ds, uiButtonItem *bitem) BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); /* not exactly needed, rna has this */ if (but->optype) { - char *opstr = WM_operator_pystring(but->block->evil_C, but->optype, but->opptr, 0); + char *opstr = WM_operator_pystring_ex(but->block->evil_C, NULL, false, but->optype, but->opptr); BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : ""); MEM_freeN(opstr); } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 15fbd51c6fc..3ef613f5867 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -539,7 +539,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* so the context is passed to itemf functions (some py itemf functions use it) */ WM_operator_properties_sanitize(opptr, false); - str = WM_operator_pystring(C, but->optype, opptr, 0); + str = WM_operator_pystring_ex(C, NULL, false, but->optype, opptr); /* operator info */ if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) { diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index b4b79059f93..f5afff56545 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -1034,6 +1034,7 @@ void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier); /* python compatible string representation of this property, (must be freed!) */ char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index, int max_prop_length); +char *RNA_pointer_as_string_id(struct bContext *C, PointerRNA *ptr); char *RNA_pointer_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop_ptr, PointerRNA *ptr_prop); char *RNA_pointer_as_string_keywords_ex(struct bContext *C, PointerRNA *ptr, const bool skip_optional_value, const bool all_args, diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index fe457a14718..6c216936190 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4980,7 +4980,7 @@ bool RNA_property_is_unlink(PropertyRNA *prop) /* string representation of a property, python * compatible but can be used for display too, * context may be NULL */ -static char *rna_pointer_as_string__idprop(bContext *C, PointerRNA *ptr) +char *RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr) { DynStr *dynstr = BLI_dynstr_new(); char *cstring; @@ -5031,7 +5031,7 @@ static char *rna_pointer_as_string__bldata(PointerRNA *ptr) char *RNA_pointer_as_string(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *prop_ptr, PointerRNA *ptr_prop) { if (RNA_property_flag(prop_ptr) & PROP_IDPROPERTY) { - return rna_pointer_as_string__idprop(C, ptr_prop); + return RNA_pointer_as_string_id(C, ptr_prop); } else { return rna_pointer_as_string__bldata(ptr_prop); diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index d13ec3c461a..754952cd65f 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -345,7 +345,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) error_val = pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: "); if (error_val == 0) - buf = WM_operator_pystring(C, ot, &ptr, all_args); + buf = WM_operator_pystring_ex(C, NULL, all_args, ot, &ptr); WM_operator_properties_free(&ptr); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 75a6e4465bf..1f38368399a 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -272,7 +272,9 @@ bool WM_operator_last_properties_store(struct wmOperator *op); /* operator as a python command (resultuing string must be freed) */ -char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args); +char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op, const bool all_args, + struct wmOperatorType *ot, struct PointerRNA *opptr); +char *WM_operator_pystring(struct bContext *C, struct wmOperator *op, const bool all_args); char *WM_prop_pystring_assign(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int index); void WM_operator_bl_idname(char *to, const char *from); void WM_operator_py_idname(char *to, const char *from); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 825c1ca9252..d60901f1325 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -491,7 +491,7 @@ int WM_operator_poll_context(bContext *C, wmOperatorType *ot, short context) static void wm_operator_print(bContext *C, wmOperator *op) { /* context is needed for enum function */ - char *buf = WM_operator_pystring(C, op->type, op->ptr, false); + char *buf = WM_operator_pystring(C, op, false); printf("%s\n", buf); MEM_freeN(buf); } @@ -626,7 +626,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal if (op->type->flag & OPTYPE_REGISTER) { if (G.background == 0) { /* ends up printing these in the terminal, gets annoying */ /* Report the python string representation of the operator */ - char *buf = WM_operator_pystring(C, op->type, op->ptr, false); + char *buf = WM_operator_pystring(C, op, false); BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); MEM_freeN(buf); } @@ -660,7 +660,7 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) if (repeat == 0) { if (G.debug & G_DEBUG_WM) { - char *buf = WM_operator_pystring(C, op->type, op->ptr, false); + char *buf = WM_operator_pystring(C, op, false); BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); MEM_freeN(buf); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index eb42f44b696..ab8dac396c5 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -521,13 +521,14 @@ void WM_operator_bl_idname(char *to, const char *from) to[0] = 0; } -/* print a string representation of the operator, with the args that it runs - * so python can run it again, +/* Print a string representation of the operator, with the args that it runs so python can run it again. * - * When calling from an existing wmOperator do. - * WM_operator_pystring(op->type, op->ptr); + * When calling from an existing wmOperator, better to use simple version: + * WM_operator_pystring(C, op); + * + * Note: both op and opptr may be NULL (op is only used for macro operators). */ -char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, int all_args) +char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, wmOperatorType *ot, PointerRNA *opptr) { char idname_py[OP_MAX_TYPENAME]; @@ -539,24 +540,53 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i /* arbitrary, but can get huge string with stroke painting otherwise */ int max_prop_length = 10; - /* only to get the orginal props for comparisons */ - PointerRNA opptr_default; + WM_operator_py_idname(idname_py, ot->idname); + BLI_dynstr_appendf(dynstr, "bpy.ops.%s(", idname_py); + + if (op && op->macro.first) { + /* Special handling for macros, else we only get default values in this case... */ + wmOperator *opm; + bool first_op = true; + for (opm = op->macro.first; opm; opm = opm->next) { + PointerRNA *opmptr = opm->ptr; + PointerRNA opmptr_default; + if (opmptr == NULL) { + WM_operator_properties_create_ptr(&opmptr_default, opm->type); + opmptr = &opmptr_default; + } + + cstring_args = RNA_pointer_as_string_id(C, opmptr); + if (first_op) { + BLI_dynstr_appendf(dynstr, "%s=%s", opm->type->idname, cstring_args); + first_op = false; + } + else { + BLI_dynstr_appendf(dynstr, ", %s=%s", opm->type->idname, cstring_args); + } + MEM_freeN(cstring_args); - if (opptr == NULL) { - WM_operator_properties_create_ptr(&opptr_default, ot); - opptr = &opptr_default; + if (opmptr == &opmptr_default) { + WM_operator_properties_free(&opmptr_default); + } + } } + else { + /* only to get the orginal props for comparisons */ + PointerRNA opptr_default; - WM_operator_py_idname(idname_py, ot->idname); - BLI_dynstr_appendf(dynstr, "bpy.ops.%s(", idname_py); + if (opptr == NULL) { + WM_operator_properties_create_ptr(&opptr_default, ot); + opptr = &opptr_default; + } - cstring_args = RNA_pointer_as_string_keywords(C, opptr, false, - all_args, max_prop_length); - BLI_dynstr_append(dynstr, cstring_args); - MEM_freeN(cstring_args); + cstring_args = RNA_pointer_as_string_keywords(C, opptr, false, all_args, max_prop_length); + BLI_dynstr_append(dynstr, cstring_args); + MEM_freeN(cstring_args); - if (opptr == &opptr_default) - WM_operator_properties_free(&opptr_default); + if (opptr == &opptr_default) { + WM_operator_properties_free(&opptr_default); + } + } BLI_dynstr_append(dynstr, ")"); @@ -565,6 +595,11 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i return cstring; } +char *WM_operator_pystring(bContext *C, wmOperator *op, const bool all_args) +{ + return WM_operator_pystring_ex(C, op, all_args, op->type, op->ptr); +} + /* return NULL if no match is found */ #if 0 static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 2916dddc68f..80f3a617bac 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -541,7 +541,8 @@ void WM_operator_py_idname(char *to, const char *from) {STUB_ASSERT(0);} void WM_operator_ui_popup(struct bContext *C, struct wmOperator *op, int width, int height) {STUB_ASSERT(0);} short insert_keyframe(struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag) {STUB_ASSERT(0); return 0;} short delete_keyframe(struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag) {STUB_ASSERT(0); return 0;} -char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args) {STUB_ASSERT(0); return (char *)NULL;} +char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op, const bool all_args, struct wmOperatorType *ot, struct PointerRNA *opptr) {STUB_ASSERT(0); return (char *)NULL;} +char *WM_operator_pystring(struct bContext *C, struct wmOperator *op, const bool all_args) {STUB_ASSERT(0); return (char *)NULL;} struct wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value) {STUB_ASSERT(0); return (struct wmKeyMapItem *)NULL;} struct wmKeyMapItem *WM_modalkeymap_add_item_str(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value) {STUB_ASSERT(0); return (struct wmKeyMapItem *)NULL;} struct wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, EnumPropertyItem *items) {STUB_ASSERT(0); return (struct wmKeyMap *) NULL;} -- cgit v1.2.3 From f392ebd77ed1df0f6fe8588acc6b46a9e2719252 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Wed, 6 Nov 2013 20:59:04 +0000 Subject: OSX/scons: huge change, now you can set a user-config.py just with the desired variables changed --- SConstruct | 119 +++++++++++++++++++++++-- build_files/scons/config/darwin-config.py | 139 ++++-------------------------- build_files/scons/tools/btools.py | 3 +- 3 files changed, 131 insertions(+), 130 deletions(-) diff --git a/SConstruct b/SConstruct index 4ef56db46d4..3ffd3f42b32 100644 --- a/SConstruct +++ b/SConstruct @@ -285,17 +285,99 @@ if 'cudakernels' in B.targets: env['WITH_BF_CYCLES_CUDA_BINARIES'] = True env['WITH_BF_PYTHON'] = False -# Extended OSX_SDK and 3D_CONNEXION_CLIENT_LIBRARY and JAckOSX detection for OSX + +############################################################################# +################### Automatic configuration for OSX ################## +############################################################################# + if env['OURPLATFORM']=='darwin': + + import commands + + cmd = 'uname -p' + MAC_PROC=commands.getoutput(cmd) + cmd = 'sw_vers -productVersion' + MAC_CUR_VER=cmd_res=commands.getoutput(cmd) + cmd = 'xcodebuild -version' + cmd_xcode=commands.getoutput(cmd) + env['XCODE_CUR_VER']=cmd_xcode[6:][:3] # truncate output to major.minor version + cmd = 'xcodebuild -showsdks' + cmd_sdk=commands.getoutput(cmd) + env['MACOSX_SDK_CHECK']=cmd_sdk + cmd = 'xcode-select --print-path' + XCODE_SELECT_PATH=commands.getoutput(cmd) + if XCODE_SELECT_PATH.endswith("/Contents/Developer"): + XCODE_BUNDLE=XCODE_SELECT_PATH[:-19] + else: + XCODE_BUNDLE=XCODE_SELECT_PATH + print B.bc.OKGREEN + "Detected Xcode version: -- " + B.bc.ENDC + env['XCODE_CUR_VER'] + " --" print "Available " + env['MACOSX_SDK_CHECK'] - if not 'Mac OS X 10.6' in env['MACOSX_SDK_CHECK']: - print B.bc.OKGREEN + "Building with user-defined OS X SDK ( Xcode 4.4 or newer )" - elif not 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']: - print B.bc.OKGREEN + "Auto-setting available MacOSX SDK -> " + B.bc.ENDC + "MacOSX10.6.sdk" + + if env['MACOSX_SDK'] == '': # no set sdk, choosing best one found + if 'OS X 10.9' in env['MACOSX_SDK_CHECK']: + env['MACOSX_DEPLOYMENT_TARGET'] = '10.6' + env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.9.sdk' + elif 'OS X 10.8' in env['MACOSX_SDK_CHECK']: + env['MACOSX_DEPLOYMENT_TARGET'] = '10.6' + env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.8.sdk' + elif 'OS X 10.7' in env['MACOSX_SDK_CHECK']: + env['MACOSX_DEPLOYMENT_TARGET'] = '10.6' + env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.7.sdk' + elif 'OS X 10.6' in env['MACOSX_SDK_CHECK']: + env['MACOSX_DEPLOYMENT_TARGET'] = '10.6' + env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.6.sdk' + elif 'OS X 10.5' in env['MACOSX_SDK_CHECK']: + env['MACOSX_DEPLOYMENT_TARGET'] = '10.5' + env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.5.sdk' + else: + env['MACOSX_SDK']='/Developer/SDKs/MacOSX' + env['MACOSX_SDK'] + '.sdk' + + if env['XCODE_CUR_VER'] >= '4.3': ## since version 4.3, XCode and developer dir are bundled ## + env['MACOSX_SDK'] = XCODE_BUNDLE + '/Contents/Developer/Platforms/MacOSX.platform' + env['MACOSX_SDK'] + print B.bc.OKGREEN + "Using OSX SDK :" + B.bc.ENDC + env['MACOSX_SDK'] + + if not env['WITH_OSX_STATICPYTHON'] == 1: + # python 3.3 uses Python-framework additionally installed in /Library/Frameworks + env['BF_PYTHON'] = '/Library/Frameworks/Python.framework/Versions/' + env['BF_PYTHON_INC'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/include/python' + env['BF_PYTHON_VERSION'] + 'm' + env['BF_PYTHON_BINARY'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/bin/python' + env['BF_PYTHON_VERSION'] + env['BF_PYTHON_LIB'] = '' + env['BF_PYTHON_LIBPATH'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/lib/python' + env['BF_PYTHON_VERSION'] + '/config-' + env['BF_PYTHON_VERSION'] +'m' + + #Ray trace optimization + if env['WITH_BF_RAYOPTIMIZATION'] == 1: + if env['MACOSX_ARCHITECTURE'] == 'x86_64' or env['MACOSX_ARCHITECTURE'] == 'i386': + env['WITH_BF_RAYOPTIMIZATION'] = 1 + else: + env['WITH_BF_RAYOPTIMIZATION'] = 0 + if env['MACOSX_ARCHITECTURE'] == 'i386': + env['BF_RAYOPTIMIZATION_SSE_FLAGS'] = env['BF_RAYOPTIMIZATION_SSE_FLAGS']+['-msse'] + elif env['MACOSX_ARCHITECTURE'] == 'x86_64': + env['BF_RAYOPTIMIZATION_SSE_FLAGS'] = env['BF_RAYOPTIMIZATION_SSE_FLAGS']+['-msse','-msse2'] + + if env['MACOSX_ARCHITECTURE'] == 'x86_64' or env['MACOSX_ARCHITECTURE'] == 'ppc64': + ARCH_FLAGS = ['-m64'] else: - print B.bc.OKGREEN + "Found recommended sdk :" + B.bc.ENDC + " using MacOSX10.5.sdk" + ARCH_FLAGS = ['-m32'] + env['CPPFLAGS'] = list(ARCH_FLAGS) + + SDK_FLAGS=['-isysroot', env['MACOSX_SDK'],'-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-arch',env['MACOSX_ARCHITECTURE']] # always used + env['PLATFORM_LINKFLAGS'] = ['-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-isysroot', env['MACOSX_SDK'],'-arch',env['MACOSX_ARCHITECTURE']]+env['PLATFORM_LINKFLAGS'] + env['CCFLAGS']=SDK_FLAGS+env['CCFLAGS'] + env['CXXFLAGS']=SDK_FLAGS+env['CXXFLAGS'] + + #Intel Macs are CoreDuo and Up + if env['MACOSX_ARCHITECTURE'] == 'i386' or env['MACOSX_ARCHITECTURE'] == 'x86_64': + env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-ftree-vectorize','-msse','-msse2','-msse3'] + else: + env['CCFLAGS'] = env['CCFLAGS']+['-fno-strict-aliasing'] + + # Intel 64bit Macs are Core2Duo and up + if env['MACOSX_ARCHITECTURE'] == 'x86_64': + env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-mssse3'] + if env['XCODE_CUR_VER'] >= '5' and not (env['CXX'][:-2].endswith('4.6') or env['CXX'][:-2].endswith('4.8')): env['CCFLAGS'].append('-ftemplate-depth=1024') # only valid for clang bundled with xcode 5 @@ -320,17 +402,40 @@ if env['OURPLATFORM']=='darwin': else: env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','Jackmp']) + if env['WITH_BF_QUICKTIME'] == 1: + env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','QTKit'] + + if not env['WITH_OSX_STATICPYTHON'] == 1: + env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','Python'] + + #Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer ) + # if your compiler does not have accurate suffix you may have to enable it by hand ! + if env['CC'][:-2].endswith('4.6') or env['CC'][:-2].endswith('4.8'): + env['WITH_BF_OPENMP'] = 1 # multithreading for fluids, cloth, sculpt and smoke + else: + env['WITH_BF_OPENMP'] = 0 + + env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+ARCH_FLAGS + if env['WITH_BF_CYCLES_OSL'] == 1: OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath # we need 2 variants of passing the oslexec with the force_load option, string and list type atm if env['CC'][:-2].endswith('4.8'): - env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-loslexec','-loslquery']) + env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-loslexec','-loslquery']) else: env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-force_load '+ OSX_OSL_LIBPATH +'/liboslexec.a','-loslquery']) env.Append(BF_PROGRAM_LINKFLAGS=['-Xlinker','-force_load','-Xlinker',OSX_OSL_LIBPATH +'/liboslexec.a']) # Trying to get rid of eventually clashes, we export some explicite as local symbols env.Append(LINKFLAGS=['-Xlinker','-unexported_symbols_list','-Xlinker','./source/creator/osx_locals.map']) + + #for < 10.7.sdk, SystemStubs needs to be linked + if env['MACOSX_SDK'].endswith("10.6.sdk") or env['MACOSX_SDK'].endswith("10.5.sdk"): + env['LLIBS'].append('SystemStubs') + +############################################################################# +################### End Automatic configuration for OSX ################## +############################################################################# if env['WITH_BF_OPENMP'] == 1: if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 84665548d96..2d658fcb756 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -1,55 +1,12 @@ -# -# Note : if you want to alter this file -# copy it as a whole in the upper folder -# as user-config.py -# dont create a new file with only some -# vars changed. - import commands -# IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs -USE_SDK=True - ############################################################################# -################### Cocoa & architecture settings ################## +################### Compiler & architecture settings ################## ############################################################################# MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64 - - -cmd = 'uname -p' -MAC_PROC=commands.getoutput(cmd) -cmd = 'sw_vers -productVersion' -MAC_CUR_VER=cmd_res=commands.getoutput(cmd) -cmd = 'xcodebuild -version' -cmd_xcode=commands.getoutput(cmd) -XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version -cmd = 'xcodebuild -showsdks' -cmd_sdk=commands.getoutput(cmd) -MACOSX_SDK_CHECK=cmd_sdk -cmd = 'xcode-select --print-path' -XCODE_SELECT_PATH=commands.getoutput(cmd) -if XCODE_SELECT_PATH.endswith("/Contents/Developer"): - XCODE_BUNDLE=XCODE_SELECT_PATH[:-19] -else: - XCODE_BUNDLE=XCODE_SELECT_PATH - - -# Default target OSX settings per architecture -# Can be customized - -if 'Mac OS X 10.5' in MACOSX_SDK_CHECK: - # OSX 10.5/6 with Xcode 3.x - MACOSX_DEPLOYMENT_TARGET = '10.5' - MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' -elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK: - # OSX 10.6/7 with Xcode 4.x - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk' -else: - # OSX 10.7/8/9 with Xcode 4.4 and higher (no 10.6sdk! ) - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk' +MACOSX_SDK='' # set an sdk name like '10.7' or leave empty for automatic choosing highest available +MACOSX_DEPLOYMENT_TARGET = '10.6' # gcc always defaults to the system standard compiler linked by a shim or symlink CC = 'gcc' @@ -57,20 +14,10 @@ CXX = 'g++' LCGDIR = '#../lib/darwin-9.x.universal' LIBDIR = '${LCGDIR}' -if XCODE_CUR_VER >= '4.3': ## since version 4.3, XCode and developer dir are bundled ## - MACOSX_SDK = XCODE_BUNDLE + '/Contents/Developer/Platforms/MacOSX.platform' + MACOSX_SDK - ############################################################################# ################### Dependency settings ################## ############################################################################# -#Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer ) -# if your compiler does not have accurate suffix you may have to enable it by hand ! -if CC[:-2].endswith('4.6') or CC[:-2].endswith('4.8'): - WITH_BF_OPENMP = True # multithreading for fluids, cloth, sculpt and smoke -else: - WITH_BF_OPENMP = False - # enable ffmpeg support WITH_BF_FFMPEG = True BF_FFMPEG = LIBDIR + '/ffmpeg' @@ -82,23 +29,13 @@ BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore BF_PYTHON_VERSION = '3.3' WITH_OSX_STATICPYTHON = True -if WITH_OSX_STATICPYTHON: - # python 3.3 uses precompiled libraries in bf svn /lib by default - - BF_PYTHON = LIBDIR + '/python' - BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m' - # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}' - BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m' - BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}' - # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System'] -else: - # python 3.2 uses Python-framework additionally installed in /Library/Frameworks - - BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/' - BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}m' - BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}' - #BF_PYTHON_LIB = '' - BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config-${BF_PYTHON_VERSION}m' +# python 3.3 uses precompiled libraries in bf svn /lib by default +BF_PYTHON = LIBDIR + '/python' +BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m' +# BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}' +BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m' +BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}' +# BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System'] WITH_BF_OPENAL = True BF_OPENAL = LIBDIR + '/openal' @@ -275,14 +212,8 @@ BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35'] WITH_BF_FREESTYLE = True #Ray trace optimization -if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386': - WITH_BF_RAYOPTIMIZATION = True -else: - WITH_BF_RAYOPTIMIZATION = False -if MACOSX_ARCHITECTURE == 'i386': - BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse'] -elif MACOSX_ARCHITECTURE == 'x86_64': - BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2'] +WITH_BF_RAYOPTIMIZATION = True +BF_RAYOPTIMIZATION_SSE_FLAGS = [] # SpaceNavigator and related 3D mice, driver must be 3DxWare 10 Beta 4 (Mac OS X) or later ! WITH_BF_3DMOUSE = True @@ -293,53 +224,17 @@ WITH_BF_3DMOUSE = True BF_QUIET = '1' # suppress verbose output -if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64': - ARCH_FLAGS = ['-m64'] -else: - ARCH_FLAGS = ['-m32'] - CFLAGS = [] CXXFLAGS = [] CCFLAGS = ['-pipe','-funsigned-char'] +PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL'] -CPPFLAGS = list(ARCH_FLAGS) - -PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS - -if WITH_BF_QUICKTIME: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit'] - -if not WITH_OSX_STATICPYTHON: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python'] - - -#for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore) -if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk") or MACOSX_SDK.endswith("10.9.sdk"): - LLIBS = ['stdc++'] -else: - LLIBS = ['stdc++', 'SystemStubs'] - -if USE_SDK: - SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MACOSX_DEPLOYMENT_TARGET,'-arch',MACOSX_ARCHITECTURE] - PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MACOSX_DEPLOYMENT_TARGET,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS - CCFLAGS=SDK_FLAGS+CCFLAGS - CXXFLAGS=SDK_FLAGS+CXXFLAGS - -#Intel Macs are CoreDuo and Up -if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64': - REL_CFLAGS = [] - REL_CXXFLAGS = [] - REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3'] -else: - CCFLAGS += ['-fno-strict-aliasing'] - REL_CFLAGS = [] - REL_CXXFLAGS = [] - REL_CCFLAGS = ['-DNDEBUG', '-O2'] +LLIBS = ['stdc++'] -# Intel 64bit Macs are Core2Duo and up -if MACOSX_ARCHITECTURE == 'x86_64': - REL_CCFLAGS += ['-mssse3'] +REL_CFLAGS = [] +REL_CXXFLAGS = [] +REL_CCFLAGS = ['-DNDEBUG', '-O2'] CC_WARN = ['-Wall'] C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes'] diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 65cbcf4e1ec..c542435fb47 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -179,7 +179,7 @@ def validate_arguments(args, bc): 'BF_PROFILE_CFLAGS', 'BF_PROFILE_CCFLAGS', 'BF_PROFILE_CXXFLAGS', 'BF_PROFILE_LINKFLAGS', 'BF_DEBUG_CFLAGS', 'BF_DEBUG_CCFLAGS', 'BF_DEBUG_CXXFLAGS', 'C_WARN', 'CC_WARN', 'CXX_WARN', - 'LLIBS', 'PLATFORM_LINKFLAGS','MACOSX_ARCHITECTURE', 'MACOSX_SDK_CHECK', 'XCODE_CUR_VER', + 'LLIBS', 'PLATFORM_LINKFLAGS', 'MACOSX_ARCHITECTURE', 'MACOSX_SDK', 'MACOSX_SDK_CHECK', 'XCODE_CUR_VER', 'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS', 'MACOSX_DEPLOYMENT_TARGET' ] @@ -501,6 +501,7 @@ def read_opts(env, cfg, args): ('LLIBS', 'Platform libs', []), ('PLATFORM_LINKFLAGS', 'Platform linkflags', []), ('MACOSX_ARCHITECTURE', 'python_arch.zip select', ''), + ('MACOSX_SDK', 'Set OS X SDK', ''), ('MACOSX_SDK_CHECK', 'Detect available OS X SDK`s', ''), ('XCODE_CUR_VER', 'Detect XCode version', ''), ('MACOSX_DEPLOYMENT_TARGET', 'Detect OS X target version', ''), -- cgit v1.2.3 From 232c97fdebe046f55fe30a840c51141644092e96 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 6 Nov 2013 21:08:16 +0000 Subject: Fix for error in r61159: the new gpencil_new_layer_col in UserDef is supposed to be a 4 float RGBA color, but has only 3 floats. This was overwriting tweak_threshold in UserDef and breaking transform operators ... --- source/blender/makesdna/DNA_userdef_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index ae01536eebe..37d5f313dfb 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -474,7 +474,7 @@ typedef struct UserDef { struct ColorBand coba_weight; /* from texture.h */ float sculpt_paint_overlay_col[3]; - float gpencil_new_layer_col[3]; /* default color for newly created Grease Pencil layers */ + float gpencil_new_layer_col[4]; /* default color for newly created Grease Pencil layers */ short tweak_threshold; short pad3; -- cgit v1.2.3 From f07ed3c27032b8f132a7ca8294df1a3b91946fcf Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 6 Nov 2013 21:21:37 +0000 Subject: Removed the automatic "link swapping" feature from the node link operator: When a link was being dragged to an already connected input, the existing links were shifted to the next free socket. This was originally intended as a way to speed up workflow for math and mix nodes, but more often than not it just gets in the way. Most binary (or n-ary) functions are not even commutative, i.e. changing the order of sockets does not usually produce the correct result. Also this includes the more common case where one actually wants to replace a socket, which then requires a second click to remove the shifted connection. All in all this is not a helpful feature. --- .../editors/space_node/node_relationships.c | 53 +++++++++------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index a8c619a15fb..4304ee6c418 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -395,38 +395,28 @@ void NODE_OT_link_viewer(wmOperatorType *ot) /* *************************** add link op ******************** */ -static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeLink *link) +static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link) { + bNodeTree *ntree = snode->edittree; + bNodeSocket *from = link->fromsock, *to = link->tosock; + int max_from = from->limit, max_to = to->limit; + int count_from = 1, count_to = 1; /* start at 1, link is included */ bNodeLink *tlink; - bNodeSocket *sock; - - if (tsock && nodeCountSocketLinks(snode->edittree, link->tosock) > tsock->limit) { - - for (tlink = snode->edittree->links.first; tlink; tlink = tlink->next) { - if (link != tlink && tlink->tosock == link->tosock) - break; + + for (tlink = ntree->links.first; tlink; tlink = tlink->next) { + if (tlink == link) + continue; + + if (tlink->fromsock == from) { + ++count_from; + if (count_from > max_from) + nodeRemLink(ntree, tlink); } - if (tlink) { - /* try to move the existing link to the next available socket */ - if (tlink->tonode) { - /* is there a free input socket with the target type? */ - for (sock = tlink->tonode->inputs.first; sock; sock = sock->next) { - if (sock->type == tlink->tosock->type) - if (nodeCountSocketLinks(snode->edittree, sock) < sock->limit) - break; - } - if (sock) { - tlink->tosock = sock; - sock->flag &= ~SOCK_HIDDEN; - } - else { - nodeRemLink(snode->edittree, tlink); - } - } - else - nodeRemLink(snode->edittree, tlink); - - snode->edittree->update |= NTREE_UPDATE_LINKS; + + if (tlink->tosock == to) { + ++count_to; + if (count_to > max_to) + nodeRemLink(ntree, tlink); } } } @@ -527,8 +517,7 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event) link->tonode->update |= NODE_UPDATE; /* we might need to remove a link */ - if (in_out == SOCK_OUT) - node_remove_extra_links(snode, link->tosock, link); + node_remove_extra_links(snode, link); } else nodeRemLink(ntree, link); @@ -1325,7 +1314,7 @@ void ED_node_link_insert(ScrArea *sa) link->tonode = select; link->tosock = best_input; - node_remove_extra_links(snode, link->tosock, link); + node_remove_extra_links(snode, link); link->flag &= ~NODE_LINKFLAG_HILITE; nodeAddLink(snode->edittree, select, best_output, node, sockto); -- cgit v1.2.3 From ec470d731e5a715fe10f7210bb06f996f141814c Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Wed, 6 Nov 2013 23:19:01 +0000 Subject: OSX/scons: for completeness, added WITH_BF_OPENMP switch --- SConstruct | 9 +++++---- build_files/scons/config/darwin-config.py | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 3ffd3f42b32..c4079341df9 100644 --- a/SConstruct +++ b/SConstruct @@ -410,10 +410,11 @@ if env['OURPLATFORM']=='darwin': #Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer ) # if your compiler does not have accurate suffix you may have to enable it by hand ! - if env['CC'][:-2].endswith('4.6') or env['CC'][:-2].endswith('4.8'): - env['WITH_BF_OPENMP'] = 1 # multithreading for fluids, cloth, sculpt and smoke - else: - env['WITH_BF_OPENMP'] = 0 + if env['WITH_BF_OPENMP'] == 1: + if env['CC'][:-2].endswith('4.6') or env['CC'][:-2].endswith('4.8'): + env['WITH_BF_OPENMP'] = 1 # multithreading for fluids, cloth, sculpt and smoke + else: + env['WITH_BF_OPENMP'] = 0 env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+ARCH_FLAGS diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 2d658fcb756..0b0120e4473 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -211,6 +211,9 @@ BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35'] #Freestyle WITH_BF_FREESTYLE = True +#OpenMP ( will be checked for compiler support and turned off eventually ) +WITH_BF_OPENMP = True + #Ray trace optimization WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = [] -- cgit v1.2.3 From 921d3555edda3c43bba7f45c5892310263b4e0e6 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 7 Nov 2013 08:33:09 +0000 Subject: Fix #37348, Different behaviour in Node editor. Adding nodes from the search operator now also removes them again if the subsequent transform is cancelled, like with the regular node shift+A menu operators. --- release/scripts/startup/bl_operators/node.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py index 77978c71ed9..0814d0144ab 100644 --- a/release/scripts/startup/bl_operators/node.py +++ b/release/scripts/startup/bl_operators/node.py @@ -222,7 +222,7 @@ class NODE_OT_add_search(NodeAddOperator, Operator): self.create_node(context, item.nodetype) if self.use_transform: - bpy.ops.transform.translate('INVOKE_DEFAULT') + bpy.ops.transform.translate('INVOKE_DEFAULT', remove_on_cancel=True) return {'FINISHED'} else: -- cgit v1.2.3 From be09e694b1a983b2aeb158290bb6dc831e1b8622 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 7 Nov 2013 08:40:47 +0000 Subject: Fix #37338: Add objects from addon work in a Linked Scene Added a poll function to add object helper which checks whether scene is linked or not. All the primitives which are delivered from this helper will work properly for linked scenes. If there're still primitives which are not delivered from this class, well nothing i can do now. --- release/scripts/modules/bpy_extras/object_utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py index 7ce5aff581a..a14f0128444 100644 --- a/release/scripts/modules/bpy_extras/object_utils.py +++ b/release/scripts/modules/bpy_extras/object_utils.py @@ -201,6 +201,10 @@ class AddObjectHelper: subtype='EULER', ) + @classmethod + def poll(self, context): + return context.scene.library is None + def object_add_grid_scale(context): """ -- cgit v1.2.3 From 9708f7921d3c865107f371349dc2a6726775f92c Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 7 Nov 2013 09:02:29 +0000 Subject: Cleanup: nice bool return value from ed_node_link_conditions function instead of using the space pointer for this. --- .../editors/space_node/node_relationships.c | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 4304ee6c418..23ecb87151b 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -1173,52 +1173,57 @@ void NODE_OT_detach(wmOperatorType *ot) /* prevent duplicate testing code below */ -static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select) +static bool ed_node_link_conditions(ScrArea *sa, SpaceNode **r_snode, bNode **r_select) { SpaceNode *snode = sa ? sa->spacedata.first : NULL; - bNode *node; + bNode *node, *select = NULL; bNodeLink *link; - /* no unlucky accidents */ - if (sa == NULL || sa->spacetype != SPACE_NODE) return NULL; + *r_snode = snode; + *r_select = NULL; - *select = NULL; + /* no unlucky accidents */ + if (sa == NULL || sa->spacetype != SPACE_NODE) + return false; for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (*select) + if (select) break; else - *select = node; + select = node; } } /* only one selected */ - if (node || *select == NULL) return NULL; + if (node || select == NULL) + return false; /* correct node */ - if ((*select)->inputs.first == NULL || (*select)->outputs.first == NULL) return NULL; + if (select->inputs.first == NULL || select->outputs.first == NULL) + return false; /* test node for links */ for (link = snode->edittree->links.first; link; link = link->next) { if (nodeLinkIsHidden(link)) continue; - if (link->tonode == *select || link->fromnode == *select) - return NULL; + if (link->tonode == select || link->fromnode == select) + return false; } - return snode; + *r_select = select; + return true; } /* test == 0, clear all intersect flags */ void ED_node_link_intersect_test(ScrArea *sa, int test) { bNode *select; - SpaceNode *snode = ed_node_link_conditions(sa, &select); + SpaceNode *snode; bNodeLink *link, *selink = NULL; float mcoords[6][2]; - if (snode == NULL) return; + if (!ed_node_link_conditions(sa, &snode, &select)) return; /* clear flags */ for (link = snode->edittree->links.first; link; link = link->next) @@ -1293,11 +1298,11 @@ static bNodeSocket *socket_best_match(ListBase *sockets) void ED_node_link_insert(ScrArea *sa) { bNode *node, *select; - SpaceNode *snode = ed_node_link_conditions(sa, &select); + SpaceNode *snode; bNodeLink *link; bNodeSocket *sockto; - if (snode == NULL) return; + if (!ed_node_link_conditions(sa, &snode, &select)) return; /* get the link */ for (link = snode->edittree->links.first; link; link = link->next) -- cgit v1.2.3 From 81184c61734e16286f48b57ee9d5f32ade5eb5ad Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 7 Nov 2013 09:02:30 +0000 Subject: Fix for node link highlighting not getting reset if a transform operator is cancelled and the node removed. Pass the 'test' option in node link insert testing on to the conditions function, so that at least the highlight flags get cleared before exiting the link insert function, even if there is no actual selected node to insert. --- source/blender/editors/space_node/node_relationships.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 23ecb87151b..9f5e8a6f9d9 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -1173,7 +1173,7 @@ void NODE_OT_detach(wmOperatorType *ot) /* prevent duplicate testing code below */ -static bool ed_node_link_conditions(ScrArea *sa, SpaceNode **r_snode, bNode **r_select) +static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, bNode **r_select) { SpaceNode *snode = sa ? sa->spacedata.first : NULL; bNode *node, *select = NULL; @@ -1186,6 +1186,11 @@ static bool ed_node_link_conditions(ScrArea *sa, SpaceNode **r_snode, bNode **r_ if (sa == NULL || sa->spacetype != SPACE_NODE) return false; + if (!test) { + /* no need to look for a node */ + return true; + } + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { if (select) @@ -1223,7 +1228,7 @@ void ED_node_link_intersect_test(ScrArea *sa, int test) bNodeLink *link, *selink = NULL; float mcoords[6][2]; - if (!ed_node_link_conditions(sa, &snode, &select)) return; + if (!ed_node_link_conditions(sa, test, &snode, &select)) return; /* clear flags */ for (link = snode->edittree->links.first; link; link = link->next) @@ -1302,7 +1307,7 @@ void ED_node_link_insert(ScrArea *sa) bNodeLink *link; bNodeSocket *sockto; - if (!ed_node_link_conditions(sa, &snode, &select)) return; + if (!ed_node_link_conditions(sa, true, &snode, &select)) return; /* get the link */ for (link = snode->edittree->links.first; link; link = link->next) -- cgit v1.2.3 From c2aca3b517bc27723627399008cfe9ad5248fc9a Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 7 Nov 2013 09:15:29 +0000 Subject: Fix for node transform offsets when adding new nodes: The transform operator was using the node->totr rect for defining the initial location of the node - but this is only defined after the node has been drawn at least once, so nodes would jump to (0,0) after adding ... Use the locx/locy instead (including DPI factor), which is more reliable. --- source/blender/editors/transform/transform_conversions.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 5332e843ea1..06da1edbcdc 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5963,8 +5963,9 @@ static void createTransObject(bContext *C, TransInfo *t) static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) { /* use top-left corner as the transform origin for nodes */ - td2d->loc[0] = node->totr.xmin; - td2d->loc[1] = node->totr.ymax; + /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */ + td2d->loc[0] = UI_DPI_FAC * node->locx; + td2d->loc[1] = UI_DPI_FAC * node->locy; td2d->loc[2] = 0.0f; td2d->loc2d = td2d->loc; /* current location */ @@ -5973,8 +5974,8 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) td->loc = td2d->loc; copy_v3_v3(td->iloc, td->loc); /* use node center instead of origin (top-left corner) */ - td->center[0] = BLI_rctf_cent_x(&node->totr); - td->center[1] = BLI_rctf_cent_y(&node->totr); + td->center[0] = td2d->loc[0] + BLI_rctf_size_x(&node->totr); + td->center[1] = td2d->loc[1] + BLI_rctf_size_y(&node->totr); td->center[2] = 0.0f; memset(td->axismtx, 0, sizeof(td->axismtx)); -- cgit v1.2.3 From bef6b06a47d9cdedf73324c298e038706e6eb888 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Thu, 7 Nov 2013 12:33:35 +0000 Subject: Fix for [#36819] *AFTER 2.69* Audio Only Sequencer wont render The original description is not a bug, but the mixdown options were missing as scons was lacking the required defines during compile time. --- source/blender/editors/sound/SConscript | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/sound/SConscript b/source/blender/editors/sound/SConscript index 016f8055da0..33feedf51cc 100644 --- a/source/blender/editors/sound/SConscript +++ b/source/blender/editors/sound/SConscript @@ -44,4 +44,10 @@ incs = ' '.join(incs) defs = [] +if env['WITH_BF_FFMPEG']: + defs.append('WITH_FFMPEG') + +if env['WITH_BF_SNDFILE']: + defs.append('WITH_SNDFILE') + env.BlenderLib ( 'bf_editors_sound', sources, Split(incs), defs, libtype=['core'], priority=[35] ) -- cgit v1.2.3 From 56e283408ace8dec9add4fa32e8f40ddeac94a36 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 7 Nov 2013 13:14:33 +0000 Subject: Fix the small mess in read versionning code (we had two "pending versioning" blocks, and a triangulate one that was outside of any block, plus I think existing "pending versionning" code was not added when 2.69.2 sub-version was created...). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moved all non-yet-versioned stuff back into a single block at the end, let’s try not to forget to integrate it for 2.69.3! ;) --- source/blender/blenloader/intern/readfile.c | 89 ++++++++++++++--------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 48c61c7db6b..e4b06aeaece 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9701,7 +9701,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } - + if (!MAIN_VERSION_ATLEAST(main, 269, 1)) { /* Removal of Cycles SSS Compatible falloff */ FOREACH_NODETREE(main, ntree, id) { @@ -9718,10 +9718,38 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } FOREACH_NODETREE_END } + if (!MAIN_VERSION_ATLEAST(main, 269, 2)) { + /* Initialize CDL settings for Color Balance nodes */ + FOREACH_NODETREE(main, ntree, id) { + if (ntree->type == NTREE_COMPOSIT) { + bNode *node; + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_COLORBALANCE) { + NodeColorBalance *n = node->storage; + if (node->custom1 == 0) { + /* LGG mode stays the same, just init CDL settings */ + ntreeCompositColorBalanceSyncFromLGG(ntree, node); + } + else if (node->custom1 == 1) { + /* CDL previously used same variables as LGG, copy them over + * and then sync LGG for comparable results in both modes. + */ + copy_v3_v3(n->offset, n->lift); + copy_v3_v3(n->power, n->gamma); + copy_v3_v3(n->slope, n->gain); + ntreeCompositColorBalanceSyncFromCDL(ntree, node); + } + } + } + } + } FOREACH_NODETREE_END + } + { bScreen *sc; ScrArea *sa; SpaceLink *sl; + Scene *scene; /* Update files using invalid (outdated) outlinevis Outliner values. */ for (sc = main->screen.first; sc; sc = sc->id.next) { @@ -9761,57 +9789,26 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } - } - if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "quad_method")) { - Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { - ModifierData *md; - for (md = ob->modifiers.first; md; md = md->next) { - if (md->type == eModifierType_Triangulate) { - TriangulateModifierData *tmd = (TriangulateModifierData *)md; - if ((tmd->flag & MOD_TRIANGULATE_BEAUTY)) { - tmd->quad_method = MOD_TRIANGULATE_QUAD_BEAUTY; - tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY; - } - else { - tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED; - tmd->ngon_method = MOD_TRIANGULATE_NGON_SCANFILL; - } - } - } - } - } - - if (!MAIN_VERSION_ATLEAST(main, 269, 2)) { - /* Initialize CDL settings for Color Balance nodes */ - FOREACH_NODETREE(main, ntree, id) { - if (ntree->type == NTREE_COMPOSIT) { - bNode *node; - for (node = ntree->nodes.first; node; node = node->next) { - if (node->type == CMP_NODE_COLORBALANCE) { - NodeColorBalance *n = node->storage; - if (node->custom1 == 0) { - /* LGG mode stays the same, just init CDL settings */ - ntreeCompositColorBalanceSyncFromLGG(ntree, node); + if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "quad_method")) { + Object *ob; + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Triangulate) { + TriangulateModifierData *tmd = (TriangulateModifierData *)md; + if ((tmd->flag & MOD_TRIANGULATE_BEAUTY)) { + tmd->quad_method = MOD_TRIANGULATE_QUAD_BEAUTY; + tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY; } - else if (node->custom1 == 1) { - /* CDL previously used same variables as LGG, copy them over - * and then sync LGG for comparable results in both modes. - */ - copy_v3_v3(n->offset, n->lift); - copy_v3_v3(n->power, n->gamma); - copy_v3_v3(n->slope, n->gain); - ntreeCompositColorBalanceSyncFromCDL(ntree, node); + else { + tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED; + tmd->ngon_method = MOD_TRIANGULATE_NGON_SCANFILL; } } } } - } FOREACH_NODETREE_END - } - - { - Scene *scene; + } for (scene = main->scene.first; scene; scene = scene->id.next) { if (scene->gm.matmode == GAME_MAT_TEXFACE) { -- cgit v1.2.3 From a0286f42f91b3001486abb8999911ebac7560491 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 7 Nov 2013 13:32:32 +0000 Subject: "Render Audio" cleanup: * Removed audio-only options from ffmpeg render settings (added some versionning code too)! * Moved the Mixdon button from the Scene->Audio pannel to the Render->Render panel. --- release/scripts/startup/bl_ui/properties_render.py | 6 ++- release/scripts/startup/bl_ui/properties_scene.py | 2 - source/blender/blenkernel/BKE_writeffmpeg.h | 47 ++++++++++++---------- source/blender/blenkernel/intern/writeffmpeg.c | 16 -------- source/blender/blenloader/CMakeLists.txt | 4 ++ source/blender/blenloader/SConscript | 3 ++ source/blender/blenloader/intern/readfile.c | 10 +++++ source/blender/makesrna/intern/rna_scene.c | 2 - 8 files changed, 46 insertions(+), 44 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 7b09fd6ab16..5061e534c9b 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -67,9 +67,11 @@ class RENDER_PT_render(RenderButtonsPanel, Panel): row = layout.row(align=True) row.operator("render.render", text="Render", icon='RENDER_STILL') row.operator("render.render", text="Animation", icon='RENDER_ANIMATION').animation = True - row.operator("render.play_rendered_anim", text="Play", icon='PLAY') + row.operator("sound.mixdown", text="Audio", icon='PLAY_AUDIO') - layout.prop(rd, "display_mode", text="Display") + split = layout.split(1 / 3) + split.operator("render.play_rendered_anim", text="Play", icon='PLAY') + split.prop(rd, "display_mode", text="Display") class RENDER_PT_dimensions(RenderButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index 5e9cbbda21f..91a5abd0ad0 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -227,8 +227,6 @@ class SCENE_PT_audio(SceneButtonsPanel, Panel): col.prop(ffmpeg, "audio_channels", text="") col.prop(ffmpeg, "audio_mixrate", text="Rate") - layout.operator("sound.mixdown") - class SCENE_PT_physics(SceneButtonsPanel, Panel): bl_label = "Gravity" diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index 8a11d48d063..347c8b60532 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -38,31 +38,34 @@ extern "C" { #endif -#define FFMPEG_MPEG1 0 -#define FFMPEG_MPEG2 1 -#define FFMPEG_MPEG4 2 -#define FFMPEG_AVI 3 -#define FFMPEG_MOV 4 -#define FFMPEG_DV 5 -#define FFMPEG_H264 6 -#define FFMPEG_XVID 7 -#define FFMPEG_FLV 8 -#define FFMPEG_MKV 9 -#define FFMPEG_OGG 10 -#define FFMPEG_WAV 11 -#define FFMPEG_MP3 12 +enum { + FFMPEG_MPEG1 = 0, + FFMPEG_MPEG2 = 1, + FFMPEG_MPEG4 = 2, + FFMPEG_AVI = 3, + FFMPEG_MOV = 4, + FFMPEG_DV = 5, + FFMPEG_H264 = 6, + FFMPEG_XVID = 7, + FFMPEG_FLV = 8, + FFMPEG_MKV = 9, + FFMPEG_OGG = 10, + FFMPEG_INVALID = 11, +}; -#define FFMPEG_PRESET_NONE 0 -#define FFMPEG_PRESET_DVD 1 -#define FFMPEG_PRESET_SVCD 2 -#define FFMPEG_PRESET_VCD 3 -#define FFMPEG_PRESET_DV 4 -#define FFMPEG_PRESET_H264 5 -#define FFMPEG_PRESET_THEORA 6 -#define FFMPEG_PRESET_XVID 7 +enum { + FFMPEG_PRESET_NONE = 0, + FFMPEG_PRESET_DVD = 1, + FFMPEG_PRESET_SVCD = 2, + FFMPEG_PRESET_VCD = 3, + FFMPEG_PRESET_DV = 4, + FFMPEG_PRESET_H264 = 5, + FFMPEG_PRESET_THEORA = 6, + FFMPEG_PRESET_XVID = 7, +}; struct IDProperty; -struct RenderData; +struct RenderData; struct ReportList; struct Scene; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 5507baecd76..bcf5e712eff 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -298,16 +298,6 @@ static const char **get_file_extensions(int format) static const char *rv[] = { ".ogv", ".ogg", NULL }; return rv; } - case FFMPEG_MP3: - { - static const char *rv[] = { ".mp3", NULL }; - return rv; - } - case FFMPEG_WAV: - { - static const char *rv[] = { ".wav", NULL }; - return rv; - } default: return NULL; } @@ -875,12 +865,6 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report case FFMPEG_FLV: fmt->video_codec = CODEC_ID_FLV1; break; - case FFMPEG_MP3: - fmt->audio_codec = CODEC_ID_MP3; - /* fall-through */ - case FFMPEG_WAV: - fmt->video_codec = CODEC_ID_NONE; - break; case FFMPEG_MPEG4: default: fmt->video_codec = CODEC_ID_MPEG4; diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index f865962bac9..24b8df78258 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -66,4 +66,8 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +if(WITH_CODEC_FFMPEG) + add_definitions(-DWITH_FFMPEG) +endif() + blender_add_lib(bf_blenloader "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/blenloader/SConscript b/source/blender/blenloader/SConscript index 3882cc1029a..bd002e59fa4 100644 --- a/source/blender/blenloader/SConscript +++ b/source/blender/blenloader/SConscript @@ -51,6 +51,9 @@ defs = [] if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') +if env['WITH_BF_FFMPEG']: + defs.append('WITH_FFMPEG') + if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): env.BlenderLib('bf_blenloader', sources, incs, defs, libtype=['core', 'player'], priority = [167, 30]) #, cc_compileflags=['/WX']) else: diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e4b06aeaece..910ff1d9ebe 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -153,6 +153,7 @@ #include "BKE_tracking.h" #include "BKE_treehash.h" #include "BKE_sound.h" +#include "BKE_writeffmpeg.h" #include "IMB_imbuf.h" // for proxy / timecode versioning stuff @@ -9821,6 +9822,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if (scene->toolsettings->snap_node_mode == SCE_SNAP_MODE_INCREMENT) scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID; } + + /* Update for removed "sound-only" option in FFMPEG export settings. */ +#ifdef WITH_FFMPEG + for (scene = main->scene.first; scene; scene = scene->id.next) { + if (scene->r.ffcodecdata.type >= FFMPEG_INVALID) { + scene->r.ffcodecdata.type = FFMPEG_AVI; + } + } +#endif } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index d31a29623a1..2a68f0afc35 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3776,8 +3776,6 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {FFMPEG_OGG, "OGG", 0, "Ogg", ""}, {FFMPEG_MKV, "MKV", 0, "Matroska", ""}, {FFMPEG_FLV, "FLASH", 0, "Flash", ""}, - {FFMPEG_WAV, "WAV", 0, "Wav", ""}, - {FFMPEG_MP3, "MP3", 0, "Mp3", ""}, {0, NULL, 0, NULL, NULL} }; -- cgit v1.2.3 From 463b65bf0a67389b327e87b9e86122251689a7be Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Thu, 7 Nov 2013 13:56:40 +0000 Subject: OSX/scons: ARCH_FLAGS where not prperly added to CPPFLAGS --- SConstruct | 4 ++-- build_files/scons/config/darwin-config.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index c4079341df9..c76106a0d26 100644 --- a/SConstruct +++ b/SConstruct @@ -360,8 +360,8 @@ if env['OURPLATFORM']=='darwin': ARCH_FLAGS = ['-m64'] else: ARCH_FLAGS = ['-m32'] - - env['CPPFLAGS'] = list(ARCH_FLAGS) + + env.Append(CPPFLAGS=ARCH_FLAGS) SDK_FLAGS=['-isysroot', env['MACOSX_SDK'],'-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-arch',env['MACOSX_ARCHITECTURE']] # always used env['PLATFORM_LINKFLAGS'] = ['-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-isysroot', env['MACOSX_SDK'],'-arch',env['MACOSX_ARCHITECTURE']]+env['PLATFORM_LINKFLAGS'] diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py index 0b0120e4473..09dc32f082a 100644 --- a/build_files/scons/config/darwin-config.py +++ b/build_files/scons/config/darwin-config.py @@ -230,6 +230,7 @@ BF_QUIET = '1' # suppress verbose output CFLAGS = [] CXXFLAGS = [] CCFLAGS = ['-pipe','-funsigned-char'] +CPPFLAGS = [] PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL'] -- cgit v1.2.3 From 4c009dfe85bc9944861cc01d50b1898f24d61ddb Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Thu, 7 Nov 2013 14:06:21 +0000 Subject: OSX/scons: some cleanups --- SConstruct | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/SConstruct b/SConstruct index c76106a0d26..4607df20ad1 100644 --- a/SConstruct +++ b/SConstruct @@ -344,6 +344,7 @@ if env['OURPLATFORM']=='darwin': env['BF_PYTHON_BINARY'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/bin/python' + env['BF_PYTHON_VERSION'] env['BF_PYTHON_LIB'] = '' env['BF_PYTHON_LIBPATH'] = env['BF_PYTHON'] + env['BF_PYTHON_VERSION'] + '/lib/python' + env['BF_PYTHON_VERSION'] + '/config-' + env['BF_PYTHON_VERSION'] +'m' + env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','Python'] # link to python framework #Ray trace optimization if env['WITH_BF_RAYOPTIMIZATION'] == 1: @@ -364,10 +365,10 @@ if env['OURPLATFORM']=='darwin': env.Append(CPPFLAGS=ARCH_FLAGS) SDK_FLAGS=['-isysroot', env['MACOSX_SDK'],'-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-arch',env['MACOSX_ARCHITECTURE']] # always used - env['PLATFORM_LINKFLAGS'] = ['-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-isysroot', env['MACOSX_SDK'],'-arch',env['MACOSX_ARCHITECTURE']]+env['PLATFORM_LINKFLAGS'] + env['PLATFORM_LINKFLAGS'] = ['-mmacosx-version-min='+ env['MACOSX_DEPLOYMENT_TARGET'],'-isysroot', env['MACOSX_SDK'],'-arch',env['MACOSX_ARCHITECTURE']]+ARCH_FLAGS+env['PLATFORM_LINKFLAGS'] env['CCFLAGS']=SDK_FLAGS+env['CCFLAGS'] env['CXXFLAGS']=SDK_FLAGS+env['CXXFLAGS'] - + #Intel Macs are CoreDuo and Up if env['MACOSX_ARCHITECTURE'] == 'i386' or env['MACOSX_ARCHITECTURE'] == 'x86_64': env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-ftree-vectorize','-msse','-msse2','-msse3'] @@ -405,9 +406,6 @@ if env['OURPLATFORM']=='darwin': if env['WITH_BF_QUICKTIME'] == 1: env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','QTKit'] - if not env['WITH_OSX_STATICPYTHON'] == 1: - env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','Python'] - #Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer ) # if your compiler does not have accurate suffix you may have to enable it by hand ! if env['WITH_BF_OPENMP'] == 1: @@ -415,8 +413,6 @@ if env['OURPLATFORM']=='darwin': env['WITH_BF_OPENMP'] = 1 # multithreading for fluids, cloth, sculpt and smoke else: env['WITH_BF_OPENMP'] = 0 - - env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+ARCH_FLAGS if env['WITH_BF_CYCLES_OSL'] == 1: OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath -- cgit v1.2.3 From 67162306a7cb4e0ca4b38bec6f77de4f13c21571 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 7 Nov 2013 14:07:13 +0000 Subject: Tweak for ui range of track size in 3d viewport Patch by Sebastian Koenig, thanks! --- source/blender/makesrna/intern/rna_space.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 07723b34837..6545661cdf1 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2071,6 +2071,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "tracks_draw_size", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, FLT_MAX); + RNA_def_property_ui_range(prop, 0, 5, 1, 3); RNA_def_property_float_sdna(prop, NULL, "bundle_size"); RNA_def_property_ui_text(prop, "Tracks Size", "Display size of tracks from reconstructed data"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); -- cgit v1.2.3 From e572a433a8fefa4e45318c545b48eb8c82bb97ef Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Thu, 7 Nov 2013 15:05:59 +0000 Subject: OSX/scons: make gcc version detection more futureproof --- SConstruct | 4 +++- build_files/scons/tools/Blender.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 4607df20ad1..f5165606700 100644 --- a/SConstruct +++ b/SConstruct @@ -409,10 +409,12 @@ if env['OURPLATFORM']=='darwin': #Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer ) # if your compiler does not have accurate suffix you may have to enable it by hand ! if env['WITH_BF_OPENMP'] == 1: - if env['CC'][:-2].endswith('4.6') or env['CC'][:-2].endswith('4.8'): + if env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.6.1': env['WITH_BF_OPENMP'] = 1 # multithreading for fluids, cloth, sculpt and smoke + print B.bc.OKGREEN + "Using OpenMP" else: env['WITH_BF_OPENMP'] = 0 + print B.bc.OKGREEN + "Disabled OpenMP" if env['WITH_BF_CYCLES_OSL'] == 1: OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index b79ba991b9a..06cc6b7f00a 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -700,7 +700,8 @@ def AppIt(target=None, source=None, env=None): commands.getoutput(cmd) cmd = 'find %s/%s.app -name __MACOSX -exec rm -rf {} \;'%(installdir, binary) commands.getoutput(cmd) - if env['CC'][:-2].endswith('4.6') or env['CC'][:-2].endswith('4.8'): # for correct errorhandling with gcc 4.6/4.8.x we need the gcc.dylib and gomp.dylib to link, thus distribute in app-bundle + if env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.6.1': # for correct errorhandling with gcc <= 4.6.1 we need the gcc.dylib and gomp.dylib to link, thus distribute in app-bundle + print "Bundling libgcc and libgomp" cmd = 'mkdir %s/%s.app/Contents/MacOS/lib'%(installdir, binary) commands.getoutput(cmd) instname = env['BF_CXX'] -- cgit v1.2.3 From 106cff1b93b812e54eb375e24b1765e2a4f65eb4 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Thu, 7 Nov 2013 15:25:11 +0000 Subject: OSX/buildbot: after scons refactor we only need the vars to change --- .../buildbot/config/user-config-mac-i386.py | 376 -------------------- .../buildbot/config/user-config-mac-x86_64.py | 379 +-------------------- 2 files changed, 1 insertion(+), 754 deletions(-) diff --git a/build_files/buildbot/config/user-config-mac-i386.py b/build_files/buildbot/config/user-config-mac-i386.py index e0074785a01..fa18b74cf87 100644 --- a/build_files/buildbot/config/user-config-mac-i386.py +++ b/build_files/buildbot/config/user-config-mac-i386.py @@ -1,379 +1,3 @@ -# -# Note : if you want to alter this file -# copy it as a whole in the upper folder -# as user-config.py -# dont create a new file with only some -# vars changed. - -import commands - -# IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs -USE_SDK=True - -############################################################################# -################### Cocoa & architecture settings ################## -############################################################################# - MACOSX_ARCHITECTURE = 'i386' # valid archs: ppc, i386, ppc64, x86_64 - - -cmd = 'uname -p' -MAC_PROC=commands.getoutput(cmd) -cmd = 'sw_vers -productVersion' -MAC_CUR_VER=cmd_res=commands.getoutput(cmd) -cmd = 'xcodebuild -version' -cmd_xcode=commands.getoutput(cmd) -XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version -cmd = 'xcodebuild -showsdks' -cmd_sdk=commands.getoutput(cmd) -MACOSX_SDK_CHECK=cmd_sdk -cmd = 'xcode-select --print-path' -XCODE_SELECT_PATH=commands.getoutput(cmd) -if XCODE_SELECT_PATH.endswith("/Contents/Developer"): - XCODE_BUNDLE=XCODE_SELECT_PATH[:-19] -else: - XCODE_BUNDLE=XCODE_SELECT_PATH - - -# Default target OSX settings per architecture -# Can be customized - -if 'Mac OS X 10.5' in MACOSX_SDK_CHECK: - # OSX 10.5/6 with Xcode 3.x - MAC_MIN_VERS = '10.5' - MACOSX_DEPLOYMENT_TARGET = '10.5' - MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' -elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK: - # OSX 10.6/7 with Xcode 4.x - MAC_MIN_VERS = '10.6' - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' -else: - # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! ) - MAC_MIN_VERS = '10.6' - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc' - CXX = 'g++' - -LIBDIR = '${LCGDIR}' - -if XCODE_CUR_VER >= '4.3': ## since version 4.3, XCode and developer dir are bundled ## - MACOSX_SDK = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform' + MACOSX_SDK - -############################################################################# -################### Dependency settings ################## -############################################################################# - -#Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer ) -# if your compiler does not have accurate suffix you may have to enable it by hand ! -if CC[:-2].endswith('4.6'): - WITH_BF_OPENMP = True # multithreading for fluids, cloth, sculpt and smoke -else: - WITH_BF_OPENMP = False - -# enable ffmpeg support -WITH_BF_FFMPEG = True -BF_FFMPEG = LIBDIR + '/ffmpeg' -BF_FFMPEG_INC = "${BF_FFMPEG}/include" -BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib' -BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg bz2' -#bz2 is a standard osx dynlib - -BF_PYTHON_VERSION = '3.3' -WITH_OSX_STATICPYTHON = True - -if WITH_OSX_STATICPYTHON: - # python 3.3 uses precompiled libraries in bf svn /lib by default - - BF_PYTHON = LIBDIR + '/python' - BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m' - # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}' - BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m' - BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}' - # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System'] -else: - # python 3.2 uses Python-framework additionally installed in /Library/Frameworks - - BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/' - BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}m' - BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}' - #BF_PYTHON_LIB = '' - BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config-${BF_PYTHON_VERSION}m' - -WITH_BF_OPENAL = True -#different lib must be used following version of gcc -# for gcc 3.3 -#BF_OPENAL = LIBDIR + '/openal' -# for gcc 3.4 and ulterior -if MAC_PROC == 'powerpc': - BF_OPENAL = '#../lib/darwin-8.0.0-powerpc/openal' -else : - BF_OPENAL = LIBDIR + '/openal' - -WITH_BF_STATICOPENAL = False -BF_OPENAL_INC = '${BF_OPENAL}/include' # only headers from libdir needed for proper use of framework !!!! -#BF_OPENAL_LIB = 'openal' -#BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib' -# Warning, this static lib configuration is untested! users of this OS please confirm. -#BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a' - -# Warning, this static lib configuration is untested! users of this OS please confirm. -BF_CXX = '/usr' -WITH_BF_STATICCXX = False -BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a' - -# we use simply jack framework -WITH_BF_JACK = True -BF_JACK = '/Library/Frameworks/Jackmp.framework' -BF_JACK_INC = '${BF_JACK}/headers' -#BF_JACK_LIB = 'jack' # not used due framework -BF_JACK_LIBPATH = '${BF_JACK}' - -WITH_BF_SNDFILE = True -BF_SNDFILE = LIBDIR + '/sndfile' -BF_SNDFILE_INC = '${BF_SNDFILE}/include' -BF_SNDFILE_LIB = 'sndfile FLAC ogg vorbis vorbisenc' -BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib ${BF_FFMPEG}/lib' #ogg libs are stored in ffmpeg dir - -WITH_BF_SDL = True -BF_SDL = LIBDIR + '/sdl' #$(shell sdl-config --prefix) -BF_SDL_INC = '${BF_SDL}/include' #$(shell $(BF_SDL)/bin/sdl-config --cflags) -BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer -BF_SDL_LIBPATH = '${BF_SDL}/lib' - -WITH_BF_OPENEXR = True -WITH_BF_STATICOPENEXR = False -BF_OPENEXR = '${LCGDIR}/openexr' -BF_OPENEXR_INC = '${BF_OPENEXR}/include ${BF_OPENEXR}/include/OpenEXR' -BF_OPENEXR_LIB = ' Iex Half IlmImf Imath IlmThread' -BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib' -# Warning, this static lib configuration is untested! users of this OS please confirm. -BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a' - -WITH_BF_DDS = True - -#Color Management System -WITH_BF_LCMS = False -BF_LCMS = LIBDIR + '/lcms' -BF_LCMS_INC = '${BF_LCMS}/include' -BF_LCMS_LIB = 'lcms' -BF_LCMS_LIBPATH = '${BF_LCMS}/lib' - -WITH_BF_JPEG = True -BF_JPEG = LIBDIR + '/jpeg' -BF_JPEG_INC = '${BF_JPEG}/include' -BF_JPEG_LIB = 'jpeg' -BF_JPEG_LIBPATH = '${BF_JPEG}/lib' - -WITH_BF_PNG = True -BF_PNG = LIBDIR + '/png' -BF_PNG_INC = '${BF_PNG}/include' -BF_PNG_LIB = 'png' -BF_PNG_LIBPATH = '${BF_PNG}/lib' - -WITH_BF_TIFF = True -BF_TIFF = LIBDIR + '/tiff' -BF_TIFF_INC = '${BF_TIFF}/include' -BF_TIFF_LIB = 'tiff' -BF_TIFF_LIBPATH = '${BF_TIFF}/lib' - -WITH_BF_ZLIB = True -BF_ZLIB = '/usr' -BF_ZLIB_INC = '${BF_ZLIB}/include' -BF_ZLIB_LIB = 'z' - -WITH_BF_INTERNATIONAL = True - -WITH_BF_GAMEENGINE = True -WITH_BF_PLAYER = True -WITH_BF_OCEANSIM = True - -WITH_BF_BULLET = True -BF_BULLET = '#extern/bullet2/src' -BF_BULLET_INC = '${BF_BULLET}' -BF_BULLET_LIB = 'extern_bullet' - -WITH_BF_FFTW3 = True -BF_FFTW3 = LIBDIR + '/fftw3' -BF_FFTW3_INC = '${BF_FFTW3}/include' -BF_FFTW3_LIB = 'libfftw3' -BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib' - -BF_FREETYPE = LIBDIR + '/freetype' -BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2' -BF_FREETYPE_LIB = 'freetype' -BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib' - -WITH_BF_QUICKTIME = True - -WITH_BF_ICONV = True -BF_ICONV = '/usr' -BF_ICONV_INC = '${BF_ICONV}/include' -BF_ICONV_LIB = 'iconv' -#BF_ICONV_LIBPATH = '${BF_ICONV}/lib' - -# Mesa Libs should go here if your using them as well.... -WITH_BF_STATICOPENGL = True -BF_OPENGL_LIB = 'GL GLU' -BF_OPENGL_LIBPATH = '/System/Library/Frameworks/OpenGL.framework/Libraries' -BF_OPENGL_LINKFLAGS = ['-framework', 'OpenGL'] - -#OpenCollada flags -WITH_BF_COLLADA = True -BF_COLLADA = '#source/blender/collada' -BF_COLLADA_INC = '${BF_COLLADA}' -BF_COLLADA_LIB = 'bf_collada' -BF_OPENCOLLADA = LIBDIR + '/opencollada' -BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include' -BF_OPENCOLLADA_LIB = 'OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 buffer ftoa' -BF_OPENCOLLADA_LIBPATH = LIBDIR + '/opencollada' -BF_PCRE = LIBDIR + '/opencollada' -BF_PCRE_LIB = 'pcre' -BF_PCRE_LIBPATH = '${BF_PCRE}/lib' -#BF_EXPAT = '/usr' -#BF_EXPAT_LIB = 'expat' -#BF_EXPAT_LIBPATH = '/usr/lib' - -# Cycles -WITH_BF_CYCLES = True - -#OSL - -WITH_BF_CYCLES_OSL = True -BF_OSL = LIBDIR + '/osl' -BF_OSL_INC = '${BF_OSL}/include' -# note oslexec would passed via program linkflags, which is needed to -# make llvm happy with osl_allocate_closure_component -#BF_OSL_LIB = 'oslcomp oslquery' -BF_OSL_LIBPATH = '${BF_OSL}/lib' -BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' - -WITH_BF_LLVM = True -BF_LLVM = LIBDIR + '/llvm' -BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \ - 'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \ - 'LLVMTarget LLVMMC LLVMCore LLVMSupport' -BF_LLVM_LIBPATH = '${BF_LLVM}/lib' - -WITH_BF_OIIO = True -BF_OIIO = LIBDIR + '/openimageio' -BF_OIIO_INC = '${BF_OIIO}/include' -BF_OIIO_LIB = 'OpenImageIO' -BF_OIIO_LIBPATH = '${BF_OIIO}/lib' - -WITH_BF_OCIO = True -BF_OCIO = LIBDIR + '/opencolorio' -BF_OCIO_INC = '${BF_OCIO}/include' -BF_OCIO_LIB = 'OpenColorIO tinyxml yaml-cpp' -BF_OCIO_LIBPATH = '${BF_OCIO}/lib' - -WITH_BF_BOOST = True -BF_BOOST = LIBDIR + '/boost' -BF_BOOST_INC = '${BF_BOOST}/include' -BF_BOOST_LIB = 'boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt boost_wave-mt' -BF_BOOST_LIB_INTERNATIONAL = 'boost_locale-mt' -BF_BOOST_LIBPATH = '${BF_BOOST}/lib' - WITH_BF_CYCLES_CUDA_BINARIES = True -BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc' -BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35'] - -#Freestyle -WITH_BF_FREESTYLE = True - -#Ray trace optimization -if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386': - WITH_BF_RAYOPTIMIZATION = True -else: - WITH_BF_RAYOPTIMIZATION = False -if MACOSX_ARCHITECTURE == 'i386': - BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse'] -elif MACOSX_ARCHITECTURE == 'x86_64': - BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2'] - -# SpaceNavigator and related 3D mice, driver must be 3DxWare 10 Beta 4 (Mac OS X) or later ! -WITH_BF_3DMOUSE = True - -############################################################################# -################### various compile settings and flags ################## -############################################################################# - -BF_QUIET = '1' # suppress verbose output - -if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64': - ARCH_FLAGS = ['-m64'] -else: - ARCH_FLAGS = ['-m32'] - -CFLAGS = [] -CXXFLAGS = [] -CCFLAGS = ['-pipe','-funsigned-char'] - -CPPFLAGS = list(ARCH_FLAGS) - -PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS - -if WITH_BF_QUICKTIME: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit'] - -if not WITH_OSX_STATICPYTHON: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python'] - - -#for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore) -if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk") or MACOSX_SDK.endswith("10.9.sdk"): - LLIBS = ['stdc++'] -else: - LLIBS = ['stdc++', 'SystemStubs'] - -if USE_SDK: - SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE] - PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS - CCFLAGS=SDK_FLAGS+CCFLAGS - CXXFLAGS=SDK_FLAGS+CXXFLAGS - -#Intel Macs are CoreDuo and Up -if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64': - REL_CFLAGS = [] - REL_CXXFLAGS = [] - REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3','-mfpmath=sse'] -else: - CCFLAGS += ['-fno-strict-aliasing'] - REL_CFLAGS = [] - REL_CXXFLAGS = [] - REL_CCFLAGS = ['-DNDEBUG', '-O2'] - -# Intel 64bit Macs are Core2Duo and up -if MACOSX_ARCHITECTURE == 'x86_64': - REL_CCFLAGS += ['-march=core2','-mssse3','-with-tune=core2','-enable-threads'] - -CC_WARN = ['-Wall'] -C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes'] -CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare'] - -##FIX_STUBS_WARNINGS = -Wno-unused - -##LOPTS = --dynamic -##DYNLDFLAGS = -shared $(LDFLAGS) - -BF_PROFILE_CCFLAGS = ['-pg', '-g '] -BF_PROFILE_LINKFLAGS = ['-pg'] -BF_PROFILE = False - -BF_DEBUG = False -BF_DEBUG_CCFLAGS = ['-g', '-D_DEBUG'] - -############################################################################# -################### Output directories ################## -############################################################################# -BF_BUILDDIR='../build/darwin' -BF_INSTALLDIR='../install/darwin' diff --git a/build_files/buildbot/config/user-config-mac-x86_64.py b/build_files/buildbot/config/user-config-mac-x86_64.py index 0fbd30e4aa1..2b12762f934 100644 --- a/build_files/buildbot/config/user-config-mac-x86_64.py +++ b/build_files/buildbot/config/user-config-mac-x86_64.py @@ -1,379 +1,2 @@ -# -# Note : if you want to alter this file -# copy it as a whole in the upper folder -# as user-config.py -# dont create a new file with only some -# vars changed. - -import commands - -# IMPORTANT NOTE : OFFICIAL BUILDS SHOULD BE DONE WITH SDKs -USE_SDK=True - -############################################################################# -################### Cocoa & architecture settings ################## -############################################################################# - MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64 - - -cmd = 'uname -p' -MAC_PROC=commands.getoutput(cmd) -cmd = 'sw_vers -productVersion' -MAC_CUR_VER=cmd_res=commands.getoutput(cmd) -cmd = 'xcodebuild -version' -cmd_xcode=commands.getoutput(cmd) -XCODE_CUR_VER=cmd_xcode[6:][:3] # truncate output to major.minor version -cmd = 'xcodebuild -showsdks' -cmd_sdk=commands.getoutput(cmd) -MACOSX_SDK_CHECK=cmd_sdk -cmd = 'xcode-select --print-path' -XCODE_SELECT_PATH=commands.getoutput(cmd) -if XCODE_SELECT_PATH.endswith("/Contents/Developer"): - XCODE_BUNDLE=XCODE_SELECT_PATH[:-19] -else: - XCODE_BUNDLE=XCODE_SELECT_PATH - - -# Default target OSX settings per architecture -# Can be customized - -if 'Mac OS X 10.5' in MACOSX_SDK_CHECK: - # OSX 10.5/6 with Xcode 3.x - MAC_MIN_VERS = '10.5' - MACOSX_DEPLOYMENT_TARGET = '10.5' - MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' -elif 'Mac OS X 10.6' in MACOSX_SDK_CHECK: - # OSX 10.6/7 with Xcode 4.x - MAC_MIN_VERS = '10.6' - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.6.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc-4.2' - CXX = 'g++-4.2' -else: - # OSX 10.8 with Xcode 4.4 and higher (no 10.6sdk! ) - MAC_MIN_VERS = '10.6' - MACOSX_DEPLOYMENT_TARGET = '10.6' - MACOSX_SDK='/Developer/SDKs/MacOSX10.8.sdk' - LCGDIR = '#../lib/darwin-9.x.universal' - CC = 'gcc' - CXX = 'g++' - -LIBDIR = '${LCGDIR}' - -if XCODE_CUR_VER >= '4.3': ## since version 4.3, XCode and developer dir are bundled ## - MACOSX_SDK = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform' + MACOSX_SDK - -############################################################################# -################### Dependency settings ################## -############################################################################# - -#Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer ) -# if your compiler does not have accurate suffix you may have to enable it by hand ! -if CC[:-2].endswith('4.6'): - WITH_BF_OPENMP = True # multithreading for fluids, cloth, sculpt and smoke -else: - WITH_BF_OPENMP = False - -# enable ffmpeg support -WITH_BF_FFMPEG = True -BF_FFMPEG = LIBDIR + '/ffmpeg' -BF_FFMPEG_INC = "${BF_FFMPEG}/include" -BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib' -BF_FFMPEG_LIB = 'avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg bz2' -#bz2 is a standard osx dynlib - -BF_PYTHON_VERSION = '3.3' -WITH_OSX_STATICPYTHON = True - -if WITH_OSX_STATICPYTHON: - # python 3.3 uses precompiled libraries in bf svn /lib by default - - BF_PYTHON = LIBDIR + '/python' - BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}m' - # BF_PYTHON_BINARY = '${BF_PYTHON}/bin/python${BF_PYTHON_VERSION}' - BF_PYTHON_LIB = 'python${BF_PYTHON_VERSION}m' - BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib/python${BF_PYTHON_VERSION}' - # BF_PYTHON_LINKFLAGS = ['-u', '_PyMac_Error', '-framework', 'System'] -else: - # python 3.2 uses Python-framework additionally installed in /Library/Frameworks - - BF_PYTHON = '/Library/Frameworks/Python.framework/Versions/' - BF_PYTHON_INC = '${BF_PYTHON}${BF_PYTHON_VERSION}/include/python${BF_PYTHON_VERSION}m' - BF_PYTHON_BINARY = '${BF_PYTHON}${BF_PYTHON_VERSION}/bin/python${BF_PYTHON_VERSION}' - #BF_PYTHON_LIB = '' - BF_PYTHON_LIBPATH = '${BF_PYTHON}${BF_PYTHON_VERSION}/lib/python${BF_PYTHON_VERSION}/config-${BF_PYTHON_VERSION}m' - -WITH_BF_OPENAL = True -#different lib must be used following version of gcc -# for gcc 3.3 -#BF_OPENAL = LIBDIR + '/openal' -# for gcc 3.4 and ulterior -if MAC_PROC == 'powerpc': - BF_OPENAL = '#../lib/darwin-8.0.0-powerpc/openal' -else : - BF_OPENAL = LIBDIR + '/openal' - -WITH_BF_STATICOPENAL = False -BF_OPENAL_INC = '${BF_OPENAL}/include' # only headers from libdir needed for proper use of framework !!!! -#BF_OPENAL_LIB = 'openal' -#BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib' -# Warning, this static lib configuration is untested! users of this OS please confirm. -#BF_OPENAL_LIB_STATIC = '${BF_OPENAL}/lib/libopenal.a' - -# Warning, this static lib configuration is untested! users of this OS please confirm. -BF_CXX = '/usr' -WITH_BF_STATICCXX = False -BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a' - -# we use simply jack framework -WITH_BF_JACK = True -BF_JACK = '/Library/Frameworks/Jackmp.framework' -BF_JACK_INC = '${BF_JACK}/headers' -#BF_JACK_LIB = 'jack' # not used due framework -BF_JACK_LIBPATH = '${BF_JACK}' - -WITH_BF_SNDFILE = True -BF_SNDFILE = LIBDIR + '/sndfile' -BF_SNDFILE_INC = '${BF_SNDFILE}/include' -BF_SNDFILE_LIB = 'sndfile FLAC ogg vorbis vorbisenc' -BF_SNDFILE_LIBPATH = '${BF_SNDFILE}/lib ${BF_FFMPEG}/lib' #ogg libs are stored in ffmpeg dir - -WITH_BF_SDL = True -BF_SDL = LIBDIR + '/sdl' #$(shell sdl-config --prefix) -BF_SDL_INC = '${BF_SDL}/include' #$(shell $(BF_SDL)/bin/sdl-config --cflags) -BF_SDL_LIB = 'SDL' #BF_SDL #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer -BF_SDL_LIBPATH = '${BF_SDL}/lib' - -WITH_BF_OPENEXR = True -WITH_BF_STATICOPENEXR = False -BF_OPENEXR = '${LCGDIR}/openexr' -BF_OPENEXR_INC = '${BF_OPENEXR}/include ${BF_OPENEXR}/include/OpenEXR' -BF_OPENEXR_LIB = ' Iex Half IlmImf Imath IlmThread' -BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib' -# Warning, this static lib configuration is untested! users of this OS please confirm. -BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a' - -WITH_BF_DDS = True - -#Color Management System -WITH_BF_LCMS = False -BF_LCMS = LIBDIR + '/lcms' -BF_LCMS_INC = '${BF_LCMS}/include' -BF_LCMS_LIB = 'lcms' -BF_LCMS_LIBPATH = '${BF_LCMS}/lib' - -WITH_BF_JPEG = True -BF_JPEG = LIBDIR + '/jpeg' -BF_JPEG_INC = '${BF_JPEG}/include' -BF_JPEG_LIB = 'jpeg' -BF_JPEG_LIBPATH = '${BF_JPEG}/lib' - -WITH_BF_PNG = True -BF_PNG = LIBDIR + '/png' -BF_PNG_INC = '${BF_PNG}/include' -BF_PNG_LIB = 'png' -BF_PNG_LIBPATH = '${BF_PNG}/lib' - -WITH_BF_TIFF = True -BF_TIFF = LIBDIR + '/tiff' -BF_TIFF_INC = '${BF_TIFF}/include' -BF_TIFF_LIB = 'tiff' -BF_TIFF_LIBPATH = '${BF_TIFF}/lib' - -WITH_BF_ZLIB = True -BF_ZLIB = '/usr' -BF_ZLIB_INC = '${BF_ZLIB}/include' -BF_ZLIB_LIB = 'z' - -WITH_BF_INTERNATIONAL = True - -WITH_BF_GAMEENGINE = True -WITH_BF_PLAYER = True -WITH_BF_OCEANSIM = True - -WITH_BF_BULLET = True -BF_BULLET = '#extern/bullet2/src' -BF_BULLET_INC = '${BF_BULLET}' -BF_BULLET_LIB = 'extern_bullet' - -WITH_BF_FFTW3 = True -BF_FFTW3 = LIBDIR + '/fftw3' -BF_FFTW3_INC = '${BF_FFTW3}/include' -BF_FFTW3_LIB = 'libfftw3' -BF_FFTW3_LIBPATH = '${BF_FFTW3}/lib' - -BF_FREETYPE = LIBDIR + '/freetype' -BF_FREETYPE_INC = '${BF_FREETYPE}/include ${BF_FREETYPE}/include/freetype2' -BF_FREETYPE_LIB = 'freetype' -BF_FREETYPE_LIBPATH = '${BF_FREETYPE}/lib' - -WITH_BF_QUICKTIME = True - -WITH_BF_ICONV = True -BF_ICONV = '/usr' -BF_ICONV_INC = '${BF_ICONV}/include' -BF_ICONV_LIB = 'iconv' -#BF_ICONV_LIBPATH = '${BF_ICONV}/lib' - -# Mesa Libs should go here if your using them as well.... -WITH_BF_STATICOPENGL = True -BF_OPENGL_LIB = 'GL GLU' -BF_OPENGL_LIBPATH = '/System/Library/Frameworks/OpenGL.framework/Libraries' -BF_OPENGL_LINKFLAGS = ['-framework', 'OpenGL'] - -#OpenCollada flags -WITH_BF_COLLADA = True -BF_COLLADA = '#source/blender/collada' -BF_COLLADA_INC = '${BF_COLLADA}' -BF_COLLADA_LIB = 'bf_collada' -BF_OPENCOLLADA = LIBDIR + '/opencollada' -BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include' -BF_OPENCOLLADA_LIB = 'OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 buffer ftoa' -BF_OPENCOLLADA_LIBPATH = LIBDIR + '/opencollada' -BF_PCRE = LIBDIR + '/opencollada' -BF_PCRE_LIB = 'pcre' -BF_PCRE_LIBPATH = '${BF_PCRE}/lib' -#BF_EXPAT = '/usr' -#BF_EXPAT_LIB = 'expat' -#BF_EXPAT_LIBPATH = '/usr/lib' - -# Cycles -WITH_BF_CYCLES = True - -#OSL - -WITH_BF_CYCLES_OSL = True -BF_OSL = LIBDIR + '/osl' -BF_OSL_INC = '${BF_OSL}/include' -# note oslexec would passed via program linkflags, which is needed to -# make llvm happy with osl_allocate_closure_component -#BF_OSL_LIB = 'oslcomp oslquery' -BF_OSL_LIBPATH = '${BF_OSL}/lib' -BF_OSL_COMPILER = '${BF_OSL}/bin/oslc' - -WITH_BF_LLVM = True -BF_LLVM = LIBDIR + '/llvm' -BF_LLVM_LIB = 'LLVMBitReader LLVMJIT LLVMipo LLVMVectorize LLVMBitWriter LLVMX86CodeGen LLVMX86Desc LLVMX86Info LLVMX86AsmPrinter ' + \ - 'LLVMX86Utils LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMExecutionEngine ' + \ - 'LLVMTarget LLVMMC LLVMCore LLVMSupport' -BF_LLVM_LIBPATH = '${BF_LLVM}/lib' - -WITH_BF_OIIO = True -BF_OIIO = LIBDIR + '/openimageio' -BF_OIIO_INC = '${BF_OIIO}/include' -BF_OIIO_LIB = 'OpenImageIO' -BF_OIIO_LIBPATH = '${BF_OIIO}/lib' - -WITH_BF_OCIO = True -BF_OCIO = LIBDIR + '/opencolorio' -BF_OCIO_INC = '${BF_OCIO}/include' -BF_OCIO_LIB = 'OpenColorIO tinyxml yaml-cpp' -BF_OCIO_LIBPATH = '${BF_OCIO}/lib' - -WITH_BF_BOOST = True -BF_BOOST = LIBDIR + '/boost' -BF_BOOST_INC = '${BF_BOOST}/include' -BF_BOOST_LIB = 'boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt boost_wave-mt' -BF_BOOST_LIB_INTERNATIONAL = 'boost_locale-mt' -BF_BOOST_LIBPATH = '${BF_BOOST}/lib' - -WITH_BF_CYCLES_CUDA_BINARIES = True -BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc' -BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35'] - -#Freestyle -WITH_BF_FREESTYLE = True - -#Ray trace optimization -if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'i386': - WITH_BF_RAYOPTIMIZATION = True -else: - WITH_BF_RAYOPTIMIZATION = False -if MACOSX_ARCHITECTURE == 'i386': - BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse'] -elif MACOSX_ARCHITECTURE == 'x86_64': - BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse','-msse2'] - -# SpaceNavigator and related 3D mice, driver must be 3DxWare 10 Beta 4 (Mac OS X) or later ! -WITH_BF_3DMOUSE = True - -############################################################################# -################### various compile settings and flags ################## -############################################################################# - -BF_QUIET = '1' # suppress verbose output - -if MACOSX_ARCHITECTURE == 'x86_64' or MACOSX_ARCHITECTURE == 'ppc64': - ARCH_FLAGS = ['-m64'] -else: - ARCH_FLAGS = ['-m32'] - -CFLAGS = [] -CXXFLAGS = [] -CCFLAGS = ['-pipe','-funsigned-char'] - -CPPFLAGS = list(ARCH_FLAGS) - -PLATFORM_LINKFLAGS = ['-fexceptions','-framework','CoreServices','-framework','Foundation','-framework','IOKit','-framework','AppKit','-framework','Cocoa','-framework','Carbon','-framework','AudioUnit','-framework','AudioToolbox','-framework','CoreAudio','-framework','OpenAL']+ARCH_FLAGS - -if WITH_BF_QUICKTIME: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','QTKit'] - -if not WITH_OSX_STATICPYTHON: - PLATFORM_LINKFLAGS = PLATFORM_LINKFLAGS+['-framework','Python'] - - -#for > 10.7.sdk, SystemStubs needs to be excluded (lib doesn't exist anymore) -if MACOSX_SDK.endswith("10.7.sdk") or MACOSX_SDK.endswith("10.8.sdk") or MACOSX_SDK.endswith("10.9.sdk"): - LLIBS = ['stdc++'] -else: - LLIBS = ['stdc++', 'SystemStubs'] - -if USE_SDK: - SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS,'-arch',MACOSX_ARCHITECTURE] - PLATFORM_LINKFLAGS = ['-mmacosx-version-min='+MAC_MIN_VERS,'-Wl','-isysroot',MACOSX_SDK,'-arch',MACOSX_ARCHITECTURE]+PLATFORM_LINKFLAGS - CCFLAGS=SDK_FLAGS+CCFLAGS - CXXFLAGS=SDK_FLAGS+CXXFLAGS - -#Intel Macs are CoreDuo and Up -if MACOSX_ARCHITECTURE == 'i386' or MACOSX_ARCHITECTURE == 'x86_64': - REL_CFLAGS = [] - REL_CXXFLAGS = [] - REL_CCFLAGS = ['-DNDEBUG', '-O2','-ftree-vectorize','-msse','-msse2','-msse3','-mfpmath=sse'] -else: - CCFLAGS += ['-fno-strict-aliasing'] - REL_CFLAGS = [] - REL_CXXFLAGS = [] - REL_CCFLAGS = ['-DNDEBUG', '-O2'] - -# Intel 64bit Macs are Core2Duo and up -if MACOSX_ARCHITECTURE == 'x86_64': - REL_CCFLAGS += ['-march=core2','-mssse3','-with-tune=core2','-enable-threads'] - -CC_WARN = ['-Wall'] -C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes'] -CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare'] - -##FIX_STUBS_WARNINGS = -Wno-unused - -##LOPTS = --dynamic -##DYNLDFLAGS = -shared $(LDFLAGS) - -BF_PROFILE_CCFLAGS = ['-pg', '-g '] -BF_PROFILE_LINKFLAGS = ['-pg'] -BF_PROFILE = False - -BF_DEBUG = False -BF_DEBUG_CCFLAGS = ['-g', '-D_DEBUG'] - -############################################################################# -################### Output directories ################## -############################################################################# - -BF_BUILDDIR='../build/darwin' -BF_INSTALLDIR='../install/darwin' +WITH_BF_CYCLES_CUDA_BINARIES = True \ No newline at end of file -- cgit v1.2.3 From 1457924a21cb0339b10866c4461f87a6f8c25ff8 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Thu, 7 Nov 2013 23:40:06 +0000 Subject: Fix for [#37293] Audio does not Scrub, plays fully instead --- intern/audaspace/OpenAL/AUD_OpenALDevice.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp index 676a86e88fe..c3877c2c9f2 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -119,6 +119,14 @@ AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, A { length = m_device->m_buffersize; reader->read(length, eos, m_device->m_buffer.getBuffer()); + + if(length == 0) + { + // AUD_XXX: TODO: don't fill all buffers and enqueue them later + length = 1; + memset(m_device->m_buffer.getBuffer(), 0, length * AUD_DEVICE_SAMPLE_SIZE(specs)); + } + alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(), length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate); @@ -132,8 +140,7 @@ AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, A try { - alSourceQueueBuffers(m_source, CYCLE_BUFFERS, - m_buffers); + alSourceQueueBuffers(m_source, CYCLE_BUFFERS, m_buffers); if(alGetError() != AL_NO_ERROR) AUD_THROW(AUD_ERROR_OPENAL, queue_error); } @@ -289,6 +296,14 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::seek(float position) { length = m_device->m_buffersize; m_reader->read(length, m_eos, m_device->m_buffer.getBuffer()); + + if(length == 0) + { + // AUD_XXX: TODO: don't fill all buffers and enqueue them later + length = 1; + memset(m_device->m_buffer.getBuffer(), 0, length * AUD_DEVICE_SAMPLE_SIZE(specs)); + } + alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(), length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate); @@ -933,9 +948,8 @@ void AUD_OpenALDevice::updateStreams() break; } - // unqueue buffer - alSourceUnqueueBuffers(sound->m_source, 1, - &sound->m_buffers[sound->m_current]); + // unqueue buffer (warning: this might fail for slow early returning sources (none exist so far) if the buffer was not queued due to recent changes - has to be tested) + alSourceUnqueueBuffers(sound->m_source, 1, &sound->m_buffers[sound->m_current]); ALenum err; if((err = alGetError()) != AL_NO_ERROR) { -- cgit v1.2.3 From bbade535fb88d26df57ae644f6ede259bd3f1c45 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 8 Nov 2013 08:46:43 +0000 Subject: fix for crash when deleting from an id property, with a non-string key. --- source/blender/python/generic/idprop_py_api.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index 88a56fac93b..da136675e1d 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -525,7 +525,17 @@ int BPy_Wrap_SetMapItem(IDProperty *prop, PyObject *key, PyObject *val) } if (val == NULL) { /* del idprop[key] */ - IDProperty *pkey = IDP_GetPropertyFromGroup(prop, _PyUnicode_AsString(key)); + IDProperty *pkey; + const char *name = _PyUnicode_AsString(key); + + if (name == NULL) { + PyErr_Format(PyExc_KeyError, + "expected a string, not %.200s", + Py_TYPE(key)->tp_name); + return -1; + } + + pkey = IDP_GetPropertyFromGroup(prop, name); if (pkey) { IDP_FreeFromGroup(prop, pkey); return 0; -- cgit v1.2.3 From 5ef717bec6c92e5a496f591285faf8db4d01f40b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 8 Nov 2013 11:25:50 +0000 Subject: [#37327] Inconsistent numeric input conversion. Issue was actually that micrometer was not drawing correctly (from r58165), reverted that fix and instead use utf8 drawing for editmode metrics when using a unit system (we already had a similar hack for surfaces and volumes, anyway). --- source/blender/blenkernel/intern/unit.c | 15 +++++---------- source/blender/editors/space_view3d/drawobject.c | 10 +++++----- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index a69df62f505..3c03712231a 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -95,11 +95,6 @@ typedef struct bUnitDef { #define B_UNIT_DEF_SUPPRESS 1 /* Use for units that are not used enough to be translated into for common use */ #define B_UNIT_DEF_TENTH 2 /* Display a unit even if its value is 0.1, eg 0.1mm instead of 100um */ -/* workaround encoding issue with "µm", bug [#36090] */ -#define B_UNIT_CHAR_MICRO "\xb5" -#define UM B_UNIT_CHAR_MICRO"m" -#define US B_UNIT_CHAR_MICRO"s" - /* define a single unit */ typedef struct bUnitCollection { struct bUnitDef *units; @@ -121,7 +116,7 @@ static struct bUnitDef buMetricLenDef[] = { {"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, {"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, {"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH}, - {"micrometer", "micrometers", UM, "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too? + {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, /* These get displayed because of float precision problems in the transform header, * could work around, but for now probably people wont use these */ @@ -154,7 +149,7 @@ static struct bUnitDef buMetricAreaDef[] = { {"square decimeter", "square decimetees", "dm²", "dm2", "Square Decimeters", UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, {"square centimeter", "square centimeters", "cm²", "cm2", "Square Centimeters", UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, {"square millimeter", "square millimeters", "mm²", "mm2", "Square Millimeters", UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH}, - {"square micrometer", "square micrometers", UM"²", "um2", "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, + {"square micrometer", "square micrometers", "µm²", "um2", "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; static struct bUnitCollection buMetricAreaCollection = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef) / sizeof(bUnitDef)}; @@ -180,7 +175,7 @@ static struct bUnitDef buMetricVolDef[] = { {"cubic decimeter", "cubic decimeters", "dm³", "dm3", "Cubic Decimeters", UN_SC_DM * UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, {"cubic centimeter", "cubic centimeters", "cm³", "cm3", "Cubic Centimeters", UN_SC_CM * UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, {"cubic millimeter", "cubic millimeters", "mm³", "mm3", "Cubic Millimeters", UN_SC_MM * UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH}, - {"cubic micrometer", "cubic micrometers", UM"³", "um3", "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, + {"cubic micrometer", "cubic micrometers", "µm³", "um3", "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; static struct bUnitCollection buMetricVolCollection = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef) / sizeof(bUnitDef)}; @@ -258,7 +253,7 @@ static struct bUnitDef buNaturalTimeDef[] = { {"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE}, {"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0, B_UNIT_DEF_NONE}, - {"microsecond", "microseconds", US, "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, + {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; static struct bUnitCollection buNaturalTimeCollection = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef) / sizeof(bUnitDef)}; @@ -278,7 +273,7 @@ static struct bUnitDef buCameraLenDef[] = { {"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS}, {"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, {"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, - {"micrometer", "micrometers", UM, "um", "Micrometers", UN_SC_MM, 0.0, B_UNIT_DEF_SUPPRESS}, // micron too? + {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_MM, 0.0, B_UNIT_DEF_SUPPRESS}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; static struct bUnitCollection buCameraLenCollection = {buCameraLenDef, 3, 0, sizeof(buCameraLenDef) / sizeof(bUnitDef)}; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index c4c246be711..3ed1d15a9ee 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2695,7 +2695,10 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMesh *em, UnitSettings *unit) { - const short txt_flag = V3D_CACHE_TEXT_ASCII | V3D_CACHE_TEXT_LOCALCLIP; + /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square, etc.). + * See bug #36090. + */ + const short txt_flag = V3D_CACHE_TEXT_LOCALCLIP | (unit->system ? 0 : V3D_CACHE_TEXT_ASCII); Mesh *me = ob->data; float v1[3], v2[3], v3[3], vmid[3], fvec[3]; char numstr[32]; /* Stores the measurement display text here */ @@ -2868,14 +2871,11 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe bUnit_AsString(numstr, sizeof(numstr), \ (double)(area * unit->scale_length * unit->scale_length), \ 3, unit->system, B_UNIT_AREA, do_split, false); \ - view3d_cached_text_draw_add(vmid, numstr, 0, \ - /* Metric system uses unicode "squared" sign! */ \ - txt_flag ^ V3D_CACHE_TEXT_ASCII, col); \ } \ else { \ BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \ - view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col); \ } \ + view3d_cached_text_draw_add(vmid, numstr, 0, txt_flag, col); \ } (void)0 UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col); -- cgit v1.2.3 From 8a717f83260e0402970ed770a342efaf1cf9a27e Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Fri, 8 Nov 2013 13:19:51 +0000 Subject: OSX/scons: remove never used MAC_PROC and minor cleanups --- SConstruct | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index f5165606700..92f7d947662 100644 --- a/SConstruct +++ b/SConstruct @@ -294,8 +294,6 @@ if env['OURPLATFORM']=='darwin': import commands - cmd = 'uname -p' - MAC_PROC=commands.getoutput(cmd) cmd = 'sw_vers -productVersion' MAC_CUR_VER=cmd_res=commands.getoutput(cmd) cmd = 'xcodebuild -version' @@ -335,6 +333,7 @@ if env['OURPLATFORM']=='darwin': if env['XCODE_CUR_VER'] >= '4.3': ## since version 4.3, XCode and developer dir are bundled ## env['MACOSX_SDK'] = XCODE_BUNDLE + '/Contents/Developer/Platforms/MacOSX.platform' + env['MACOSX_SDK'] + print B.bc.OKGREEN + "Using OSX SDK :" + B.bc.ENDC + env['MACOSX_SDK'] if not env['WITH_OSX_STATICPYTHON'] == 1: @@ -379,7 +378,7 @@ if env['OURPLATFORM']=='darwin': if env['MACOSX_ARCHITECTURE'] == 'x86_64': env['REL_CCFLAGS'] = env['REL_CCFLAGS']+['-mssse3'] - if env['XCODE_CUR_VER'] >= '5' and not (env['CXX'][:-2].endswith('4.6') or env['CXX'][:-2].endswith('4.8')): + if env['XCODE_CUR_VER'] >= '5' and not env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.6.1': env['CCFLAGS'].append('-ftemplate-depth=1024') # only valid for clang bundled with xcode 5 # for now, Mac builders must download and install the 3DxWare 10 Beta 4 driver framework from 3Dconnexion -- cgit v1.2.3 From a3ec6edc05a4d4819d7e9ba448f74c3cc5f695bc Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Fri, 8 Nov 2013 13:44:10 +0000 Subject: OSX/scons: make MACOSX_SDK_CHECK a local var is sconstruct and remove from env, also fix a longstanding misuse of MACOSX_SDK_CHECK in ceres, use MACOSX_SDK instead --- SConstruct | 16 ++++++++-------- build_files/scons/tools/btools.py | 3 +-- extern/libmv/third_party/ceres/SConscript | 2 +- extern/libmv/third_party/ceres/bundle.sh | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/SConstruct b/SConstruct index 92f7d947662..4a08b691e07 100644 --- a/SConstruct +++ b/SConstruct @@ -293,7 +293,7 @@ if 'cudakernels' in B.targets: if env['OURPLATFORM']=='darwin': import commands - + cmd = 'sw_vers -productVersion' MAC_CUR_VER=cmd_res=commands.getoutput(cmd) cmd = 'xcodebuild -version' @@ -301,7 +301,7 @@ if env['OURPLATFORM']=='darwin': env['XCODE_CUR_VER']=cmd_xcode[6:][:3] # truncate output to major.minor version cmd = 'xcodebuild -showsdks' cmd_sdk=commands.getoutput(cmd) - env['MACOSX_SDK_CHECK']=cmd_sdk + MACOSX_SDK_CHECK=cmd_sdk cmd = 'xcode-select --print-path' XCODE_SELECT_PATH=commands.getoutput(cmd) if XCODE_SELECT_PATH.endswith("/Contents/Developer"): @@ -310,22 +310,22 @@ if env['OURPLATFORM']=='darwin': XCODE_BUNDLE=XCODE_SELECT_PATH print B.bc.OKGREEN + "Detected Xcode version: -- " + B.bc.ENDC + env['XCODE_CUR_VER'] + " --" - print "Available " + env['MACOSX_SDK_CHECK'] + print "Available " + MACOSX_SDK_CHECK if env['MACOSX_SDK'] == '': # no set sdk, choosing best one found - if 'OS X 10.9' in env['MACOSX_SDK_CHECK']: + if 'OS X 10.9' in MACOSX_SDK_CHECK: env['MACOSX_DEPLOYMENT_TARGET'] = '10.6' env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.9.sdk' - elif 'OS X 10.8' in env['MACOSX_SDK_CHECK']: + elif 'OS X 10.8' in MACOSX_SDK_CHECK: env['MACOSX_DEPLOYMENT_TARGET'] = '10.6' env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.8.sdk' - elif 'OS X 10.7' in env['MACOSX_SDK_CHECK']: + elif 'OS X 10.7' in MACOSX_SDK_CHECK: env['MACOSX_DEPLOYMENT_TARGET'] = '10.6' env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.7.sdk' - elif 'OS X 10.6' in env['MACOSX_SDK_CHECK']: + elif 'OS X 10.6' in MACOSX_SDK_CHECK: env['MACOSX_DEPLOYMENT_TARGET'] = '10.6' env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.6.sdk' - elif 'OS X 10.5' in env['MACOSX_SDK_CHECK']: + elif 'OS X 10.5' in MACOSX_SDK_CHECK: env['MACOSX_DEPLOYMENT_TARGET'] = '10.5' env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.5.sdk' else: diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index c542435fb47..607b761261c 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -179,7 +179,7 @@ def validate_arguments(args, bc): 'BF_PROFILE_CFLAGS', 'BF_PROFILE_CCFLAGS', 'BF_PROFILE_CXXFLAGS', 'BF_PROFILE_LINKFLAGS', 'BF_DEBUG_CFLAGS', 'BF_DEBUG_CCFLAGS', 'BF_DEBUG_CXXFLAGS', 'C_WARN', 'CC_WARN', 'CXX_WARN', - 'LLIBS', 'PLATFORM_LINKFLAGS', 'MACOSX_ARCHITECTURE', 'MACOSX_SDK', 'MACOSX_SDK_CHECK', 'XCODE_CUR_VER', + 'LLIBS', 'PLATFORM_LINKFLAGS', 'MACOSX_ARCHITECTURE', 'MACOSX_SDK', 'XCODE_CUR_VER', 'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS', 'MACOSX_DEPLOYMENT_TARGET' ] @@ -502,7 +502,6 @@ def read_opts(env, cfg, args): ('PLATFORM_LINKFLAGS', 'Platform linkflags', []), ('MACOSX_ARCHITECTURE', 'python_arch.zip select', ''), ('MACOSX_SDK', 'Set OS X SDK', ''), - ('MACOSX_SDK_CHECK', 'Detect available OS X SDK`s', ''), ('XCODE_CUR_VER', 'Detect XCode version', ''), ('MACOSX_DEPLOYMENT_TARGET', 'Detect OS X target version', ''), diff --git a/extern/libmv/third_party/ceres/SConscript b/extern/libmv/third_party/ceres/SConscript index a914135fddc..164aedfe415 100644 --- a/extern/libmv/third_party/ceres/SConscript +++ b/extern/libmv/third_party/ceres/SConscript @@ -28,7 +28,7 @@ defs.append('CERES_HAVE_RWLOCK') if env['WITH_BF_OPENMP']: defs.append('CERES_USE_OPENMP') -if 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']: +if 'Mac OS X 10.5' in env['MACOSX_SDK']: defs.append('CERES_NO_TR1') incs = '. ../../ ../../../Eigen3 ./include ./internal ../gflags' diff --git a/extern/libmv/third_party/ceres/bundle.sh b/extern/libmv/third_party/ceres/bundle.sh index 6ab348af118..a6f040b6d29 100755 --- a/extern/libmv/third_party/ceres/bundle.sh +++ b/extern/libmv/third_party/ceres/bundle.sh @@ -225,7 +225,7 @@ defs.append('CERES_HAVE_RWLOCK') if env['WITH_BF_OPENMP']: defs.append('CERES_USE_OPENMP') -if 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']: +if 'Mac OS X 10.5' in env['MACOSX_SDK']: defs.append('CERES_NO_TR1') incs = '. ../../ ../../../Eigen3 ./include ./internal ../gflags' -- cgit v1.2.3 From 774987a38150c8e43114b58aad9c619dac5eafd7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 8 Nov 2013 15:01:43 +0000 Subject: use assert to check for incorrect use of BLF_draw_ascii() --- source/blender/blenfont/intern/blf_font.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index d46df829295..998b415a6af 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -210,6 +210,7 @@ void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len) blf_font_ensure_ascii_table(font); while ((c = *(str++)) && len--) { + BLI_assert(c < 128); if ((g = glyph_ascii_table[c]) == NULL) continue; if (has_kerning) -- cgit v1.2.3 From b144f155799fc7438d3870fac824f287f80be738 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Fri, 8 Nov 2013 18:01:05 +0000 Subject: knife tool: Clean up line hits when starting a new cut Fixes intersection points of the previous cut still being drawn when starting a new cut. --- source/blender/editors/mesh/editmesh_knife.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 32d17f6c599..2e476da2558 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -792,9 +792,13 @@ static void knife_add_cut(KnifeTool_OpData *kcd) kcd->totlinehit = 0; } -static void knife_finish_cut(KnifeTool_OpData *UNUSED(kcd)) +static void knife_finish_cut(KnifeTool_OpData *kcd) { - + if (kcd->linehits) { + MEM_freeN(kcd->linehits); + kcd->linehits = NULL; + kcd->totlinehit = 0; + } } static void knifetool_draw_angle_snapping(const KnifeTool_OpData *kcd) -- cgit v1.2.3 From 0d1a49936627f2885b058f23920490bc6ed7c282 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Fri, 8 Nov 2013 18:01:07 +0000 Subject: knife tool: Remove unused 'extend' variable --- source/blender/editors/mesh/editmesh_knife.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 2e476da2558..de57d24640f 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -203,7 +203,7 @@ typedef struct KnifeTool_OpData { } mode; int prevmode; - bool snap_midpoints, extend; + bool snap_midpoints; bool ignore_edge_snapping; bool ignore_vert_snapping; @@ -2602,8 +2602,6 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd, kcd->vthresh = KMAXDIST - 1; kcd->ethresh = KMAXDIST; - kcd->extend = true; - knife_recalc_projmat(kcd); ED_region_tag_redraw(kcd->ar); @@ -2821,10 +2819,6 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) if (kcd->mode == MODE_DRAGGING) { knife_add_cut(kcd); - if (!kcd->extend) { - knife_finish_cut(kcd); - kcd->mode = MODE_IDLE; - } } else if (kcd->mode != MODE_PANNING) { knife_start_cut(kcd); -- cgit v1.2.3 From ac6d91b9396c15d8bf1aa550adb4ca8c7125dd81 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 8 Nov 2013 20:44:48 +0000 Subject: Be ready for changes in bf-translations repository Made it so if there's release/datafiles/locale/po folder, then all the .po files will be converted to .mo at blender compile time and installed to an appropriate location. Uses small own implementation msgfmt which is based on msgfmt.py from Python project, but also supports contexts. There's no functional changes for until we've switched to use source .po files instead of pre-compiled .mo. P.S. Well, there's one change which is msgfmt.cc being compiled even if it's not used, but would rather not clutter code with checks since pretty soon we'll use this program anyway. --- SConstruct | 21 ++- build_files/cmake/macros.cmake | 30 ++++ intern/locale/CMakeLists.txt | 8 + intern/locale/SConscript | 46 ++++++ intern/locale/msgfmt.cc | 366 +++++++++++++++++++++++++++++++++++++++++ source/creator/CMakeLists.txt | 50 +++++- 6 files changed, 519 insertions(+), 2 deletions(-) create mode 100644 intern/locale/msgfmt.cc diff --git a/SConstruct b/SConstruct index 4a08b691e07..29d4d65b167 100644 --- a/SConstruct +++ b/SConstruct @@ -944,6 +944,9 @@ if env['OURPLATFORM']!='darwin': def check_path(path, member): return (member in path.split(os.sep)) + po_dir = os.path.join("release", "datafiles", "locale", "po") + need_compile_mo = os.path.exists(po_dir) + for intpath in internationalpaths: for dp, dn, df in os.walk(intpath): if '.svn' in dn: @@ -952,7 +955,10 @@ if env['OURPLATFORM']!='darwin': dn.remove('_svn') # we only care about release/datafiles/fonts, release/datafiles/locales - if check_path(dp, "fonts") or check_path(dp, "locale"): + if check_path(dp, "locale"): + if need_compile_mo and check_path(dp, "po"): + continue + elif check_path(dp, "fonts"): pass else: continue @@ -966,6 +972,19 @@ if env['OURPLATFORM']!='darwin': env.Execute(Mkdir(dir)) scriptinstall.append(env.Install(dir=dir,source=source)) + if need_compile_mo: + for f in os.listdir(po_dir): + if not f.endswith(".po"): + continue + + locale_name = os.path.splitext(f)[0] + + mo_file = os.path.join(B.root_build_dir, "locale", locale_name + ".mo") + + dir = os.path.join(env['BF_INSTALLDIR'], VERSION) + dir = os.path.join(dir, "datafiles", "locale", locale_name, "LC_MESSAGES") + scriptinstall.append(env.InstallAs(os.path.join(dir, "blender.mo"), mo_file)) + #-- icons if env['OURPLATFORM']=='linux': iconlist = [] diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index fdc0fb63c8e..7a06352ac70 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -870,3 +870,33 @@ macro(svg_to_png unset(_file_to) endmacro() + +macro(msgfmt_simple + file_from + list_to_add) + + # remove ../'s + get_filename_component(_file_from_we ${file_from} NAME_WE) + + get_filename_component(_file_from ${file_from} REALPATH) + get_filename_component(_file_to ${CMAKE_CURRENT_BINARY_DIR}/${_file_from_we}.mo REALPATH) + + list(APPEND ${list_to_add} ${_file_to}) + + get_filename_component(_file_to_path ${_file_to} PATH) + + add_custom_command( + OUTPUT ${_file_to} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path} + COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/msgfmt ${_file_from} ${_file_to} + DEPENDS msgfmt) + + message("${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/msgfmt ${_file_from} ${_file_to}") + + set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE) + + unset(_file_from_we) + unset(_file_from) + unset(_file_to) + unset(_file_to_path) +endmacro() diff --git a/intern/locale/CMakeLists.txt b/intern/locale/CMakeLists.txt index 1f14a0e7a6a..3599aa68545 100644 --- a/intern/locale/CMakeLists.txt +++ b/intern/locale/CMakeLists.txt @@ -45,3 +45,11 @@ if(WITH_INTERNATIONAL) endif() blender_add_lib(bf_intern_locale "${SRC}" "${INC}" "${INC_SYS}") + +# ----------------------------------------------------------------------------- +# Build msgfmt executable +set(MSFFMT_SRC + msgfmt.cc +) + +add_executable(msgfmt ${MSFFMT_SRC}) diff --git a/intern/locale/SConscript b/intern/locale/SConscript index f60bd90fb38..546fd3e8b40 100644 --- a/intern/locale/SConscript +++ b/intern/locale/SConscript @@ -37,3 +37,49 @@ if env['WITH_BF_INTERNATIONAL']: incs += ' ' + env['BF_BOOST_INC'] env.BlenderLib( 'bf_intern_locale', sources, Split(incs), defs, libtype=['intern','player'], priority=[10, 185]) + +if env['WITH_BF_INTERNATIONAL']: + import os + from os.path import dirname + + def normpath(path): + return os.path.abspath(os.path.normpath(path)) + + # build directory + source_dir = Dir('.').srcnode().path + root_build_dir = normpath(env['BF_BUILDDIR']) + root_source_dir = dirname(dirname(normpath(source_dir))) + po_dir = os.path.join(root_source_dir, "release", "datafiles", "locale", "po") + build_dir = os.path.join(root_build_dir, 'locale') + + if os.path.exists(po_dir): + # create directory if needed + if not os.path.exists(build_dir): + os.makedirs(build_dir) + + msgfmt_tool = env.Clone() + targetpath = root_build_dir + '/msgfmt' + msgfmt_target = msgfmt_tool.Program(target = targetpath, source = ['msgfmt.cc']) + + locale = env.Clone() + + # dependencies + dependencies = [targetpath] + + # add command for each locale + all_mo_files = [] + for f in os.listdir(po_dir): + if not f.endswith(".po"): + continue + + po_file = os.path.join(po_dir, f) + mo_file = os.path.join(build_dir, os.path.splitext(f)[0] + ".mo") + + command = "\"%s\" \"%s\" \"%s\"" % (targetpath, po_file, mo_file) + + locale.Command(mo_file, po_file, command) + locale.Depends(mo_file, dependencies) + + all_mo_files.append(mo_file) + + env.Depends("boost_locale_wrapper.cpp", all_mo_files) diff --git a/intern/locale/msgfmt.cc b/intern/locale/msgfmt.cc new file mode 100644 index 00000000000..cd858cda82d --- /dev/null +++ b/intern/locale/msgfmt.cc @@ -0,0 +1,366 @@ +// Written by Sergey Sharybin +// Added support for contexts +// +// Based on Python script msgfmt.py from Python source +// code tree, which was written by Written by +// Martin v. Löwis +// +// Generate binary message catalog from textual translation description. +// +// This program converts a textual Uniforum-style message catalog (.po file) into +// a binary GNU catalog (.mo file). This is essentially the same function as the +// GNU msgfmt program, however, it is a simpler implementation. +// +// Usage: msgfmt input.po output.po + +#include +#include +#include +#include +#include +#include +#include + +namespace { + +std::map MESSAGES; + +bool starts_with(const std::string &string, + const std::string &prefix) { + return prefix.size() <= string.size() && + string.compare(0, prefix.size(), prefix) == 0; +} + +std::string ltrim(const std::string &s) { + std::string result = s; + result.erase(result.begin(), + std::find_if(result.begin(), + result.end(), + std::not1(std::ptr_fun(std::isspace)))); + return result; +} + +std::string rtrim(const std::string &s) { + std::string result = s; + result.erase( + std::find_if(result.rbegin(), + result.rend(), + std::not1(std::ptr_fun(std::isspace))).base(), + result.end()); + return result; +} + +std::string trim(const std::string &s) { + return ltrim(rtrim(s)); +} + +std::string unescape(const std::string &s) { + std::string result; + std::string::const_iterator it = s.begin(); + while (it != s.end()) { + char current_char = *it++; + if (current_char == '\\' && it != s.end()) { + char next_char = *it++; + if (next_char == '\\') { + current_char = '\\'; + } else if (next_char == 'n') { + current_char = '\n'; + } else if (next_char == 't') { + current_char = '\t'; + } else { + current_char = next_char; + } + } + result += current_char; + } + + if (result[0] == '"' && result[result.size() - 1] == '"') { + result = result.substr(1, result.size() - 2); + } + + return result; +} + +// Add a non-fuzzy translation to the dictionary. +void add(const std::string &msgctxt, + const std::string &msgid, + const std::string &msgstr, + bool fuzzy) { + if (fuzzy == false && msgstr.empty() == false) { + if (msgctxt.empty()) { + MESSAGES[msgid] = msgstr; + } else { + MESSAGES[msgctxt + (char)0x04 + msgid] = msgstr; + } + } +} + +template +void get_keys(std::map map, + std::vector *keys) { + for (typename std::map::iterator it = map.begin(); + it != map.end(); + it++) { + keys->push_back(it->first); + } +} + +std::string intToBytes(int value) { + std::string result; + for (unsigned int i = 0; i < sizeof(value); i++) { + result += (unsigned char) ((value >> (i * 8)) & 0xff); + } + return result; +} + +typedef enum { + SECTION_NONE = 0, + SECTION_CTX = 1, + SECTION_ID = 2, + SECTION_STR = 3 +} eSectionType; + +struct Offset { + unsigned int o1, l1, o2, l2; +}; + +// Return the generated output. +std::string generate(void) { + // The keys are sorted in the .mo file + std::vector keys; + + // Get list of sorted keys. + get_keys(MESSAGES, &keys); + std::sort(keys.begin(), keys.end()); + + std::vector offsets; + std::string ids = "", strs = ""; + for (std::vector::iterator it = keys.begin(); + it != keys.end(); + it++) { + std::string &id = *it; + // For each string, we need size and file offset. Each string is NUL + // terminated; the NUL does not count into the size. + Offset offset = {(unsigned int) ids.size(), + (unsigned int) id.size(), + (unsigned int) strs.size(), + (unsigned int) MESSAGES[id].size()}; + offsets.push_back(offset); + ids += id + '\0'; + strs += MESSAGES[id] + '\0'; + } + + // The header is 7 32-bit unsigned integers. We don't use hash tables, so + // the keys start right after the index tables. + // translated string. + int keystart = 7 * 4 + 16 * keys.size(); + // and the values start after the keys + int valuestart = keystart + ids.size(); + std::vector koffsets; + std::vector voffsets; + // The string table first has the list of keys, then the list of values. + // Each entry has first the size of the string, then the file offset. + for (std::vector::iterator it = offsets.begin(); + it != offsets.end(); + it++) { + Offset &offset = *it; + koffsets.push_back(offset.l1); + koffsets.push_back(offset.o1 + keystart); + voffsets.push_back(offset.l2); + voffsets.push_back(offset.o2 + valuestart); + } + + std::vector all_offsets; + all_offsets.reserve(koffsets.size() + voffsets.size()); + all_offsets.insert(all_offsets.end(), koffsets.begin(), koffsets.end()); + all_offsets.insert(all_offsets.end(), voffsets.begin(), voffsets.end()); + + std::string output = ""; + output += intToBytes(0x950412de); // Magic + output += intToBytes(0x0); // Version + output += intToBytes(keys.size()); // # of entries + output += intToBytes(7 * 4); // start of key index + output += intToBytes(7 * 4 + keys.size() * 8); // start of value index + output += intToBytes(0); // Size of hash table + output += intToBytes(0); // Offset of hash table + + for (std::vector::iterator it = all_offsets.begin(); + it != all_offsets.end(); + it++) { + int offset = *it; + output += intToBytes(offset); + } + + output += ids; + output += strs; + + return output; +} + +void make(const char *input_file_name, + const char *output_file_name) { + std::map messages; + + // Start off assuming Latin-1, so everything decodes without failure, + // until we know the exact encoding. + // TODO(sergey): Support encoding. + // const char *encoding = "latin-1"; + + eSectionType section = SECTION_NONE; + bool fuzzy = false; + bool is_plural = false; + std::string msgctxt, msgid, msgstr; + + std::ifstream input_file_stream(input_file_name); + + // Parse the catalog. + int lno = 0; + for (std::string l; getline(input_file_stream, l); ) { + lno++; + // If we get a comment line after a msgstr, this is a new entry. + if (l[0] == '#' && section == SECTION_STR) { + add(msgctxt, msgid, msgstr, fuzzy); + section = SECTION_NONE; + fuzzy = false; + } + // Record a fuzzy mark. + if (starts_with(l, "#,") && l.find("fuzzy") != std::string::npos) { + fuzzy = 1; + } + // Skip comments + if (l[0] == '#') { + continue; + } + // Now we are in a msgid section, output previous section. + if (starts_with(l, "msgctxt")) { + if (section == SECTION_STR) { + add(msgctxt, msgid, msgstr, fuzzy); + } + section = SECTION_CTX; + l = l.substr(7, l.size() - 7); + msgctxt = msgid = msgstr = ""; + } + else if (starts_with(l, "msgid") && !starts_with(l, "msgid_plural")) { + if (section == SECTION_STR) { + add(msgctxt, msgid, msgstr, fuzzy); + msgctxt = ""; + if (msgid == "") { +#if 0 + // See whether there is an encoding declaration. + p = HeaderParser(); + charset = p.parsestr(msgstr.decode(encoding)).get_content_charset(); + if (charset) { + encoding = charset; + } +#else + // Not ported to C++ yet. + std::cerr << "Encoding declarations are not supported yet.\n" + << std::endl; + abort(); +#endif + } + } + section = SECTION_ID; + l = l.substr(5, l.size() - 5); + msgid = msgstr = ""; + is_plural = false; + } else if (starts_with(l, "msgid_plural")) { + // This is a message with plural forms. + if (section != SECTION_ID) { + std::cerr << "msgid_plural not preceeded by msgid on" + << input_file_name << ":" + << lno + << std::endl; + abort(); + } + l = l.substr(12, l.size() - 12); + msgid += '\0'; // separator of singular and plural + is_plural = true; + } else if (starts_with(l, "msgstr")) { + // Now we are in a msgstr section + section = SECTION_STR; + if (starts_with(l, "msgstr[")) { + if (is_plural == false) { + std::cerr << "plural without msgid_plural on " + << input_file_name << ":" + << lno + << std::endl; + abort(); + } + int bracket_position = l.find(']'); + if (bracket_position == std::string::npos) { + std::cerr << "Syntax error on " + << input_file_name << ":" + << lno + << std::endl; + abort(); + } + l = l.substr(bracket_position, l.size() - bracket_position); + if (msgstr != "") { + msgstr += '\0'; // Separator of the various plural forms; + } + } else { + if (is_plural) { + std::cerr << "indexed msgstr required for plural on " + << input_file_name << ":" + << lno + << std::endl; + abort(); + } + l = l.substr(6, l.size() - 6); + } + } + // Skip empty lines. + l = trim(l); + if (l.empty()) { + continue; + } + l = unescape(l); + if (section == SECTION_CTX) { + // TODO(sergey): Support encoding. + // msgid += l.encode(encoding); + msgctxt += l; + } + else if (section == SECTION_ID) { + // TODO(sergey): Support encoding. + // msgid += l.encode(encoding); + msgid += l; + } else if (section == SECTION_STR) { + // TODO(sergey): Support encoding. + // msgstr += l.encode(encoding) + msgstr += l; + } else { + std::cerr << "Syntax error on " + << input_file_name << ":" + << lno + << std::endl; + abort(); + } + // Add last entry + if (section == SECTION_STR) { + add(msgctxt, msgid, msgstr, fuzzy); + } + } + + // Compute output + std::string output = generate(); + + std::ofstream output_file_stream(output_file_name, + std::ios::out | std::ios::binary); + output_file_stream << output; +} + +} // namespace + +int main(int argc, char **argv) { + if (argc != 3) { + printf("Usage: %s \n", argv[0]); + return EXIT_FAILURE; + } + const char *input_file = argv[1]; + const char *output_file = argv[2]; + + make(input_file, output_file); + + return EXIT_SUCCESS; +} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 33d5c7dc90b..b386312bb55 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -318,11 +318,59 @@ endif() if(WITH_INTERNATIONAL) install( DIRECTORY - ${CMAKE_SOURCE_DIR}/release/datafiles/locale ${CMAKE_SOURCE_DIR}/release/datafiles/fonts DESTINATION ${TARGETDIR_VER}/datafiles PATTERN ".svn" EXCLUDE ) + + set(_locale_dir "${CMAKE_SOURCE_DIR}/release/datafiles/locale") + + if(EXISTS "${_locale_dir}/po") + set(_locale_target_dir ${TARGETDIR_VER}/datafiles/locale) + + file(GLOB _po_files "${_locale_dir}/po/*.po") + foreach(_po_file ${_po_files}) + msgfmt_simple(${_po_file} _all_mo_files) + endforeach() + + # Create a custom target which will compile all po to mo + add_custom_target( + locales + DEPENDS ${_all_mo_files}) + + add_dependencies(blender locales) + + # Generate INSTALL rules + install( + FILES ${_locale_dir}/languages + DESTINATION ${_locale_target_dir} + ) + + foreach(_mo_file ${_all_mo_files}) + get_filename_component(_locale_name ${_mo_file} NAME_WE) + install( + FILES ${_mo_file} + DESTINATION ${_locale_target_dir}/${_locale_name}/LC_MESSAGES + RENAME blender.mo + ) + unset(_locale_name) + endforeach() + + unset(_all_mo_files) + unset(_po_files) + unset(_po_file) + unset(_mo_file) + unset(_locale_target_dir) + else() + install( + DIRECTORY + ${_locale_dir} + DESTINATION ${TARGETDIR_VER}/datafiles + PATTERN ".svn" EXCLUDE + ) + endif() + + unset(_locale_dir) endif() # color management -- cgit v1.2.3 From 396fb315c5f0267a0511eda87221c8a2836c6f21 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 9 Nov 2013 10:35:32 +0000 Subject: More fix for [#37327] Inconsistent numeric input conversion. When a single element is involved, apply directly the values instead of using the diff from init values. This avoids glitches when going from huge values to very small ones (due to float precision). Note we should probably switch to doubles here, ultimately, but would leave that for later. Manys thanks to Armin Zingler, who did all the investigation work on this point! --- .../blender/editors/space_view3d/view3d_buttons.c | 62 ++++++++++++++++------ 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index eea084b4750..c4fdacaa915 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -482,7 +482,15 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - add_v3_v3(eve->co, &median[LOC_X]); + if (tot == 1) { + /* In case we only have one element selected, copy directly the value instead of applying + * the diff. Avoids some glitches when going e.g. from 3 to 0.0001 (see [#37327]). + */ + copy_v3_v3(eve->co, &ve_median[LOC_X]); + } + else { + add_v3_v3(eve->co, &median[LOC_X]); + } } } @@ -623,10 +631,12 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float nu = nurbs->first; while (nu) { if (nu->type == CU_BEZIER) { - bezt = nu->bezt; - a = nu->pntsu; - while (a--) { + for (a = nu->pntsu, bezt = nu->bezt; a--; bezt++) { if (bezt->f2 & SELECT) { + /* Here we always have to use the diff... :/ + * Cannot avoid some glitches when going e.g. from 3 to 0.0001 (see [#37327]), + * unless we use doubles. + */ add_v3_v3(bezt->vec[0], &median[LOC_X]); add_v3_v3(bezt->vec[1], &median[LOC_X]); add_v3_v3(bezt->vec[2], &median[LOC_X]); @@ -647,22 +657,39 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } else { if (bezt->f1 & SELECT) { - add_v3_v3(bezt->vec[0], &median[LOC_X]); + if (tot == 1) { + copy_v3_v3(bezt->vec[0], &ve_median[LOC_X]); + } + else { + add_v3_v3(bezt->vec[0], &median[LOC_X]); + } } if (bezt->f3 & SELECT) { - add_v3_v3(bezt->vec[2], &median[LOC_X]); + if (tot == 1) { + copy_v3_v3(bezt->vec[2], &ve_median[LOC_X]); + } + else { + add_v3_v3(bezt->vec[2], &median[LOC_X]); + } } } - bezt++; } } else { - bp = nu->bp; - a = nu->pntsu * nu->pntsv; - while (a--) { + for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a--; bp++) { if (bp->f1 & SELECT) { - add_v3_v3(bp->vec, &median[LOC_X]); - bp->vec[3] += median[C_BWEIGHT]; + if (tot == 1) { + copy_v3_v3(bp->vec, &ve_median[LOC_X]); + bp->vec[3] = ve_median[C_BWEIGHT]; + bp->radius = ve_median[C_RADIUS]; + bp->alfa = ve_median[C_TILT]; + } + else { + add_v3_v3(bp->vec, &median[LOC_X]); + bp->vec[3] += median[C_BWEIGHT]; + bp->radius += median[C_RADIUS]; + bp->alfa += median[C_TILT]; + } if (median[C_WEIGHT] != 0.0f) { if (ELEM(scale_w, 0.0f, 1.0f)) { @@ -674,11 +701,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float CLAMP(bp->weight, 0.0f, 1.0f); } } - - bp->radius += median[C_RADIUS]; - bp->alfa += median[C_TILT]; } - bp++; } } BKE_nurb_test2D(nu); @@ -697,7 +720,12 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float bp = lt->editlatt->latt->def; while (a--) { if (bp->f1 & SELECT) { - add_v3_v3(bp->vec, &median[LOC_X]); + if (tot == 1) { + copy_v3_v3(bp->vec, &ve_median[LOC_X]); + } + else { + add_v3_v3(bp->vec, &median[LOC_X]); + } if (median[L_WEIGHT] != 0.0f) { if (ELEM(scale_w, 0.0f, 1.0f)) { -- cgit v1.2.3 From cc7b2a0b046f9eb0548b8a1e84c4deb5754487c1 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 9 Nov 2013 13:14:00 +0000 Subject: Cycles / Fresnel Node: * Add a "Normal" Input to the Fresnel node. * Fix for the Fresnel GLSL code (normalize the Incoming vector). Patch #37384 by Philipp Oeser (lichtwerk) , thanks! --- intern/cycles/kernel/svm/svm_fresnel.h | 8 ++++++-- intern/cycles/render/nodes.cpp | 7 ++++++- source/blender/gpu/shaders/gpu_shader_material.glsl | 2 +- source/blender/nodes/shader/nodes/node_shader_fresnel.c | 7 +++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/intern/cycles/kernel/svm/svm_fresnel.h b/intern/cycles/kernel/svm/svm_fresnel.h index 549c0351d83..d97d6a3738f 100644 --- a/intern/cycles/kernel/svm/svm_fresnel.h +++ b/intern/cycles/kernel/svm/svm_fresnel.h @@ -18,13 +18,17 @@ CCL_NAMESPACE_BEGIN /* Fresnel Node */ -__device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, uint ior_value, uint out_offset) +__device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, uint ior_value, uint node) { + uint normal_offset, out_offset; + decode_node_uchar4(node, &normal_offset, &out_offset, NULL, NULL); float eta = (stack_valid(ior_offset))? stack_load_float(stack, ior_offset): __uint_as_float(ior_value); + float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N; + eta = fmaxf(eta, 1.0f + 1e-5f); eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta; - float f = fresnel_dielectric_cos(dot(sd->I, sd->N), eta); + float f = fresnel_dielectric_cos(dot(sd->I, normal_in), eta); stack_store_float(stack, out_offset, f); } diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 5352840d2cb..4919222e81c 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -3166,12 +3166,17 @@ FresnelNode::FresnelNode() void FresnelNode::compile(SVMCompiler& compiler) { + ShaderInput *normal_in = input("Normal"); ShaderInput *ior_in = input("IOR"); ShaderOutput *fac_out = output("Fac"); compiler.stack_assign(ior_in); compiler.stack_assign(fac_out); - compiler.add_node(NODE_FRESNEL, ior_in->stack_offset, __float_as_int(ior_in->value.x), fac_out->stack_offset); + + if(normal_in->link) + compiler.stack_assign(normal_in); + + compiler.add_node(NODE_FRESNEL, ior_in->stack_offset, __float_as_int(ior_in->value.x), compiler.encode_uchar4(normal_in->stack_offset, fac_out->stack_offset)); } void FresnelNode::compile(OSLCompiler& compiler) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 633112095a7..78664f3b539 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2131,7 +2131,7 @@ void node_add_shader(vec4 shader1, vec4 shader2, out vec4 shader) void node_fresnel(float ior, vec3 N, vec3 I, out float result) { float eta = max(ior, 0.00001); - result = fresnel_dielectric(I, N, (gl_FrontFacing)? eta: 1.0/eta); + result = fresnel_dielectric(normalize(I), N, (gl_FrontFacing)? eta: 1.0/eta); } /* gamma */ diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c index 1e5c10968a5..c22b0f41695 100644 --- a/source/blender/nodes/shader/nodes/node_shader_fresnel.c +++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.c @@ -30,6 +30,7 @@ /* **************** Fresnel ******************** */ static bNodeSocketTemplate sh_node_fresnel_in[] = { { SOCK_FLOAT, 1, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 1.0f, 1000.0f}, + { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; @@ -40,8 +41,10 @@ static bNodeSocketTemplate sh_node_fresnel_out[] = { static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) { - /* todo: is incoming vector normalized? */ - return GPU_stack_link(mat, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_NORMAL), GPU_builtin(GPU_VIEW_POSITION)); + if (!in[1].link) + in[1].link = GPU_builtin(GPU_VIEW_NORMAL); + + return GPU_stack_link(mat, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_POSITION)); } /* node type definition */ -- cgit v1.2.3 From 9fd03c135406a5d0a86144659792e042720c8e75 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sat, 9 Nov 2013 13:31:20 +0000 Subject: OSX/scons: Only cosmetical, a nicer formatting for available sdk listing --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 29d4d65b167..9726bdb09e0 100644 --- a/SConstruct +++ b/SConstruct @@ -310,7 +310,7 @@ if env['OURPLATFORM']=='darwin': XCODE_BUNDLE=XCODE_SELECT_PATH print B.bc.OKGREEN + "Detected Xcode version: -- " + B.bc.ENDC + env['XCODE_CUR_VER'] + " --" - print "Available " + MACOSX_SDK_CHECK + print B.bc.OKGREEN + "Available SDK's: \n" + B.bc.ENDC + MACOSX_SDK_CHECK.replace('\t', '') if env['MACOSX_SDK'] == '': # no set sdk, choosing best one found if 'OS X 10.9' in MACOSX_SDK_CHECK: -- cgit v1.2.3 From 7d3698e26c228661eeecf78a6ee7310876303763 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sat, 9 Nov 2013 16:00:08 +0000 Subject: OSX/scons: spelling and cleanup comments --- SConstruct | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/SConstruct b/SConstruct index 9726bdb09e0..f69989229f9 100644 --- a/SConstruct +++ b/SConstruct @@ -381,9 +381,7 @@ if env['OURPLATFORM']=='darwin': if env['XCODE_CUR_VER'] >= '5' and not env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.6.1': env['CCFLAGS'].append('-ftemplate-depth=1024') # only valid for clang bundled with xcode 5 - # for now, Mac builders must download and install the 3DxWare 10 Beta 4 driver framework from 3Dconnexion - # necessary header file lives here when installed: - # /Library/Frameworks/3DconnexionClient.framework/Versions/Current/Headers/ConnexionClientAPI.h + # 3DconnexionClient.framework, optionally install if env['WITH_BF_3DMOUSE'] == 1: if not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'): print "3D_CONNEXION_CLIENT_LIBRARY not found, disabling WITH_BF_3DMOUSE" # avoid build errors ! @@ -392,9 +390,7 @@ if env['OURPLATFORM']=='darwin': env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','3DconnexionClient']) env['BF_3DMOUSE_INC'] = '/Library/Frameworks/3DconnexionClient.framework/Headers' - # for now, Mac builders must download and install the JackOSX framework - # necessary header file lives here when installed: - # /Library/Frameworks/Jackmp.framework/Versions/A/Headers/jack.h + # Jackmp.framework, optionally install if env['WITH_BF_JACK'] == 1: if not os.path.exists('/Library/Frameworks/Jackmp.framework'): print "JackOSX install not found, disabling WITH_BF_JACK" # avoid build errors ! @@ -424,7 +420,7 @@ if env['OURPLATFORM']=='darwin': env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-force_load '+ OSX_OSL_LIBPATH +'/liboslexec.a','-loslquery']) env.Append(BF_PROGRAM_LINKFLAGS=['-Xlinker','-force_load','-Xlinker',OSX_OSL_LIBPATH +'/liboslexec.a']) - # Trying to get rid of eventually clashes, we export some explicite as local symbols + # Trying to get rid of eventually clashes, we export some symbols explicite as local env.Append(LINKFLAGS=['-Xlinker','-unexported_symbols_list','-Xlinker','./source/creator/osx_locals.map']) #for < 10.7.sdk, SystemStubs needs to be linked -- cgit v1.2.3 From 8c256de95999c8d1edbc148028c45b03f01a0398 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sat, 9 Nov 2013 16:32:10 +0000 Subject: OSX/scons: user request, make options succes transparent by printing it --- SConstruct | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index f69989229f9..2c30e1b72b1 100644 --- a/SConstruct +++ b/SConstruct @@ -384,19 +384,21 @@ if env['OURPLATFORM']=='darwin': # 3DconnexionClient.framework, optionally install if env['WITH_BF_3DMOUSE'] == 1: if not os.path.exists('/Library/Frameworks/3DconnexionClient.framework'): - print "3D_CONNEXION_CLIENT_LIBRARY not found, disabling WITH_BF_3DMOUSE" # avoid build errors ! env['WITH_BF_3DMOUSE'] = 0 + print B.bc.OKGREEN + "3DconnexionClient install not found, disabling WITH_BF_3DMOUSE" # avoid build errors ! else: env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','3DconnexionClient']) env['BF_3DMOUSE_INC'] = '/Library/Frameworks/3DconnexionClient.framework/Headers' + print B.bc.OKGREEN + "Using 3Dconnexion" # Jackmp.framework, optionally install if env['WITH_BF_JACK'] == 1: if not os.path.exists('/Library/Frameworks/Jackmp.framework'): - print "JackOSX install not found, disabling WITH_BF_JACK" # avoid build errors ! env['WITH_BF_JACK'] = 0 + print B.bc.OKGREEN + "JackOSX install not found, disabling WITH_BF_JACK" # avoid build errors ! else: env.Append(LINKFLAGS=['-F/Library/Frameworks','-Xlinker','-weak_framework','-Xlinker','Jackmp']) + print B.bc.OKGREEN + "Using Jack" if env['WITH_BF_QUICKTIME'] == 1: env['PLATFORM_LINKFLAGS'] = env['PLATFORM_LINKFLAGS']+['-framework','QTKit'] @@ -409,7 +411,7 @@ if env['OURPLATFORM']=='darwin': print B.bc.OKGREEN + "Using OpenMP" else: env['WITH_BF_OPENMP'] = 0 - print B.bc.OKGREEN + "Disabled OpenMP" + print B.bc.OKGREEN + "Disabled OpenMP, not supported by compiler" if env['WITH_BF_CYCLES_OSL'] == 1: OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath -- cgit v1.2.3 From efa23a47edebb7a459ca2e62ba922a01bff76dbb Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 9 Nov 2013 17:05:07 +0000 Subject: uiList: fix a bug in computing visual active index (afaict, in case of reordering, was affecting "keep active visible" feature when resizing, and the "active label color" in custom themes). --- source/blender/editors/interface/interface_templates.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 11990a5d052..46cff2fb458 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2855,6 +2855,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co items_shown = dyn_data->items_shown; if (items_shown >= 0) { + bool activei_mapping_pending = true; items_ptr = MEM_mallocN(sizeof(_uilist_item) * items_shown, AT); //printf("%s: items shown: %d.\n", __func__, items_shown); RNA_PROP_BEGIN (dataptr, itemptr, prop) @@ -2875,8 +2876,10 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co items_ptr[ii].org_idx = i; items_ptr[ii].flt_flag = dyn_data->items_filter_flags ? dyn_data->items_filter_flags[i] : 0; - if (activei == i) { + if (activei_mapping_pending && activei == i) { activei = ii; + /* So that we do not map again activei! */ + activei_mapping_pending = false; } # if 0 /* For now, do not alter active element, even if it will be hidden... */ else if (activei < i) { -- cgit v1.2.3 From a352670791c4cf5be17ec90becaa3f1e051f451b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 9 Nov 2013 18:44:37 +0000 Subject: uiList: fix another bug, where active item labels in sublayouts would not get colored as active (need recursion in sublayouts!). Was affecting e.g. Group node inputs/outputs lists. --- source/blender/editors/interface/interface_layout.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 89c244009e5..e5bcc3d6863 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2423,7 +2423,10 @@ void ui_layout_list_set_labels_active(uiLayout *layout) { uiButtonItem *bitem; for (bitem = layout->items.first; bitem; bitem = bitem->item.next) { - if (bitem->item.type == ITEM_BUTTON && bitem->but->type == LISTLABEL) { + if (bitem->item.type != ITEM_BUTTON) { + ui_layout_list_set_labels_active((uiLayout *)(&bitem->item)); + } + else if (bitem->but->type == LISTLABEL) { uiButSetFlag(bitem->but, UI_SELECT); } } -- cgit v1.2.3 From bbcfadff35c8182dc3ccbb05d63b0362fddb3084 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 10 Nov 2013 08:15:24 +0000 Subject: Work around for bug [#37376] wrong tooltips on few minus buttons Until we have a way to customize tooltips based on operator parameters... --- release/scripts/startup/bl_operators/presets.py | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 05dfd882180..ae6ec3946f1 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -221,7 +221,7 @@ class ExecutePreset(Operator): class AddPresetRender(AddPresetBase, Operator): - """Add a Render Preset""" + """Add or remove a Render Preset""" bl_idname = "render.preset_add" bl_label = "Add Render Preset" preset_menu = "RENDER_MT_presets" @@ -247,7 +247,7 @@ class AddPresetRender(AddPresetBase, Operator): class AddPresetCamera(AddPresetBase, Operator): - """Add a Camera Preset""" + """Add or remove a Camera Preset""" bl_idname = "camera.preset_add" bl_label = "Add Camera Preset" preset_menu = "CAMERA_MT_presets" @@ -266,7 +266,7 @@ class AddPresetCamera(AddPresetBase, Operator): class AddPresetSSS(AddPresetBase, Operator): - """Add a Subsurface Scattering Preset""" + """Add or remove a Subsurface Scattering Preset""" bl_idname = "material.sss_preset_add" bl_label = "Add SSS Preset" preset_menu = "MATERIAL_MT_sss_presets" @@ -294,7 +294,7 @@ class AddPresetSSS(AddPresetBase, Operator): class AddPresetCloth(AddPresetBase, Operator): - """Add a Cloth Preset""" + """Add or remove a Cloth Preset""" bl_idname = "cloth.preset_add" bl_label = "Add Cloth Preset" preset_menu = "CLOTH_MT_presets" @@ -316,7 +316,7 @@ class AddPresetCloth(AddPresetBase, Operator): class AddPresetFluid(AddPresetBase, Operator): - """Add a Fluid Preset""" + """Add or remove a Fluid Preset""" bl_idname = "fluid.preset_add" bl_label = "Add Fluid Preset" preset_menu = "FLUID_MT_presets" @@ -334,7 +334,7 @@ class AddPresetFluid(AddPresetBase, Operator): class AddPresetSunSky(AddPresetBase, Operator): - """Add a Sky & Atmosphere Preset""" + """Add or remove a Sky & Atmosphere Preset""" bl_idname = "lamp.sunsky_preset_add" bl_label = "Add Sunsky Preset" preset_menu = "LAMP_MT_sunsky_presets" @@ -363,7 +363,7 @@ class AddPresetSunSky(AddPresetBase, Operator): class AddPresetInteraction(AddPresetBase, Operator): - """Add an Application Interaction Preset""" + """Add or remove an Application Interaction Preset""" bl_idname = "wm.interaction_preset_add" bl_label = "Add Interaction Preset" preset_menu = "USERPREF_MT_interaction_presets" @@ -389,7 +389,7 @@ class AddPresetInteraction(AddPresetBase, Operator): class AddPresetTrackingCamera(AddPresetBase, Operator): - """Add a Tracking Camera Intrinsics Preset""" + """Add or remove a Tracking Camera Intrinsics Preset""" bl_idname = "clip.camera_preset_add" bl_label = "Add Camera Preset" preset_menu = "CLIP_MT_camera_presets" @@ -412,7 +412,7 @@ class AddPresetTrackingCamera(AddPresetBase, Operator): class AddPresetTrackingTrackColor(AddPresetBase, Operator): - """Add a Clip Track Color Preset""" + """Add or remove a Clip Track Color Preset""" bl_idname = "clip.track_color_preset_add" bl_label = "Add Track Color Preset" preset_menu = "CLIP_MT_track_color_presets" @@ -430,7 +430,7 @@ class AddPresetTrackingTrackColor(AddPresetBase, Operator): class AddPresetTrackingSettings(AddPresetBase, Operator): - """Add a motion tracking settings preset""" + """Add or remove a motion tracking settings preset""" bl_idname = "clip.tracking_settings_preset_add" bl_label = "Add Tracking Settings Preset" preset_menu = "CLIP_MT_tracking_settings_presets" @@ -459,7 +459,7 @@ class AddPresetTrackingSettings(AddPresetBase, Operator): class AddPresetNodeColor(AddPresetBase, Operator): - """Add a Node Color Preset""" + """Add or remove a Node Color Preset""" bl_idname = "node.node_color_preset_add" bl_label = "Add Node Color Preset" preset_menu = "NODE_MT_node_color_presets" @@ -477,7 +477,7 @@ class AddPresetNodeColor(AddPresetBase, Operator): class AddPresetInterfaceTheme(AddPresetBase, Operator): - """Add a theme preset""" + """Add or remove a theme preset""" bl_idname = "wm.interface_theme_preset_add" bl_label = "Add Theme Preset" preset_menu = "USERPREF_MT_interface_theme_presets" @@ -485,7 +485,7 @@ class AddPresetInterfaceTheme(AddPresetBase, Operator): class AddPresetKeyconfig(AddPresetBase, Operator): - """Add a Key-config Preset""" + """Add or remove a Key-config Preset""" bl_idname = "wm.keyconfig_preset_add" bl_label = "Add Keyconfig Preset" preset_menu = "USERPREF_MT_keyconfigs" @@ -508,7 +508,7 @@ class AddPresetKeyconfig(AddPresetBase, Operator): class AddPresetOperator(AddPresetBase, Operator): - """Add an Operator Preset""" + """Add or remove an Operator Preset""" bl_idname = "wm.operator_preset_add" bl_label = "Operator Preset" preset_menu = "WM_MT_operator_presets" -- cgit v1.2.3 From 07534f05d5cc5ad7f31d6544da6e2aafb0051508 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Nov 2013 12:26:03 +0000 Subject: no need to call isnan() on unsigned ints (causes error on freebsd/clang) --- source/blender/imbuf/intern/cineon/cineonlib.c | 4 ++-- source/blender/imbuf/intern/cineon/dpxlib.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c index 1481b2aaa66..3c3bdcfbf2c 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.c +++ b/source/blender/imbuf/intern/cineon/cineonlib.c @@ -277,10 +277,10 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t return NULL; } - if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32 || isnan(cineon->element[i].refLowData)) + if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32 || cineon->element[i].refLowData) cineon->element[i].refLowData = 0; - if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32 || isnan(cineon->element[i].refHighData)) + if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32 || cineon->element[i].refHighData) cineon->element[i].refHighData = (unsigned int)cineon->element[i].maxValue; if (cineon->element[i].refLowQuantity == CINEON_UNDEFINED_R32 || isnan(cineon->element[i].refLowQuantity)) diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index 5a4371d84ba..006236e647e 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -300,10 +300,10 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf case descriptor_RGB: case descriptor_RGBA: case descriptor_ABGR: - if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refLowData)) + if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || dpx->element[i].refLowData) dpx->element[i].refLowData = 0; - if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refHighData)) + if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || dpx->element[i].refHighData) dpx->element[i].refHighData = (unsigned int)dpx->element[i].maxValue; if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity)) @@ -324,10 +324,10 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf case descriptor_CbYCr: case descriptor_CbYACrYA: case descriptor_CbYCrA: - if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refLowData)) + if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || dpx->element[i].refLowData) dpx->element[i].refLowData = 16.0f / 255.0f * dpx->element[i].maxValue; - if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refHighData)) + if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || dpx->element[i].refHighData) dpx->element[i].refHighData = 235.0f / 255.0f * dpx->element[i].maxValue; if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity)) -- cgit v1.2.3 From 73c2253ac629665715ec700b049e97fe1b17bc56 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Nov 2013 12:29:15 +0000 Subject: mistake in last commit --- source/blender/imbuf/intern/cineon/cineonlib.c | 4 ++-- source/blender/imbuf/intern/cineon/dpxlib.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c index 3c3bdcfbf2c..fddfa2618c2 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.c +++ b/source/blender/imbuf/intern/cineon/cineonlib.c @@ -277,10 +277,10 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t return NULL; } - if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32 || cineon->element[i].refLowData) + if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32) cineon->element[i].refLowData = 0; - if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32 || cineon->element[i].refHighData) + if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32) cineon->element[i].refHighData = (unsigned int)cineon->element[i].maxValue; if (cineon->element[i].refLowQuantity == CINEON_UNDEFINED_R32 || isnan(cineon->element[i].refLowQuantity)) diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index 006236e647e..e839c2fce90 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -300,10 +300,10 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf case descriptor_RGB: case descriptor_RGBA: case descriptor_ABGR: - if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || dpx->element[i].refLowData) + if (dpx->element[i].refLowData == DPX_UNDEFINED_U32) dpx->element[i].refLowData = 0; - if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || dpx->element[i].refHighData) + if (dpx->element[i].refHighData == DPX_UNDEFINED_U32) dpx->element[i].refHighData = (unsigned int)dpx->element[i].maxValue; if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity)) @@ -324,10 +324,10 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf case descriptor_CbYCr: case descriptor_CbYACrYA: case descriptor_CbYCrA: - if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || dpx->element[i].refLowData) + if (dpx->element[i].refLowData == DPX_UNDEFINED_U32) dpx->element[i].refLowData = 16.0f / 255.0f * dpx->element[i].maxValue; - if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || dpx->element[i].refHighData) + if (dpx->element[i].refHighData == DPX_UNDEFINED_U32) dpx->element[i].refHighData = 235.0f / 255.0f * dpx->element[i].maxValue; if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity)) -- cgit v1.2.3 From bfb9cefccbf8ff9733e9739e9c4dbc93a762bebe Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Sun, 10 Nov 2013 12:31:57 +0000 Subject: Added options for how bevel amount is measured. Now there is an 'Offset Type' dropdown on tool shelf with types: Offset - current method, offset of new edge from old along sliding face Width - width of new bevel face (if segments=1) Depth - amount a chamfering plane moves down from original edge Percent - percent of way sliding edges move along their adjacent edges The different options mainly are useful when beveling more than one edge at once. Leaving as a TODO to put these in the modifier, as doing that has more permanent effects so want to let users shake out problems with this first. --- source/blender/bmesh/intern/bmesh_opdefines.c | 1 + source/blender/bmesh/intern/bmesh_operators.h | 8 +++ source/blender/bmesh/operators/bmo_bevel.c | 9 +-- source/blender/bmesh/tools/bmesh_bevel.c | 97 ++++++++++++++++++++------- source/blender/bmesh/tools/bmesh_bevel.h | 2 +- source/blender/editors/mesh/editmesh_bevel.c | 28 ++++++-- source/blender/modifiers/intern/MOD_bevel.c | 3 +- 7 files changed, 113 insertions(+), 35 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index ea533837b04..ef43d73d485 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1557,6 +1557,7 @@ static BMOpDefine bmo_bevel_def = { /* slots_in */ {{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input edges and vertices */ {"offset", BMO_OP_SLOT_FLT}, /* amount to offset beveled edge */ + {"offset_type", BMO_OP_SLOT_INT}, /* how to measure offset (enum) */ {"segments", BMO_OP_SLOT_INT}, /* number of segments in bevel */ {"vertex_only", BMO_OP_SLOT_BOOL}, /* only bevel vertices, not edges */ {{'\0'}}, diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h index 56d63694d88..b3d97947cab 100644 --- a/source/blender/bmesh/intern/bmesh_operators.h +++ b/source/blender/bmesh/intern/bmesh_operators.h @@ -117,6 +117,14 @@ enum { BMOP_POKE_BOUNDS }; +/* Bevel offset_type slot values */ +enum { + BEVEL_AMT_OFFSET, + BEVEL_AMT_WIDTH, + BEVEL_AMT_DEPTH, + BEVEL_AMT_PERCENT +}; + extern const BMOpDefine *bmo_opdefines[]; extern const int bmo_opdefines_total; diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index eef470e0d85..4eec15d4d7e 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -35,9 +35,10 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) { - const float offset = BMO_slot_float_get(op->slots_in, "offset"); - const int seg = BMO_slot_int_get(op->slots_in, "segments"); - const bool vonly = BMO_slot_bool_get(op->slots_in, "vertex_only"); + const float offset = BMO_slot_float_get(op->slots_in, "offset"); + const int offset_type = BMO_slot_int_get(op->slots_in, "offset_type"); + const int seg = BMO_slot_int_get(op->slots_in, "segments"); + const bool vonly = BMO_slot_bool_get(op->slots_in, "vertex_only"); if (offset > 0) { BMOIter siter; @@ -58,7 +59,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) } } - BM_mesh_bevel(bm, offset, seg, vonly, false, false, NULL, -1); + BM_mesh_bevel(bm, offset, offset_type, seg, vonly, false, false, NULL, -1); BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG); } diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index bb3fe129e0b..7293e400951 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -73,7 +73,8 @@ typedef struct EdgeHalf { struct BoundVert *leftv; /* left boundary vert (looking along edge to end) */ struct BoundVert *rightv; /* right boundary vert, if beveled */ int seg; /* how many segments for the bevel */ - float offset; /* offset for this edge */ + float offset_l; /* offset for this edge, on left side */ + float offset_r; /* offset for this edge, on right side */ bool is_bev; /* is this edge beveled? */ bool is_rev; /* is e->v2 the vertex at this end? */ bool is_seam; /* is e a seam for custom loopdata (e.g., UVs)? */ @@ -128,6 +129,7 @@ typedef struct BevelParams { MemArena *mem_arena; /* use for all allocs while bevel runs, if we need to free we can switch to mempool */ float offset; /* blender units to offset each side of a beveled edge */ + int offset_type; /* how offset is measured; enum defined in bmesh_operators.h */ int seg; /* number of segments in beveled edge profile */ bool vertex_only; /* bevel vertices only */ bool use_weights; /* bevel amount affected by weights on edges or verts */ @@ -469,7 +471,7 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, if (ang < 100.0f * BEVEL_EPSILON) { /* special case: e1 and e2 are parallel; put offset point perp to both, from v. * need to find a suitable plane. - * if offsets are different, we're out of luck: just use e1->offset */ + * if offsets are different, we're out of luck: just use e1->offset_r */ if (f) copy_v3_v3(norm_v, f->no); else @@ -477,14 +479,14 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, cross_v3_v3v3(norm_perp1, dir1, norm_v); normalize_v3(norm_perp1); copy_v3_v3(off1a, v->co); - madd_v3_v3fl(off1a, norm_perp1, e1->offset); + madd_v3_v3fl(off1a, norm_perp1, e1->offset_r); copy_v3_v3(meetco, off1a); } else if (fabsf(ang - (float)M_PI) < 100.0f * BEVEL_EPSILON) { /* special case e1 and e2 are antiparallel, so bevel is into * a zero-area face. Just make the offset point on the * common line, at offset distance from v. */ - slide_dist(e2, v, e2->offset, meetco); + slide_dist(e2, v, e2->offset_l, meetco); } else { /* get normal to plane where meet point should be */ @@ -504,10 +506,10 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, /* get points that are offset distances from each line, then another point on each line */ copy_v3_v3(off1a, v->co); - madd_v3_v3fl(off1a, norm_perp1, e1->offset); + madd_v3_v3fl(off1a, norm_perp1, e1->offset_r); add_v3_v3v3(off1b, off1a, dir1); copy_v3_v3(off2a, v->co); - madd_v3_v3fl(off2a, norm_perp2, e2->offset); + madd_v3_v3fl(off2a, norm_perp2, e2->offset_l); add_v3_v3v3(off2b, off2a, dir2); /* intersect the lines; by construction they should be on the same plane and not parallel */ @@ -552,10 +554,10 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, /* get points that are offset distances from each line, then another point on each line */ copy_v3_v3(off1a, v->co); - madd_v3_v3fl(off1a, norm_perp1, e1->offset); + madd_v3_v3fl(off1a, norm_perp1, e1->offset_r); sub_v3_v3v3(off1b, off1a, dir1); copy_v3_v3(off2a, v->co); - madd_v3_v3fl(off2a, norm_perp2, e2->offset); + madd_v3_v3fl(off2a, norm_perp2, e2->offset_l); add_v3_v3v3(off2b, off2a, dir2); ang = angle_v3v3(dir1, dir2); @@ -564,7 +566,7 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, copy_v3_v3(meetco, off1a); } else if (fabsf(ang - (float)M_PI) < 100.0f * BEVEL_EPSILON) { - slide_dist(e2, v, e2->offset, meetco); + slide_dist(e2, v, e2->offset_l, meetco); } else { iret = isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2); @@ -612,7 +614,7 @@ static void offset_in_plane(EdgeHalf *e, const float plane_no[3], int left, floa cross_v3_v3v3(fdir, no, dir); normalize_v3(fdir); copy_v3_v3(r, v->co); - madd_v3_v3fl(r, fdir, e->offset); + madd_v3_v3fl(r, fdir, left? e->offset_l : e->offset_r); } /* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco */ @@ -818,7 +820,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv) v->efirst = v->elast = e; e->rightv = v; /* make artifical extra point along unbeveled edge, and form triangle */ - slide_dist(e->next, bv->v, e->offset, co); + slide_dist(e->next, bv->v, e->offset_l, co); v = add_new_bound_vert(mem_arena, vm, co); v->efirst = v->elast = e->next; e->next->leftv = e->next->rightv = v; @@ -828,7 +830,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv) return; } - lastd = bp->vertex_only ? bv->offset : e->offset; + lastd = bp->vertex_only ? bv->offset : e->offset_l; vm->boundstart = NULL; do { if (e->is_bev) { @@ -1921,6 +1923,18 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) } } +/* Return the angle between the two faces adjacent to e. + * If there are not two, return 0. */ +static float edge_face_angle(EdgeHalf *e) { + if (e->fprev && e->fnext) { + /* angle between faces is supplement of angle between face normals */ + return (float)M_PI - angle_normalized_v3v3(e->fprev->no, e->fnext->no); + } + else { + return 0.0f; + } +} + /* take care, this flag isn't cleared before use, it just so happens that its not set */ #define BM_BEVEL_EDGE_TAG_ENABLE(bme) BM_ELEM_API_FLAG_ENABLE( (bme), _FLAG_OVERLAP) #define BM_BEVEL_EDGE_TAG_DISABLE(bme) BM_ELEM_API_FLAG_DISABLE( (bme), _FLAG_OVERLAP) @@ -1937,7 +1951,7 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) BMFace *f; BMIter iter, iter2; EdgeHalf *e; - float weight; + float weight, z; int i, found_shared_face, ccw_test_sum; int nsel = 0; int ntot = 0; @@ -2053,16 +2067,6 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) e->seg = 0; } e->is_rev = (bme->v2 == v); - if (e->is_bev) { - e->offset = bp->offset; - if (bp->use_weights) { - weight = BM_elem_float_data_get(&bm->edata, bme, CD_BWEIGHT); - e->offset *= weight; - } - } - else { - e->offset = 0.0f; - } } /* find wrap-around shared face */ BM_ITER_ELEM (f, &iter2, bme, BM_FACES_OF_EDGE) { @@ -2098,6 +2102,50 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) for (i = 0, e = bv->edges; i < ntot; i++, e++) { e->next = &bv->edges[(i + 1) % ntot]; e->prev = &bv->edges[(i + ntot - 1) % ntot]; + + /* set offsets */ + if (e->is_bev) { + /* Convert distance as specified by user into offsets along + * faces on left side and right side of this edgehalf. + * Except for percent method, offset will be same on each side. */ + switch (bp->offset_type) { + case BEVEL_AMT_OFFSET: + e->offset_l = bp->offset; + break; + case BEVEL_AMT_WIDTH: + z = fabs(2.0f * sinf(edge_face_angle(e) / 2.0f)); + if (z < BEVEL_EPSILON) + e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ + else + e->offset_l = bp->offset / z; + break; + case BEVEL_AMT_DEPTH: + z = fabs(cosf(edge_face_angle(e) / 2.0f)); + if (z < BEVEL_EPSILON) + e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ + else + e->offset_l = bp->offset / z; + break; + case BEVEL_AMT_PERCENT: + e->offset_l = BM_edge_calc_length(e->prev->e) * bp->offset / 100.0f; + e->offset_r = BM_edge_calc_length(e->next->e) * bp->offset / 100.0f; + break; + default: + BLI_assert(!"bad bevel offset kind"); + e->offset_l = bp->offset; + } + if (bp->offset_type != BEVEL_AMT_PERCENT) + e->offset_r = e->offset_l; + if (bp->use_weights) { + weight = BM_elem_float_data_get(&bm->edata, bme, CD_BWEIGHT); + e->offset_l *= weight; + e->offset_r *= weight; + } + } + else { + e->offset_l = e->offset_r = 0.0f; + } + BM_BEVEL_EDGE_TAG_DISABLE(e->e); if (e->fprev && e->fnext) e->is_seam = !contig_ldata_across_edge(bm, e->e, e->fprev, e->fnext); @@ -2370,7 +2418,7 @@ static float bevel_limit_offset(BMesh *bm, BevelParams *bp) * * \warning all tagged edges _must_ be manifold. */ -void BM_mesh_bevel(BMesh *bm, const float offset, const float segments, +void BM_mesh_bevel(BMesh *bm, const float offset, const int offset_type, const float segments, const bool vertex_only, const bool use_weights, const bool limit_offset, const struct MDeformVert *dvert, const int vertex_group) { @@ -2380,6 +2428,7 @@ void BM_mesh_bevel(BMesh *bm, const float offset, const float segments, BevelParams bp = {NULL}; bp.offset = offset; + bp.offset_type = offset_type; bp.seg = segments; bp.vertex_only = vertex_only; bp.use_weights = use_weights; diff --git a/source/blender/bmesh/tools/bmesh_bevel.h b/source/blender/bmesh/tools/bmesh_bevel.h index bee26357aca..9897b6b070c 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.h +++ b/source/blender/bmesh/tools/bmesh_bevel.h @@ -29,7 +29,7 @@ struct MDeformVert; -void BM_mesh_bevel(BMesh *bm, const float offset, const float segments, +void BM_mesh_bevel(BMesh *bm, const float offset, const int offset_type, const float segments, const bool vertex_only, const bool use_weights, const bool limit_offset, const struct MDeformVert *dvert, const int vertex_group); diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index dd3aacb2d67..7e1293ee043 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -131,6 +131,7 @@ static bool edbm_bevel_calc(wmOperator *op) BMEditMesh *em = opdata->em; BMOperator bmop; const float offset = RNA_float_get(op->ptr, "offset"); + const int offset_type = RNA_enum_get(op->ptr, "offset_type"); const int segments = RNA_int_get(op->ptr, "segments"); const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only"); @@ -140,8 +141,8 @@ static bool edbm_bevel_calc(wmOperator *op) } EDBM_op_init(em, &bmop, op, - "bevel geom=%hev offset=%f segments=%i vertex_only=%b", - BM_ELEM_SELECT, offset, segments, vertex_only); + "bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i", + BM_ELEM_SELECT, offset, segments, vertex_only, offset_type); BMO_op_exec(em->bm, &bmop); @@ -256,12 +257,14 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event) static float edbm_bevel_mval_factor(wmOperator *op, const wmEvent *event) { BevelData *opdata = op->customdata; - int use_dist = true; + bool use_dist = true; + bool is_percent = false; float mdiff[2]; float factor; mdiff[0] = opdata->mcenter[0] - event->mval[0]; mdiff[1] = opdata->mcenter[1] - event->mval[1]; + is_percent = (RNA_int_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT); if (use_dist) { factor = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length) * opdata->pixel_size; @@ -286,7 +289,13 @@ static float edbm_bevel_mval_factor(wmOperator *op, const wmEvent *event) if (factor < 0.0f) factor = 0.0f; } else { - CLAMP(factor, 0.0f, 1.0f); + if (is_percent) { + factor *= 100.0f; + CLAMP(factor, 0.0f, 100.0f); + } + else { + CLAMP(factor, 0.0f, 1.0f); + } } return factor; @@ -361,6 +370,14 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) void MESH_OT_bevel(wmOperatorType *ot) { + static EnumPropertyItem offset_type_items[] = { + {BEVEL_AMT_OFFSET, "OFFSET", 0, "Offset", "Amount is offset of new edges from original"}, + {BEVEL_AMT_WIDTH, "WIDTH", 0, "Width", "Amount is width of new face"}, + {BEVEL_AMT_DEPTH, "DEPTH", 0, "Depth", "Amount is perpendicular distance from original edge to bevel face"}, + {BEVEL_AMT_PERCENT, "PERCENT", 0, "Percent", "Amount is percent of adjacent edge length"}, + {0, NULL, 0, NULL, NULL}, + }; + /* identifiers */ ot->name = "Bevel"; ot->description = "Edge Bevel"; @@ -376,7 +393,8 @@ void MESH_OT_bevel(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING; - RNA_def_float(ot->srna, "offset", 0.0f, -FLT_MAX, FLT_MAX, "Offset", "", 0.0f, 1.0f); + RNA_def_enum(ot->srna, "offset_type", offset_type_items, 0, "Amount Type", "What distance Amount measures"); + RNA_def_float(ot->srna, "offset", 0.0f, -FLT_MAX, FLT_MAX, "Amount", "", 0.0f, 1.0f); RNA_def_int(ot->srna, "segments", 1, 1, 50, "Segments", "Segments for curved edge", 1, 8); RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex only", "Bevel only vertices"); } diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 326ffba3e2e..6a1de92f9b2 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -158,7 +158,8 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob, } } - BM_mesh_bevel(bm, bmd->value, bmd->res, + /* TODO: add offset_kind to modifier properties to, and pass in as 3rd arg here */ + BM_mesh_bevel(bm, bmd->value, 0, bmd->res, vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp, dvert, vgroup); -- cgit v1.2.3 From 8cf39603f744ff10e3e517414c563d2344fd02cc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Nov 2013 12:56:50 +0000 Subject: replace IS_EQ -> IS_EQF for use with floats. --- source/blender/blenkernel/intern/anim_sys.c | 6 +++--- source/blender/blenkernel/intern/armature.c | 6 +++--- source/blender/blenkernel/intern/constraint.c | 4 ++-- source/blender/blenloader/intern/versioning_250.c | 2 +- source/blender/editors/armature/pose_lib.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index bab4e539cf4..cb628db8cd2 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1567,11 +1567,11 @@ static float nlastrip_get_influence(NlaStrip *strip, float cframe) strip->blendout = fabsf(strip->blendout); /* result depends on where frame is in respect to blendin/out values */ - if (IS_EQ(strip->blendin, 0) == 0 && (cframe <= (strip->start + strip->blendin))) { + if (IS_EQF(strip->blendin, 0.0f) == false && (cframe <= (strip->start + strip->blendin))) { /* there is some blend-in */ return fabsf(cframe - strip->start) / (strip->blendin); } - else if (IS_EQ(strip->blendout, 0) == 0 && (cframe >= (strip->end - strip->blendout))) { + else if (IS_EQF(strip->blendout, 0.0f) == false && (cframe >= (strip->end - strip->blendout))) { /* there is some blend-out */ return fabsf(strip->end - cframe) / (strip->blendout); } @@ -1856,7 +1856,7 @@ static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, float inf *= nes->strip_time; /* optimisation: no need to try applying if there is no influence */ - if (IS_EQ(inf, 0)) return; + if (IS_EQF(inf, 0.0f)) return; /* perform blending */ switch (blendmode) { diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 83161801069..3be80a7e30d 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -285,7 +285,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a */ if (axis == 2) { /* z-axis - vertical (top/bottom) */ - if (IS_EQ(head, 0)) { + if (IS_EQF(head, 0.0f)) { if (tail < 0) strcpy(extension, "Bot"); else if (tail > 0) @@ -300,7 +300,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a } else if (axis == 1) { /* y-axis - depth (front/back) */ - if (IS_EQ(head, 0)) { + if (IS_EQF(head, 0.0f)) { if (tail < 0) strcpy(extension, "Fr"); else if (tail > 0) @@ -315,7 +315,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a } else { /* x-axis - horizontal (left/right) */ - if (IS_EQ(head, 0)) { + if (IS_EQF(head, 0.0f)) { if (tail < 0) strcpy(extension, "R"); else if (tail > 0) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 1f892432d80..aa81ea130ad 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3075,7 +3075,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar float offset; /* check to make sure len is not so close to zero that it'll cause errors */ - if (IS_EQ(len, 0) == 0) { + if (IS_EQF(len, 0.0f) == false) { /* find bounding-box range where target is located */ if (ownLoc[clamp_axis] < curveMin[clamp_axis]) { /* bounding-box range is before */ @@ -3107,7 +3107,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar curvetime = 0.0f; else if (ownLoc[clamp_axis] >= curveMax[clamp_axis]) curvetime = 1.0f; - else if (IS_EQ((curveMax[clamp_axis] - curveMin[clamp_axis]), 0) == 0) + else if (IS_EQF((curveMax[clamp_axis] - curveMin[clamp_axis]), 0.0f) == false) curvetime = (ownLoc[clamp_axis] - curveMin[clamp_axis]) / (curveMax[clamp_axis] - curveMin[clamp_axis]); else curvetime = 0.0f; diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 80e34f0fce4..62e3955ca60 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -2323,7 +2323,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) KeyBlock *kb; for (kb = key->block.first; kb; kb = kb->next) { - if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0)) + if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQF(kb->slidermax, 0.0f)) kb->slidermax = kb->slidermin + 1.0f; } } diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 4a40eff204a..69ee794e1d9 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -567,7 +567,7 @@ static int poselib_remove_exec(bContext *C, wmOperator *op) if (fcu->bezt) { for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { /* check if remove */ - if (IS_EQ(bezt->vec[1][0], marker->frame)) { + if (IS_EQF(bezt->vec[1][0], (float)marker->frame)) { delete_fcurve_key(fcu, i, 1); break; } -- cgit v1.2.3 From aaa99106fe3c40e2b8cf4d60e14597a976b2f983 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Nov 2013 14:13:26 +0000 Subject: make IS_EQ and IS_EQF typecheck args --- source/blender/blenlib/BLI_utildefines.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index c3a3c035ed3..9bf720c03ea 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -240,8 +240,13 @@ #define CLAMPIS(a, b, c) ((a) < (b) ? (b) : (a) > (c) ? (c) : (a)) -#define IS_EQ(a, b) ((fabs((double)(a) - (b)) >= (double) FLT_EPSILON) ? 0 : 1) -#define IS_EQF(a, b) ((fabsf((float)(a) - (b)) >= (float) FLT_EPSILON) ? 0 : 1) +#define IS_EQ(a, b) ( \ + CHECK_TYPE_INLINE(a, double), CHECK_TYPE_INLINE(b, double), \ + ((fabs((double)(a) - (b)) >= (double) FLT_EPSILON) ? false : true)) + +#define IS_EQF(a, b) ( \ + CHECK_TYPE_INLINE(a, float), CHECK_TYPE_INLINE(b, float), \ + ((fabsf((float)(a) - (b)) >= (float) FLT_EPSILON) ? false : true)) #define IS_EQT(a, b, c) ((a > b) ? (((a - b) <= c) ? 1 : 0) : ((((b - a) <= c) ? 1 : 0))) #define IN_RANGE(a, b, c) ((b < c) ? ((b < a && a < c) ? 1 : 0) : ((c < a && a < b) ? 1 : 0)) -- cgit v1.2.3 From d27f8103dd0d2fcc20974431fa063a2a87d780de Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 10 Nov 2013 19:51:44 +0000 Subject: Fix [#37393] Input dimensions are case sensitive in the property panel, uppercase input is misinterpreted Typo in lowercasing code! --- source/blender/blenkernel/intern/unit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 3c03712231a..4b6ac824fd8 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -609,9 +609,10 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca int i; char *ch = str; - for (i = 0; (i >= len_max || *ch == '\0'); i++, ch++) + for (i = 0; (i < len_max || *ch != '\0'); i++, ch++) { if ((*ch >= 'A') && (*ch <= 'Z')) *ch += ('a' - 'A'); + } } for (unit = usys->units; unit->name; unit++) { -- cgit v1.2.3 From 647f425265b38055a922eb665662fcd468891407 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 10 Nov 2013 20:32:27 +0000 Subject: Fix [#37394] UV Map cannot be renamed. Own epic failure! CustomData_get_named_layer() returns a relative index, not an absolute one. :( --- source/blender/blenkernel/intern/mesh.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index a77f768835a..844252c583c 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -708,26 +708,32 @@ bool BKE_mesh_uv_cdlayer_rename(Mesh *me, const char *old_name, const char *new_ return false; } else { - lidx = lidx_start + (fidx - fidx_start); + lidx = fidx; } } - pidx = pidx_start + (lidx - lidx_start); + pidx = lidx; } else { if (lidx == -1) { - lidx = lidx_start + (pidx - pidx_start); + lidx = pidx; } if (fidx == -1 && do_tessface) { - fidx = fidx_start + (pidx - pidx_start); + fidx = pidx; } } #if 0 /* For now, we do not consider mismatch in indices (i.e. same name leading to (relative) different indices). */ - else if ((pidx - pidx_start) != (lidx - lidx_start)) { - lidx = lidx_start + (pidx - pidx_start); + else if (pidx != lidx) { + lidx = pidx; } #endif + /* Go back to absolute indices! */ + pidx += pidx_start; + lidx += lidx_start; + if (fidx != -1) + fidx += fidx_start; + return BKE_mesh_uv_cdlayer_rename_index(me, pidx, lidx, fidx, new_name, do_tessface); } } -- cgit v1.2.3 From dcfb858a7629cb505318ce755075a9c77e6aa376 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 11 Nov 2013 12:08:31 +0000 Subject: Fix #37395: Rendering with a movie strip behind a scene shows inconsistent results For now just make sure conversion to sequencer space will ensure imbuf's color space names is set properly. Might be some further changes needed to make colorspace flow more clear in sequencer, but that's for later. --- source/blender/blenkernel/intern/sequencer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 1235018546e..49b237fc3ea 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -463,6 +463,7 @@ void BKE_sequencer_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, int make_ if (!STREQ(float_colorspace, to_colorspace)) { IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, true); + sequencer_imbuf_assign_spaces(scene, ibuf); } } } -- cgit v1.2.3 From 39673718864f018307e49fac62696341b3230628 Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Mon, 11 Nov 2013 12:19:39 +0000 Subject: Used wrong RNA access routine in bevel amount commit. --- source/blender/editors/mesh/editmesh_bevel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 7e1293ee043..ddb58cd6c7b 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -264,7 +264,7 @@ static float edbm_bevel_mval_factor(wmOperator *op, const wmEvent *event) mdiff[0] = opdata->mcenter[0] - event->mval[0]; mdiff[1] = opdata->mcenter[1] - event->mval[1]; - is_percent = (RNA_int_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT); + is_percent = (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT); if (use_dist) { factor = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length) * opdata->pixel_size; -- cgit v1.2.3 From 7fc1088164303df0807fd78ccffbd0ec8a12a09e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 11 Nov 2013 14:29:01 +0000 Subject: Fix [#37388] Grid fill crashes blender in specific situation. With some geometries, we can have a valid first path, without being able to find a valid second one, added needed check. --- source/blender/bmesh/operators/bmo_fill_grid.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c index 4e302a8ff63..50d25202f7e 100644 --- a/source/blender/bmesh/operators/bmo_fill_grid.c +++ b/source/blender/bmesh/operators/bmo_fill_grid.c @@ -633,7 +633,12 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op) goto cleanup; } - BM_mesh_edgeloops_find_path(bm, &eloops_rail, bm_edge_test_rail_cb, (void *)bm, v_a_first, v_b_last); + /* We may find a first path, but not a second one! See geometry attached to bug [#37388]. */ + if (BM_mesh_edgeloops_find_path(bm, &eloops_rail, bm_edge_test_rail_cb, bm, v_a_first, v_b_last) == false) { + BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, + "Loops are not connected by wire/boundary edges"); + goto cleanup; + } /* Check flipping by comparing path length */ estore_rail_a = eloops_rail.first; @@ -656,7 +661,7 @@ void bmo_grid_fill_exec(BMesh *bm, BMOperator *op) BM_edgeloop_free(estore_rail_a); estore_rail_a = estore_rail_b; - /* reverse so these so both are sorted the same way */ + /* reverse so both are sorted the same way */ BM_edgeloop_flip(bm, estore_b); SWAP(BMVert *, v_b_first, v_b_last); -- cgit v1.2.3 From 59e46005261ea2739fe3d3009ac7cc43fdfa6833 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 11 Nov 2013 20:37:19 +0000 Subject: Fix [#37380] vertex paint colors don't render. Another Evil Typo (r) one, you could add much more than the 8 allowed VCol layers! Note: added some (warning-only) checks in mesh validate functions, but we still have a big issue with new cdlayer merge function, which could generate more than 8 layers of UVs or VCol... Don't know yet how to handle this situation. :( --- source/blender/blenkernel/intern/mesh_validate.c | 30 +++++++++++++++++++++++- source/blender/editors/mesh/mesh_data.c | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 1c9576d74d0..a4f5529ee43 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -922,7 +922,7 @@ bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata, { bool is_valid = true; bool is_change_v, is_change_e, is_change_l, is_change_p; - int tot_texpoly, tot_uvloop; + int tot_texpoly, tot_uvloop, tot_vcolloop; CustomDataMask mask = check_meshmask ? CD_MASK_MESH : 0; is_valid &= mesh_validate_customdata(vdata, mask, do_verbose, do_fixes, &is_change_v); @@ -932,10 +932,23 @@ bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata, tot_texpoly = CustomData_number_of_layers(pdata, CD_MTEXPOLY); tot_uvloop = CustomData_number_of_layers(ldata, CD_MLOOPUV); + tot_vcolloop = CustomData_number_of_layers(ldata, CD_MLOOPCOL); if (tot_texpoly != tot_uvloop) { PRINT_ERR("\tCustomDataLayer mismatch, tot_texpoly(%d), tot_uvloop(%d)\n", tot_texpoly, tot_uvloop); } + if (tot_texpoly > MAX_MTFACE) { + PRINT_ERR("\tMore UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MTFACE, tot_texpoly - MAX_MTFACE); + } + if (tot_uvloop > MAX_MTFACE) { + PRINT_ERR("\tMore UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MTFACE, tot_uvloop - MAX_MTFACE); + } + if (tot_vcolloop > MAX_MCOL) { + PRINT_ERR("\tMore VCol layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MCOL, tot_vcolloop - MAX_MCOL); + } *r_change = (is_change_v || is_change_e || is_change_l || is_change_p); @@ -989,10 +1002,25 @@ void BKE_mesh_cd_validate(Mesh *me) { int totlayer_mtex = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY); int totlayer_uv = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); + int totlayer_mcol = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL); int mtex_index = CustomData_get_layer_index(&me->pdata, CD_MTEXPOLY); int uv_index = CustomData_get_layer_index(&me->ldata, CD_MLOOPUV); int i; + /* XXX For now, do not delete those, just warn they are not really usable. */ + if (UNLIKELY(totlayer_mtex > MAX_MTFACE)) { + printf("WARNING! More UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MTFACE, totlayer_mtex - MAX_MTFACE); + } + if (UNLIKELY(totlayer_uv > MAX_MTFACE)) { + printf("WARNING! More UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MTFACE, totlayer_uv - MAX_MTFACE); + } + if (UNLIKELY(totlayer_mcol > MAX_MCOL)) { + printf("WARNING! More VCol layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MCOL, totlayer_mcol - MAX_MCOL); + } + if (LIKELY(totlayer_mtex == totlayer_uv)) { /* pass */ } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index e8cbf0926d4..f35a46b50d3 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -417,7 +417,7 @@ int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set) } else { layernum = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL); - if (layernum >= CD_MLOOPCOL) { + if (layernum >= MAX_MCOL) { return -1; } -- cgit v1.2.3 From ef1bc03fce51e2d79551ae87f2f8c7af8f0c6295 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Tue, 12 Nov 2013 02:28:26 +0000 Subject: Fix #37092 and #37381: crashes in the .object() method of Freestyle iterators. Now the method checks if the iterator is at the end, and returns None if that is the case. --- .../blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp | 2 ++ .../blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp | 2 ++ .../blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp | 2 ++ .../freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp | 2 ++ .../blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp | 2 ++ .../freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp | 2 ++ 6 files changed, 12 insertions(+) diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp index 510875ebb2f..0daaa1a0476 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp @@ -115,6 +115,8 @@ PyDoc_STRVAR(AdjacencyIterator_object_doc, static PyObject *AdjacencyIterator_object_get(BPy_AdjacencyIterator *self, void *UNUSED(closure)) { + if (self->a_it->isEnd()) + Py_RETURN_NONE; ViewEdge *ve = self->a_it->operator*(); if (ve) return BPy_ViewEdge_from_ViewEdge(*ve); diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp index 3e2f0102dc3..91e8de118a9 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp @@ -175,6 +175,8 @@ PyDoc_STRVAR(ChainingIterator_object_doc, static PyObject *ChainingIterator_object_get(BPy_ChainingIterator *self, void *UNUSED(closure)) { + if (self->c_it->isEnd()) + Py_RETURN_NONE; ViewEdge *ve = self->c_it->operator*(); if (ve) return BPy_ViewEdge_from_ViewEdge(*ve); diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp index 3e45ef17c1b..1655b766a6b 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp @@ -97,6 +97,8 @@ PyDoc_STRVAR(CurvePointIterator_object_doc, static PyObject *CurvePointIterator_object_get(BPy_CurvePointIterator *self, void *UNUSED(closure)) { + if (self->cp_it->isEnd()) + Py_RETURN_NONE; return BPy_CurvePoint_from_CurvePoint(self->cp_it->operator*()); } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp index 3a537eb672a..2f6c8ff7348 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp @@ -123,6 +123,8 @@ PyDoc_STRVAR(Interface0DIterator_object_doc, static PyObject *Interface0DIterator_object_get(BPy_Interface0DIterator *self, void *UNUSED(closure)) { + if (self->if0D_it->isEnd()) + Py_RETURN_NONE; return Any_BPy_Interface0D_from_Interface0D(self->if0D_it->operator*()); } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp index f30621f01e3..c191a94f08d 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp @@ -122,6 +122,8 @@ PyDoc_STRVAR(ViewEdgeIterator_object_doc, static PyObject *ViewEdgeIterator_object_get(BPy_ViewEdgeIterator *self, void *UNUSED(closure)) { + if (!self->ve_it->isEnd()) + Py_RETURN_NONE; ViewEdge *ve = self->ve_it->operator*(); if (ve) return BPy_ViewEdge_from_ViewEdge(*ve); diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp index f2b0e604c22..cbefcd3292e 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp @@ -103,6 +103,8 @@ PyDoc_STRVAR(orientedViewEdgeIterator_object_doc, static PyObject *orientedViewEdgeIterator_object_get(BPy_orientedViewEdgeIterator *self, void *UNUSED(closure)) { + if (self->ove_it->isEnd()) + Py_RETURN_NONE; return BPy_directedViewEdge_from_directedViewEdge(self->ove_it->operator*()); } -- cgit v1.2.3 From e177ac100ba83c9f53d715aed86a092106554088 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 12 Nov 2013 07:02:04 +0000 Subject: Fix [#37409] Missing Buttons in Edit Strip Sub-Menu for Sound Strips in the VSE Add back mute & lock buttons to audio strips (these should not have been removed, own fault). --- release/scripts/startup/bl_ui/space_sequencer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index ea88d35b4e9..6f28bcb2225 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -416,6 +416,10 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel): sub.prop(strip, "blend_alpha", text="Opacity", slider=True) row.prop(strip, "mute", toggle=True, icon='RESTRICT_VIEW_ON' if strip.mute else 'RESTRICT_VIEW_OFF', text="") row.prop(strip, "lock", toggle=True, icon='LOCKED' if strip.lock else 'UNLOCKED', text="") + else: + row = layout.row(align=True) + row.prop(strip, "mute", toggle=True, icon='RESTRICT_VIEW_ON' if strip.mute else 'RESTRICT_VIEW_OFF') + row.prop(strip, "lock", toggle=True, icon='LOCKED' if strip.lock else 'UNLOCKED') col = layout.column() sub = col.column() -- cgit v1.2.3 From ba7fd8cd5c173730c8c2250eac7ea48fafd519c7 Mon Sep 17 00:00:00 2001 From: Irie Shinsuke Date: Tue, 12 Nov 2013 10:59:40 +0000 Subject: Change the behavior of AO pass in Blender internal's shader/render node tree so that it becomes (1.0, 1.0, 1.0) when AO is disabled. For materials using AO pass, this makes the material preview and the GLSL preview more accurate, but shouldn't affect final rendering in most cases because we usually enable AO when using the AO pass in node tree. Thanks to Brecht for code review. --- .../blender/gpu/shaders/gpu_shader_material.glsl | 10 +++++++++ .../nodes/shader/nodes/node_shader_material.c | 1 + source/blender/render/intern/source/shadeoutput.c | 26 ++++++++++++---------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 78664f3b539..5e5fac3049c 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -393,11 +393,21 @@ void set_rgb_zero(out vec3 outval) outval = vec3(0.0); } +void set_rgb_one(out vec3 outval) +{ + outval = vec3(1.0); +} + void set_rgba_zero(out vec4 outval) { outval = vec4(0.0); } +void set_rgba_one(out vec4 outval) +{ + outval = vec4(1.0); +} + void brightness_contrast(vec4 col, float brightness, float contrast, out vec4 outcol) { float a = 1.0 + contrast; diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c index 4200f515a80..820e0f479be 100644 --- a/source/blender/nodes/shader/nodes/node_shader_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_material.c @@ -299,6 +299,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU if (node->type == SH_NODE_MATERIAL_EXT) { out[MAT_OUT_DIFFUSE].link = shr.diff; out[MAT_OUT_SPEC].link = shr.spec; + GPU_link(mat, "set_rgb_one", &out[MAT_OUT_AO].link); } return 1; diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 114961394c4..dbc9c47446f 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -1789,18 +1789,20 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) } /* AO pass */ - if (R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) { - if (((passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) || - (passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) - { - if (R.r.mode & R_SHADOW) { - /* AO was calculated for scanline already */ - if (shi->depth || shi->volume_depth) - ambient_occlusion(shi); - copy_v3_v3(shr->ao, shi->ao); - copy_v3_v3(shr->env, shi->env); /* XXX multiply */ - copy_v3_v3(shr->indirect, shi->indirect); /* XXX multiply */ - } + if (((passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) || + (passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) { + if ((R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && (R.r.mode & R_SHADOW)) { + /* AO was calculated for scanline already */ + if (shi->depth || shi->volume_depth) + ambient_occlusion(shi); + copy_v3_v3(shr->ao, shi->ao); + copy_v3_v3(shr->env, shi->env); /* XXX multiply */ + copy_v3_v3(shr->indirect, shi->indirect); /* XXX multiply */ + } + else { + shr->ao[0]= shr->ao[1]= shr->ao[2]= 1.0f; + zero_v3(shr->env); + zero_v3(shr->indirect); } } -- cgit v1.2.3 From 8663b940eda703c45baf664c9aa379a9ecb684f9 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 12 Nov 2013 18:17:58 +0000 Subject: Instead of requiring a const char* return from the (optional) node label callback function, let it write into a mutable string buffer. This will allow actual dynamic labels for nodes using the python API. --- source/blender/blenkernel/BKE_node.h | 6 +++--- source/blender/blenkernel/intern/node.c | 10 +++++----- source/blender/editors/space_node/drawnode.c | 4 +++- source/blender/editors/space_node/node_draw.c | 6 +++--- .../composite/nodes/node_composite_moviedistortion.c | 6 +++--- source/blender/nodes/intern/node_common.c | 4 ++-- source/blender/nodes/intern/node_common.h | 2 +- source/blender/nodes/intern/node_util.c | 17 +++++++++-------- source/blender/nodes/intern/node_util.h | 8 ++++---- 9 files changed, 33 insertions(+), 30 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 05824ae6950..1fdceb872f9 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -175,7 +175,7 @@ typedef struct bNodeType { void (*draw_backdrop)(struct SpaceNode *snode, struct ImBuf *backdrop, struct bNode *node, int x, int y); /// Optional custom label function for the node header. - const char *(*labelfunc)(struct bNode *); + void (*labelfunc)(struct bNode *node, char *label, int maxlen); /// Optional custom resize handle polling. int (*resize_area_func)(struct bNode *node, int x, int y); /// Optional selection area polling. @@ -556,7 +556,7 @@ void BKE_node_preview_set_pixel(struct bNodePreview *preview, const f /* ************** NODE TYPE ACCESS *************** */ -const char *nodeLabel(struct bNode *node); +void nodeLabel(struct bNode *node, char *label, int maxlen); int nodeGroupPoll(struct bNodeTree *nodetree, struct bNodeTree *grouptree); @@ -571,7 +571,7 @@ void node_type_storage(struct bNodeType *ntype, const char *storagename, void (*freefunc)(struct bNode *node), void (*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, struct bNode *src_node)); -void node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *)); +void node_type_label(struct bNodeType *ntype, void (*labelfunc)(struct bNode *, char *label, int maxlen)); void node_type_update(struct bNodeType *ntype, void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node), void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id)); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index cc4263f4392..d441b103743 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3089,14 +3089,14 @@ void nodeSynchronizeID(bNode *node, bool copy_to_id) /* ************* node type access ********** */ -const char *nodeLabel(bNode *node) +void nodeLabel(bNode *node, char *label, int maxlen) { if (node->label[0] != '\0') - return node->label; + BLI_strncpy(label, node->label, maxlen); else if (node->typeinfo->labelfunc) - return node->typeinfo->labelfunc(node); + node->typeinfo->labelfunc(node, label, maxlen); else - return IFACE_(node->typeinfo->ui_name); + BLI_strncpy(label, IFACE_(node->typeinfo->ui_name), maxlen); } static void node_type_base_defaults(bNodeType *ntype) @@ -3267,7 +3267,7 @@ void node_type_storage(bNodeType *ntype, ntype->freefunc = freefunc; } -void node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *)) +void node_type_label(struct bNodeType *ntype, void (*labelfunc)(struct bNode *, char *label, int maxlen)) { ntype->labelfunc = labelfunc; } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 1af800ebf24..e7a08d2c626 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -391,12 +391,14 @@ static void node_draw_frame_label(bNode *node, const float aspect) NodeFrame *data = (NodeFrame *)node->storage; rctf *rct = &node->totr; int color_id = node_get_colorid(node); - const char *label = nodeLabel(node); + char label[MAX_NAME]; /* XXX a bit hacky, should use separate align values for x and y */ float width, ascender; float x, y; const int font_size = data->label_size / aspect; + nodeLabel(node, label, sizeof(label)); + BLF_enable(fontid, BLF_ASPECT); BLF_aspect(fontid, aspect, aspect, 1.0f); BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */ diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index e031e056cd3..f4ffeb05608 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -868,7 +868,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN UI_ThemeColor(TH_TEXT); #endif - BLI_strncpy(showname, nodeLabel(node), sizeof(showname)); + nodeLabel(node, showname, sizeof(showname)); //if (node->flag & NODE_MUTED) // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ @@ -1035,8 +1035,8 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b UI_ThemeColor(TH_TEXT); if (node->miniwidth > 0.0f) { - BLI_strncpy(showname, nodeLabel(node), sizeof(showname)); - + nodeLabel(node, showname, sizeof(showname)); + //if (node->flag & NODE_MUTED) // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c index b110cffd080..4d4781a4ffa 100644 --- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c +++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c @@ -48,12 +48,12 @@ static bNodeSocketTemplate cmp_node_moviedistortion_out[] = { { -1, 0, "" } }; -static const char *label(bNode *node) +static void label(bNode *node, char *label, int maxlen) { if (node->custom1 == 0) - return IFACE_("Undistortion"); + BLI_strncpy(label, IFACE_("Undistortion"), maxlen); else - return IFACE_("Distortion"); + BLI_strncpy(label, IFACE_("Distortion"), maxlen); } static void init(const bContext *C, PointerRNA *ptr) diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index a8133460628..c5f98ea64bd 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -82,9 +82,9 @@ bNodeSocket *node_group_find_output_socket(bNode *groupnode, const char *identif } /* groups display their internal tree name as label */ -const char *node_group_label(bNode *node) +void node_group_label(bNode *node, char *label, int maxlen) { - return (node->id) ? node->id->name + 2 : IFACE_("Missing Datablock"); + BLI_strncpy(label, (node->id) ? node->id->name + 2 : IFACE_("Missing Datablock"), maxlen); } int node_group_poll_instance(bNode *node, bNodeTree *nodetree) diff --git a/source/blender/nodes/intern/node_common.h b/source/blender/nodes/intern/node_common.h index 498da607b91..8c7cefedee6 100644 --- a/source/blender/nodes/intern/node_common.h +++ b/source/blender/nodes/intern/node_common.h @@ -37,7 +37,7 @@ struct bNodeTree; -const char *node_group_label(struct bNode *node); +void node_group_label(struct bNode *node, char *label, int maxlen); int node_group_poll_instance(struct bNode *node, struct bNodeTree *nodetree); void ntree_update_reroute_nodes(struct bNodeTree *ntree); diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index e77f0a08331..0820c2acd50 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -36,6 +36,7 @@ #include "DNA_node_types.h" #include "BLI_listbase.h" +#include "BLI_string.h" #include "BLI_utildefines.h" #include "BLF_translation.h" @@ -82,32 +83,32 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context), bNode *node, bNode /**** Labels ****/ -const char *node_blend_label(bNode *node) +void node_blend_label(bNode *node, char *label, int maxlen) { const char *name; RNA_enum_name(ramp_blend_items, node->custom1, &name); - return IFACE_(name); + BLI_strncpy(label, IFACE_(name), maxlen); } -const char *node_math_label(bNode *node) +void node_math_label(bNode *node, char *label, int maxlen) { const char *name; RNA_enum_name(node_math_items, node->custom1, &name); - return IFACE_(name); + BLI_strncpy(label, IFACE_(name), maxlen); } -const char *node_vect_math_label(bNode *node) +void node_vect_math_label(bNode *node, char *label, int maxlen) { const char *name; RNA_enum_name(node_vec_math_items, node->custom1, &name); - return IFACE_(name); + BLI_strncpy(label, IFACE_(name), maxlen); } -const char *node_filter_label(bNode *node) +void node_filter_label(bNode *node, char *label, int maxlen) { const char *name; RNA_enum_name(node_filter_items, node->custom1, &name); - return IFACE_(name); + BLI_strncpy(label, IFACE_(name), maxlen); } void node_update_internal_links_default(bNodeTree *ntree, bNode *node) diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h index 2b3f84420f9..03a167cdb1a 100644 --- a/source/blender/nodes/intern/node_util.h +++ b/source/blender/nodes/intern/node_util.h @@ -71,10 +71,10 @@ extern void *node_initexec_curves(struct bNodeExecContext *context, struct bNode /**** Labels ****/ -const char *node_blend_label(struct bNode *node); -const char *node_math_label(struct bNode *node); -const char *node_vect_math_label(struct bNode *node); -const char *node_filter_label(struct bNode *node); +void node_blend_label(struct bNode *node, char *label, int maxlen); +void node_math_label(struct bNode *node, char *label, int maxlen); +void node_vect_math_label(struct bNode *node, char *label, int maxlen); +void node_filter_label(struct bNode *node, char *label, int maxlen); void node_update_internal_links_default(struct bNodeTree *ntree, struct bNode *node); -- cgit v1.2.3 From 4d4ef0434b0078364824c2fe5ebfb8153fb44956 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 12 Nov 2013 18:18:04 +0000 Subject: Make dynamic node labels possible as a registerable function 'draw_label' (simple 'label' identifier is already in use, need to avoid API breakage). This should simply return a string. The dynamic label can still be overridden by the user-defined node.label string. --- source/blender/blenkernel/BKE_node.h | 6 ++-- source/blender/blenkernel/intern/node.c | 6 ++-- source/blender/editors/space_node/drawnode.c | 8 ++--- source/blender/editors/space_node/node_draw.c | 4 +-- source/blender/makesrna/intern/rna_nodetree.c | 34 +++++++++++++++++++++- .../nodes/node_composite_moviedistortion.c | 2 +- source/blender/nodes/intern/node_common.c | 2 +- source/blender/nodes/intern/node_common.h | 2 +- source/blender/nodes/intern/node_util.c | 8 ++--- source/blender/nodes/intern/node_util.h | 8 ++--- 10 files changed, 56 insertions(+), 24 deletions(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 1fdceb872f9..b700cbb16db 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -175,7 +175,7 @@ typedef struct bNodeType { void (*draw_backdrop)(struct SpaceNode *snode, struct ImBuf *backdrop, struct bNode *node, int x, int y); /// Optional custom label function for the node header. - void (*labelfunc)(struct bNode *node, char *label, int maxlen); + void (*labelfunc)(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); /// Optional custom resize handle polling. int (*resize_area_func)(struct bNode *node, int x, int y); /// Optional selection area polling. @@ -556,7 +556,7 @@ void BKE_node_preview_set_pixel(struct bNodePreview *preview, const f /* ************** NODE TYPE ACCESS *************** */ -void nodeLabel(struct bNode *node, char *label, int maxlen); +void nodeLabel(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); int nodeGroupPoll(struct bNodeTree *nodetree, struct bNodeTree *grouptree); @@ -571,7 +571,7 @@ void node_type_storage(struct bNodeType *ntype, const char *storagename, void (*freefunc)(struct bNode *node), void (*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, struct bNode *src_node)); -void node_type_label(struct bNodeType *ntype, void (*labelfunc)(struct bNode *, char *label, int maxlen)); +void node_type_label(struct bNodeType *ntype, void (*labelfunc)(struct bNodeTree *ntree, struct bNode *, char *label, int maxlen)); void node_type_update(struct bNodeType *ntype, void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node), void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id)); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index d441b103743..869dbe032c9 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3089,12 +3089,12 @@ void nodeSynchronizeID(bNode *node, bool copy_to_id) /* ************* node type access ********** */ -void nodeLabel(bNode *node, char *label, int maxlen) +void nodeLabel(bNodeTree *ntree, bNode *node, char *label, int maxlen) { if (node->label[0] != '\0') BLI_strncpy(label, node->label, maxlen); else if (node->typeinfo->labelfunc) - node->typeinfo->labelfunc(node, label, maxlen); + node->typeinfo->labelfunc(ntree, node, label, maxlen); else BLI_strncpy(label, IFACE_(node->typeinfo->ui_name), maxlen); } @@ -3267,7 +3267,7 @@ void node_type_storage(bNodeType *ntype, ntype->freefunc = freefunc; } -void node_type_label(struct bNodeType *ntype, void (*labelfunc)(struct bNode *, char *label, int maxlen)) +void node_type_label(struct bNodeType *ntype, void (*labelfunc)(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen)) { ntype->labelfunc = labelfunc; } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index e7a08d2c626..50a4b515490 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -384,7 +384,7 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, node->totr = rect; } -static void node_draw_frame_label(bNode *node, const float aspect) +static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float aspect) { /* XXX font id is crap design */ const int fontid = UI_GetStyle()->widgetlabel.uifont_id; @@ -397,7 +397,7 @@ static void node_draw_frame_label(bNode *node, const float aspect) float x, y; const int font_size = data->label_size / aspect; - nodeLabel(node, label, sizeof(label)); + nodeLabel(ntree, node, label, sizeof(label)); BLF_enable(fontid, BLF_ASPECT); BLF_aspect(fontid, aspect, aspect, 1.0f); @@ -420,7 +420,7 @@ static void node_draw_frame_label(bNode *node, const float aspect) } static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, - bNodeTree *UNUSED(ntree), bNode *node, bNodeInstanceKey UNUSED(key)) + bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key)) { rctf *rct = &node->totr; int color_id = node_get_colorid(node); @@ -469,7 +469,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, } /* label */ - node_draw_frame_label(node, snode->aspect); + node_draw_frame_label(ntree, node, snode->aspect); UI_ThemeClearColor(color_id); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index f4ffeb05608..6f2f8dee105 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -868,7 +868,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN UI_ThemeColor(TH_TEXT); #endif - nodeLabel(node, showname, sizeof(showname)); + nodeLabel(ntree, node, showname, sizeof(showname)); //if (node->flag & NODE_MUTED) // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ @@ -1035,7 +1035,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b UI_ThemeColor(TH_TEXT); if (node->miniwidth > 0.0f) { - nodeLabel(node, showname, sizeof(showname)); + nodeLabel(ntree, node, showname, sizeof(showname)); //if (node->flag & NODE_MUTED) // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 2b9c2bd4e9a..6b5bced75bd 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1280,6 +1280,29 @@ static void rna_Node_draw_buttons_ext(struct uiLayout *layout, bContext *C, Poin RNA_parameter_list_free(&list); } +static void rna_Node_draw_label(bNodeTree *ntree, bNode *node, char *label, int maxlen) +{ + extern FunctionRNA rna_Node_draw_label_func; + + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + void *ret; + char *rlabel; + + func = &rna_Node_draw_label_func; /* RNA_struct_find_function(&ptr, "draw_label"); */ + + RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); + RNA_parameter_list_create(&list, &ptr, func); + node->typeinfo->ext.call(NULL, &ptr, func, &list); + + RNA_parameter_get_lookup(&list, "label", &ret); + rlabel = *(char **)ret; + BLI_strncpy(label, rlabel != NULL ? rlabel : "", maxlen); + + RNA_parameter_list_free(&list); +} + static int rna_Node_is_registered_node_type(StructRNA *type) { return (RNA_struct_blender_type_get(type) != NULL); @@ -1321,7 +1344,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc PointerRNA dummyptr; FunctionRNA *func; PropertyRNA *parm; - int have_function[8]; + int have_function[9]; /* setup dummy node & node type to store static properties in */ memset(&dummynt, 0, sizeof(bNodeType)); @@ -1379,6 +1402,7 @@ static bNodeType *rna_Node_register_base(Main *bmain, ReportList *reports, Struc nt->freefunc_api = (have_function[5]) ? rna_Node_free : NULL; nt->draw_buttons = (have_function[6]) ? rna_Node_draw_buttons : NULL; nt->draw_buttons_ex = (have_function[7]) ? rna_Node_draw_buttons_ext : NULL; + nt->labelfunc = (have_function[8]) ? rna_Node_draw_label : NULL; /* sanitize size values in case not all have been registered */ if (nt->maxwidth < nt->minwidth) @@ -7149,6 +7173,14 @@ static void rna_def_node(BlenderRNA *brna) RNA_def_property_struct_type(parm, "UILayout"); RNA_def_property_ui_text(parm, "Layout", "Layout in the UI"); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + + /* dynamic label */ + func = RNA_def_function(srna, "draw_label", NULL); + RNA_def_function_ui_description(func, "Returns a dynamic label string"); + RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); + parm = RNA_def_string(func, "label", "", MAX_NAME, "Label", ""); + RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */ + RNA_def_function_output(func, parm); } static void rna_def_node_link(BlenderRNA *brna) diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c index 4d4781a4ffa..1d411aafe68 100644 --- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c +++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c @@ -48,7 +48,7 @@ static bNodeSocketTemplate cmp_node_moviedistortion_out[] = { { -1, 0, "" } }; -static void label(bNode *node, char *label, int maxlen) +static void label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) { if (node->custom1 == 0) BLI_strncpy(label, IFACE_("Undistortion"), maxlen); diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index c5f98ea64bd..a3298de5d59 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -82,7 +82,7 @@ bNodeSocket *node_group_find_output_socket(bNode *groupnode, const char *identif } /* groups display their internal tree name as label */ -void node_group_label(bNode *node, char *label, int maxlen) +void node_group_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) { BLI_strncpy(label, (node->id) ? node->id->name + 2 : IFACE_("Missing Datablock"), maxlen); } diff --git a/source/blender/nodes/intern/node_common.h b/source/blender/nodes/intern/node_common.h index 8c7cefedee6..df3937f5a3e 100644 --- a/source/blender/nodes/intern/node_common.h +++ b/source/blender/nodes/intern/node_common.h @@ -37,7 +37,7 @@ struct bNodeTree; -void node_group_label(struct bNode *node, char *label, int maxlen); +void node_group_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); int node_group_poll_instance(struct bNode *node, struct bNodeTree *nodetree); void ntree_update_reroute_nodes(struct bNodeTree *ntree); diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index 0820c2acd50..3997d9cbcac 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -83,28 +83,28 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context), bNode *node, bNode /**** Labels ****/ -void node_blend_label(bNode *node, char *label, int maxlen) +void node_blend_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) { const char *name; RNA_enum_name(ramp_blend_items, node->custom1, &name); BLI_strncpy(label, IFACE_(name), maxlen); } -void node_math_label(bNode *node, char *label, int maxlen) +void node_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) { const char *name; RNA_enum_name(node_math_items, node->custom1, &name); BLI_strncpy(label, IFACE_(name), maxlen); } -void node_vect_math_label(bNode *node, char *label, int maxlen) +void node_vect_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) { const char *name; RNA_enum_name(node_vec_math_items, node->custom1, &name); BLI_strncpy(label, IFACE_(name), maxlen); } -void node_filter_label(bNode *node, char *label, int maxlen) +void node_filter_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) { const char *name; RNA_enum_name(node_filter_items, node->custom1, &name); diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h index 03a167cdb1a..64b2028874b 100644 --- a/source/blender/nodes/intern/node_util.h +++ b/source/blender/nodes/intern/node_util.h @@ -71,10 +71,10 @@ extern void *node_initexec_curves(struct bNodeExecContext *context, struct bNode /**** Labels ****/ -void node_blend_label(struct bNode *node, char *label, int maxlen); -void node_math_label(struct bNode *node, char *label, int maxlen); -void node_vect_math_label(struct bNode *node, char *label, int maxlen); -void node_filter_label(struct bNode *node, char *label, int maxlen); +void node_blend_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); +void node_math_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); +void node_vect_math_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); +void node_filter_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); void node_update_internal_links_default(struct bNodeTree *ntree, struct bNode *node); -- cgit v1.2.3 From 8db4f87546e74c407d3f6eeae73522c9c5996d7a Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 12 Nov 2013 18:18:06 +0000 Subject: Small example for dynamic node labels in the custom_nodes.py template script. --- release/scripts/templates_py/custom_nodes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/release/scripts/templates_py/custom_nodes.py b/release/scripts/templates_py/custom_nodes.py index 975ae1881f2..bf89c0debad 100644 --- a/release/scripts/templates_py/custom_nodes.py +++ b/release/scripts/templates_py/custom_nodes.py @@ -109,6 +109,11 @@ class MyCustomNode(Node, MyCustomTreeNode): # myStringProperty button will only be visible in the sidebar layout.prop(self, "myStringProperty") + # Optional: custom label + # Explicit user label overrides this, but here we can define a label dynamically + def draw_label(self): + return "I am a custom node" + ### Node Categories ### # Node categories are a python system for automatically -- cgit v1.2.3 From c53f80aeed256874c1e2bc683400f816ed80e469 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 12 Nov 2013 18:29:08 +0000 Subject: Fix for [#37362] Audio strips sometimes are evaluated incorrectly. For details see bug comments. The problem was that blender's animation system didn't update the audio animation system anymore due to an optimization. Fixed this in a complex but proper way in the audio animation system, so that it can handle gaps of missing values. --- .../audaspace/intern/AUD_AnimateableProperty.cpp | 85 +++++++++++++++++++++- intern/audaspace/intern/AUD_AnimateableProperty.h | 14 ++++ 2 files changed, 95 insertions(+), 4 deletions(-) diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.cpp b/intern/audaspace/intern/AUD_AnimateableProperty.cpp index 0b333e687ff..6d1a307d868 100644 --- a/intern/audaspace/intern/AUD_AnimateableProperty.cpp +++ b/intern/audaspace/intern/AUD_AnimateableProperty.cpp @@ -47,6 +47,15 @@ AUD_AnimateableProperty::AUD_AnimateableProperty(int count) : pthread_mutexattr_destroy(&attr); } +void AUD_AnimateableProperty::updateUnknownCache(int start, int end) +{ + float* buf = getBuffer(); + + for(int i = start; i <= end; i++) + // TODO: maybe first instead of zero order interpolation? + memcpy(buf + i * m_count, buf + (start - 1) * m_count, m_count * sizeof(float)); +} + AUD_AnimateableProperty::~AUD_AnimateableProperty() { pthread_mutex_destroy(&m_mutex); @@ -67,6 +76,7 @@ void AUD_AnimateableProperty::write(const float* data) AUD_MutexLock lock(*this); m_isAnimated = false; + m_unknown.clear(); memcpy(getBuffer(), data, m_count * sizeof(float)); } @@ -74,18 +84,85 @@ void AUD_AnimateableProperty::write(const float* data, int position, int count) { AUD_MutexLock lock(*this); - m_isAnimated = true; - int pos = getSize() / (sizeof(float) * m_count); + if(!m_isAnimated) + pos = 0; + + m_isAnimated = true; + assureSize((count + position) * m_count * sizeof(float), true); float* buf = getBuffer(); memcpy(buf + position * m_count, data, count * m_count * sizeof(float)); - for(int i = pos; i < position; i++) - memcpy(buf + i * m_count, buf + (pos - 1) * m_count, m_count * sizeof(float)); + // have to fill up space between? + if(pos < position) + { + m_unknown.push_back(Unknown(pos, position - 1)); + + if(pos == 0) + { + memset(buf, 0, position * m_count * sizeof(float)); + } + else + updateUnknownCache(pos, position - 1); + } + // otherwise it's not at the end, let's check if some unknown part got filled + else + { + for(std::list::iterator it = m_unknown.begin(); it != m_unknown.end(); it++) + { + // unknown area before position + if(it->end < position) + continue; + + // we're after the new area, let's stop + if(it->start >= position + count) + break; + + // we have an intersection, now 4 cases: + // the start is included + if(position <= it->start) + { + // the end is included + if(position + count > it->end) + { + // simply delete + std::list::iterator it2 = it; + it++; + m_unknown.erase(it2); + } + // the end is excluded, a second part remains + else + { + // update second part + it->start = position + count; + updateUnknownCache(it->start, it->end); + break; + } + } + // start is excluded, a first part remains + else + { + // the end is included + if(position + count > it->end) + { + // update first part + it->end = position - 1; + } + // the end is excluded, a second part remains + else + { + // add another item and update both parts + m_unknown.insert(it, Unknown(it->start, position - 1)); + it->start = position + count; + updateUnknownCache(it->start, it->end); + } + } + } + } } void AUD_AnimateableProperty::read(float position, float* out) diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.h b/intern/audaspace/intern/AUD_AnimateableProperty.h index 322748ad571..37eb8f84550 100644 --- a/intern/audaspace/intern/AUD_AnimateableProperty.h +++ b/intern/audaspace/intern/AUD_AnimateableProperty.h @@ -34,6 +34,7 @@ #include "AUD_ILockable.h" #include +#include /** * This class saves animation data for float properties. @@ -41,6 +42,14 @@ class AUD_AnimateableProperty : private AUD_Buffer, public AUD_ILockable { private: + struct Unknown { + int start; + int end; + + Unknown(int start, int end) : + start(start), end(end) {} + }; + /// The count of floats for a single property. const int m_count; @@ -50,10 +59,15 @@ private: /// The mutex for locking. pthread_mutex_t m_mutex; + /// The list of unknown buffer areas. + std::list m_unknown; + // hide copy constructor and operator= AUD_AnimateableProperty(const AUD_AnimateableProperty&); AUD_AnimateableProperty& operator=(const AUD_AnimateableProperty&); + void updateUnknownCache(int start, int end); + public: /** * Creates a new animateable property. -- cgit v1.2.3 From 6bbca88f6622007ec0adfbb194df56a7b114ac56 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 15 Nov 2013 12:19:08 +0600 Subject: Initialize git submodules for addons, locales and scons Uses relative paths to repositories, so this is expected to work fine for any protocol we support (git, ssh and http). Uses ignore=all for all the submodules, so updating them to latest remote hash does not tags blender repository as changes. But it is still possible to make changes to submodules and commit them from their path. --- .gitmodules | 16 ++++++++++++++++ release/datafiles/locale | 1 + release/scripts/addons | 1 + release/scripts/addons_contrib | 1 + scons | 1 + 5 files changed, 20 insertions(+) create mode 100644 .gitmodules create mode 160000 release/datafiles/locale create mode 160000 release/scripts/addons create mode 160000 release/scripts/addons_contrib create mode 160000 scons diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..4ce5a2466e6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,16 @@ +[submodule "release/scripts/addons"] + path = release/scripts/addons + url = ../blender-addons.git + ignore = all +[submodule "release/scripts/addons_contrib"] + path = release/scripts/addons_contrib + url = ../blender-addons-contrib.git + ignore = all +[submodule "release/datafiles/locale"] + path = release/datafiles/locale + url = ../blender-translations.git + ignore = all +[submodule "scons"] + path = scons + url = ../scons.git + ignore = all diff --git a/release/datafiles/locale b/release/datafiles/locale new file mode 160000 index 00000000000..cb1967cc63a --- /dev/null +++ b/release/datafiles/locale @@ -0,0 +1 @@ +Subproject commit cb1967cc63a6d2d75d2b59cdf91c5f5645285aea diff --git a/release/scripts/addons b/release/scripts/addons new file mode 160000 index 00000000000..c50944e808d --- /dev/null +++ b/release/scripts/addons @@ -0,0 +1 @@ +Subproject commit c50944e808d6c74148237e85866e893628f0fee6 diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib new file mode 160000 index 00000000000..31545d25c9c --- /dev/null +++ b/release/scripts/addons_contrib @@ -0,0 +1 @@ +Subproject commit 31545d25c9cb41d271a3f3ef84d327708572290e diff --git a/scons b/scons new file mode 160000 index 00000000000..ccea0f01de1 --- /dev/null +++ b/scons @@ -0,0 +1 @@ +Subproject commit ccea0f01de1c3e9210086bd447df71bae353fa07 -- cgit v1.2.3 From 89e5c875387ade12d5f093d40762e9c6dd9ea1c2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 13 Nov 2013 16:42:31 +0600 Subject: Remove debug-only print from cmake macros Left it there by an accident. --- build_files/cmake/macros.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 7a06352ac70..e7e88ad5703 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -891,8 +891,6 @@ macro(msgfmt_simple COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/msgfmt ${_file_from} ${_file_to} DEPENDS msgfmt) - message("${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/msgfmt ${_file_from} ${_file_to}") - set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE) unset(_file_from_we) -- cgit v1.2.3 From efd518b3795e4548fcd6ca849c81ccd17eb6dbe8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 13 Nov 2013 17:02:28 +0600 Subject: Fix for msgfmt leaving context from previous message string --- intern/locale/msgfmt.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/intern/locale/msgfmt.cc b/intern/locale/msgfmt.cc index cd858cda82d..312e4728973 100644 --- a/intern/locale/msgfmt.cc +++ b/intern/locale/msgfmt.cc @@ -221,6 +221,7 @@ void make(const char *input_file_name, if (l[0] == '#' && section == SECTION_STR) { add(msgctxt, msgid, msgstr, fuzzy); section = SECTION_NONE; + msgctxt = ""; fuzzy = false; } // Record a fuzzy mark. -- cgit v1.2.3 From ac21db957a6c2f2723752c6a30734f06b0a667e3 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 15 Nov 2013 03:51:17 +0600 Subject: Add functional and cctype headers to msgfmt.cc Fixes compilation with MSVC compilers. Patch by leszekswirski (Lech Swirski) with some own tweaks. Differential Revision: http://developer.blender.org/D2 --- intern/locale/msgfmt.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intern/locale/msgfmt.cc b/intern/locale/msgfmt.cc index 312e4728973..17720adfa48 100644 --- a/intern/locale/msgfmt.cc +++ b/intern/locale/msgfmt.cc @@ -14,7 +14,9 @@ // Usage: msgfmt input.po output.po #include +#include #include +#include #include #include #include -- cgit v1.2.3 From 345c5092397a98845fb384a5ecd172d3d0ccdd74 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Nov 2013 18:51:31 +1100 Subject: add gitignore --- .gitignore | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..d4e04b64dca --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# generic files to ignore +.* + +# python temp paths +__pycache__/ +*.py[cod] + +# editors +*~ +*.swp +*.swo +*# + +# ms-windows +Thumbs.db +ehthumbs.db +Desktop.ini + +# commonly used paths in blender +/blender.bin +/user-config.py + -- cgit v1.2.3 From 825b0e8bc422174965ed8c0376d3d25b4f923394 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Nov 2013 18:59:50 +1100 Subject: support for paths with spaces in makefile --- GNUmakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 417ff7770ed..26aaa3f0565 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -32,7 +32,7 @@ OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]') # Source and Build DIR's -BLENDER_DIR:=$(shell pwd -P) +BLENDER_DIR:="$(shell pwd -P)" BUILD_TYPE:=Release ifndef BUILD_CMAKE_ARGS @@ -40,7 +40,7 @@ ifndef BUILD_CMAKE_ARGS endif ifndef BUILD_DIR - BUILD_DIR:=$(shell dirname $(BLENDER_DIR))/build_$(OS_NCASE) + BUILD_DIR:="$(shell dirname $(BLENDER_DIR))/build_$(OS_NCASE)" endif -- cgit v1.2.3 From 927dea436ee47e4dcabcde8eb4b167f0c32a08f2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 15 Nov 2013 17:11:59 +0600 Subject: Further tweaks to buildinfo Summary: Old idea with changes since previous release tag didn't work good enough. In most of the cases tag was done in a branch hence not actually reachable from the master branch. Now change since release is gone, and date of the latest commit is used instead. The date is displayed in format YYYY-MM-DD HH:mm in the splash. New bpy.app fields: - build_commit_timestamp is an unix timestamp of the commit blender was build from. - build_commit_date is a date of that commit. - build_commit_time is a time of that commit. Reviewers: campbellbarton Differential Revision: http://developer.blender.org/D5 --- build_files/cmake/buildinfo.cmake | 38 ++++------------------ build_files/scons/tools/Blender.py | 13 ++------ release/scripts/modules/sys_info.py | 5 +-- source/blender/blenkernel/BKE_main.h | 3 +- source/blender/blenloader/intern/readfile.c | 11 +++++-- source/blender/blenloader/intern/writefile.c | 7 ++-- source/blender/collada/DocumentExporter.cpp | 17 ++++------ source/blender/makesdna/DNA_fileglobal_types.h | 3 +- source/blender/python/intern/bpy_app.c | 16 ++++++--- source/blender/windowmanager/intern/wm_operators.c | 30 +++++++---------- .../bad_level_call_stubs/CMakeLists.txt | 4 ++- source/creator/CMakeLists.txt | 4 ++- source/creator/buildinfo.c | 4 ++- source/creator/creator.c | 36 +++++++++++--------- 14 files changed, 85 insertions(+), 106 deletions(-) diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake index ae2f87b49be..2db03d3efe9 100644 --- a/build_files/cmake/buildinfo.cmake +++ b/build_files/cmake/buildinfo.cmake @@ -5,7 +5,7 @@ # with a default in case anything fails, for examble when using git-svn set(MY_WC_HASH "") set(MY_WC_BRANCH "") -set(MY_WC_CHANGE "unknown") +set(MY_WC_COMMIT_TIMESTAMP 0) # Guess if this is a SVN working copy and then look up the revision if(EXISTS ${SOURCE_DIR}/.git/) @@ -29,19 +29,10 @@ if(EXISTS ${SOURCE_DIR}/.git/) OUTPUT_VARIABLE _git_latest_version_tag OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT _git_latest_version_tag STREQUAL "") - execute_process(COMMAND git rev-list HEAD ^${_git_latest_version_tag} --count - WORKING_DIRECTORY ${SOURCE_DIR} - OUTPUT_VARIABLE MY_WC_CHANGE - OUTPUT_STRIP_TRAILING_WHITESPACE) - else() - # For the time being we don't have annotated release tags, - # count all the revisions in branch. - execute_process(COMMAND git rev-list HEAD --count - WORKING_DIRECTORY ${SOURCE_DIR} - OUTPUT_VARIABLE MY_WC_CHANGE - OUTPUT_STRIP_TRAILING_WHITESPACE) - endif() + execute_process(COMMAND git log -1 --format=%ct + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_COMMIT_TIMESTAMP + OUTPUT_STRIP_TRAILING_WHITESPACE) # Update GIT index before getting dirty files execute_process(COMMAND git update-index -q --refresh @@ -61,23 +52,6 @@ if(EXISTS ${SOURCE_DIR}/.git/) unset(_git_latest_version_tag) endif() endif() -else() - # Some crazy folks like me could have hacked git-svn chekout in a way - # so svnversion gives proper svn revision for themm which required having - # empty .svn folder. - # - # For such a crazy blokes put svn check into an else branch. - # - # (sergey) - if(EXISTS ${SOURCE_DIR}/.svn/) - # The FindSubversion.cmake module is part of the standard distribution - include(FindSubversion) - - if(Subversion_FOUND) - Subversion_WC_INFO(${SOURCE_DIR} MY) - set(MY_WC_CHANGE "${MY_WC_REVISION}") - endif() - endif() endif() # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake @@ -94,7 +68,7 @@ endif() # Write a file with the SVNVERSION define file(WRITE buildinfo.h.txt "#define BUILD_HASH \"${MY_WC_HASH}\"\n" - "#define BUILD_CHANGE \"${MY_WC_CHANGE}\"\n" + "#define BUILD_COMMIT_TIMESTAMP ${MY_WC_COMMIT_TIMESTAMP}\n" "#define BUILD_BRANCH \"${MY_WC_BRANCH}\"\n" "#define BUILD_DATE \"${BUILD_DATE}\"\n" "#define BUILD_TIME \"${BUILD_TIME}\"\n" diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 06cc6b7f00a..8715c2367e4 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -411,18 +411,9 @@ def buildinfo(lenv, build_type): build_date = time.strftime ("%Y-%m-%d") build_time = time.strftime ("%H:%M:%S") if os.path.isdir(os.path.abspath('.git')): - latest_version_tag = os.popen('git describe --match "v[0-9]*" --abbrev=0').read().strip() - if latest_version_tag: - build_change = os.popen('git rev-list HEAD ' + latest_version_tag + ' --count').read().strip() - else: - build_change = os.popen('git rev-list HEAD --count').read().strip() - + build_commit_timestamp = os.popen('git log -1 --format=%ct').read().strip() build_hash = os.popen('git rev-parse --short HEAD').read().strip() build_branch = os.popen('git rev-parse --abbrev-ref HEAD').read().strip() - elif os.path.isdir(os.path.abspath('.svn')): - build_hash = '' - build_change = os.popen('svnversion').read()[:-1] # remove \n - build_branch = '' else: build_hash = '' build_change = 'unknown' @@ -445,7 +436,7 @@ def buildinfo(lenv, build_type): 'BUILD_DATE=\\"%s\\"'%(build_date), 'BUILD_TYPE=\\"%s\\"'%(build_type), 'BUILD_HASH=\\"%s\\"'%(build_hash), - 'BUILD_CHANGE=\\"%s\\"'%(build_change), + 'BUILD_COMMIT_TIMESTAMP=%s'%(build_commit_timestamp), 'BUILD_BRANCH=\\"%s\\"'%(build_branch), 'WITH_BUILDINFO', 'BUILD_PLATFORM=\\"%s:%s\\"'%(platform.system(), platform.architecture()[0]), diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py index 3fd4a60d0b1..83f2647c5b2 100644 --- a/release/scripts/modules/sys_info.py +++ b/release/scripts/modules/sys_info.py @@ -68,10 +68,11 @@ def write_sysinfo(op): output.write("\nBlender:\n") output.write(lilies) if bpy.app.build_branch and bpy.app.build_branch != "Unknown": - output.write("version %s, branch %r, chage %r, hash %r, %r\n" % + output.write("version %s, branch %r, commit date %r %r, hash %r, %r\n" % (bpy.app.version_string, bpy.app.build_branch, - bpy.app.build_change, + bpy.app.build_commit_date, + bpy.app.build_commit_time, bpy.app.build_hash, bpy.app.build_type)) else: diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 36c1f5dcf1f..629eda3b583 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -53,7 +53,8 @@ typedef struct Main { char name[1024]; /* 1024 = FILE_MAX */ short versionfile, subversionfile; /* see BLENDER_VERSION, BLENDER_SUBVERSION */ short minversionfile, minsubversionfile; - char build_change[16], build_hash[16]; /* change number and hash from buildinfo */ + unsigned long build_commit_timestamp; /* commit's timestamp from buildinfo */ + char build_hash[16]; /* hash from buildinfo */ short recovered; /* indicate the main->name (file) is the recovered one */ struct Library *curlib; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 910ff1d9ebe..e2876317e38 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7293,7 +7293,7 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) bfd->main->subversionfile = fg->subversion; bfd->main->minversionfile = fg->minversion; bfd->main->minsubversionfile = fg->minsubversion; - BLI_strncpy(bfd->main->build_change, fg->build_change, sizeof(bfd->main->build_change)); + bfd->main->build_commit_timestamp = fg->build_commit_timestamp; BLI_strncpy(bfd->main->build_hash, fg->build_hash, sizeof(bfd->main->build_hash)); bfd->winpos = fg->winpos; @@ -7929,9 +7929,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* WATCH IT!!!: pointers from libdata have not been converted */ if (G.debug & G_DEBUG) { - printf("read file %s\n Version %d sub %d change %s hash %s\n", + char build_commit_datetime[32]; + time_t temp_time = main->build_commit_timestamp; + struct tm *tm = gmtime(&temp_time); + strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm); + + printf("read file %s\n Version %d sub %d date %s hash %s\n", fd->relabase, main->versionfile, main->subversionfile, - main->build_change, main->build_hash); + build_commit_datetime, main->build_hash); } blo_do_versions_pre250(fd, lib, main); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index cf7a5329a35..1f417df38d2 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3285,13 +3285,14 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) fg.minsubversion= BLENDER_MINSUBVERSION; #ifdef WITH_BUILDINFO { - extern char build_change[], build_hash[]; + extern unsigned long build_commit_timestamp; + extern char build_hash[]; /* TODO(sergey): Add branch name to file as well? */ - BLI_strncpy(fg.build_change, build_change, sizeof(fg.build_change)); + fg.build_commit_timestamp = build_commit_timestamp; BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash)); } #else - BLI_strncpy(fg.build_change, "unknown", sizeof(fg.build_change)); + fg.build_commit_timestamp = 0; BLI_strncpy(fg.build_hash, "unknown", sizeof(fg.build_hash)); #endif writestruct(wd, GLOB, "FileGlobal", 1, &fg); diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 9aa0f6e2831..9d590968481 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -101,7 +101,8 @@ extern "C" #include "ED_keyframing.h" #ifdef WITH_BUILDINFO -extern char build_change[]; +extern char build_commit_date[]; +extern char build_commit_time[]; extern char build_hash[]; #endif @@ -227,16 +228,12 @@ void DocumentExporter::exportCurrentScene(Scene *sce) } char version_buf[128]; #ifdef WITH_BUILDINFO - /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ - if (build_hash[0] != '\0') { - sprintf(version_buf, "Blender %d.%02d.%d change:%s, hash:", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, - build_change, build_hash); - } - else { - sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, build_change); - } + BLI_snprintf(version_buf, sizeof(version_buf), "Blender %d.%02d.%d commit date:%s, hash:", + BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, + build_commit_date, blender_commit_time, build_hash); #else - sprintf(version_buf, "Blender %d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); + BLI_snprintf(version_buf, sizeof(version_buf), "Blender %d.%02d.%d", + BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); #endif asset.getContributor().mAuthoringTool = version_buf; asset.add(); diff --git a/source/blender/makesdna/DNA_fileglobal_types.h b/source/blender/makesdna/DNA_fileglobal_types.h index 734741fa687..f0f8fe7d40c 100644 --- a/source/blender/makesdna/DNA_fileglobal_types.h +++ b/source/blender/makesdna/DNA_fileglobal_types.h @@ -48,7 +48,8 @@ typedef struct FileGlobal { struct Scene *curscene; int fileflags; int globalf; - char build_change[16], build_hash[16]; /* change number and hash from buildinfo */ + unsigned long build_commit_timestamp; /* commit timestamp from buildinfo */ + char build_hash[12]; /* hash from buildinfo */ /* file path where this was saved, for recover */ char filename[1024]; /* 1024 = FILE_MAX */ } FileGlobal; diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 3a529496f02..21767196e11 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -53,7 +53,9 @@ #ifdef BUILD_DATE extern char build_date[]; extern char build_time[]; -extern char build_change[]; +extern unsigned long build_commit_timestamp; +extern char build_commit_date[]; +extern char build_commit_time[]; extern char build_hash[]; extern char build_branch[]; extern char build_platform[]; @@ -77,7 +79,9 @@ static PyStructSequence_Field app_info_fields[] = { /* buildinfo */ {(char *)"build_date", (char *)"The date this blender instance was built"}, {(char *)"build_time", (char *)"The time this blender instance was built"}, - {(char *)"build_change", (char *)"The change number this blender instance was built with"}, + {(char *)"build_commit_timestamp", (char *)"The unix timestamp of commit this blender instance was built"}, + {(char *)"build_commit_date", (char *)"The date of commit this blender instance was built"}, + {(char *)"build_commit_time", (char *)"The time of commit this blender instance was built"}, {(char *)"build_hash", (char *)"The commit hash this blender instance was built with"}, {(char *)"build_branch", (char *)"The branch this blender instance was built from"}, {(char *)"build_platform", (char *)"The platform this blender instance was built for"}, @@ -111,10 +115,8 @@ static PyObject *make_app_info(void) if (app_info == NULL) { return NULL; } -#if 0 #define SetIntItem(flag) \ PyStructSequence_SET_ITEM(app_info, pos++, PyLong_FromLong(flag)) -#endif #define SetStrItem(str) \ PyStructSequence_SET_ITEM(app_info, pos++, PyUnicode_FromString(str)) #define SetBytesItem(str) \ @@ -137,7 +139,9 @@ static PyObject *make_app_info(void) #ifdef BUILD_DATE SetBytesItem(build_date); SetBytesItem(build_time); - SetBytesItem(build_change); + SetIntItem(build_commit_timestamp); + SetBytesItem(build_commit_date); + SetBytesItem(build_commit_time); SetBytesItem(build_hash); SetBytesItem(build_branch); SetBytesItem(build_platform); @@ -149,6 +153,8 @@ static PyObject *make_app_info(void) #else SetBytesItem("Unknown"); SetBytesItem("Unknown"); + SetIntItem(0); + SetBytesItem("Unknown"); SetBytesItem("Unknown"); SetBytesItem("Unknown"); SetBytesItem("Unknown"); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index ab8dac396c5..6396ef12495 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1677,24 +1677,19 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar #ifdef WITH_BUILDINFO int label_delta = 0; - int hash_width, change_width; - char change_buf[128] = "\0"; + int hash_width, date_width; + char date_buf[128] = "\0"; char hash_buf[128] = "\0"; - extern char build_hash[], build_change[], build_branch[]; + extern unsigned long build_commit_timestamp; + extern char build_hash[], build_commit_date[], build_commit_time[], build_branch[]; - /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ - if (build_hash[0] != '\0') { - /* Builds made from tag only shows tag sha */ - BLI_snprintf(hash_buf, sizeof(hash_buf), "Hash: %s", build_hash); - BLI_snprintf(change_buf, sizeof(change_buf), "Change: %s", build_change); - } - else { - BLI_snprintf(change_buf, sizeof(change_buf), "r%s", build_change); - } + /* Builds made from tag only shows tag sha */ + BLI_snprintf(hash_buf, sizeof(hash_buf), "Hash: %s", build_hash); + BLI_snprintf(date_buf, sizeof(date_buf), "Date: %s %s", build_commit_date, build_commit_time); BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi); hash_width = (int)BLF_width(style->widgetlabel.uifont_id, hash_buf) + 0.5f * U.widget_unit; - change_width = (int)BLF_width(style->widgetlabel.uifont_id, change_buf) + 0.5f * U.widget_unit; + date_width = (int)BLF_width(style->widgetlabel.uifont_id, date_buf) + 0.5f * U.widget_unit; #endif /* WITH_BUILDINFO */ block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); @@ -1710,16 +1705,13 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, NULL); #ifdef WITH_BUILDINFO - if (!STREQ(build_change, "0")) { - uiDefBut(block, LABEL, 0, change_buf, U.pixelsize * 494 - change_width, U.pixelsize * 270, change_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + if (build_commit_timestamp != 0) { + uiDefBut(block, LABEL, 0, date_buf, U.pixelsize * 494 - date_width, U.pixelsize * 270, date_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); label_delta = 12; } uiDefBut(block, LABEL, 0, hash_buf, U.pixelsize * 494 - hash_width, U.pixelsize * (270 - label_delta), hash_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); - /* TODO(sergey): As soon as we fully switched to GIT, no need to check - * whether branch is empty or not. - */ - if (build_branch[0] != '\0' && !STREQ(build_branch, "master")) { + if (!STREQ(build_branch, "master")) { char branch_buf[128] = "\0"; int branch_width; BLI_snprintf(branch_buf, sizeof(branch_buf), "Branch: %s", build_branch); diff --git a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt index f8fe401cb1c..0d71b157fb6 100644 --- a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt +++ b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt @@ -52,7 +52,9 @@ if(WITH_BUILDINFO) ) add_definitions(-DBUILD_DATE="\"\"" -DBUILD_TIME="\"\"" - -DBUILD_CHANGE="\"\"" + -DBUILD_COMMIT_TIMESTAMP=0" + -DBUILD_COMMIT_DATE="\"\"" + -DBUILD_COMMIT_TIME="\"\"" -DBUILD_HASH="\"\"" -DBUILD_PLATFORM="\"\"" -DBUILD_BRANCH="\"\"" diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index b386312bb55..0ef32f4dc02 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -131,7 +131,9 @@ if(WITH_BUILDINFO) # # define in header now, else these get out of date on rebuilds. # -DBUILD_DATE="${BUILD_DATE}" # -DBUILD_TIME="${BUILD_TIME}" - # -DBUILD_CHANGE="${BUILD_CHANGE}" + # -DBUILD_COMMIT_TIMESTAMP="${BUILD_COMMIT_TIMESTAMP}" + # -DBUILD_COMMIT_TIME="${BUILD_COMMIT_TIME}" + # -DBUILD_COMMIT_DATE="${BUILD_COMMIT_DATE}" # -DBUILD_HASH="${BUILD_HASH}" # -DBUILD_BRANCH="${BUILD_BRANCH}" -DWITH_BUILDINFO_HEADER # alternative to lines above diff --git a/source/creator/buildinfo.c b/source/creator/buildinfo.c index d51249980a8..795eec0df40 100644 --- a/source/creator/buildinfo.c +++ b/source/creator/buildinfo.c @@ -40,7 +40,9 @@ char build_date[] = BUILD_DATE; char build_time[] = BUILD_TIME; char build_hash[] = BUILD_HASH; -char build_change[] = BUILD_CHANGE; +unsigned long build_commit_timestamp = BUILD_COMMIT_TIMESTAMP; +char build_commit_date[16] = "\0"; +char build_commit_time[16] = "\0"; char build_branch[] = BUILD_BRANCH; char build_platform[] = BUILD_PLATFORM; diff --git a/source/creator/creator.c b/source/creator/creator.c index 8221552a1d7..508847af5e3 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -154,7 +154,12 @@ extern char build_date[]; extern char build_time[]; extern char build_hash[]; -extern char build_change[]; +extern unsigned long build_commit_timestamp; + +/* TODO(sergey): ideally size need to be in sync with buildinfo.c */ +extern char build_commit_date[16]; +extern char build_commit_time[16]; + extern char build_branch[]; extern char build_platform[]; extern char build_type[]; @@ -221,14 +226,9 @@ static int print_version(int UNUSED(argc), const char **UNUSED(argv), void *UNUS #ifdef BUILD_DATE printf("\tbuild date: %s\n", build_date); printf("\tbuild time: %s\n", build_time); - /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ - if (build_hash[0] != '\0') { - printf("\tbuild revision: %s\n", build_change); - } - else { - printf("\tbuild change: %s\n", build_change); - printf("\tbuild hash: %s\n", build_hash); - } + printf("\tbuild commit date: %s\n", build_commit_date); + printf("\tbuild commit time: %s\n", build_commit_time); + printf("\tbuild hash: %s\n", build_hash); printf("\tbuild platform: %s\n", build_platform); printf("\tbuild type: %s\n", build_type); printf("\tbuild c flags: %s\n", build_cflags); @@ -602,13 +602,8 @@ static void blender_crash_handler(int signum) #ifndef BUILD_DATE BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Unknown revision\n", BLEND_VERSION_ARG); #else - /* TODO(sergey): As soon as we fully switched to GIT, no need to check build_hash. */ - if (build_hash[0] != '\0') { - BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Change: %s, Hash %s\n", BLEND_VERSION_ARG, build_change, build_hash); - } - else { - BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Revision: %s\n", BLEND_VERSION_ARG, build_change); - } + BLI_snprintf(header, sizeof(header), "# " BLEND_VERSION_FMT ", Commit date: %s %s, Hash %s\n", + BLEND_VERSION_ARG, build_commit_date, build_commit_time, build_hash); #endif /* open the crash log */ @@ -1517,6 +1512,15 @@ int main(int argc, const char **argv) } } +#ifdef BUILD_DATE + { + time_t temp_time = build_commit_timestamp; + struct tm *tm = gmtime(&temp_time); + strftime(build_commit_date, sizeof(build_commit_date), "%Y-%m-%d", tm); + strftime(build_commit_time, sizeof(build_commit_time), "%H:%M", tm); + } +#endif + C = CTX_create(); #ifdef WITH_PYTHON_MODULE -- cgit v1.2.3 From f19eef9ed8a66c815daf33f929c4ac9498dd840d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 15 Nov 2013 20:38:39 +0600 Subject: Add .arcconfig for Phabricator Arcanist Summary: http://wiki.blender.org/index.php/Dev:Doc/Tools/Code_Review --- 1.patch | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 1.patch diff --git a/1.patch b/1.patch new file mode 100644 index 00000000000..b74f31c68c0 --- /dev/null +++ b/1.patch @@ -0,0 +1,24 @@ +commit c50944e808d6c74148237e85866e893628f0fee6 +Author: Brecht Van Lommel +Date: Wed Nov 13 20:30:45 2013 +0100 + + Add .arcconfig for Phabricator Arcanist + + Summary: http://wiki.blender.org/index.php/Dev:Doc/Tools/Code_Review + + Reviewed By: sergey + + Differential Revision: http://developer.blender.org/D1 + +diff --git a/.arcconfig b/.arcconfig +new file mode 100644 +index 0000000..cfe68c6 +--- /dev/null ++++ b/.arcconfig +@@ -0,0 +1,6 @@ ++{ ++ "project_id" : "Blender", ++ "conduit_uri" : "http://developer.blender.org/", ++ "git.default-relative-commit" : "origin/master", ++ "arc.land.update.default" : "rebase" ++} -- cgit v1.2.3 From a00f0469ca9f1b64b336e70539676b8d232dbde7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 15 Nov 2013 20:40:43 +0600 Subject: Added the wrong file. Now addin .arcconfig for real. Summary is still: http://wiki.blender.org/index.php/Dev:Doc/Tools/Code_Review --- .arcconfig | 6 ++++++ 1.patch | 24 ------------------------ 2 files changed, 6 insertions(+), 24 deletions(-) create mode 100644 .arcconfig delete mode 100644 1.patch diff --git a/.arcconfig b/.arcconfig new file mode 100644 index 00000000000..57f6c39f1ea --- /dev/null +++ b/.arcconfig @@ -0,0 +1,6 @@ +{ + "project_id" : "Blender", + "conduit_uri" : "http://developer.blender.org/", + "git.default-relative-commit" : "origin/master", + "arc.land.update.default" : "rebase" +} diff --git a/1.patch b/1.patch deleted file mode 100644 index b74f31c68c0..00000000000 --- a/1.patch +++ /dev/null @@ -1,24 +0,0 @@ -commit c50944e808d6c74148237e85866e893628f0fee6 -Author: Brecht Van Lommel -Date: Wed Nov 13 20:30:45 2013 +0100 - - Add .arcconfig for Phabricator Arcanist - - Summary: http://wiki.blender.org/index.php/Dev:Doc/Tools/Code_Review - - Reviewed By: sergey - - Differential Revision: http://developer.blender.org/D1 - -diff --git a/.arcconfig b/.arcconfig -new file mode 100644 -index 0000000..cfe68c6 ---- /dev/null -+++ b/.arcconfig -@@ -0,0 +1,6 @@ -+{ -+ "project_id" : "Blender", -+ "conduit_uri" : "http://developer.blender.org/", -+ "git.default-relative-commit" : "origin/master", -+ "arc.land.update.default" : "rebase" -+} -- cgit v1.2.3 From 92f3fa3fcd97211f7eb9c5d210b0897e481f3a24 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Fri, 15 Nov 2013 10:46:10 +0100 Subject: OSX/scons: make another gcc conditional futureproof --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 2c30e1b72b1..8f4acde4a04 100644 --- a/SConstruct +++ b/SConstruct @@ -416,7 +416,7 @@ if env['OURPLATFORM']=='darwin': if env['WITH_BF_CYCLES_OSL'] == 1: OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath # we need 2 variants of passing the oslexec with the force_load option, string and list type atm - if env['CC'][:-2].endswith('4.8'): + if env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.8': env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-loslexec','-loslquery']) else: env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-force_load '+ OSX_OSL_LIBPATH +'/liboslexec.a','-loslquery']) -- cgit v1.2.3 From 4836fc78a04680a2180053901f8633a16facfaed Mon Sep 17 00:00:00 2001 From: jensverwiebe Date: Fri, 15 Nov 2013 16:30:49 +0100 Subject: Cmake: little typo breaking player --- source/blenderplayer/bad_level_call_stubs/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt index 0d71b157fb6..1d681d28589 100644 --- a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt +++ b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt @@ -52,7 +52,7 @@ if(WITH_BUILDINFO) ) add_definitions(-DBUILD_DATE="\"\"" -DBUILD_TIME="\"\"" - -DBUILD_COMMIT_TIMESTAMP=0" + -DBUILD_COMMIT_TIMESTAMP=0 -DBUILD_COMMIT_DATE="\"\"" -DBUILD_COMMIT_TIME="\"\"" -DBUILD_HASH="\"\"" -- cgit v1.2.3 From 9a78cda32111be9e1c9e2b9c158b27334d3c8804 Mon Sep 17 00:00:00 2001 From: howardt Date: Fri, 15 Nov 2013 10:19:38 -0500 Subject: Fix Bevel artifacts bug T37053 In the case that there are two beveled edges with one unbeveled one in between, and the widths don't allow them to magically line up, it is better to slide along unbeveled edge. Sometimes bevel widths are uneven (this was the case before) and it is a followup TODO to do a width cleanup pass afterwards to even the edges up as much as possible. --- source/blender/bmesh/tools/bmesh_bevel.c | 159 ++++++++++++++++++++----------- 1 file changed, 106 insertions(+), 53 deletions(-) diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 7293e400951..a1f08583e2c 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -133,6 +133,7 @@ typedef struct BevelParams { int seg; /* number of segments in beveled edge profile */ bool vertex_only; /* bevel vertices only */ bool use_weights; /* bevel amount affected by weights on edges or verts */ + bool preserve_widths; /* should bevel prefer widths over angles, if forced to choose? */ const struct MDeformVert *dvert; /* vertex group array, maybe set if vertex_only */ int vertex_group; /* vertex group index, maybe set if vertex_only */ } BevelParams; @@ -208,6 +209,28 @@ static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme) return NULL; } +/* find the BevVert corresponding to BMVert bmv */ +static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv) +{ + return BLI_ghash_lookup(bp->vert_hash, bmv); +} + +/* Find the EdgeHalf representing the other end of e->e. + * That may not have been constructed yet, in which case return NULL. */ +static EdgeHalf *find_other_end_edge_half(BevelParams *bp, EdgeHalf *e) +{ + BevVert *bvother; + EdgeHalf *eother; + + bvother = find_bevvert(bp, e->is_rev ? e->e->v1 : e->e->v2); + if (bvother) { + eother = find_edge_half(bvother, e->e); + BLI_assert(eother != NULL); + return eother; + } + return NULL; +} + /* Return the next EdgeHalf after from_e that is beveled. * If from_e is NULL, find the first beveled edge. */ static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e) @@ -225,12 +248,6 @@ static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e) return NULL; } -/* find the BevVert corresponding to BMVert bmv */ -static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv) -{ - return BLI_ghash_lookup(bp->vert_hash, bmv); -} - /* Return a good representative face (for materials, etc.) for faces * created around/near BoundVert v */ static BMFace *boundvert_rep_face(BoundVert *v) @@ -522,19 +539,40 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, } } +/* Like offset_in_two planes, but for the case where we prefer to solve the problem + * of not meeting at the same point by choosing to change the bevel offset on one + * of the appropriate side of either e1 or e2, in order that the lines can meet on emid. */ +static void offset_on_edge_between(BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, + BMVert *v, float meetco[3]) +{ + BLI_assert(e1->is_bev && e2->is_bev && !emid->is_bev); + + /* If have to change offset of e1 or e2, which one? + * Prefer the one whose other end hasn't been constructed yet. + * Following will choose to change e2 if both have already been constructed. */ + if (find_other_end_edge_half(bp, e1)) { + offset_meet(e1, emid, v, e1->fnext, TRUE, meetco); + /* now e2's left offset is probably different */ + e2->offset_l = dist_to_line_v3(meetco, v->co, BM_edge_other_vert(e2->e, v)->co); + } + else { + offset_meet(emid, e2, v, emid->fnext, TRUE, meetco); + /* now e1's right offset is probably different */ + e1->offset_r = dist_to_line_v3(meetco, v->co, BM_edge_other_vert(e1->e, v)->co); + } +} + /* Like offset_meet, but with a mid edge between them that is used * to calculate the planes in which to run the offset lines. - * They may not meet exactly: the offsets for the edges may be different - * or both the planes and the lines may be angled so that they can't meet. + * They may not meet exactly: the lines may be angled so that they can't meet, + * probably because one or both faces is non-planar. * In that case, pick a close point on emid, which should be the dividing - * edge between the two planes. - * TODO: should have a global 'offset consistency' prepass to adjust offset - * widths so that all edges have the same offset at both ends. */ -static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, + * edge between the two planes. */ +static void offset_in_two_planes(BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, BMVert *v, float meetco[3]) { float dir1[3], dir2[3], dirmid[3], norm_perp1[3], norm_perp2[3], - off1a[3], off1b[3], off2a[3], off2b[3], isect2[3], co[3], + off1a[3], off1b[3], off2a[3], off2b[3], isect2[3], f1no[3], f2no[3], ang; int iret; @@ -562,8 +600,8 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, ang = angle_v3v3(dir1, dir2); if (ang < 100.0f * BEVEL_EPSILON) { - /* lines are parallel; off1a is a good meet point */ - copy_v3_v3(meetco, off1a); + /* lines are parallel; put intersection on emid */ + offset_on_edge_between(bp, e1, e2, emid, v, meetco); } else if (fabsf(ang - (float)M_PI) < 100.0f * BEVEL_EPSILON) { slide_dist(e2, v, e2->offset_l, meetco); @@ -575,11 +613,10 @@ static void offset_in_two_planes(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, copy_v3_v3(meetco, off1a); } else if (iret == 2) { - /* lines are not coplanar; meetco and isect2 are nearest to first and second lines */ + /* lines are not coplanar and don't meet; meetco and isect2 are nearest to first and second lines */ if (len_v3v3(meetco, isect2) > 100.0f * BEVEL_EPSILON) { - /* offset lines don't meet: project average onto emid; this is not ideal (see TODO above) */ - mid_v3_v3v3(co, meetco, isect2); - closest_to_line_v3(meetco, co, v->co, BM_edge_other_vert(emid->e, v)->co); + /* offset lines don't meet so can't preserve widths; fallback on sliding along edge between */ + offset_on_edge_between(bp, e1, e2, emid, v, meetco); } } /* else iret == 1 and the lines are coplanar so meetco has the intersection */ @@ -849,7 +886,10 @@ static void build_boundary(BevelParams *bp, BevVert *bv) if (e->prev->prev->is_bev) { BLI_assert(e->prev->prev != e); /* see: edgecount 2, selcount 1 case */ /* find meet point between e->prev->prev and e and attach e->prev there */ - offset_in_two_planes(e->prev->prev, e, e->prev, bv->v, co); + if (bp->preserve_widths) + offset_in_two_planes(bp, e->prev->prev, e, e->prev, bv->v, co); + else + offset_on_edge_between(bp, e->prev->prev, e, e->prev, bv->v, co); v = add_new_bound_vert(mem_arena, vm, co); v->efirst = e->prev->prev; v->elast = v->ebev = e; @@ -1950,7 +1990,7 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) BMEdge *bme2, *unflagged_bme, *first_bme; BMFace *f; BMIter iter, iter2; - EdgeHalf *e; + EdgeHalf *e, *eother; float weight, z; int i, found_shared_face, ccw_test_sum; int nsel = 0; @@ -2107,39 +2147,51 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) if (e->is_bev) { /* Convert distance as specified by user into offsets along * faces on left side and right side of this edgehalf. - * Except for percent method, offset will be same on each side. */ - switch (bp->offset_type) { - case BEVEL_AMT_OFFSET: - e->offset_l = bp->offset; - break; - case BEVEL_AMT_WIDTH: - z = fabs(2.0f * sinf(edge_face_angle(e) / 2.0f)); - if (z < BEVEL_EPSILON) - e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ - else - e->offset_l = bp->offset / z; - break; - case BEVEL_AMT_DEPTH: - z = fabs(cosf(edge_face_angle(e) / 2.0f)); - if (z < BEVEL_EPSILON) - e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ - else - e->offset_l = bp->offset / z; - break; - case BEVEL_AMT_PERCENT: - e->offset_l = BM_edge_calc_length(e->prev->e) * bp->offset / 100.0f; - e->offset_r = BM_edge_calc_length(e->next->e) * bp->offset / 100.0f; - break; - default: - BLI_assert(!"bad bevel offset kind"); - e->offset_l = bp->offset; + * Except for percent method, offset will be same on each side. + * + * First check to see if other end has had construction made, + * because offset may have been forced to another number + * (but for percent method all 4 widths can be different). */ + + eother = find_other_end_edge_half(bp, e); + if (eother && bp->offset_type != BEVEL_AMT_PERCENT) { + e->offset_l = eother->offset_r; + e->offset_r = eother->offset_l; } - if (bp->offset_type != BEVEL_AMT_PERCENT) - e->offset_r = e->offset_l; - if (bp->use_weights) { - weight = BM_elem_float_data_get(&bm->edata, bme, CD_BWEIGHT); - e->offset_l *= weight; - e->offset_r *= weight; + else { + switch (bp->offset_type) { + case BEVEL_AMT_OFFSET: + e->offset_l = bp->offset; + break; + case BEVEL_AMT_WIDTH: + z = fabs(2.0f * sinf(edge_face_angle(e) / 2.0f)); + if (z < BEVEL_EPSILON) + e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ + else + e->offset_l = bp->offset / z; + break; + case BEVEL_AMT_DEPTH: + z = fabs(cosf(edge_face_angle(e) / 2.0f)); + if (z < BEVEL_EPSILON) + e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ + else + e->offset_l = bp->offset / z; + break; + case BEVEL_AMT_PERCENT: + e->offset_l = BM_edge_calc_length(e->prev->e) * bp->offset / 100.0f; + e->offset_r = BM_edge_calc_length(e->next->e) * bp->offset / 100.0f; + break; + default: + BLI_assert(!"bad bevel offset kind"); + e->offset_l = bp->offset; + } + if (bp->offset_type != BEVEL_AMT_PERCENT) + e->offset_r = e->offset_l; + if (bp->use_weights) { + weight = BM_elem_float_data_get(&bm->edata, bme, CD_BWEIGHT); + e->offset_l *= weight; + e->offset_r *= weight; + } } } else { @@ -2432,6 +2484,7 @@ void BM_mesh_bevel(BMesh *bm, const float offset, const int offset_type, const f bp.seg = segments; bp.vertex_only = vertex_only; bp.use_weights = use_weights; + bp.preserve_widths = false; bp.dvert = dvert; bp.vertex_group = vertex_group; -- cgit v1.2.3 From 53fffbafbef694a2378fbf605cc25259a3154f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Fri, 15 Nov 2013 16:54:05 +0100 Subject: Fix for own mistake in r61178: bNodeTree->links ListBase was being modified while iterating ... --- source/blender/editors/space_node/node_relationships.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 9f5e8a6f9d9..b50066560fb 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -401,22 +401,27 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link) bNodeSocket *from = link->fromsock, *to = link->tosock; int max_from = from->limit, max_to = to->limit; int count_from = 1, count_to = 1; /* start at 1, link is included */ - bNodeLink *tlink; + bNodeLink *tlink, *tlink_next; - for (tlink = ntree->links.first; tlink; tlink = tlink->next) { + for (tlink = ntree->links.first; tlink; tlink = tlink_next) { + tlink_next = tlink->next; if (tlink == link) continue; - if (tlink->fromsock == from) { + if (tlink && tlink->fromsock == from) { ++count_from; - if (count_from > max_from) + if (count_from > max_from) { nodeRemLink(ntree, tlink); + tlink = NULL; + } } - if (tlink->tosock == to) { + if (tlink && tlink->tosock == to) { ++count_to; - if (count_to > max_to) + if (count_to > max_to) { nodeRemLink(ntree, tlink); + tlink = NULL; + } } } } -- cgit v1.2.3 From a9e0f3364fd93c51bd004d46b7b859d55b20a7b8 Mon Sep 17 00:00:00 2001 From: Jens Date: Fri, 15 Nov 2013 18:37:57 +0100 Subject: Fix collada after git switch ( undefined build_commit_time ) --- source/blender/collada/DocumentExporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 9d590968481..ee0326d5804 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -230,7 +230,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce) #ifdef WITH_BUILDINFO BLI_snprintf(version_buf, sizeof(version_buf), "Blender %d.%02d.%d commit date:%s, hash:", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, - build_commit_date, blender_commit_time, build_hash); + build_commit_date, build_commit_time, build_hash); #else BLI_snprintf(version_buf, sizeof(version_buf), "Blender %d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); -- cgit v1.2.3 From ca5bbe0e419b04d16ee7eb12fa7eaffa0266815a Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Fri, 15 Nov 2013 19:26:43 +0100 Subject: OSX/cmake: simplify system-version detection --- CMakeLists.txt | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9ba78eab53..c599b1df9fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -307,21 +307,13 @@ if(APPLE) FORCE) endif() - execute_process(COMMAND uname -r OUTPUT_VARIABLE MAC_SYS) # check for actual system-version - if(${MAC_SYS} MATCHES 13) - set(OSX_SYSTEM 10.9) - elseif(${MAC_SYS} MATCHES 12) - set(OSX_SYSTEM 10.8) - elseif(${MAC_SYS} MATCHES 11) - set(OSX_SYSTEM 10.7) - elseif(${MAC_SYS} MATCHES 10) - set(OSX_SYSTEM 10.6) - elseif(${MAC_SYS} MATCHES 9) - set(OSX_SYSTEM 10.5) - else() - set(OSX_SYSTEM unsupported) - endif() - message(STATUS "Detected system-version: " ${OSX_SYSTEM}) + execute_process(COMMAND sw_vers -productVersion OUTPUT_VARIABLE MAC_SYS OUTPUT_STRIP_TRAILING_WHITESPACE) # check for actual system-version + if( ${MAC_SYS} VERSION_LESS 10.5) + set(OSX_SYSTEM unsupported) + else() + set(OSX_SYSTEM ${MAC_SYS}) + endif() + message(STATUS "Detected system-version: " ${OSX_SYSTEM}) # workaround for incorrect cmake xcode lookup for developer previews - XCODE_VERSION does not take xcode-select path into accout # but would always look into /Applications/Xcode.app while dev versions are named Xcode-DP -- cgit v1.2.3 From 2b793822ad6392ede06bee6c20b0879bcc6b9f2a Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Fri, 15 Nov 2013 20:05:23 +0100 Subject: OSX/cmake: use CMAKE_XCODE_ATTRIBUTE rather than CMAKE_OSX_SYSROOT and set min deployment target to 10.6 now --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c599b1df9fe..fe79a2d0a62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -359,10 +359,13 @@ if(APPLE) message(STATUS "OSX_SYSROOT_PREFIX: " ${OSX_SYSROOT_PREFIX}) set(OSX_DEVELOPER_PREFIX /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk) # use guaranteed existing sdk set(CMAKE_OSX_SYSROOT ${OSX_SYSROOT_PREFIX}/${OSX_DEVELOPER_PREFIX} CACHE PATH "" FORCE) + if(${CMAKE_GENERATOR} MATCHES "Xcode") + set(CMAKE_XCODE_ATTRIBUTE_SDKROOT macosx${OSX_SYSTEM}) # to silence sdk not found warning, just overrides CMAKE_OSX_SYSROOT + endif() endif() if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "" FORCE) # 10.5 is our min. target, if you use higher sdk, weak linking happens + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING "" FORCE) # 10.6 is our min. target, if you use higher sdk, weak linking happens endif() if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode") @@ -1472,7 +1475,7 @@ elseif(WIN32) elseif(APPLE) if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5" OR ${CMAKE_OSX_DEPLOYMENT_TARGET} STRGREATER "10.5") - set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/10.7 + set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/7/8/9 endif() if(WITH_LIBS10.5) -- cgit v1.2.3 From f06c02b8dd5b97de68e4f173a43e4f2eaf41993a Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Fri, 15 Nov 2013 22:20:51 +0200 Subject: Support for symmetrical box masking in sculpt mode. Now box masking will take the symmetry options into account. --- source/blender/editors/sculpt_paint/paint_mask.c | 69 +++++++++++++++++------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 980223e24c0..c563305a3da 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -163,14 +163,31 @@ static int is_effected(float planes[4][4], const float co[3]) return isect_point_planes_v3(planes, 4, co); } +static void flip_plane(float out[4], const float in[4], const char symm) +{ + if (symm & SCULPT_SYMM_X) + out[0] = -in[0]; + else + out[0] = in[0]; + if (symm & SCULPT_SYMM_Y) + out[1] = -in[1]; + else + out[1] = in[1]; + if (symm & SCULPT_SYMM_Z) + out[2] = -in[2]; + else + out[2] = in[2]; + + out[3] = in[3]; +} + int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNUSED(extend)) { -#ifdef _OPENMP Sculpt *sd = vc->scene->toolsettings->sculpt; -#endif BoundBox bb; bglMats mats = {{0}}; float clip_planes[4][4]; + float clip_planes_final[4][4]; ARegion *ar = vc->ar; struct Scene *scene = vc->scene; Object *ob = vc->obact; @@ -180,7 +197,8 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU DerivedMesh *dm; PBVH *pbvh; PBVHNode **nodes; - int totnode, i; + int totnode, i, symmpass; + int symm = sd->flags & 7; mode = PAINT_MASK_FLOOD_VALUE; value = select ? 1.0 : 0.0; @@ -196,31 +214,46 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU pbvh = dm->getPBVH(ob, dm); ob->sculpt->pbvh = pbvh; - BKE_pbvh_search_gather(pbvh, BKE_pbvh_node_planes_contain_AABB, clip_planes, &nodes, &totnode); - sculpt_undo_push_begin("Mask box fill"); + for (symmpass = 0; symmpass <= symm; ++symmpass) { + if (symmpass == 0 || + (symm & symmpass && + (symm != 5 || symmpass != 3) && + (symm != 6 || (symmpass != 3 && symmpass != 5)))) + { + int j = 0; + + /* flip the planes symmetrically as needed */ + for (; j < 4; j++) { + flip_plane(clip_planes_final[j], clip_planes[j], symmpass); + } + + BKE_pbvh_search_gather(pbvh, BKE_pbvh_node_planes_contain_AABB, clip_planes_final, &nodes, &totnode); + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for (i = 0; i < totnode; i++) { - PBVHVertexIter vi; + for (i = 0; i < totnode; i++) { + PBVHVertexIter vi; - sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); - BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { - if (is_effected(clip_planes, vi.co)) - mask_flood_fill_set_elem(vi.mask, mode, value); - } BKE_pbvh_vertex_iter_end; + BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { + if (is_effected(clip_planes_final, vi.co)) + mask_flood_fill_set_elem(vi.mask, mode, value); + } BKE_pbvh_vertex_iter_end; - BKE_pbvh_node_mark_update(nodes[i]); - if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) - multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + BKE_pbvh_node_mark_update(nodes[i]); + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + } + + if (nodes) + MEM_freeN(nodes); + } } sculpt_undo_push_end(); - if (nodes) - MEM_freeN(nodes); - ED_region_tag_redraw(ar); return OPERATOR_FINISHED; -- cgit v1.2.3 From e9c9706ce61c66f2451ff94df1ff04786dc7437d Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Fri, 15 Nov 2013 23:00:15 +0200 Subject: Code cleanup: Use different redraw options for sculpt mask operators. Current redraw options also did an unnecessary normal recalculation on updated nodes. Also, for the box and lasso mask only push an undo node if any vertex has actually been influenced. --- source/blender/blenkernel/BKE_pbvh.h | 3 +- source/blender/blenkernel/intern/pbvh.c | 5 +++ source/blender/editors/sculpt_paint/paint_mask.c | 39 ++++++++++++++++-------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 9e21831dba0..f8c21a1fa16 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -151,8 +151,9 @@ typedef enum { void BKE_pbvh_node_mark_update(PBVHNode *node); void BKE_pbvh_node_mark_rebuild_draw(PBVHNode *node); -void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden); +void BKE_pbvh_node_mark_redraw(PBVHNode *node); void BKE_pbvh_node_mark_topology_update(PBVHNode *node); +void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden); void BKE_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 45a29f6cc90..c9822600fe7 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1283,6 +1283,11 @@ void BKE_pbvh_node_mark_rebuild_draw(PBVHNode *node) node->flag |= PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw; } +void BKE_pbvh_node_mark_redraw(PBVHNode *node) +{ + node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw; +} + void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden) { BLI_assert(node->flag & PBVH_Leaf); diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index c563305a3da..42652cfa578 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -117,7 +117,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) mask_flood_fill_set_elem(vi.mask, mode, value); } BKE_pbvh_vertex_iter_end; - BKE_pbvh_node_mark_update(nodes[i]); + BKE_pbvh_node_mark_redraw(nodes[i]); if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); } @@ -234,17 +234,24 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (i = 0; i < totnode; i++) { PBVHVertexIter vi; + bool any_masked = false; sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { - if (is_effected(clip_planes_final, vi.co)) + if (is_effected(clip_planes_final, vi.co)) { + if (!any_masked) { + any_masked = true; + + sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + + BKE_pbvh_node_mark_redraw(nodes[i]); + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + } mask_flood_fill_set_elem(vi.mask, mode, value); + } } BKE_pbvh_vertex_iter_end; - - BKE_pbvh_node_mark_update(nodes[i]); - if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) - multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); } if (nodes) @@ -359,17 +366,23 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (i = 0; i < totnode; i++) { PBVHVertexIter vi; - - sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + bool any_masked = false; BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { - if (is_effected_lasso(&data, vi.co)) + if (is_effected_lasso(&data, vi.co)) { + if (!any_masked) { + any_masked = true; + + sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + + BKE_pbvh_node_mark_redraw(nodes[i]); + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + } + mask_flood_fill_set_elem(vi.mask, mode, value); + } } BKE_pbvh_vertex_iter_end; - - BKE_pbvh_node_mark_update(nodes[i]); - if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) - multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); } sculpt_undo_push_end(); -- cgit v1.2.3 From a7d292ee4e989ee1619c4c5d55649a61e132426f Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Fri, 15 Nov 2013 23:04:18 +0200 Subject: Code cleanup, cont. A small omission here. --- source/blender/editors/sculpt_paint/paint_mask.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 42652cfa578..9b906c460e3 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -236,8 +236,6 @@ int do_sculpt_mask_box_select(ViewContext *vc, rcti *rect, bool select, bool UNU PBVHVertexIter vi; bool any_masked = false; - sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); - BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { if (is_effected(clip_planes_final, vi.co)) { if (!any_masked) { -- cgit v1.2.3 From f8eb006d091d598269fc10ae9e9ebf6c6be75dbd Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Fri, 15 Nov 2013 23:20:16 +0100 Subject: OSX/cmake: rollback ca5bbe0e419b04d16ee7eb12fa7eaffa0266815a cause OSX versions can have not subversion thus sw_vers -productVersion is not usable for sdk setting --- CMakeLists.txt | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe79a2d0a62..a408a8100e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -307,13 +307,21 @@ if(APPLE) FORCE) endif() - execute_process(COMMAND sw_vers -productVersion OUTPUT_VARIABLE MAC_SYS OUTPUT_STRIP_TRAILING_WHITESPACE) # check for actual system-version - if( ${MAC_SYS} VERSION_LESS 10.5) - set(OSX_SYSTEM unsupported) - else() - set(OSX_SYSTEM ${MAC_SYS}) - endif() - message(STATUS "Detected system-version: " ${OSX_SYSTEM}) + execute_process(COMMAND uname -r OUTPUT_VARIABLE MAC_SYS) # check for actual system-version + if(${MAC_SYS} MATCHES 13) + set(OSX_SYSTEM 10.9) + elseif(${MAC_SYS} MATCHES 12) + set(OSX_SYSTEM 10.8) + elseif(${MAC_SYS} MATCHES 11) + set(OSX_SYSTEM 10.7) + elseif(${MAC_SYS} MATCHES 10) + set(OSX_SYSTEM 10.6) + elseif(${MAC_SYS} MATCHES 9) + set(OSX_SYSTEM 10.5) + else() + set(OSX_SYSTEM unsupported) + endif() + message(STATUS "Detected system-version: " ${OSX_SYSTEM}) # workaround for incorrect cmake xcode lookup for developer previews - XCODE_VERSION does not take xcode-select path into accout # but would always look into /Applications/Xcode.app while dev versions are named Xcode-DP -- cgit v1.2.3 From f546c7a8893b8a673c37805413869b130337cd2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brecht=20Van=20L=C3=B6mmel?= Date: Sat, 16 Nov 2013 03:08:51 +0100 Subject: Addons: remove tracker URL from addon template, as this is no longer used, and link to the new Addons bug reporting page. --- release/scripts/modules/addon_utils.py | 1 - release/scripts/startup/bl_ui/space_userpref.py | 6 +++--- release/scripts/templates_py/addon_add_object.py | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 2d0c917ffa0..6f08f70458b 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -408,7 +408,6 @@ def module_bl_info(mod, info_basis={"name": "", "location": "", "description": "", "wiki_url": "", - "tracker_url": "", "support": 'COMMUNITY', "category": "", "warning": "", diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 697c070ffad..e21656c3259 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -1255,15 +1255,15 @@ class USERPREF_PT_addons(Panel): split.label(text=' ' + info["warning"], icon='ERROR') user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths) - tot_row = bool(info["wiki_url"]) + bool(info["tracker_url"]) + bool(user_addon) + tot_row = bool(info["wiki_url"]) + bool(user_addon) if tot_row: split = colsub.row().split(percentage=0.15) split.label(text="Internet:") if info["wiki_url"]: split.operator("wm.url_open", text="Documentation", icon='HELP').url = info["wiki_url"] - if info["tracker_url"]: - split.operator("wm.url_open", text="Report a Bug", icon='URL').url = info["tracker_url"] + tracker_url = "http://developer.blender.org/maniphest/task/create/?project=3&type=Bug" + split.operator("wm.url_open", text="Report a Bug", icon='URL').url = tracker_url if user_addon: split.operator("wm.addon_remove", text="Remove", icon='CANCEL').module = mod.__name__ diff --git a/release/scripts/templates_py/addon_add_object.py b/release/scripts/templates_py/addon_add_object.py index 66da6a969c7..f0d8bede6d5 100644 --- a/release/scripts/templates_py/addon_add_object.py +++ b/release/scripts/templates_py/addon_add_object.py @@ -7,7 +7,6 @@ bl_info = { "description": "Adds a new Mesh Object", "warning": "", "wiki_url": "", - "tracker_url": "", "category": "Add Mesh"} -- cgit v1.2.3 From 58afbb2ee8f9a0e08365db5e840bbb8d9f39c3ab Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 16 Nov 2013 03:26:04 +0100 Subject: Help menu: report a bug now links to the new tracker at developer.blender.org. There will be a redirect from the projects.blender.org website as well, but might as well update the link here. --- release/scripts/startup/bl_ui/space_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index f7bca1404bf..544bba17a73 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -247,7 +247,7 @@ class INFO_MT_help(Menu): layout.operator("wm.url_open", text="Developer Community", icon='URL').url = "http://www.blender.org/community/get-involved" layout.operator("wm.url_open", text="User Community", icon='URL').url = "http://www.blender.org/community/user-community" layout.separator() - layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = "http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse" + layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = "http://developer.blender.org/maniphest/task/create/?project=2&type=Bug" layout.separator() layout.operator("wm.url_open", text="Python API Reference", icon='URL').url = bpy.types.WM_OT_doc_view._prefix -- cgit v1.2.3 From cf9edb2610f51730378029c1c4fa5f12b382664a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Nov 2013 18:31:13 +1100 Subject: rangetree: support for building on freebsd-10 --- extern/rangetree/range_tree.hh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extern/rangetree/range_tree.hh b/extern/rangetree/range_tree.hh index 2a47c5a1d93..a88c70281b6 100644 --- a/extern/rangetree/range_tree.hh +++ b/extern/rangetree/range_tree.hh @@ -35,6 +35,11 @@ struct RangeTree { : min(t), max(t), single(true) {} + Range& operator=(const Range& v) { + *this = v; + return *this; + } + bool operator<(const Range& v) const { return max < v.min; } -- cgit v1.2.3 From d36a416cab8eab3a15c9086c167addc3a0cc7821 Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Sat, 16 Nov 2013 02:50:01 -0600 Subject: The tittle for "Maximum Draw Type" had capitalization inconsistent with the rest of Blender --- release/scripts/startup/bl_ui/properties_object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 6b317c49487..cbebdafbf2e 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -236,7 +236,7 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel): col = split.column() if obj_type not in {'CAMERA', 'EMPTY'}: - col.label(text="Maximum draw type:") + col.label(text="Maximum Draw Type:") col.prop(obj, "draw_type", text="") col = split.column() -- cgit v1.2.3 From 481a138144800fd09fa64df511a5f38a250a9f9f Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 16 Nov 2013 10:59:08 +0100 Subject: Test --- release/text/readme.html | 118 +++++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 55 deletions(-) diff --git a/release/text/readme.html b/release/text/readme.html index b15ea9b3847..acd9eaa6fc9 100644 --- a/release/text/readme.html +++ b/release/text/readme.html @@ -4,64 +4,72 @@ + + -

Blender 2.69

-


-

About

-

Welcome to Blender, the free, open source 3D application for modeling, animation, rendering, compositing, video editing and game creation. Blender is available for Linux, Mac OS X and Windows and has a large world-wide community.

-

Blender can be used freely for any purpose, including commercial use and distribution. It's free and open-source software, released under the GNU GPL licence. The entire source code is available on our website.

-

For more information, visit blender.org.

-


-

2.69

-

The Blender Foundation and online developer community is proud to present Blender 2.69. This release is the tenth official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features. More information about this release.

-


-

Bugs

-

Although Blender 2.69 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.

-


-

Package Contents

-

The downloaded Blender package includes:

-

• The Blender application for the chosen operating system.

-

• Scripts for importing and exporting to other 3d formats.

-

• Readme and copyright files.

-


-

Installation

-

Windows: The download .zip contains a Blender folder. You may put this anywhere on your hard drive. To launch Blender, double-click on Blender.exe.

-

Linux: Unpack the archive, then run the Blender executable.

-

Mac OS X: The downloaded package includes blender.app. Optionally copy this to your Applications folder, and add it to the dock by dragging it from there to the dock.

-

-

Installing Addons (all systems) Addons can be installed from the user preferences addons section, download an addon as a .py or .zip file, then press the "Install Addon" button and select the file to install it.

-


-

Getting Started

-

When opening Blender, you’ll see large 3D view in the center, a Toolbar on the left, a Properties editor and an Outliner on the right and a Timeline at the bottom.

-

Orbit around in the 3D view by holding the middle mouse button and dragging. Alternatively, hold the alt key and drag the left mouse button. Additionally, hold Shift to pan the view and Ctrl to zoom.

-

Select objects using the right mouse button. With the object selected, perform actions by clicking any of the tool buttons on the left, or make changes to its properties by altering any of the setting on the right.

-

For more information on how to use Blender, watch tutorials or read the manual.

-


-

Links

-

Users:

-

General information www.blender.org
- Full release log www.blender.org/development/release-logs/blender-269/
- Tutorials www.blender.org/education-help/
- Manual wiki.blender.org/index.php/Doc:2.6/Manual
- User Forum www.blenderartists.org
- IRC #blenderchat or #blender on irc.freenode.net
-

-

Developers:

-

Development www.blender.org/development/
- SVN and Bug Tracker projects.blender.org
- Get Involved www.blender.org/community/get-involved/
- IRC #blendercoders on irc.freenode.net

-


-


-


- -


+

Blender 2.70

+


+

About

+

Welcome to Blender, the free, open source 3D application for modeling, animation, rendering, compositing, video editing and game creation. Blender is available for Linux, Mac OS X and Windows and has a large world-wide community.

+

Blender can be used freely for any purpose, including commercial use and distribution. It's free and open-source software, released under the GNU GPL licence. The entire source code is available on our website.

+

For more information, visit blender.org.

+


+

2.69

+

The Blender Foundation and online developer community is proud to present Blender 2.69. This release is the tenth official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features. More information about this release.

+


+

Bugs

+

Although Blender 2.69 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.

+


+

Package Contents

+

The downloaded Blender package includes:

+

• The Blender application for the chosen operating system.

+

• Scripts for importing and exporting to other 3d formats.

+

• Readme and copyright files.

+


+

Installation

+

Windows: The download .zip contains a Blender folder. You may put this anywhere on your hard drive. To launch Blender, double-click on Blender.exe.

+

Linux: Unpack the archive, then run the Blender executable.

+

Mac OS X: The downloaded package includes blender.app. Optionally copy this to your Applications folder, and add it to the dock by dragging it from there to the dock.

+


+

Installing Addons (all systems) Addons can be installed from the user preferences addons section, download an addon as a .py or .zip file, then press the "Install Addon" button and select the file to install it.

+


+

Getting Started

+

When opening Blender, you’ll see large 3D view in the center, a Toolbar on the left, a Properties editor and an Outliner on the right and a Timeline at the bottom.

+

Orbit around in the 3D view by holding the middle mouse button and dragging. Alternatively, hold the alt key and drag the left mouse button. Additionally, hold Shift to pan the view and Ctrl to zoom.

+

Select objects using the right mouse button. With the object selected, perform actions by clicking any of the tool buttons on the left, or make changes to its properties by altering any of the setting on the right.

+

For more information on how to use Blender, watch tutorials or read the manual.

+


+

Links

+

Users:

+

General information www.blender.org
+Full release log www.blender.org/development/release-logs/blender-269/
+Tutorials www.blender.org/education-help/
+Manual wiki.blender.org/index.php/Doc:2.6/Manual
+User Forum www.blenderartists.org
+IRC #blenderchat or #blender on irc.freenode.net

+

Developers:

+

Development www.blender.org/development/
+SVN and Bug Tracker projects.blender.org
+Get Involved www.blender.org/community/get-involved/
+IRC #blendercoders on irc.freenode.net

+


+


+

Blender is open-source and free for all to use.

+


+

Enjoy.

+


-- cgit v1.2.3 From d49498a4612993b7821e62d5267e22b99f781b92 Mon Sep 17 00:00:00 2001 From: mont29 Date: Sat, 16 Nov 2013 11:30:48 +0100 Subject: Fix T37442: Disabled uiList would "freeze" Blender when trying to drag-resize it. For now, simply disable drag-resize for disabled uiLists! --- source/blender/editors/interface/interface_handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 903a5e72499..bb129c1ec9f 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -6785,7 +6785,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar) is_over_dragbut = true; } - if (is_over_dragbut && type == LEFTMOUSE && val == KM_PRESS) { + if (is_over_dragbut && type == LEFTMOUSE && val == KM_PRESS && !(but->flag & UI_BUT_DISABLED)) { uiHandleButtonData *data; int *size = (int *)but->poin; -- cgit v1.2.3 From c72dc45bcb7de371934b9ad741d1938c5827b165 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 16 Nov 2013 11:57:40 +0100 Subject: And here is the first git (testing) commit by me! Welcome to a brave new GPL3 world... well if commit works :) --- doc/license/GPL3-license.txt | 674 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 doc/license/GPL3-license.txt diff --git a/doc/license/GPL3-license.txt b/doc/license/GPL3-license.txt new file mode 100644 index 00000000000..94a9ed024d3 --- /dev/null +++ b/doc/license/GPL3-license.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. -- cgit v1.2.3 From 7a899ce9fc7fbcea219c12afe49c08114505b3aa Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Sat, 16 Nov 2013 08:07:03 -0500 Subject: Fix T37476 Bevel modifier got weight from wrong edge The bevel modifier with 'weight' activated was reading the weights from the wrong edges. --- source/blender/bmesh/tools/bmesh_bevel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index a1f08583e2c..5017c00259b 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -2188,7 +2188,7 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) if (bp->offset_type != BEVEL_AMT_PERCENT) e->offset_r = e->offset_l; if (bp->use_weights) { - weight = BM_elem_float_data_get(&bm->edata, bme, CD_BWEIGHT); + weight = BM_elem_float_data_get(&bm->edata, e->e, CD_BWEIGHT); e->offset_l *= weight; e->offset_r *= weight; } -- cgit v1.2.3 From 3e87abb4be9f3fa70c3be2d7276029d8b8929c59 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 16 Nov 2013 19:40:26 +0600 Subject: Remove nested check for .git folder exists in buildinfo.cmake Title says it all :) Pointer by IRIE Shinsuke in the ML, thanks! --- build_files/cmake/buildinfo.cmake | 68 +++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake index 2db03d3efe9..0a299af88ee 100644 --- a/build_files/cmake/buildinfo.cmake +++ b/build_files/cmake/buildinfo.cmake @@ -9,48 +9,46 @@ set(MY_WC_COMMIT_TIMESTAMP 0) # Guess if this is a SVN working copy and then look up the revision if(EXISTS ${SOURCE_DIR}/.git/) - if(EXISTS ${SOURCE_DIR}/.git/) - # The FindSubversion.cmake module is part of the standard distribution - include(FindGit) - if(GIT_FOUND) - execute_process(COMMAND git rev-parse --short HEAD - WORKING_DIRECTORY ${SOURCE_DIR} - OUTPUT_VARIABLE MY_WC_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE) + # The FindSubversion.cmake module is part of the standard distribution + include(FindGit) + if(GIT_FOUND) + execute_process(COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND git rev-parse --abbrev-ref HEAD - WORKING_DIRECTORY ${SOURCE_DIR} - OUTPUT_VARIABLE MY_WC_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE) - # Get latest version tag - execute_process(COMMAND git describe --match "v[0-9]*" --abbrev=0 - WORKING_DIRECTORY ${SOURCE_DIR} - OUTPUT_VARIABLE _git_latest_version_tag - OUTPUT_STRIP_TRAILING_WHITESPACE) + # Get latest version tag + execute_process(COMMAND git describe --match "v[0-9]*" --abbrev=0 + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE _git_latest_version_tag + OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND git log -1 --format=%ct - WORKING_DIRECTORY ${SOURCE_DIR} - OUTPUT_VARIABLE MY_WC_COMMIT_TIMESTAMP - OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND git log -1 --format=%ct + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE MY_WC_COMMIT_TIMESTAMP + OUTPUT_STRIP_TRAILING_WHITESPACE) - # Update GIT index before getting dirty files - execute_process(COMMAND git update-index -q --refresh - WORKING_DIRECTORY ${SOURCE_DIR} - OUTPUT_STRIP_TRAILING_WHITESPACE) + # Update GIT index before getting dirty files + execute_process(COMMAND git update-index -q --refresh + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND git diff-index --name-only HEAD -- - WORKING_DIRECTORY ${SOURCE_DIR} - OUTPUT_VARIABLE _git_changed_files - OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND git diff-index --name-only HEAD -- + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE _git_changed_files + OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT _git_changed_files STREQUAL "") - set(MY_WC_CHANGE "${MY_WC_CHANGE}M") - endif() - - unset(_git_changed_files) - unset(_git_latest_version_tag) + if(NOT _git_changed_files STREQUAL "") + set(MY_WC_CHANGE "${MY_WC_CHANGE}M") endif() + + unset(_git_changed_files) + unset(_git_latest_version_tag) endif() endif() -- cgit v1.2.3 From 1a0fed9ee08e4499c7a5652f1519a73a290e2962 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 16 Nov 2013 15:31:00 +0100 Subject: More fix for this stupid uppercase-to-lowercase convertion code... Thanks to Lockal for noting this! --- source/blender/blenkernel/intern/unit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 4b6ac824fd8..64470542844 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -609,7 +609,7 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca int i; char *ch = str; - for (i = 0; (i < len_max || *ch != '\0'); i++, ch++) { + for (i = 0; (i < len_max) && (*ch != '\0'); i++, ch++) { if ((*ch >= 'A') && (*ch <= 'Z')) *ch += ('a' - 'A'); } -- cgit v1.2.3 From 60ca109340f70438da65f1b9b8080122d430d4e6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 16 Nov 2013 20:39:36 +0600 Subject: Attempt to fix compilation error on windows Seems simply need to add .exe to msgfmt executable when adding custom command to SCons. Don't have windows by hand atm, so can not test for sure. --- intern/locale/SConscript | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/intern/locale/SConscript b/intern/locale/SConscript index 546fd3e8b40..a8b6d17f9d3 100644 --- a/intern/locale/SConscript +++ b/intern/locale/SConscript @@ -63,6 +63,10 @@ if env['WITH_BF_INTERNATIONAL']: locale = env.Clone() + msgfmt_executable = targetpath + if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'): + msgfmt_executable += ".exe" + # dependencies dependencies = [targetpath] @@ -75,7 +79,7 @@ if env['WITH_BF_INTERNATIONAL']: po_file = os.path.join(po_dir, f) mo_file = os.path.join(build_dir, os.path.splitext(f)[0] + ".mo") - command = "\"%s\" \"%s\" \"%s\"" % (targetpath, po_file, mo_file) + command = "\"%s\" \"%s\" \"%s\"" % (msgfmt_executable, po_file, mo_file) locale.Command(mo_file, po_file, command) locale.Depends(mo_file, dependencies) -- cgit v1.2.3 From 21f1bb49015ca2d73d57e2cd2e6d70e946cf2d83 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 16 Nov 2013 16:13:18 +0100 Subject: Git test commit, this time from Windows. --- release/text/readme.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/text/readme.html b/release/text/readme.html index acd9eaa6fc9..5ecb1ae3de1 100644 --- a/release/text/readme.html +++ b/release/text/readme.html @@ -27,7 +27,7 @@

Blender can be used freely for any purpose, including commercial use and distribution. It's free and open-source software, released under the GNU GPL licence. The entire source code is available on our website.

For more information, visit blender.org.


-

2.69

+

2.70

The Blender Foundation and online developer community is proud to present Blender 2.69. This release is the tenth official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features. More information about this release.


Bugs

-- cgit v1.2.3 From bc6ba9eb3bf8c8560d5c0dd6eb9075325190fee7 Mon Sep 17 00:00:00 2001 From: "Sv. Lockal" Date: Sat, 16 Nov 2013 19:34:06 +0400 Subject: =?UTF-8?q?Fix=20T37493:=20Defocus=20node=20with=20angle=20=3D=209?= =?UTF-8?q?0=C2=B0=20rotates=20bokeh=20only=20for=20~1.5=C2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/blender/compositor/nodes/COM_DefocusNode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp index c2bd8997525..b6dd0e526ae 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.cpp +++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp @@ -85,7 +85,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext BokehImageOperation *bokeh = new BokehImageOperation(); NodeBokehImage *bokehdata = new NodeBokehImage(); - bokehdata->angle = data->rotation; + bokehdata->angle = RAD2DEGF(data->rotation); bokehdata->rounding = 0.0f; bokehdata->flaps = data->bktype; if (data->bktype < 3) { -- cgit v1.2.3 From fd8ad2bbe438f74ec816f43141de04dfe03389d9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 16 Nov 2013 22:33:05 +0600 Subject: Further tweak to .mo compilation on windows Was wrong dependency used for msgfmt custom command. --- intern/locale/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/locale/SConscript b/intern/locale/SConscript index a8b6d17f9d3..38161b48ff0 100644 --- a/intern/locale/SConscript +++ b/intern/locale/SConscript @@ -68,7 +68,7 @@ if env['WITH_BF_INTERNATIONAL']: msgfmt_executable += ".exe" # dependencies - dependencies = [targetpath] + dependencies = [msgfmt_target] # add command for each locale all_mo_files = [] -- cgit v1.2.3 From e8bd916ba5e6d65c8bcf246f3fa3fba5e0e7bdb1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Nov 2013 04:03:09 +1100 Subject: armature editing: using too short length checking to add L/R suffix. --- source/blender/editors/armature/armature_add.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index 351fd2844c9..b91deab6c8d 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -624,7 +624,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name)); if (flipbone && forked) { // only set if mirror edit - if (strlen(newbone->name) < 30) { + if (strlen(newbone->name) < (MAXBONENAME - 2)) { if (a == 0) strcat(newbone->name, "_L"); else strcat(newbone->name, "_R"); } -- cgit v1.2.3 From 09ecfc318cb808a578d5211e44051d28e1de0706 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 17 Nov 2013 00:00:02 +0600 Subject: Fixes for buildinfo of exported source tree - Better to set branch/hash to "unknown" so it's clear build is done from exported tree. - SCons used to reference undefined variable. --- build_files/cmake/buildinfo.cmake | 4 ++-- build_files/scons/tools/Blender.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake index 0a299af88ee..389386629db 100644 --- a/build_files/cmake/buildinfo.cmake +++ b/build_files/cmake/buildinfo.cmake @@ -3,8 +3,8 @@ # Extract working copy information for SOURCE_DIR into MY_XXX variables # with a default in case anything fails, for examble when using git-svn -set(MY_WC_HASH "") -set(MY_WC_BRANCH "") +set(MY_WC_HASH "unknown") +set(MY_WC_BRANCH "unknown") set(MY_WC_COMMIT_TIMESTAMP 0) # Guess if this is a SVN working copy and then look up the revision diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 8715c2367e4..fac81953476 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -415,9 +415,9 @@ def buildinfo(lenv, build_type): build_hash = os.popen('git rev-parse --short HEAD').read().strip() build_branch = os.popen('git rev-parse --abbrev-ref HEAD').read().strip() else: - build_hash = '' - build_change = 'unknown' - build_branch = '' + build_hash = 'unknown' + build_commit_timestamp = '0' + build_branch = 'unknown' if lenv['BF_DEBUG']: build_type = "Debug" -- cgit v1.2.3 From 9c3586d9f91bd796c5347194a24cdc4b1b60c05c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 17 Nov 2013 00:09:03 +0600 Subject: Remove check for whether po folder exist It was just a temp thing to not break stuff before final git migration. --- SConstruct | 23 ++++++---------- source/creator/CMakeLists.txt | 64 ++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 51 deletions(-) diff --git a/SConstruct b/SConstruct index 8f4acde4a04..e15616e198d 100644 --- a/SConstruct +++ b/SConstruct @@ -943,7 +943,6 @@ if env['OURPLATFORM']!='darwin': return (member in path.split(os.sep)) po_dir = os.path.join("release", "datafiles", "locale", "po") - need_compile_mo = os.path.exists(po_dir) for intpath in internationalpaths: for dp, dn, df in os.walk(intpath): @@ -953,10 +952,7 @@ if env['OURPLATFORM']!='darwin': dn.remove('_svn') # we only care about release/datafiles/fonts, release/datafiles/locales - if check_path(dp, "locale"): - if need_compile_mo and check_path(dp, "po"): - continue - elif check_path(dp, "fonts"): + if check_path(dp, "fonts"): pass else: continue @@ -970,18 +966,17 @@ if env['OURPLATFORM']!='darwin': env.Execute(Mkdir(dir)) scriptinstall.append(env.Install(dir=dir,source=source)) - if need_compile_mo: - for f in os.listdir(po_dir): - if not f.endswith(".po"): - continue + for f in os.listdir(po_dir): + if not f.endswith(".po"): + continue - locale_name = os.path.splitext(f)[0] + locale_name = os.path.splitext(f)[0] - mo_file = os.path.join(B.root_build_dir, "locale", locale_name + ".mo") + mo_file = os.path.join(B.root_build_dir, "locale", locale_name + ".mo") - dir = os.path.join(env['BF_INSTALLDIR'], VERSION) - dir = os.path.join(dir, "datafiles", "locale", locale_name, "LC_MESSAGES") - scriptinstall.append(env.InstallAs(os.path.join(dir, "blender.mo"), mo_file)) + dir = os.path.join(env['BF_INSTALLDIR'], VERSION) + dir = os.path.join(dir, "datafiles", "locale", locale_name, "LC_MESSAGES") + scriptinstall.append(env.InstallAs(os.path.join(dir, "blender.mo"), mo_file)) #-- icons if env['OURPLATFORM']=='linux': diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 0ef32f4dc02..495399b43cb 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -326,51 +326,41 @@ if(WITH_INTERNATIONAL) ) set(_locale_dir "${CMAKE_SOURCE_DIR}/release/datafiles/locale") + set(_locale_target_dir ${TARGETDIR_VER}/datafiles/locale) - if(EXISTS "${_locale_dir}/po") - set(_locale_target_dir ${TARGETDIR_VER}/datafiles/locale) + file(GLOB _po_files "${_locale_dir}/po/*.po") + foreach(_po_file ${_po_files}) + msgfmt_simple(${_po_file} _all_mo_files) + endforeach() - file(GLOB _po_files "${_locale_dir}/po/*.po") - foreach(_po_file ${_po_files}) - msgfmt_simple(${_po_file} _all_mo_files) - endforeach() + # Create a custom target which will compile all po to mo + add_custom_target( + locales + DEPENDS ${_all_mo_files}) - # Create a custom target which will compile all po to mo - add_custom_target( - locales - DEPENDS ${_all_mo_files}) + add_dependencies(blender locales) - add_dependencies(blender locales) + # Generate INSTALL rules + install( + FILES ${_locale_dir}/languages + DESTINATION ${_locale_target_dir} + ) - # Generate INSTALL rules + foreach(_mo_file ${_all_mo_files}) + get_filename_component(_locale_name ${_mo_file} NAME_WE) install( - FILES ${_locale_dir}/languages - DESTINATION ${_locale_target_dir} + FILES ${_mo_file} + DESTINATION ${_locale_target_dir}/${_locale_name}/LC_MESSAGES + RENAME blender.mo ) + unset(_locale_name) + endforeach() - foreach(_mo_file ${_all_mo_files}) - get_filename_component(_locale_name ${_mo_file} NAME_WE) - install( - FILES ${_mo_file} - DESTINATION ${_locale_target_dir}/${_locale_name}/LC_MESSAGES - RENAME blender.mo - ) - unset(_locale_name) - endforeach() - - unset(_all_mo_files) - unset(_po_files) - unset(_po_file) - unset(_mo_file) - unset(_locale_target_dir) - else() - install( - DIRECTORY - ${_locale_dir} - DESTINATION ${TARGETDIR_VER}/datafiles - PATTERN ".svn" EXCLUDE - ) - endif() + unset(_all_mo_files) + unset(_po_files) + unset(_po_file) + unset(_mo_file) + unset(_locale_target_dir) unset(_locale_dir) endif() -- cgit v1.2.3 From 891a037e9b4725b79117f6f2bc469b4b3a2eeeef Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 17 Nov 2013 00:18:21 +0600 Subject: Skip .git files from submodules for install targets Also removed .svn checks when it's not longer needed. Some further tweaks (probably for OSX bundler) are likely needed. --- SConstruct | 37 ++++++------------------------------- source/creator/CMakeLists.txt | 6 ++---- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/SConstruct b/SConstruct index e15616e198d..8c27424f617 100644 --- a/SConstruct +++ b/SConstruct @@ -784,6 +784,8 @@ if env['OURPLATFORM']=='darwin': dn.remove('.svn') if '_svn' in dn: dn.remove('_svn') + if '.git' in df: + df.remove('.git') dir=env['BF_INSTALLDIR']+dp[len(bundledir):] source=[dp+os.sep+f for f in df] blenderinstall.append(env.Install(dir=dir,source=source)) @@ -813,10 +815,8 @@ if env['OURPLATFORM']!='darwin': scriptpaths=['release/scripts'] for scriptpath in scriptpaths: for dp, dn, df in os.walk(scriptpath): - if '.svn' in dn: - dn.remove('.svn') - if '_svn' in dn: - dn.remove('_svn') + if '.git' in df: + df.remove('.git') if '__pycache__' in dn: # py3.2 cache dir dn.remove('__pycache__') @@ -840,8 +840,6 @@ if env['OURPLATFORM']!='darwin': # cycles python code dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles') source=os.listdir('intern/cycles/blender/addon') - if '.svn' in source: source.remove('.svn') - if '_svn' in source: source.remove('_svn') if '__pycache__' in source: source.remove('__pycache__') source=['intern/cycles/blender/addon/'+s for s in source] scriptinstall.append(env.Install(dir=dir,source=source)) @@ -849,8 +847,6 @@ if env['OURPLATFORM']!='darwin': # cycles kernel code dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel') source=os.listdir('intern/cycles/kernel') - if '.svn' in source: source.remove('.svn') - if '_svn' in source: source.remove('_svn') if '__pycache__' in source: source.remove('__pycache__') source.remove('kernel.cpp') source.remove('CMakeLists.txt') @@ -867,16 +863,12 @@ if env['OURPLATFORM']!='darwin': # svm dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'svm') source=os.listdir('intern/cycles/kernel/svm') - if '.svn' in source: source.remove('.svn') - if '_svn' in source: source.remove('_svn') if '__pycache__' in source: source.remove('__pycache__') source=['intern/cycles/kernel/svm/'+s for s in source] scriptinstall.append(env.Install(dir=dir,source=source)) # closure dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'closure') source=os.listdir('intern/cycles/kernel/closure') - if '.svn' in source: source.remove('.svn') - if '_svn' in source: source.remove('_svn') if '__pycache__' in source: source.remove('__pycache__') source=['intern/cycles/kernel/closure/'+s for s in source] scriptinstall.append(env.Install(dir=dir,source=source)) @@ -884,8 +876,6 @@ if env['OURPLATFORM']!='darwin': # licenses dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'license') source=os.listdir('intern/cycles/doc/license') - if '.svn' in source: source.remove('.svn') - if '_svn' in source: source.remove('_svn') if '__pycache__' in source: source.remove('__pycache__') source.remove('CMakeLists.txt') source=['intern/cycles/doc/license/'+s for s in source] @@ -920,11 +910,6 @@ if env['OURPLATFORM']!='darwin': colormanagement = os.path.join('release', 'datafiles', 'colormanagement') for dp, dn, df in os.walk(colormanagement): - if '.svn' in dn: - dn.remove('.svn') - if '_svn' in dn: - dn.remove('_svn') - dir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'datafiles') dir += os.sep + os.path.basename(colormanagement) + dp[len(colormanagement):] @@ -946,10 +931,8 @@ if env['OURPLATFORM']!='darwin': for intpath in internationalpaths: for dp, dn, df in os.walk(intpath): - if '.svn' in dn: - dn.remove('.svn') - if '_svn' in dn: - dn.remove('_svn') + if '.git' in df: + df.remove('.git') # we only care about release/datafiles/fonts, release/datafiles/locales if check_path(dp, "fonts"): @@ -984,10 +967,6 @@ if env['OURPLATFORM']=='linux': icontargetlist = [] for tp, tn, tf in os.walk('release/freedesktop/icons'): - if '.svn' in tn: - tn.remove('.svn') - if '_svn' in tn: - tn.remove('_svn') for f in tf: iconlist.append(os.path.join(tp, f)) icontargetlist.append( os.path.join(*([env['BF_INSTALLDIR']] + tp.split(os.sep)[2:] + [f])) ) @@ -1013,10 +992,6 @@ if env['OURPLATFORM']=='linuxcross': textlist = [] texttargetlist = [] for tp, tn, tf in os.walk('release/text'): - if '.svn' in tn: - tn.remove('.svn') - if '_svn' in tn: - tn.remove('_svn') for f in tf: textlist.append(tp+os.sep+f) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 495399b43cb..cb745d46fa4 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -306,7 +306,7 @@ if(WITH_PYTHON) install( DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts DESTINATION ${TARGETDIR_VER} - PATTERN ".svn" EXCLUDE + PATTERN ".git" EXCLUDE PATTERN "__pycache__" EXCLUDE PATTERN "${ADDON_EXCLUDE_CONDITIONAL}" EXCLUDE PATTERN "${FREESTYLE_EXCLUDE_CONDITIONAL}" EXCLUDE @@ -322,7 +322,6 @@ if(WITH_INTERNATIONAL) DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/fonts DESTINATION ${TARGETDIR_VER}/datafiles - PATTERN ".svn" EXCLUDE ) set(_locale_dir "${CMAKE_SOURCE_DIR}/release/datafiles/locale") @@ -370,7 +369,6 @@ if(WITH_OPENCOLORIO) install( DIRECTORY ${CMAKE_SOURCE_DIR}/release/datafiles/colormanagement DESTINATION ${TARGETDIR_VER}/datafiles - PATTERN ".svn" EXCLUDE ) endif() @@ -447,7 +445,6 @@ if(UNIX AND NOT APPLE) ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor - PATTERN ".svn" EXCLUDE PATTERN "*.svg" EXCLUDE ) install( @@ -737,6 +734,7 @@ elseif(APPLE) install( DIRECTORY ${from} DESTINATION ${to} + PATTERN ".git" EXCLUDE PATTERN ".svn" EXCLUDE PATTERN "*.pyc" EXCLUDE PATTERN "*.pyo" EXCLUDE -- cgit v1.2.3 From e62cdbb474c4a09b55f046b199d3036534fd259c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Nov 2013 04:20:31 +1100 Subject: code cleanup: rename flip_side_name to BKE_deform_flip_side_name --- source/blender/blenkernel/BKE_deform.h | 3 ++- source/blender/blenkernel/intern/deform.c | 31 ++++++++++++---------- source/blender/editors/armature/armature_naming.c | 6 ++--- .../blender/editors/armature/armature_skinning.c | 7 +++-- source/blender/editors/armature/armature_utils.c | 6 ++--- source/blender/editors/armature/pose_edit.c | 6 ++--- source/blender/editors/armature/pose_select.c | 8 +++--- source/blender/editors/armature/pose_transform.c | 2 +- source/blender/editors/object/object_select.c | 8 +++--- source/blender/editors/sculpt_paint/paint_vertex.c | 8 +++--- 10 files changed, 44 insertions(+), 41 deletions(-) diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 435cad17e57..e203549fef5 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -91,6 +91,7 @@ void defvert_normalize_lock_map(struct MDeformVert *dvert, void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]); void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]); -void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number); +void BKE_deform_flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], + const bool strip_number); #endif /* __BKE_DEFORM_H__ */ diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index a183872552d..dafc0c3c754 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -447,7 +447,7 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, const bool use_default) } else { bDeformGroup *dg; - char name[sizeof(dg->name)]; + char name_flip[sizeof(dg->name)]; int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__); for (i = 0; i < defbase_tot; i++) { @@ -461,9 +461,10 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, const bool use_default) if (use_default) map[i] = i; - flip_side_name(name, dg->name, FALSE); - if (strcmp(name, dg->name)) { - flip_num = defgroup_name_index(ob, name); + BKE_deform_flip_side_name(name_flip, dg->name, false); + + if (!STREQ(name_flip, dg->name)) { + flip_num = defgroup_name_index(ob, name_flip); if (flip_num >= 0) { map[i] = flip_num; map[flip_num] = i; /* save an extra lookup */ @@ -485,7 +486,7 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, const bool use_defa } else { bDeformGroup *dg; - char name[sizeof(dg->name)]; + char name_flip[sizeof(dg->name)]; int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__); for (i = 0; i < defbase_tot; i++) { @@ -494,9 +495,9 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, const bool use_defa dg = BLI_findlink(&ob->defbase, defgroup); - flip_side_name(name, dg->name, FALSE); - if (strcmp(name, dg->name)) { - flip_num = defgroup_name_index(ob, name); + BKE_deform_flip_side_name(name_flip, dg->name, false); + if (!STREQ(name_flip, dg->name)) { + flip_num = defgroup_name_index(ob, name_flip); if (flip_num != -1) { map[defgroup] = flip_num; @@ -514,11 +515,12 @@ int defgroup_flip_index(Object *ob, int index, const bool use_default) int flip_index = -1; if (dg) { - char name[sizeof(dg->name)]; - flip_side_name(name, dg->name, 0); + char name_flip[sizeof(dg->name)]; + BKE_deform_flip_side_name(name_flip, dg->name, false); - if (strcmp(name, dg->name)) - flip_index = defgroup_name_index(ob, name); + if (!STREQ(name_flip, dg->name)) { + flip_index = defgroup_name_index(ob, name_flip); + } } return (flip_index == -1 && use_default) ? index : flip_index; @@ -602,7 +604,8 @@ void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char pre[MAX_VG /* finds the best possible flipped name. For renaming; check for unique names afterwards */ /* if strip_number: removes number extensions * note: don't use sizeof() for 'name' or 'from_name' */ -void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number) +void BKE_deform_flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], + const bool strip_number) { int len; char prefix[MAX_VGROUP_NAME] = ""; /* The part before the facing */ @@ -624,7 +627,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ if (isdigit(name[len - 1])) { index = strrchr(name, '.'); // last occurrence if (index && isdigit(index[1])) { // doesnt handle case bone.1abc2 correct..., whatever! - if (strip_number == 0) { + if (strip_number == false) { BLI_strncpy(number, index, sizeof(number)); } *index = 0; diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 2228cb8386e..10e97240898 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -289,7 +289,6 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = CTX_data_edit_object(C); bArmature *arm; - char newname[MAXBONENAME]; /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) @@ -299,8 +298,9 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { - flip_side_name(newname, ebone->name, TRUE); // 1 = do strip off number extensions - ED_armature_bone_rename(arm, ebone->name, newname); + char name_flip[MAXBONENAME]; + BKE_deform_flip_side_name(name_flip, ebone->name, true); + ED_armature_bone_rename(arm, ebone->name, name_flip); } CTX_DATA_END; diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index 0301db4b4cf..5f15d15d478 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -346,11 +346,10 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, /* find flipped group */ if (dgroup && mirror) { - char name[MAXBONENAME]; + char name_flip[MAXBONENAME]; - // 0 = don't strip off number extensions - flip_side_name(name, dgroup->name, FALSE); - dgroupflip[j] = defgroup_find_name(ob, name); + BKE_deform_flip_side_name(name_flip, dgroup->name, false); + dgroupflip[j] = defgroup_find_name(ob, name_flip); } } diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index f2f51dc1bd5..7efeeebcf1d 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -182,16 +182,16 @@ void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]) EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo) { EditBone *eboflip = NULL; - char name[MAXBONENAME]; + char name_flip[MAXBONENAME]; if (ebo == NULL) return NULL; - flip_side_name(name, ebo->name, FALSE); + BKE_deform_flip_side_name(name_flip, ebo->name, false); for (eboflip = edbo->first; eboflip; eboflip = eboflip->next) { if (ebo != eboflip) { - if (!strcmp(name, eboflip->name)) + if (!strcmp(name_flip, eboflip->name)) break; } } diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 31ff1e161e8..d1c096e6cf5 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -577,9 +577,9 @@ static int pose_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { - char newname[MAXBONENAME]; - flip_side_name(newname, pchan->name, TRUE); - ED_armature_bone_rename(arm, pchan->name, newname); + char name_flip[MAXBONENAME]; + BKE_deform_flip_side_name(name_flip, pchan->name, true); + ED_armature_bone_rename(arm, pchan->name, name_flip); } CTX_DATA_END; diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index a53d8050c5d..687b1f3f9bc 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -848,10 +848,10 @@ static int pose_bone_flip_active_exec(bContext *C, wmOperator *UNUSED(op)) if (arm->act_bone) { bPoseChannel *pchanf; - char name[MAXBONENAME]; - flip_side_name(name, arm->act_bone->name, TRUE); + char name_flip[MAXBONENAME]; + BKE_deform_flip_side_name(name_flip, arm->act_bone->name, true); - pchanf = BKE_pose_channel_find_name(ob->pose, name); + pchanf = BKE_pose_channel_find_name(ob->pose, name_flip); if (pchanf && pchanf->bone != arm->act_bone) { arm->act_bone->flag &= ~BONE_SELECTED; pchanf->bone->flag |= BONE_SELECTED; @@ -860,7 +860,7 @@ static int pose_bone_flip_active_exec(bContext *C, wmOperator *UNUSED(op)) /* in weightpaint we select the associated vertex group too */ if (ob_act->mode & OB_MODE_WEIGHT_PAINT) { - ED_vgroup_select_by_name(ob_act, name); + ED_vgroup_select_by_name(ob_act, name_flip); DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA); } diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 79ca70a6189..4e66c329088 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -302,7 +302,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, short se /* get the name - if flipping, we must flip this first */ if (flip) - flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */ + BKE_deform_flip_side_name(name, chan->name, false); else BLI_strncpy(name, chan->name, sizeof(name)); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 974dc3acef9..ffa9eed65b9 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -1078,12 +1078,12 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, primbase, selected_bases) { - char tmpname[MAXBONENAME]; + char name_flip[MAXBONENAME]; - flip_side_name(tmpname, primbase->object->id.name + 2, TRUE); + BKE_deform_flip_side_name(name_flip, primbase->object->id.name + 2, true); - if (strcmp(tmpname, primbase->object->id.name + 2) != 0) { /* names differ */ - Object *ob = (Object *)BKE_libblock_find_name(ID_OB, tmpname); + if (!STREQ(name_flip, primbase->object->id.name + 2)) { + Object *ob = (Object *)BKE_libblock_find_name(ID_OB, name_flip); if (ob) { Base *secbase = BKE_scene_base_find(scene, ob); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index c8c38eebea9..714d67c8039 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -378,12 +378,12 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active) if (defgroup) { int mirrdef; - char name[MAXBONENAME]; + char name_flip[MAXBONENAME]; - flip_side_name(name, defgroup->name, FALSE); - mirrdef = defgroup_name_index(ob, name); + BKE_deform_flip_side_name(name_flip, defgroup->name, false); + mirrdef = defgroup_name_index(ob, name_flip); if (mirrdef == -1) { - if (BKE_defgroup_new(ob, name)) { + if (BKE_defgroup_new(ob, name_flip)) { mirrdef = BLI_countlist(&ob->defbase) - 1; } } -- cgit v1.2.3 From 4fd66d7c0c569958e4db8486e63f5f2a5e64f2cc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Nov 2013 04:30:36 +1100 Subject: code cleanup: armature functions - added BKE_pose_channel_get_mirrored (matching editmode function ED_armature_bone_get_mirrored) - editbone_name_exists -> ED_armature_bone_find_name --- source/blender/blenkernel/BKE_action.h | 1 + source/blender/blenkernel/intern/action.c | 17 ++++++++++++++ source/blender/editors/armature/armature_edit.c | 4 ++-- source/blender/editors/armature/armature_intern.h | 3 --- source/blender/editors/armature/armature_naming.c | 10 ++------ .../blender/editors/armature/armature_relations.c | 4 ++-- source/blender/editors/armature/armature_utils.c | 27 ++++++++++++++-------- source/blender/editors/armature/pose_transform.c | 2 +- source/blender/editors/include/ED_armature.h | 3 ++- 9 files changed, 44 insertions(+), 27 deletions(-) diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 5c155a46182..3ac5c8c9a76 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -146,6 +146,7 @@ void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, cons struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name); struct bPoseChannel *BKE_pose_channel_active(struct Object *ob); struct bPoseChannel *BKE_pose_channel_verify(struct bPose *pose, const char *name); +struct bPoseChannel *BKE_pose_channel_get_mirrored(const struct bPose *pose, const char *name); #ifndef NDEBUG bool BKE_pose_channels_is_valid(const struct bPose *pose); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 94da2a330c1..fe0e3da605f 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -53,6 +53,7 @@ #include "BKE_anim.h" #include "BKE_animsys.h" #include "BKE_constraint.h" +#include "BKE_deform.h" #include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_idprop.h" @@ -539,6 +540,22 @@ bPoseChannel *BKE_pose_channel_active(Object *ob) return NULL; } +/** + * \see #ED_armature_bone_get_mirrored (edit-mode, matching function) + */ +bPoseChannel *BKE_pose_channel_get_mirrored(const bPose *pose, const char *name) +{ + char name_flip[MAXBONENAME]; + + BKE_deform_flip_side_name(name_flip, name, false); + + if (!STREQ(name_flip, name)) { + return BKE_pose_channel_find_name(pose, name_flip); + } + + return NULL; +} + const char *BKE_pose_ikparam_get_name(bPose *pose) { if (pose) { diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 29eebe86afa..1bc5bf0fd74 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -1127,7 +1127,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) bPoseChannel *pchan, *pchan_next; for (pchan = obedit->pose->chanbase.first; pchan; pchan = pchan_next) { pchan_next = pchan->next; - curBone = editbone_name_exists(arm->edbo, pchan->name); + curBone = ED_armature_bone_find_name(arm->edbo, pchan->name); if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) { BKE_pose_channel_free(pchan); @@ -1146,7 +1146,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == obedit) { if (ct->subtarget[0]) { - curBone = editbone_name_exists(arm->edbo, ct->subtarget); + curBone = ED_armature_bone_find_name(arm->edbo, ct->subtarget); if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) { con->flag |= CONSTRAINT_DISABLE; ct->subtarget[0] = 0; diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 83800e598ba..3707e13095b 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -229,9 +229,6 @@ struct EditBone *duplicateEditBoneObjects(struct EditBone *curBone, const char * /* editbones is the source list */ void updateDuplicateSubtargetObjects(struct EditBone *dupBone, struct ListBase *editbones, struct Object *src_ob, struct Object *dst_ob); - -EditBone *editbone_name_exists(struct ListBase *edbo, const char *name); - EditBone *add_points_bone(struct Object *obedit, float head[3], float tail[3]); void bone_free(struct bArmature *arm, struct EditBone *bone); diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 10e97240898..c574fc6a297 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -67,17 +67,11 @@ /* ************************************************** */ /* EditBone Names */ -/* checks if an EditBone with a matching name already, returning the matching bone if it exists */ -EditBone *editbone_name_exists(ListBase *edbo, const char *name) -{ - return BLI_findstring(edbo, name, offsetof(EditBone, name)); -} - /* note: there's a unique_bone_name() too! */ static bool editbone_unique_check(void *arg, const char *name) { struct {ListBase *lb; void *bone; } *data = arg; - EditBone *dupli = editbone_name_exists(data->lb, name); + EditBone *dupli = ED_armature_bone_find_name(data->lb, name); return dupli && dupli != data->bone; } @@ -155,7 +149,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* now check if we're in editmode, we need to find the unique name */ if (arm->edbo) { - EditBone *eBone = editbone_name_exists(arm->edbo, oldname); + EditBone *eBone = ED_armature_bone_find_name(arm->edbo, oldname); if (eBone) { unique_editbone_name(arm->edbo, newname, NULL); diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index 79d75c9fcda..cd24e94f9e9 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -230,7 +230,7 @@ int join_armature_exec(bContext *C, wmOperator *op) /* Copy bones and posechannels from the object to the edit armature */ for (pchan = opose->chanbase.first; pchan; pchan = pchann) { pchann = pchan->next; - curbone = editbone_name_exists(curarm->edbo, pchan->name); + curbone = ED_armature_bone_find_name(curarm->edbo, pchan->name); /* Get new name */ unique_editbone_name(arm->edbo, curbone->name, NULL); @@ -414,7 +414,7 @@ static void separate_armature_bones(Object *ob, short sel) /* go through pose-channels, checking if a bone should be removed */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) { pchann = pchan->next; - curbone = editbone_name_exists(arm->edbo, pchan->name); + curbone = ED_armature_bone_find_name(arm->edbo, pchan->name); /* check if bone needs to be removed */ if ( (sel && (curbone->flag & BONE_SELECTED)) || diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 7efeeebcf1d..2cbfb52db91 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -175,28 +175,35 @@ void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]) copy_v3_v3(mat[3], ebone->head); } +/** + * Return a pointer to the bone of the given name + */ +EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name) +{ + return BLI_findstring(edbo, name, offsetof(EditBone, name)); +} + + /* *************************************************************** */ /* Mirroring */ -/* context: editmode armature */ -EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo) +/** + * \see #BKE_pose_channel_get_mirrored (pose-mode, matching function) + */ +EditBone *ED_armature_bone_get_mirrored(const ListBase *edbo, EditBone *ebo) { - EditBone *eboflip = NULL; char name_flip[MAXBONENAME]; - + if (ebo == NULL) return NULL; BKE_deform_flip_side_name(name_flip, ebo->name, false); - for (eboflip = edbo->first; eboflip; eboflip = eboflip->next) { - if (ebo != eboflip) { - if (!strcmp(name_flip, eboflip->name)) - break; - } + if (!STREQ(name_flip, ebo->name)) { + return ED_armature_bone_find_name(edbo, name_flip); } - return eboflip; + return NULL; } /* ------------------------------------- */ diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 4e66c329088..578f048cb15 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -118,7 +118,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) pose = ob->pose; for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - curbone = editbone_name_exists(arm->edbo, pchan->name); + curbone = ED_armature_bone_find_name(arm->edbo, pchan->name); /* simply copy the head/tail values from pchan over to curbone */ copy_v3_v3(curbone->head, pchan->pose_head); diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index bb4640949c1..455378fc2ce 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -128,7 +128,8 @@ bool mouse_armature(struct bContext *C, const int mval[2], bool extend, bool des int join_armature_exec(struct bContext *C, struct wmOperator *op); struct Bone *get_indexed_bone(struct Object *ob, int index); float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const short axis_only); -EditBone *ED_armature_bone_get_mirrored(struct ListBase *edbo, EditBone *ebo); // XXX this is needed for populating the context iterators +EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name); +EditBone *ED_armature_bone_get_mirrored(const struct ListBase *edbo, EditBone *ebo); void ED_armature_sync_selection(struct ListBase *edbo); void ED_armature_validate_active(struct bArmature *arm); -- cgit v1.2.3 From ed1146b9dbe599532c9f90336ceb29d37b7435e2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Nov 2013 04:41:37 +1100 Subject: armature editmode: option for select mirror to use active bone only. --- source/blender/editors/armature/armature_select.c | 17 ++++++++++++++++- source/blender/editors/armature/pose_select.c | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 4c956ca65d4..10e77043cca 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -1054,7 +1054,8 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); bArmature *arm = obedit->data; - EditBone *ebone; + EditBone *ebone, *ebone_mirror_act = NULL; + const bool active_only = RNA_boolean_get(op->ptr, "only_active"); const bool extend = RNA_boolean_get(op->ptr, "extend"); for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { @@ -1072,12 +1073,25 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op) { const int flag_mirror = EBONE_PREV_FLAG_GET(ebone_mirror); flag_new |= flag_mirror; + + if (ebone == arm->act_edbone) { + ebone_mirror_act = ebone_mirror; + } + + /* skip all but the active or its mirror */ + if (active_only && !ELEM(arm->act_edbone, ebone, ebone_mirror)) { + continue; + } } ED_armature_ebone_selectflag_set(ebone, flag_new); } } + if (ebone_mirror_act) { + arm->act_edbone = ebone_mirror_act; + } + ED_armature_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1100,5 +1114,6 @@ void ARMATURE_OT_select_mirror(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + RNA_def_boolean(ot->srna, "only_active", false, "Active Only", "Only operate on the active bone"); RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 687b1f3f9bc..b6786db8cb3 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -887,5 +887,9 @@ void POSE_OT_select_flip_active(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "only_active", false, "Active Only", "Only operate on the active bone"); + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } -- cgit v1.2.3 From 8bc48307bac9755b68297ebc2a6565a4b2343400 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Nov 2013 05:18:10 +1100 Subject: pose mode: extend selection flipping to use the same method as editmode. adds extend and active only opton. --- release/scripts/presets/keyconfig/3dsmax.py | 3 +- release/scripts/presets/keyconfig/maya.py | 3 +- release/scripts/startup/bl_ui/space_view3d.py | 2 +- source/blender/editors/armature/armature_intern.h | 2 +- source/blender/editors/armature/armature_ops.c | 4 +- source/blender/editors/armature/armature_select.c | 5 +- source/blender/editors/armature/pose_select.c | 97 +++++++++++++++-------- 7 files changed, 76 insertions(+), 40 deletions(-) diff --git a/release/scripts/presets/keyconfig/3dsmax.py b/release/scripts/presets/keyconfig/3dsmax.py index 42a928cf80f..e4b8659a521 100644 --- a/release/scripts/presets/keyconfig/3dsmax.py +++ b/release/scripts/presets/keyconfig/3dsmax.py @@ -255,7 +255,8 @@ kmi.properties.direction = 'CHILD' kmi.properties.extend = True kmi = km.keymap_items.new('pose.select_linked', 'L', 'PRESS', alt=True) kmi = km.keymap_items.new('pose.select_grouped', 'G', 'PRESS', shift=True) -kmi = km.keymap_items.new('pose.select_flip_active', 'F', 'PRESS', shift=True) +kmi = km.keymap_items.new('pose.select_mirror', 'F', 'PRESS', shift=True) +kmi.properties.only_active = True kmi = km.keymap_items.new('pose.constraint_add_with_targets', 'C', 'PRESS', shift=True, ctrl=True) kmi = km.keymap_items.new('pose.constraints_clear', 'C', 'PRESS', ctrl=True, alt=True) kmi = km.keymap_items.new('pose.ik_add', 'I', 'PRESS', shift=True) diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index e6e0062c112..fb2871aec3e 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -315,7 +315,8 @@ kmi.properties.direction = 'CHILD' kmi.properties.extend = True kmi = km.keymap_items.new('pose.select_linked', 'L', 'PRESS') kmi = km.keymap_items.new('pose.select_grouped', 'G', 'PRESS', shift=True) -kmi = km.keymap_items.new('pose.select_flip_active', 'F', 'PRESS', shift=True) +kmi = km.keymap_items.new('pose.select_mirror', 'F', 'PRESS', shift=True) +kmi.properties.only_active = True kmi = km.keymap_items.new('pose.constraint_add_with_targets', 'C', 'PRESS', shift=True, ctrl=True) kmi = km.keymap_items.new('pose.constraints_clear', 'C', 'PRESS', ctrl=True, alt=True) kmi = km.keymap_items.new('pose.ik_add', 'I', 'PRESS', shift=True) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 3a3d3df06d8..ea2826f6fe3 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -532,7 +532,7 @@ class VIEW3D_MT_select_pose(Menu): layout.operator("pose.select_all").action = 'TOGGLE' layout.operator("pose.select_all", text="Inverse").action = 'INVERT' - layout.operator("pose.select_flip_active", text="Flip Active") + layout.operator("pose.select_mirror", text="Flip Active") layout.operator("pose.select_constraint_target", text="Constraint Target") layout.operator("pose.select_linked", text="Linked") diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 3707e13095b..bc7d69d1558 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -110,7 +110,7 @@ void POSE_OT_select_hierarchy(struct wmOperatorType *ot); void POSE_OT_select_linked(struct wmOperatorType *ot); void POSE_OT_select_constraint_target(struct wmOperatorType *ot); void POSE_OT_select_grouped(struct wmOperatorType *ot); -void POSE_OT_select_flip_active(struct wmOperatorType *ot); +void POSE_OT_select_mirror(struct wmOperatorType *ot); void POSE_OT_group_add(struct wmOperatorType *ot); void POSE_OT_group_remove(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 040b6f33f3b..4c7eb847054 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -116,7 +116,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_select_linked); WM_operatortype_append(POSE_OT_select_constraint_target); WM_operatortype_append(POSE_OT_select_grouped); - WM_operatortype_append(POSE_OT_select_flip_active); + WM_operatortype_append(POSE_OT_select_mirror); WM_operatortype_append(POSE_OT_group_add); WM_operatortype_append(POSE_OT_group_remove); @@ -363,7 +363,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "POSE_OT_select_flip_active", FKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "POSE_OT_select_mirror", FKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 10e77043cca..003f6bf36f3 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -1050,6 +1050,9 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) /****************** Mirror Select ****************/ +/** + * \note clone of #pose_select_mirror_exec keep in sync + */ static int armature_select_mirror_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -1102,7 +1105,7 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op) void ARMATURE_OT_select_mirror(wmOperatorType *ot) { /* identifiers */ - ot->name = "Mirror Select"; + ot->name = "Flip Active/Selected Bone"; ot->idname = "ARMATURE_OT_select_mirror"; ot->description = "Mirror the bone selection"; diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index b6786db8cb3..b3277c185d4 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -62,6 +62,11 @@ #include "armature_intern.h" +/* utility macros fro storing a temp int in the bone (selection flag) */ +#define PBONE_PREV_FLAG_GET(pchan) ((void)0, (GET_INT_FROM_POINTER((pchan)->temp))) +#define PBONE_PREV_FLAG_SET(pchan, val) ((pchan)->temp = SET_INT_IN_POINTER(val)) + + /* ***************** Pose Select Utilities ********************* */ /* Utility method for changing the selection status of a bone */ @@ -837,52 +842,78 @@ void POSE_OT_select_grouped(wmOperatorType *ot) /* -------------------------------------- */ -/* context active object, or weightpainted object with armature in posemode */ -static int pose_bone_flip_active_exec(bContext *C, wmOperator *UNUSED(op)) +/** + * \note clone of #armature_select_mirror_exec keep in sync + */ +static int pose_select_mirror_exec(bContext *C, wmOperator *op) { Object *ob_act = CTX_data_active_object(C); Object *ob = BKE_object_pose_armature_get(ob_act); - - if (ob && (ob->mode & OB_MODE_POSE)) { - bArmature *arm = ob->data; - - if (arm->act_bone) { - bPoseChannel *pchanf; - char name_flip[MAXBONENAME]; - BKE_deform_flip_side_name(name_flip, arm->act_bone->name, true); - - pchanf = BKE_pose_channel_find_name(ob->pose, name_flip); - if (pchanf && pchanf->bone != arm->act_bone) { - arm->act_bone->flag &= ~BONE_SELECTED; - pchanf->bone->flag |= BONE_SELECTED; - - arm->act_bone = pchanf->bone; - - /* in weightpaint we select the associated vertex group too */ - if (ob_act->mode & OB_MODE_WEIGHT_PAINT) { - ED_vgroup_select_by_name(ob_act, name_flip); - DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA); + bArmature *arm; + bPoseChannel *pchan, *pchan_mirror_act = NULL; + const bool active_only = RNA_boolean_get(op->ptr, "only_active"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); + + if ((ob && (ob->mode & OB_MODE_POSE)) == 0) { + return OPERATOR_CANCELLED; + } + + arm = ob->data; + + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + const int flag = (pchan->bone->flag & BONE_SELECTED); + PBONE_PREV_FLAG_SET(pchan, flag); + } + + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + if (PBONE_SELECTABLE(arm, pchan->bone)) { + bPoseChannel *pchan_mirror; + int flag_new = extend ? PBONE_PREV_FLAG_GET(pchan) : 0; + + if ((pchan_mirror = BKE_pose_channel_get_mirrored(ob->pose, pchan->name)) && + (PBONE_VISIBLE(arm, pchan_mirror->bone))) + { + const int flag_mirror = PBONE_PREV_FLAG_GET(pchan_mirror); + flag_new |= flag_mirror; + + if (pchan->bone == arm->act_bone) { + pchan_mirror_act = pchan_mirror; + } + + /* skip all but the active or its mirror */ + if (active_only && !ELEM(arm->act_bone, pchan->bone, pchan_mirror->bone)) { + continue; } - - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - - return OPERATOR_FINISHED; } + + pchan->bone->flag = (pchan->bone->flag & ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) | flag_new; } } - - return OPERATOR_CANCELLED; + + if (pchan_mirror_act) { + arm->act_bone = pchan_mirror_act->bone; + + /* in weightpaint we select the associated vertex group too */ + if (ob_act->mode & OB_MODE_WEIGHT_PAINT) { + ED_vgroup_select_by_name(ob_act, pchan_mirror_act->name); + DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA); + } + } + + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); + + return OPERATOR_FINISHED; } -void POSE_OT_select_flip_active(wmOperatorType *ot) +void POSE_OT_select_mirror(wmOperatorType *ot) { /* identifiers */ - ot->name = "Flip Selected Active Bone"; - ot->idname = "POSE_OT_select_flip_active"; - ot->description = "Activate the bone with a flipped name"; + ot->name = "Flip Active/Selected Bone"; + ot->idname = "POSE_OT_select_mirror"; + ot->description = "Mirror the bone selection"; /* api callbacks */ - ot->exec = pose_bone_flip_active_exec; + ot->exec = pose_select_mirror_exec; ot->poll = ED_operator_posemode; /* flags */ -- cgit v1.2.3 From f2faebe9cf6aea833f60da93efcffb7f0c271d82 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 17 Nov 2013 00:45:11 +0600 Subject: Fix compilation error with SCons when using BUILDINFO and git is not found Fallback to "no buildinfo" mode in this case. --- build_files/scons/tools/Blender.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index fac81953476..ca3f94a72af 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -410,10 +410,17 @@ def buildinfo(lenv, build_type): """ build_date = time.strftime ("%Y-%m-%d") build_time = time.strftime ("%H:%M:%S") + if os.path.isdir(os.path.abspath('.git')): build_commit_timestamp = os.popen('git log -1 --format=%ct').read().strip() - build_hash = os.popen('git rev-parse --short HEAD').read().strip() - build_branch = os.popen('git rev-parse --abbrev-ref HEAD').read().strip() + if not build_commit_timestamp: + # Git command not found + build_hash = 'unknown' + build_commit_timestamp = '0' + build_branch = 'unknown' + else: + build_hash = os.popen('git rev-parse --short HEAD').read().strip() + build_branch = os.popen('git rev-parse --abbrev-ref HEAD').read().strip() else: build_hash = 'unknown' build_commit_timestamp = '0' -- cgit v1.2.3 From b0ff255b55388de58925c2cd4974739c9592a036 Mon Sep 17 00:00:00 2001 From: Henrik Aarnio Date: Sat, 16 Nov 2013 19:58:29 +0100 Subject: Transform: vertex snapping for curves This adds vertex snapping capabilities for curves. Snaps to all control points of other objects, and visible + selected control points and handles in curve edit mode. Reviewed By: brecht Differential Revision: http://developer.blender.org/D3 --- source/blender/editors/transform/transform_snap.c | 62 +++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 5ace7e3a738..59c16f61295 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -37,6 +37,7 @@ #include "PIL_time.h" #include "DNA_armature_types.h" +#include "DNA_curve_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" #include "DNA_mesh_types.h" @@ -1415,6 +1416,64 @@ static bool snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *ar return retval; } +static bool snapCurve(short snap_mode, ARegion *ar, Object *ob, Curve *cu, float obmat[4][4], + const float ray_start[3], const float ray_normal[3], const float mval[2], + float r_loc[3], float *UNUSED(r_no), float *r_dist_px, float *r_depth) +{ + float imat[4][4]; + float ray_start_local[3], ray_normal_local[3]; + bool retval = false; + int u; + + Nurb *nu; + + /* only vertex snapping mode (eg control points and handles) supported for now) */ + if (snap_mode != SCE_SNAP_MODE_VERTEX) { + return retval; + } + + invert_m4_m4(imat, obmat); + + copy_v3_v3(ray_start_local, ray_start); + copy_v3_v3(ray_normal_local, ray_normal); + + mul_m4_v3(imat, ray_start_local); + mul_mat3_m4_v3(imat, ray_normal_local); + + for (nu = (ob->mode == OB_MODE_EDIT ? cu->editnurb->nurbs.first : cu->nurb.first); nu; nu = nu->next) { + for (u = 0; u < nu->pntsu; u++){ + switch (snap_mode) { + case SCE_SNAP_MODE_VERTEX: + { + if (ob->mode == OB_MODE_EDIT) { + /* don't snap to selected (moving) or hidden */ + if (nu->bezt[u].f2 & SELECT || nu->bezt[u].hide != 0) { + break; + } + retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + /* don't snap if handle is selected (moving), or if it is aligning to a moving handle */ + if (!(nu->bezt[u].f1 & SELECT) && !(nu->bezt[u].h1 & HD_ALIGN && nu->bezt[u].f3 & SELECT)) { + retval |= snapVertex(ar, nu->bezt[u].vec[0], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + } + if (!(nu->bezt[u].f3 & SELECT) && !(nu->bezt[u].h2 & HD_ALIGN && nu->bezt[u].f1 & SELECT)) { + retval |= snapVertex(ar, nu->bezt[u].vec[2], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + } + } else { + /* curve is not visible outside editmode if nurb length less than two */ + if (nu->pntsu > 1) { + retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + } + } + break; + } + default: + break; + } + } + } + return retval; +} + static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[4][4], const float ray_start[3], const float ray_normal[3], const float mval[2], float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth) @@ -1738,6 +1797,9 @@ static bool snapObject(Scene *scene, short snap_mode, ARegion *ar, Object *ob, f else if (ob->type == OB_ARMATURE) { retval = snapArmature(snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth); } + else if (ob->type == OB_CURVE) { + retval = snapCurve(snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth); + } else if (ob->type == OB_EMPTY) { retval = snapEmpty(snap_mode, ar, ob, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist_px, r_depth); } -- cgit v1.2.3 From a05e90f5fca40aeb0fa14211edbd80416ffc2cb3 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sat, 16 Nov 2013 21:46:35 +0100 Subject: OSX/scons: fix msgfmt binary linking and locale files distribution --- build_files/scons/tools/Blender.py | 12 +++++++++++- intern/locale/SConscript | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index ca3f94a72af..45b65b52587 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -641,7 +641,17 @@ def AppIt(target=None, source=None, env=None): if binary == 'blender': cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles'%(installdir, binary, VERSION) commands.getoutput(cmd) - cmd = 'cp -R %s/release/datafiles/locale %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION) + cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles/locale'%(installdir, binary, VERSION) + commands.getoutput(cmd) + mo_dir = os.path.join(builddir[:-4], "locale") + for f in os.listdir(mo_dir): + cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles/locale/%s'%(installdir, binary, VERSION, f[:-3]) + commands.getoutput(cmd) + cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles/locale/%s/LC_MESSAGES'%(installdir, binary, VERSION, f[:-3]) + commands.getoutput(cmd) + cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s/datafiles/locale/%s/LC_MESSAGES/blender.mo'%(mo_dir, f, installdir, binary, VERSION, f[:-3]) + commands.getoutput(cmd) + cmd = 'cp -R %s/release/datafiles/locale/languages %s/%s.app/Contents/MacOS/%s/datafiles/locale/'%(bldroot, installdir, binary, VERSION) commands.getoutput(cmd) cmd = 'cp -R %s/release/datafiles/fonts %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION) commands.getoutput(cmd) diff --git a/intern/locale/SConscript b/intern/locale/SConscript index 38161b48ff0..3fb3e1f8993 100644 --- a/intern/locale/SConscript +++ b/intern/locale/SConscript @@ -59,6 +59,9 @@ if env['WITH_BF_INTERNATIONAL']: msgfmt_tool = env.Clone() targetpath = root_build_dir + '/msgfmt' + if env['OURPLATFORM'] == 'darwin': + msgfmt_tool.Replace( LINKFLAGS = '/usr/lib/libgcc_s.1.dylib /usr/lib/libstdc++.6.dylib /usr/lib/libSystem.B.dylib') # only need this dependencies + msgfmt_target = msgfmt_tool.Program(target = targetpath, source = ['msgfmt.cc']) locale = env.Clone() -- cgit v1.2.3 From c239baa0badfdc0170159d2bd45c05618f6ed8f9 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sat, 16 Nov 2013 22:13:51 +0100 Subject: OSX/scons: small reorder and spelling --- build_files/scons/tools/Blender.py | 4 ++-- intern/locale/SConscript | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 45b65b52587..77d20720713 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -643,6 +643,8 @@ def AppIt(target=None, source=None, env=None): commands.getoutput(cmd) cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles/locale'%(installdir, binary, VERSION) commands.getoutput(cmd) + cmd = 'cp -R %s/release/datafiles/fonts %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION) + commands.getoutput(cmd) mo_dir = os.path.join(builddir[:-4], "locale") for f in os.listdir(mo_dir): cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles/locale/%s'%(installdir, binary, VERSION, f[:-3]) @@ -653,8 +655,6 @@ def AppIt(target=None, source=None, env=None): commands.getoutput(cmd) cmd = 'cp -R %s/release/datafiles/locale/languages %s/%s.app/Contents/MacOS/%s/datafiles/locale/'%(bldroot, installdir, binary, VERSION) commands.getoutput(cmd) - cmd = 'cp -R %s/release/datafiles/fonts %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION) - commands.getoutput(cmd) if env['WITH_BF_OCIO']: cmd = 'cp -R %s/release/datafiles/colormanagement %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION) commands.getoutput(cmd) diff --git a/intern/locale/SConscript b/intern/locale/SConscript index 3fb3e1f8993..42941e2105f 100644 --- a/intern/locale/SConscript +++ b/intern/locale/SConscript @@ -60,7 +60,7 @@ if env['WITH_BF_INTERNATIONAL']: msgfmt_tool = env.Clone() targetpath = root_build_dir + '/msgfmt' if env['OURPLATFORM'] == 'darwin': - msgfmt_tool.Replace( LINKFLAGS = '/usr/lib/libgcc_s.1.dylib /usr/lib/libstdc++.6.dylib /usr/lib/libSystem.B.dylib') # only need this dependencies + msgfmt_tool.Replace( LINKFLAGS = '/usr/lib/libgcc_s.1.dylib /usr/lib/libstdc++.6.dylib /usr/lib/libSystem.B.dylib') # only need these dependencies msgfmt_target = msgfmt_tool.Program(target = targetpath, source = ['msgfmt.cc']) -- cgit v1.2.3 From c592ebf5df4a2be3b70bd3e2f2bba0e3d5908704 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sat, 16 Nov 2013 22:10:27 +0000 Subject: Freestyle: a follow-up fix of trunk revision 61233. When an iterator has reached the end, any reference of the object pointed by it will now lead to a RuntimeError instead of returning None, with the aim of forcing Python API users to check the end of iteration rather than implicitly indicating the error condition. Acknowledgement to flokkievids for API discussions in the BlenderArtists.org Freestyle for Blender thread. --- .../freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp | 10 ++++++++-- .../freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp | 6 ++++-- .../intern/python/Iterator/BPy_CurvePointIterator.cpp | 6 ++++-- .../intern/python/Iterator/BPy_Interface0DIterator.cpp | 6 ++++-- .../freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp | 4 ++++ .../intern/python/Iterator/BPy_StrokeVertexIterator.cpp | 6 ++++-- .../freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp | 9 ++++++--- .../intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp | 6 ++++-- 8 files changed, 38 insertions(+), 15 deletions(-) diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp index 0daaa1a0476..292729782ec 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp @@ -115,8 +115,10 @@ PyDoc_STRVAR(AdjacencyIterator_object_doc, static PyObject *AdjacencyIterator_object_get(BPy_AdjacencyIterator *self, void *UNUSED(closure)) { - if (self->a_it->isEnd()) - Py_RETURN_NONE; + if (self->a_it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError, "iteration has stopped"); + return NULL; + } ViewEdge *ve = self->a_it->operator*(); if (ve) return BPy_ViewEdge_from_ViewEdge(*ve); @@ -131,6 +133,10 @@ PyDoc_STRVAR(AdjacencyIterator_is_incoming_doc, static PyObject *AdjacencyIterator_is_incoming_get(BPy_AdjacencyIterator *self, void *UNUSED(closure)) { + if (self->a_it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError, "iteration has stopped"); + return NULL; + } return PyBool_from_bool(self->a_it->isIncoming()); } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp index 91e8de118a9..9a4eb2b7f61 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp @@ -175,8 +175,10 @@ PyDoc_STRVAR(ChainingIterator_object_doc, static PyObject *ChainingIterator_object_get(BPy_ChainingIterator *self, void *UNUSED(closure)) { - if (self->c_it->isEnd()) - Py_RETURN_NONE; + if (self->c_it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError, "iteration has stopped"); + return NULL; + } ViewEdge *ve = self->c_it->operator*(); if (ve) return BPy_ViewEdge_from_ViewEdge(*ve); diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp index 1655b766a6b..0329aa99acc 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp @@ -97,8 +97,10 @@ PyDoc_STRVAR(CurvePointIterator_object_doc, static PyObject *CurvePointIterator_object_get(BPy_CurvePointIterator *self, void *UNUSED(closure)) { - if (self->cp_it->isEnd()) - Py_RETURN_NONE; + if (self->cp_it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError, "iteration has stopped"); + return NULL; + } return BPy_CurvePoint_from_CurvePoint(self->cp_it->operator*()); } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp index 2f6c8ff7348..3a246263efa 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp @@ -123,8 +123,10 @@ PyDoc_STRVAR(Interface0DIterator_object_doc, static PyObject *Interface0DIterator_object_get(BPy_Interface0DIterator *self, void *UNUSED(closure)) { - if (self->if0D_it->isEnd()) - Py_RETURN_NONE; + if (self->if0D_it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError, "iteration has stopped"); + return NULL; + } return Any_BPy_Interface0D_from_Interface0D(self->if0D_it->operator*()); } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp index d493b6c158b..ccf52c64757 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp @@ -115,6 +115,10 @@ PyDoc_STRVAR(SVertexIterator_object_doc, static PyObject *SVertexIterator_object_get(BPy_SVertexIterator *self, void *UNUSED(closure)) { + if (self->sv_it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError, "iteration has stopped"); + return NULL; + } SVertex *sv = self->sv_it->operator->(); if (sv) return BPy_SVertex_from_SVertex(*sv); diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp index 3174980b7d9..8287e280186 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp @@ -109,8 +109,10 @@ PyDoc_STRVAR(StrokeVertexIterator_object_doc, static PyObject *StrokeVertexIterator_object_get(BPy_StrokeVertexIterator *self, void *UNUSED(closure)) { - if (!self->reversed && self->sv_it->isEnd()) - Py_RETURN_NONE; + if (!self->reversed && self->sv_it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError, "iteration has stopped"); + return NULL; + } StrokeVertex *sv = self->sv_it->operator->(); if (sv) return BPy_StrokeVertex_from_StrokeVertex(*sv); diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp index c191a94f08d..87e05a790b4 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp @@ -122,8 +122,10 @@ PyDoc_STRVAR(ViewEdgeIterator_object_doc, static PyObject *ViewEdgeIterator_object_get(BPy_ViewEdgeIterator *self, void *UNUSED(closure)) { - if (!self->ve_it->isEnd()) - Py_RETURN_NONE; + if (!self->ve_it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError, "iteration has stopped"); + return NULL; + } ViewEdge *ve = self->ve_it->operator*(); if (ve) return BPy_ViewEdge_from_ViewEdge(*ve); @@ -140,7 +142,8 @@ static PyObject *ViewEdgeIterator_current_edge_get(BPy_ViewEdgeIterator *self, v ViewEdge *ve = self->ve_it->getCurrentEdge(); if (ve) return BPy_ViewEdge_from_ViewEdge(*ve); - Py_RETURN_NONE;} + Py_RETURN_NONE; +} static int ViewEdgeIterator_current_edge_set(BPy_ViewEdgeIterator *self, PyObject *value, void *UNUSED(closure)) { diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp index cbefcd3292e..12ca3d6cc4a 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp @@ -103,8 +103,10 @@ PyDoc_STRVAR(orientedViewEdgeIterator_object_doc, static PyObject *orientedViewEdgeIterator_object_get(BPy_orientedViewEdgeIterator *self, void *UNUSED(closure)) { - if (self->ove_it->isEnd()) - Py_RETURN_NONE; + if (self->ove_it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError, "iteration has stopped"); + return NULL; + } return BPy_directedViewEdge_from_directedViewEdge(self->ove_it->operator*()); } -- cgit v1.2.3 From 87c66bc6a43508adb4a9d040e336973694d8e22e Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 17 Nov 2013 00:37:12 +0100 Subject: Documentation: * Update readme for 2.70 (content + links), also updates for new tracker/git. * Fix some links to the new blender.org website * Release logs now point directly to the wiki, I don't see a reason to point to the website, just to redirect to the wiki after all. --- release/scripts/startup/bl_ui/space_info.py | 4 ++-- release/text/readme.html | 16 ++++++++-------- source/blender/windowmanager/intern/wm_operators.c | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 544bba17a73..52592594748 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -239,12 +239,12 @@ class INFO_MT_help(Menu): layout = self.layout layout.operator("wm.url_open", text="Manual", icon='HELP').url = "http://wiki.blender.org/index.php/Doc:2.6/Manual" - layout.operator("wm.url_open", text="Release Log", icon='URL').url = "http://www.blender.org/development/release-logs/blender-269" + layout.operator("wm.url_open", text="Release Log", icon='URL').url = "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70" layout.separator() layout.operator("wm.url_open", text="Blender Website", icon='URL').url = "http://www.blender.org" layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = "http://www.blender.org/e-shop" - layout.operator("wm.url_open", text="Developer Community", icon='URL').url = "http://www.blender.org/community/get-involved" + layout.operator("wm.url_open", text="Developer Community", icon='URL').url = "http://www.blender.org/get-involved/" layout.operator("wm.url_open", text="User Community", icon='URL').url = "http://www.blender.org/community/user-community" layout.separator() layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = "http://developer.blender.org/maniphest/task/create/?project=2&type=Bug" diff --git a/release/text/readme.html b/release/text/readme.html index 5ecb1ae3de1..7d79c8c3bad 100644 --- a/release/text/readme.html +++ b/release/text/readme.html @@ -28,10 +28,10 @@

For more information, visit blender.org.


2.70

-

The Blender Foundation and online developer community is proud to present Blender 2.69. This release is the tenth official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features. More information about this release.

+

The Blender Foundation and online developer community is proud to present Blender 2.70. This release is the first official stable release of the Blender 2.7 series. More information about this release.


Bugs

-

Although Blender 2.69 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.

+

Although Blender 2.70 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.


Package Contents

The downloaded Blender package includes:

@@ -50,20 +50,20 @@

When opening Blender, you’ll see large 3D view in the center, a Toolbar on the left, a Properties editor and an Outliner on the right and a Timeline at the bottom.

Orbit around in the 3D view by holding the middle mouse button and dragging. Alternatively, hold the alt key and drag the left mouse button. Additionally, hold Shift to pan the view and Ctrl to zoom.

Select objects using the right mouse button. With the object selected, perform actions by clicking any of the tool buttons on the left, or make changes to its properties by altering any of the setting on the right.

-

For more information on how to use Blender, watch tutorials or read the manual.

+

For more information on how to use Blender, check out the support page.


Links

Users:

General information www.blender.org
-Full release log www.blender.org/development/release-logs/blender-269/
-Tutorials www.blender.org/education-help/
+Full release log wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70
+Tutorials www.blender.org/support/tutorials/
Manual wiki.blender.org/index.php/Doc:2.6/Manual
User Forum www.blenderartists.org
IRC #blenderchat or #blender on irc.freenode.net

Developers:

-

Development www.blender.org/development/
-SVN and Bug Tracker projects.blender.org
-Get Involved www.blender.org/community/get-involved/
+

Development www.blender.org/get-involved/developers/
+GIT and Bug Tracker developer.blender.org/
+Get Involved www.blender.org/get-involved/
IRC #blendercoders on irc.freenode.net



diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 6396ef12495..da78f89f63a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1741,11 +1741,11 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar col = uiLayoutColumn(split, FALSE); uiItemL(col, IFACE_("Links"), ICON_NONE); uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", - "http://www.blender.org/blenderorg/blender-foundation/donation-payment"); + "http://www.blender.org/foundation/donation-payment/"); uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url", - "http://www.blender.org/development/credits"); + "http://www.blender.org/about/credits/"); uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", - "http://www.blender.org/development/release-logs/blender-269"); + "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.70"); uiItemStringO(col, IFACE_("Manual"), ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.6/Manual"); uiItemStringO(col, IFACE_("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org"); -- cgit v1.2.3 From f9785bdeb4ebe3ebc9527ba3eb45793c660bb3ec Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 17 Nov 2013 00:44:08 +0100 Subject: * Some less technical tooltip for the splash screen. --- source/blender/windowmanager/intern/wm_operators.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index da78f89f63a..50575095825 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1800,7 +1800,7 @@ static void WM_OT_splash(wmOperatorType *ot) { ot->name = "Splash Screen"; ot->idname = "WM_OT_splash"; - ot->description = "Opens a blocking popup region with release info"; + ot->description = "Opens the splash screen with release info"; ot->invoke = wm_splash_invoke; ot->poll = WM_operator_winactive; -- cgit v1.2.3 From c9209de573ad680dbad6b560c05a90b02b780267 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Nov 2013 14:54:42 +1100 Subject: vertex weights: add weight quantize tool. --- release/scripts/startup/bl_ui/space_view3d.py | 1 + .../scripts/startup/bl_ui/space_view3d_toolbar.py | 1 + source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + source/blender/editors/object/object_vgroup.c | 76 ++++++++++++++++++++++ 5 files changed, 80 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index ea2826f6fe3..16cef7cf6fb 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1502,6 +1502,7 @@ class VIEW3D_MT_paint_weight(Menu): layout.operator("object.vertex_group_mirror", text="Mirror") layout.operator("object.vertex_group_invert", text="Invert") layout.operator("object.vertex_group_clean", text="Clean") + layout.operator("object.vertex_group_quantize", text="Quantize") layout.operator("object.vertex_group_levels", text="Levels") layout.operator("object.vertex_group_blend", text="Blend") layout.operator("object.vertex_group_transfer_weight", text="Transfer Weights") diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 088dfc31973..8c86cc6c8a5 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1115,6 +1115,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel): col.operator("object.vertex_group_mirror", text="Mirror") col.operator("object.vertex_group_invert", text="Invert") col.operator("object.vertex_group_clean", text="Clean") + col.operator("object.vertex_group_quantize", text="Quantize") col.operator("object.vertex_group_levels", text="Levels") col.operator("object.vertex_group_blend", text="Blend") col.operator("object.vertex_group_transfer_weight", text="Transfer Weights") diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 4ff3bc9ac06..313ac1d29f0 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -222,6 +222,7 @@ void OBJECT_OT_vertex_group_fix(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_invert(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_blend(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_clean(struct wmOperatorType *ot); +void OBJECT_OT_vertex_group_quantize(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_limit_total(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_mirror(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_set_active(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 333e5ff3006..f5c2bcbef70 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -191,6 +191,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_vertex_group_levels); WM_operatortype_append(OBJECT_OT_vertex_group_blend); WM_operatortype_append(OBJECT_OT_vertex_group_clean); + WM_operatortype_append(OBJECT_OT_vertex_group_quantize); WM_operatortype_append(OBJECT_OT_vertex_group_limit_total); WM_operatortype_append(OBJECT_OT_vertex_group_mirror); WM_operatortype_append(OBJECT_OT_vertex_group_set_active); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index a6f7c4d5383..16ee400fa67 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2398,6 +2398,44 @@ static void vgroup_clean_subset(Object *ob, const bool *vgroup_validmap, const i } } +static void vgroup_quantize_subset(Object *ob, const bool *vgroup_validmap, const int vgroup_tot, const int UNUSED(subset_count), + const int steps) +{ + MDeformVert **dvert_array = NULL; + int dvert_tot = 0; + const bool use_vert_sel = vertex_group_use_vert_sel(ob); + const bool use_mirror = (ob->type == OB_MESH) ? (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X) != 0 : false; + ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, use_vert_sel); + + if (dvert_array) { + const float steps_fl = steps; + MDeformVert *dv; + int i; + + if (use_mirror && use_vert_sel) { + ED_vgroup_parray_mirror_assign(ob, dvert_array, dvert_tot); + } + + for (i = 0; i < dvert_tot; i++) { + MDeformWeight *dw; + int j; + + /* in case its not selected */ + if (!(dv = dvert_array[i])) { + continue; + } + + for (j = 0, dw = dv->dw; j < dv->totweight; j++, dw++) { + if ((dw->def_nr < vgroup_tot) && vgroup_validmap[dw->def_nr]) { + dw->weight = floorf((dw->weight * steps_fl) + 0.5f) / steps_fl; + CLAMP(dw->weight, 0.0f, 1.0f); + } + } + } + + MEM_freeN(dvert_array); + } +} static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr, const char sel, const char sel_mirr, @@ -3754,6 +3792,44 @@ void OBJECT_OT_vertex_group_clean(wmOperatorType *ot) "Keep verts assigned to at least one group when cleaning"); } +static int vertex_group_quantize_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_context(C); + + const int steps = RNA_int_get(op->ptr, "steps"); + eVGroupSelect subset_type = RNA_enum_get(op->ptr, "group_select_mode"); + + int subset_count, vgroup_tot; + + const bool *vgroup_validmap = ED_vgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count); + vgroup_quantize_subset(ob, vgroup_validmap, vgroup_tot, subset_count, steps); + MEM_freeN((void *)vgroup_validmap); + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_vertex_group_quantize(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Quantize Vertex Weights"; + ot->idname = "OBJECT_OT_vertex_group_quantize"; + ot->description = "Set weights to a fixed number of steps"; + + /* api callbacks */ + ot->poll = vertex_group_poll; + ot->exec = vertex_group_quantize_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + vgroup_operator_subset_select_props(ot, true); + RNA_def_int(ot->srna, "steps", 4, 1, 1000, "Steps", "Number of steps between 0 and 1", 1, 100); +} + static int vertex_group_limit_total_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); -- cgit v1.2.3 From 85bbef0f4ea2e7cacf2f681367f34fb6037d1df1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Nov 2013 15:09:57 +1100 Subject: python api internals: no need to set the stop-iter exception string. --- source/blender/python/bmesh/bmesh_py_types.c | 3 +-- source/blender/python/bmesh/bmesh_py_types_select.c | 3 +-- source/blender/python/generic/idprop_py_api.c | 2 +- source/blender/python/intern/bpy_rna.c | 2 +- source/gameengine/Ketsji/KX_PythonSeq.cpp | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 448f02a3772..97d88c5d189 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -2879,8 +2879,7 @@ static PyObject *bpy_bmiter_next(BPy_BMIter *self) { BMHeader *ele = BM_iter_step(&self->iter); if (ele == NULL) { - PyErr_SetString(PyExc_StopIteration, - "bpy_bmiter_next stop"); + PyErr_SetNone(PyExc_StopIteration); return NULL; } else { diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c index 5069670a665..1906fc8c90e 100644 --- a/source/blender/python/bmesh/bmesh_py_types_select.c +++ b/source/blender/python/bmesh/bmesh_py_types_select.c @@ -341,8 +341,7 @@ static PyObject *bpy_bmeditseliter_next(BPy_BMEditSelIter *self) { BMEditSelection *ese = self->ese; if (ese == NULL) { - PyErr_SetString(PyExc_StopIteration, - "bpy_bmiter_next stop"); + PyErr_SetNone(PyExc_StopIteration); return NULL; } else { diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c index da136675e1d..c3cbe7ddbf9 100644 --- a/source/blender/python/generic/idprop_py_api.c +++ b/source/blender/python/generic/idprop_py_api.c @@ -1397,7 +1397,7 @@ static PyObject *BPy_Group_Iter_Next(BPy_IDGroup_Iter *self) } } else { - PyErr_SetString(PyExc_StopIteration, "iterator at end"); + PyErr_SetNone(PyExc_StopIteration); return NULL; } } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4d4d4873390..5a87870d198 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -6044,7 +6044,7 @@ static PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self) static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *self) { if (self->iter.valid == false) { - PyErr_SetString(PyExc_StopIteration, "pyrna_prop_collection_iter stop"); + PyErr_SetNone(PyExc_StopIteration); return NULL; } else { diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp index 247f4173d1d..ab4f2c2d2c9 100644 --- a/source/gameengine/Ketsji/KX_PythonSeq.cpp +++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp @@ -383,7 +383,7 @@ static PyObject *KX_PythonSeq_nextIter(KX_PythonSeq *self) self->iter++; if ( object==NULL ) { self->iter= -1; /* for reuse */ - PyErr_SetString(PyExc_StopIteration, "iterator at end"); + PyErr_SetNone(PyExc_StopIteration); } return object; /* can be NULL for end of iterator */ } -- cgit v1.2.3 From 4882cb6f28ba51eaa1660e0db7c70af11c73ab5e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Nov 2013 18:54:03 +1100 Subject: convenience makefile: support spaces in paths also update for new source/tools paths. --- GNUmakefile | 78 +++++++++++++++++++------------------- release/datafiles/blender_icons.sh | 6 +-- release/datafiles/prvicons.sh | 4 +- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 26aaa3f0565..11ae1ffdf70 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -32,7 +32,7 @@ OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]') # Source and Build DIR's -BLENDER_DIR:="$(shell pwd -P)" +BLENDER_DIR:=$(shell pwd -P) BUILD_TYPE:=Release ifndef BUILD_CMAKE_ARGS @@ -40,7 +40,7 @@ ifndef BUILD_CMAKE_ARGS endif ifndef BUILD_DIR - BUILD_DIR:="$(shell dirname $(BLENDER_DIR))/build_$(OS_NCASE)" + BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE) endif @@ -87,8 +87,8 @@ endif # Macro for configuring cmake CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \ - -H$(BLENDER_DIR) \ - -B$(BUILD_DIR) \ + -H"$(BLENDER_DIR)" \ + -B"$(BUILD_DIR)" \ -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE) @@ -133,7 +133,7 @@ bpy: all # ----------------------------------------------------------------------------- # Configuration (save some cd'ing around) config: - $(CMAKE_CONFIG_TOOL) $(BUILD_DIR) + $(CMAKE_CONFIG_TOOL) "$(BUILD_DIR)" # ----------------------------------------------------------------------------- @@ -205,7 +205,7 @@ package_pacman: cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg --asroot package_archive: - make -C $(BUILD_DIR) -s package_archive + make -C "$(BUILD_DIR)" -s package_archive @echo archive in "$(BUILD_DIR)/release" @@ -231,25 +231,25 @@ test_deprecated: test_style_c: # run our own checks on C/C++ style - PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/source/blender $(BLENDER_DIR)/source/creator --no-length-check + PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" "$(BLENDER_DIR)/source/blender" "$(BLENDER_DIR)/source/creator" --no-length-check test_style_c_qtc: # run our own checks on C/C++ style USE_QTC_TASK=1 \ - PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/source/blender $(BLENDER_DIR)/source/creator --no-length-check > \ + PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" "$(BLENDER_DIR)/source/blender" "$(BLENDER_DIR)/source/creator" --no-length-check > \ test_style.tasks @echo "written: test_style.tasks" test_style_osl: # run our own checks on C/C++ style - PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/intern/cycles/kernel/shaders + PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" "$(BLENDER_DIR)/intern/cycles/kernel/shaders" test_style_osl_qtc: # run our own checks on C/C++ style USE_QTC_TASK=1 \ - PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/intern/cycles/kernel/shaders > \ + PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" "$(BLENDER_DIR)/intern/cycles/kernel/shaders" > \ test_style.tasks @echo "written: test_style.tasks" @@ -258,13 +258,13 @@ test_style_osl_qtc: # project_qtcreator: - python3 build_files/cmake/cmake_qtcreator_project.py $(BUILD_DIR) + python3 build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)" project_netbeans: - python3 build_files/cmake/cmake_netbeans_project.py $(BUILD_DIR) + python3 build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)" project_eclipse: - cmake -G"Eclipse CDT4 - Unix Makefiles" -H$(BLENDER_DIR) -B$(BUILD_DIR) + cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)" # ----------------------------------------------------------------------------- @@ -273,49 +273,49 @@ project_eclipse: check_cppcheck: $(CMAKE_CONFIG) - cd $(BUILD_DIR) ; \ - python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py 2> \ - $(BLENDER_DIR)/check_cppcheck.txt + cd "$(BUILD_DIR)" ; \ + python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \ + "$(BLENDER_DIR)/check_cppcheck.txt" @echo "written: check_cppcheck.txt" check_clang_array: $(CMAKE_CONFIG) - cd $(BUILD_DIR) ; \ - python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py + cd "$(BUILD_DIR)" ; \ + python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py" check_splint: $(CMAKE_CONFIG) - cd $(BUILD_DIR) ; \ - python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py + cd "$(BUILD_DIR)" ; \ + python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py" check_sparse: $(CMAKE_CONFIG) - cd $(BUILD_DIR) ; \ - python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py + cd "$(BUILD_DIR)" ; \ + python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py" check_smatch: $(CMAKE_CONFIG) - cd $(BUILD_DIR) ; \ - python3 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py + cd "$(BUILD_DIR)" ; \ + python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py" check_spelling_py: - cd $(BUILD_DIR) ; \ - PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/spell_check_source.py $(BLENDER_DIR)/release/scripts + cd "$(BUILD_DIR)" ; \ + PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" "$(BLENDER_DIR)/release/scripts" check_spelling_c: - cd $(BUILD_DIR) ; \ - PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/spell_check_source.py $(BLENDER_DIR)/source + cd "$(BUILD_DIR)" ; \ + PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" "$(BLENDER_DIR)/source" check_spelling_c_qtc: - cd $(BUILD_DIR) ; USE_QTC_TASK=1 \ - PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/spell_check_source.py $(BLENDER_DIR)/source > \ - $(BLENDER_DIR)/check_spelling_c.tasks + cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \ + PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" "$(BLENDER_DIR)/source" > \ + "$(BLENDER_DIR)/check_spelling_c.tasks" check_spelling_osl: - cd $(BUILD_DIR) ; PYTHONIOENCODING=utf_8 python3 $(BLENDER_DIR)/source/tools/spell_check_source.py $(BLENDER_DIR)/intern/cycles/kernel/shaders + cd "$(BUILD_DIR)" ; PYTHONIOENCODING=utf_8 python3 "$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" "$(BLENDER_DIR)/intern/cycles/kernel/shaders" check_descriptions: - $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python $(BLENDER_DIR)/source/tools/check_descriptions.py + "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python "$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py" # ----------------------------------------------------------------------------- # Utilities @@ -328,8 +328,8 @@ tbz: @echo "blender_archive.tar.bz2 written" icons: - $(BLENDER_DIR)/release/datafiles/blender_icons.sh - $(BLENDER_DIR)/release/datafiles/prvicons.sh + "$(BLENDER_DIR)/release/datafiles/blender_icons.sh" + "$(BLENDER_DIR)/release/datafiles/prvicons.sh" # ----------------------------------------------------------------------------- @@ -338,7 +338,7 @@ icons: # Simple version of ./doc/python_api/sphinx_doc_gen.sh with no PDF generation. doc_py: - $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python doc/python_api/sphinx_doc_gen.py + "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python doc/python_api/sphinx_doc_gen.py cd doc/python_api ; sphinx-build -b html sphinx-in sphinx-out @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/contents.html'" @@ -347,14 +347,14 @@ doc_doxy: @echo "docs written into: '$(BLENDER_DIR)/doc/doxygen/html/index.html'" doc_dna: - $(BUILD_DIR)/bin/blender --background -noaudio --factory-startup --python doc/blender_file_format/BlendFileDnaExporter_25.py + "$(BUILD_DIR)/bin/blender" --background -noaudio --factory-startup --python doc/blender_file_format/BlendFileDnaExporter_25.py @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'" doc_man: - python3 doc/manpage/blender.1.py $(BUILD_DIR)/bin/blender + python3 doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender" clean: - $(MAKE) -C $(BUILD_DIR) clean + $(MAKE) -C "$(BUILD_DIR)" clean .PHONY: all diff --git a/release/datafiles/blender_icons.sh b/release/datafiles/blender_icons.sh index 9c2cedaaf6c..62746d0ab7e 100755 --- a/release/datafiles/blender_icons.sh +++ b/release/datafiles/blender_icons.sh @@ -1,8 +1,8 @@ #!/bin/sh # This script updates icons from the SVG file -BASEDIR=$(dirname $0) +BASEDIR=$(dirname "$0") -inkscape $BASEDIR/blender_icons.svg --export-dpi=90 --without-gui --export-png=$BASEDIR/blender_icons16.png -inkscape $BASEDIR/blender_icons.svg --export-dpi=180 --without-gui --export-png=$BASEDIR/blender_icons32.png +inkscape "$BASEDIR/blender_icons.svg" --export-dpi=90 --without-gui --export-png="$BASEDIR/blender_icons16.png" +inkscape "$BASEDIR/blender_icons.svg" --export-dpi=180 --without-gui --export-png="$BASEDIR/blender_icons32.png" diff --git a/release/datafiles/prvicons.sh b/release/datafiles/prvicons.sh index 1a82b4db71c..95546ff0a4a 100755 --- a/release/datafiles/prvicons.sh +++ b/release/datafiles/prvicons.sh @@ -1,7 +1,7 @@ #!/bin/sh # This script updates icons from the SVG file -BASEDIR=$(dirname $0) +BASEDIR=$(dirname "$0") -inkscape $BASEDIR/prvicons.svg --without-gui --export-png=$BASEDIR/prvicons.png +inkscape "$BASEDIR/prvicons.svg" --without-gui --export-png="$BASEDIR/prvicons.png" -- cgit v1.2.3 From c3788b60f4af8ede604375e9f5275691bc7fa7f2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Nov 2013 21:16:39 +1100 Subject: Convenience Makefile: spaces in the build path would fail still. --- GNUmakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 11ae1ffdf70..e6998cf1c96 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -54,15 +54,15 @@ ifneq "$(findstring debug, $(MAKECMDGOALS))" "" endif ifneq "$(findstring lite, $(MAKECMDGOALS))" "" BUILD_DIR:=$(BUILD_DIR)_lite - BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake + BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake" endif ifneq "$(findstring headless, $(MAKECMDGOALS))" "" BUILD_DIR:=$(BUILD_DIR)_bpy - BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake + BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake" endif ifneq "$(findstring bpy, $(MAKECMDGOALS))" "" BUILD_DIR:=$(BUILD_DIR)_bpy - BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake + BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake" endif @@ -118,7 +118,7 @@ all: @echo @echo Building Blender ... - $(MAKE) -C $(BUILD_DIR) -s -j $(NPROCS) install + $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install @echo @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild. @echo blender installed, run from: "$(BUILD_DIR)/bin/blender" -- cgit v1.2.3 From 8f7f8d679ce54fe2fb3c51a10d1d8f1a53c548e5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Nov 2013 22:00:57 +1100 Subject: Style Cleanup: whitespace --- source/blender/blenkernel/intern/deform.c | 7 +-- source/blender/bmesh/tools/bmesh_bevel.c | 54 +++++++++++----------- source/blender/editors/transform/transform_snap.c | 7 +-- .../composite/nodes/node_composite_colorbalance.c | 2 +- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index dafc0c3c754..8aeacda8100 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -335,9 +335,10 @@ void defvert_normalize_lock_single(MDeformVert *dvert, } /* Same as defvert_normalize() if no locked vgroup is a member of the subset */ -void defvert_normalize_lock_map(MDeformVert *dvert, - const bool *vgroup_subset, const int vgroup_tot, - const bool *lock_flags, const int defbase_tot) +void defvert_normalize_lock_map( + MDeformVert *dvert, + const bool *vgroup_subset, const int vgroup_tot, + const bool *lock_flags, const int defbase_tot) { if (dvert->totweight == 0) { /* nothing */ diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 5017c00259b..af3160b004d 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -543,7 +543,7 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, * of not meeting at the same point by choosing to change the bevel offset on one * of the appropriate side of either e1 or e2, in order that the lines can meet on emid. */ static void offset_on_edge_between(BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, - BMVert *v, float meetco[3]) + BMVert *v, float meetco[3]) { BLI_assert(e1->is_bev && e2->is_bev && !emid->is_bev); @@ -1965,7 +1965,8 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) /* Return the angle between the two faces adjacent to e. * If there are not two, return 0. */ -static float edge_face_angle(EdgeHalf *e) { +static float edge_face_angle(EdgeHalf *e) +{ if (e->fprev && e->fnext) { /* angle between faces is supplement of angle between face normals */ return (float)M_PI - angle_normalized_v3v3(e->fprev->no, e->fnext->no); @@ -2160,30 +2161,31 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } else { switch (bp->offset_type) { - case BEVEL_AMT_OFFSET: - e->offset_l = bp->offset; - break; - case BEVEL_AMT_WIDTH: - z = fabs(2.0f * sinf(edge_face_angle(e) / 2.0f)); - if (z < BEVEL_EPSILON) - e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ - else - e->offset_l = bp->offset / z; - break; - case BEVEL_AMT_DEPTH: - z = fabs(cosf(edge_face_angle(e) / 2.0f)); - if (z < BEVEL_EPSILON) - e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ - else - e->offset_l = bp->offset / z; - break; - case BEVEL_AMT_PERCENT: - e->offset_l = BM_edge_calc_length(e->prev->e) * bp->offset / 100.0f; - e->offset_r = BM_edge_calc_length(e->next->e) * bp->offset / 100.0f; - break; - default: - BLI_assert(!"bad bevel offset kind"); - e->offset_l = bp->offset; + case BEVEL_AMT_OFFSET: + e->offset_l = bp->offset; + break; + case BEVEL_AMT_WIDTH: + z = fabsf(2.0f * sinf(edge_face_angle(e) / 2.0f)); + if (z < BEVEL_EPSILON) + e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ + else + e->offset_l = bp->offset / z; + break; + case BEVEL_AMT_DEPTH: + z = fabsf(cosf(edge_face_angle(e) / 2.0f)); + if (z < BEVEL_EPSILON) + e->offset_l = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ + else + e->offset_l = bp->offset / z; + break; + case BEVEL_AMT_PERCENT: + e->offset_l = BM_edge_calc_length(e->prev->e) * bp->offset / 100.0f; + e->offset_r = BM_edge_calc_length(e->next->e) * bp->offset / 100.0f; + break; + default: + BLI_assert(!"bad bevel offset kind"); + e->offset_l = bp->offset; + break; } if (bp->offset_type != BEVEL_AMT_PERCENT) e->offset_r = e->offset_l; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 59c16f61295..8283197c70b 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -397,7 +397,7 @@ void applyGridAbsolute(TransInfo *t) copy_v3_v3(iloc, td->ob->obmat[3]); } - mul_v3_v3fl(loc, iloc, 1.0f/grid_size); + mul_v3_v3fl(loc, iloc, 1.0f / grid_size); loc[0] = floorf(loc[0]); loc[1] = floorf(loc[1]); loc[2] = floorf(loc[2]); @@ -1441,7 +1441,7 @@ static bool snapCurve(short snap_mode, ARegion *ar, Object *ob, Curve *cu, float mul_mat3_m4_v3(imat, ray_normal_local); for (nu = (ob->mode == OB_MODE_EDIT ? cu->editnurb->nurbs.first : cu->nurb.first); nu; nu = nu->next) { - for (u = 0; u < nu->pntsu; u++){ + for (u = 0; u < nu->pntsu; u++) { switch (snap_mode) { case SCE_SNAP_MODE_VERTEX: { @@ -1458,7 +1458,8 @@ static bool snapCurve(short snap_mode, ARegion *ar, Object *ob, Curve *cu, float if (!(nu->bezt[u].f3 & SELECT) && !(nu->bezt[u].h2 & HD_ALIGN && nu->bezt[u].f1 & SELECT)) { retval |= snapVertex(ar, nu->bezt[u].vec[2], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); } - } else { + } + else { /* curve is not visible outside editmode if nurb length less than two */ if (nu->pntsu > 1) { retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index 81ebc7c4c3b..5e7bbfaa1d3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -70,7 +70,7 @@ void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *UNUSED(ntree), bNode *node) for (c = 0; c < 3; ++c) { float d = n->slope[c] + n->offset[c]; - n->lift[c] = (d != 0.0f ? n->slope[c] + 2.0f*n->offset[c] / d : 0.0f); + n->lift[c] = (d != 0.0f ? n->slope[c] + 2.0f * n->offset[c] / d : 0.0f); n->gain[c] = d; n->gamma[c] = (n->power[c] != 0.0f) ? 1.0f / n->power[c] : 1000000.0f; } -- cgit v1.2.3 From 94416a493c3a5c1b2406b991ff67fa4e964ead08 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sun, 17 Nov 2013 15:16:21 +0100 Subject: OSX/scons: using ditto autocreates dirs, spares 2 steps of mkdir iterating over .mo files, faster bundling --- build_files/scons/tools/Blender.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 77d20720713..e750ce09aff 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -641,23 +641,19 @@ def AppIt(target=None, source=None, env=None): if binary == 'blender': cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles'%(installdir, binary, VERSION) commands.getoutput(cmd) - cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles/locale'%(installdir, binary, VERSION) - commands.getoutput(cmd) cmd = 'cp -R %s/release/datafiles/fonts %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION) commands.getoutput(cmd) + cmd = 'cp -R %s/release/datafiles/locale/languages %s/%s.app/Contents/MacOS/%s/datafiles/locale/'%(bldroot, installdir, binary, VERSION) + commands.getoutput(cmd) mo_dir = os.path.join(builddir[:-4], "locale") for f in os.listdir(mo_dir): - cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles/locale/%s'%(installdir, binary, VERSION, f[:-3]) - commands.getoutput(cmd) - cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/datafiles/locale/%s/LC_MESSAGES'%(installdir, binary, VERSION, f[:-3]) - commands.getoutput(cmd) - cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s/datafiles/locale/%s/LC_MESSAGES/blender.mo'%(mo_dir, f, installdir, binary, VERSION, f[:-3]) + cmd = 'ditto %s/%s %s/%s.app/Contents/MacOS/%s/datafiles/locale/%s/LC_MESSAGES/blender.mo'%(mo_dir, f, installdir, binary, VERSION, f[:-3]) commands.getoutput(cmd) - cmd = 'cp -R %s/release/datafiles/locale/languages %s/%s.app/Contents/MacOS/%s/datafiles/locale/'%(bldroot, installdir, binary, VERSION) - commands.getoutput(cmd) + if env['WITH_BF_OCIO']: cmd = 'cp -R %s/release/datafiles/colormanagement %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION) commands.getoutput(cmd) + cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/%s/'%(bldroot,installdir,binary,VERSION) commands.getoutput(cmd) @@ -710,8 +706,6 @@ def AppIt(target=None, source=None, env=None): commands.getoutput(cmd) if env['CC'].split('/')[len(env['CC'].split('/'))-1][4:] >= '4.6.1': # for correct errorhandling with gcc <= 4.6.1 we need the gcc.dylib and gomp.dylib to link, thus distribute in app-bundle print "Bundling libgcc and libgomp" - cmd = 'mkdir %s/%s.app/Contents/MacOS/lib'%(installdir, binary) - commands.getoutput(cmd) instname = env['BF_CXX'] cmd = 'ditto --arch %s %s/lib/libgcc_s.1.dylib %s/%s.app/Contents/MacOS/lib/'%(osxarch, instname, installdir, binary) # copy libgcc commands.getoutput(cmd) -- cgit v1.2.3 From b764fe58c575c7c9343f635cc0cf7836c2a4e14b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 17 Nov 2013 09:23:18 +0100 Subject: CMake OS X: enable FFMPEG and Quicktime by default to match release and scons. --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a408a8100e5..8195785a372 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,10 +216,13 @@ option(WITH_IMAGE_FRAMESERVER "Enable image FrameServer Support for rendering" # Audio/Video format support option(WITH_CODEC_AVI "Enable Blenders own AVI file support (raw/jpeg)" ON) option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" OFF) - option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF) + if(APPLE) - option(WITH_CODEC_QUICKTIME "Enable Quicktime Support" OFF) + option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" ON) + option(WITH_CODEC_QUICKTIME "Enable Quicktime Support" ON) +else() + option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" OFF) endif() # 3D format support -- cgit v1.2.3 From 84c30edbdfe00bc3b8f39504c4dff5ab607f3ece Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Nov 2013 02:39:26 +1100 Subject: fix for crash with new buildinfo, when gmtime() returns NULL --- source/blender/blenloader/intern/readfile.c | 7 ++++++- source/creator/creator.c | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e2876317e38..01a71cfd63d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7932,7 +7932,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) char build_commit_datetime[32]; time_t temp_time = main->build_commit_timestamp; struct tm *tm = gmtime(&temp_time); - strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm); + if (LIKELY(tm)) { + strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm); + } + else { + BLI_strncpy(build_commit_datetime, "date-unknown", sizeof(build_commit_datetime)); + } printf("read file %s\n Version %d sub %d date %s hash %s\n", fd->relabase, main->versionfile, main->subversionfile, diff --git a/source/creator/creator.c b/source/creator/creator.c index 508847af5e3..adedab80338 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1516,8 +1516,15 @@ int main(int argc, const char **argv) { time_t temp_time = build_commit_timestamp; struct tm *tm = gmtime(&temp_time); - strftime(build_commit_date, sizeof(build_commit_date), "%Y-%m-%d", tm); - strftime(build_commit_time, sizeof(build_commit_time), "%H:%M", tm); + if (LIKELY(tm)) { + strftime(build_commit_date, sizeof(build_commit_date), "%Y-%m-%d", tm); + strftime(build_commit_time, sizeof(build_commit_time), "%H:%M", tm); + } + else { + const char *unknown = "date-unknown"; + BLI_strncpy(build_commit_date, unknown, sizeof(build_commit_date)); + BLI_strncpy(build_commit_time, unknown, sizeof(build_commit_time)); + } } #endif -- cgit v1.2.3 From 537f28fc0eba79fd735c71eeaec17e387b4629c3 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 17 Nov 2013 16:04:26 -0800 Subject: Fix T37325: applyRotation() wasn't working correctly on rigid bodies in the game engine. During the physics cleanup/refactor, the rotation matrix in CcdPhysicsController::RelativeRotate() became transposed. --- source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 71bdce0e1ae..6ce52b60426 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -947,9 +947,9 @@ void CcdPhysicsController::RelativeRotate(const MT_Matrix3x3& rotval,bool local return; } - btMatrix3x3 drotmat(rotval[0].x(), rotval[1].x(), rotval[2].x(), - rotval[0].y(), rotval[1].y(), rotval[2].y(), - rotval[0].z(), rotval[1].z(), rotval[2].z()); + btMatrix3x3 drotmat(rotval[0].x(), rotval[0].y(), rotval[0].z(), + rotval[1].x(), rotval[1].y(), rotval[1].z(), + rotval[2].x(), rotval[2].y(), rotval[2].z()); btMatrix3x3 currentOrn; -- cgit v1.2.3 From e806e5ce3797e88733161858a35e2c718d82187a Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 18 Nov 2013 01:54:10 +1300 Subject: Fix spelling error in comment --- source/blender/blenkernel/intern/constraint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index aa81ea130ad..0dbb739e6f8 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1008,7 +1008,7 @@ static bConstraintTypeInfo CTI_TRACKTO = { trackto_evaluate /* evaluate */ }; -/* --------- Inverse-Kinemetics --------- */ +/* --------- Inverse-Kinematics --------- */ static void kinematic_new_data(void *cdata) { -- cgit v1.2.3 From cee7fbdfaa647dd05a49b8450227b8c9a12e80a0 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 18 Nov 2013 14:02:49 +1300 Subject: Fix T37413 - Fit-Curve option for Array Modifier ignores constraint results Unless I'm missing something here (probably with regards to parenting), it makes more sense that constraint results are considered here as well (for example, if Limit Scale constraints get applied on the object), as this allows for greater flexibility when creating setups with this. --- source/blender/modifiers/intern/MOD_array.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 7c47fd5862e..bc38b0e030b 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -384,18 +384,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if (amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) { Curve *cu = amd->curve_ob->data; if (cu) { - float tmp_mat[3][3]; - float scale; - - BKE_object_to_mat3(amd->curve_ob, tmp_mat); - scale = mat3_to_scale(tmp_mat); - if (!amd->curve_ob->curve_cache || !amd->curve_ob->curve_cache->path) { cu->flag |= CU_PATH; // needed for path & bevlist BKE_displist_make_curveTypes(scene, amd->curve_ob, 0); } - if (amd->curve_ob->curve_cache->path) + if (amd->curve_ob->curve_cache->path) { + float scale = mat4_to_scale(amd->curve_ob->obmat); length = scale * amd->curve_ob->curve_cache->path->totdist; + } } } -- cgit v1.2.3 From 0ff70d942fa6a27ef416e59199a5c5590307dba2 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 18 Nov 2013 15:53:46 +1300 Subject: Code cleanup - Reduce duplication of layer number calculations here --- source/blender/editors/interface/interface_layout.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index e5bcc3d6863..b23d7018a55 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -391,20 +391,26 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in uiBlockBeginAlign(block); for (a = 0; a < colbuts; a++) { - if (layer_used & (1 << (a + b * colbuts))) icon = ICON_LAYER_USED; + int layer_num = a + b * colbuts; + int layer_flag = 1 << layer_num; + + if (layer_used & layer_flag) icon = ICON_LAYER_USED; else icon = ICON_BLANK1; - but = uiDefAutoButR(block, ptr, prop, a + b * colbuts, "", icon, x + butw * a, y + buth, butw, buth); + but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth); if (subtype == PROP_LAYER_MEMBER) - uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + b * colbuts)); + uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); } for (a = 0; a < colbuts; a++) { - if (layer_used & (1 << (a + len / 2 + b * colbuts))) icon = ICON_LAYER_USED; + int layer_num = a + len / 2 + b * colbuts; + int layer_flag = 1 << layer_num; + + if (layer_used & layer_flag) icon = ICON_LAYER_USED; else icon = ICON_BLANK1; - but = uiDefAutoButR(block, ptr, prop, a + len / 2 + b * colbuts, "", icon, x + butw * a, y, butw, buth); + but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth); if (subtype == PROP_LAYER_MEMBER) - uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + len / 2 + b * colbuts)); + uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); } uiBlockEndAlign(block); -- cgit v1.2.3 From 4ea79fcdda6523faf875128ef3d6e8a8ecff67c9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 18 Nov 2013 16:06:31 +1300 Subject: Patch T37363: Highlight bone layers with active bones (as for Object Layers) Patch by Jose Molina Garcia (sentinel), with style fixes by myself. --- .../blender/editors/interface/interface_layout.c | 33 +++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b23d7018a55..0f6034ba1cd 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -54,6 +54,8 @@ #include "UI_interface.h" +#include "ED_armature.h" + #include "WM_api.h" #include "WM_types.h" @@ -375,6 +377,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in int cols = (len >= 20) ? 2 : 1; const unsigned int colbuts = len / (2 * cols); unsigned int layer_used = 0; + unsigned int layer_active = 0; uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, FALSE)); @@ -384,7 +387,15 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in if (ptr->type == &RNA_Armature) { bArmature *arm = (bArmature *)ptr->data; + layer_used = arm->layer_used; + + if (arm->edbo && arm->act_edbone) { + layer_active |= arm->act_edbone->layer; + } + else if (arm->act_bone) { + layer_active |= arm->act_bone->layer; + } } for (b = 0; b < cols; b++) { @@ -394,8 +405,15 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in int layer_num = a + b * colbuts; int layer_flag = 1 << layer_num; - if (layer_used & layer_flag) icon = ICON_LAYER_USED; - else icon = ICON_BLANK1; + if (layer_used & layer_flag) { + if (layer_active & layer_flag) + icon = ICON_LAYER_ACTIVE; + else + icon = ICON_LAYER_USED; + } + else { + icon = ICON_BLANK1; + } but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth); if (subtype == PROP_LAYER_MEMBER) @@ -405,8 +423,15 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in int layer_num = a + len / 2 + b * colbuts; int layer_flag = 1 << layer_num; - if (layer_used & layer_flag) icon = ICON_LAYER_USED; - else icon = ICON_BLANK1; + if (layer_used & layer_flag) { + if (layer_active & layer_flag) + icon = ICON_LAYER_ACTIVE; + else + icon = ICON_LAYER_USED; + } + else { + icon = ICON_BLANK1; + } but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth); if (subtype == PROP_LAYER_MEMBER) -- cgit v1.2.3 From 69cbf3d83562f552811d82153e631ff1b4c7594a Mon Sep 17 00:00:00 2001 From: IRIE Shinsuke Date: Mon, 18 Nov 2013 11:30:06 +0900 Subject: Fix for T36936: Crash when starting BI rendered view Discard the render database when stopping the rendered preview, otherwise starting it again may cause a segmentation fault because undo/redo with non-rendered preview corrupts the database. --- source/blender/editors/space_view3d/space_view3d.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 58c0df6b6bd..3fbb78ac016 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -62,6 +62,7 @@ #include "WM_types.h" #include "RE_engine.h" +#include "RE_pipeline.h" #include "RNA_access.h" @@ -271,6 +272,8 @@ void ED_view3d_shade_update(Main *bmain, View3D *v3d, ScrArea *sa) if (rv3d && rv3d->render_engine) { WM_jobs_kill_type(wm, ar, WM_JOB_TYPE_RENDER_PREVIEW); + if (rv3d->render_engine->re) + RE_Database_Free(rv3d->render_engine->re); RE_engine_free(rv3d->render_engine); rv3d->render_engine = NULL; } -- cgit v1.2.3 From 8b3524c215fc8ab2a020d1914742a8fe576d8fae Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 18 Nov 2013 13:05:57 +0600 Subject: Fix T37486: Displacement bake from multires crashes when preview level is on 0 Revert "Code cleanup: remove unused block from multire baker" This reverts commit 63b01f6beee8eced14ff013ca93732f5c176ad10. Multires displacement baker in fact uses level 0 for the original subdivided mesh. Missed this when was making an original commit. --- .../blender/render/intern/source/multires_bake.c | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c index a920306732d..3ae075b4936 100644 --- a/source/blender/render/intern/source/multires_bake.c +++ b/source/blender/render/intern/source/multires_bake.c @@ -611,9 +611,6 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, float crn_x, crn_y; int grid_size, S, face_side; int *grid_offset, g_index; - int side, grid_index, loc_offs, cell_index, cell_side, row, col; - - BLI_assert(lvl > 0); lodm->getTessFace(lodm, face_index, &mface); @@ -624,19 +621,25 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, face_side = (grid_size << 1) - 1; - side = (1 << (lvl - 1)) + 1; - grid_index = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, face_index); - loc_offs = face_index % (1 << (2 * lvl)); - cell_index = loc_offs % ((side - 1) * (side - 1)); - cell_side = (grid_size - 1) / (side - 1); - row = cell_index / (side - 1); - col = cell_index % (side - 1); - - S = face_index / (1 << (2 * (lvl - 1))) - grid_offset[grid_index]; - g_index = grid_offset[grid_index]; - - crn_y = (row * cell_side) + u * cell_side; - crn_x = (col * cell_side) + v * cell_side; + if (lvl == 0) { + g_index = grid_offset[face_index]; + S = mdisp_rot_face_to_crn(mface.v4 ? 4 : 3, face_side, u * (face_side - 1), v * (face_side - 1), &crn_x, &crn_y); + } + else { + int side = (1 << (lvl - 1)) + 1; + int grid_index = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, face_index); + int loc_offs = face_index % (1 << (2 * lvl)); + int cell_index = loc_offs % ((side - 1) * (side - 1)); + int cell_side = (grid_size - 1) / (side - 1); + int row = cell_index / (side - 1); + int col = cell_index % (side - 1); + + S = face_index / (1 << (2 * (lvl - 1))) - grid_offset[grid_index]; + g_index = grid_offset[grid_index]; + + crn_y = (row * cell_side) + u * cell_side; + crn_x = (col * cell_side) + v * cell_side; + } CLAMP(crn_x, 0.0f, grid_size); CLAMP(crn_y, 0.0f, grid_size); -- cgit v1.2.3 From 238d2f962dc7f15188ea02d65950b1d2945d029a Mon Sep 17 00:00:00 2001 From: Walid Shouman Date: Mon, 18 Nov 2013 18:20:21 +1100 Subject: BMesh Refactor: BKE_bmbvh_new can now be created without an EditMesh. This adds BM_bmesh_calc_tessellation() so we can get triangles from a bmesh without having to have an editmesh available. --- source/blender/blenkernel/BKE_editmesh_bvh.h | 6 +- source/blender/blenkernel/intern/editderivedmesh.c | 4 +- source/blender/blenkernel/intern/editmesh.c | 144 +------------------ source/blender/blenkernel/intern/editmesh_bvh.c | 48 ++++--- source/blender/bmesh/intern/bmesh_polygon.c | 159 +++++++++++++++++++++ source/blender/bmesh/intern/bmesh_polygon.h | 2 + source/blender/editors/mesh/editmesh_knife.c | 8 +- source/blender/editors/mesh/editmesh_utils.c | 2 +- source/blender/editors/transform/transform.c | 2 +- 9 files changed, 207 insertions(+), 168 deletions(-) diff --git a/source/blender/blenkernel/BKE_editmesh_bvh.h b/source/blender/blenkernel/BKE_editmesh_bvh.h index 7b4ad4284c6..aeac00b06c1 100644 --- a/source/blender/blenkernel/BKE_editmesh_bvh.h +++ b/source/blender/blenkernel/BKE_editmesh_bvh.h @@ -33,15 +33,19 @@ #define __BKE_EDITMESH_BVH_H__ struct BMEditMesh; +struct BMesh; struct BMFace; struct BMVert; +struct BMLoop; struct BMBVHTree; struct BVHTree; struct Scene; typedef struct BMBVHTree BMBVHTree; -BMBVHTree *BKE_bmbvh_new(struct BMEditMesh *em, int flag, const float (*cos_cage)[3], const bool cos_cage_free); +BMBVHTree *BKE_bmbvh_new_from_editmesh(struct BMEditMesh *em, int flag, const float (*cos_cage)[3], const bool cos_cage_free); +BMBVHTree *BKE_bmbvh_new(struct BMesh *bm, struct BMLoop *(*looptris)[3], int looptris_tot, int flag, + const float (*cos_cage)[3], const bool cos_cage_free); void BKE_bmbvh_free(BMBVHTree *tree); struct BVHTree *BKE_bmbvh_tree_get(BMBVHTree *tree); struct BMFace *BKE_bmbvh_ray_cast(BMBVHTree *tree, const float co[3], const float dir[3], const float radius, diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 6fb5dd56ce5..c3538b141b5 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -1851,7 +1851,7 @@ static void statvis_calc_thickness( BM_mesh_elem_index_ensure(bm, BM_VERT); } - bmtree = BKE_bmbvh_new(em, 0, vertexCos, false); + bmtree = BKE_bmbvh_new_from_editmesh(em, 0, vertexCos, false); for (i = 0; i < tottri; i++) { BMFace *f_hit; @@ -1951,7 +1951,7 @@ static void statvis_calc_intersect( BM_mesh_elem_index_ensure(bm, BM_VERT); } - bmtree = BKE_bmbvh_new(em, 0, vertexCos, false); + bmtree = BKE_bmbvh_new_from_editmesh(em, 0, vertexCos, false); BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { BMFace *f_hit; diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c index 1fc7d024428..88cef0ec031 100644 --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.c @@ -102,9 +102,8 @@ BMEditMesh *BKE_editmesh_from_object(Object *ob) static void editmesh_tessface_calc_intern(BMEditMesh *em) { - /* use this to avoid locking pthread for _every_ polygon - * and calling the fill function */ -#define USE_TESSFACE_SPEEDUP + /* allocating space before calculating the tessellation */ + BMesh *bm = em->bm; @@ -114,13 +113,6 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em) const int looptris_tot_prev_alloc = em->looptris ? (MEM_allocN_len(em->looptris) / sizeof(*em->looptris)) : 0; BMLoop *(*looptris)[3]; - BMIter iter; - BMFace *efa; - BMLoop *l; - int i = 0; - - ScanFillContext sf_ctx; - MemArena *sf_arena = NULL; #if 0 /* note, we could be clever and re-use this array but would need to ensure @@ -136,7 +128,7 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em) /* this means no reallocs for quad dominant models, for */ if ((em->looptris != NULL) && - /* (em->tottri >= looptris_tot)) */ + /* (*em->tottri >= looptris_tot)) */ /* check against alloc'd size incase we over alloc'd a little */ ((looptris_tot_prev_alloc >= looptris_tot) && (looptris_tot_prev_alloc <= looptris_tot * 2))) { @@ -149,136 +141,10 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em) #endif - BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { - /* don't consider two-edged faces */ - if (UNLIKELY(efa->len < 3)) { - /* do nothing */ - } - -#ifdef USE_TESSFACE_SPEEDUP - - /* no need to ensure the loop order, we know its ok */ - - else if (efa->len == 3) { -#if 0 - int j; - BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) { - looptris[i][j] = l; - } - i += 1; -#else - /* more cryptic but faster */ - BMLoop **l_ptr = looptris[i++]; - l_ptr[0] = l = BM_FACE_FIRST_LOOP(efa); - l_ptr[1] = l = l->next; - l_ptr[2] = l->next; -#endif - } - else if (efa->len == 4) { -#if 0 - BMLoop *ltmp[4]; - int j; - BLI_array_grow_items(looptris, 2); - BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) { - ltmp[j] = l; - } - - looptris[i][0] = ltmp[0]; - looptris[i][1] = ltmp[1]; - looptris[i][2] = ltmp[2]; - i += 1; - - looptris[i][0] = ltmp[0]; - looptris[i][1] = ltmp[2]; - looptris[i][2] = ltmp[3]; - i += 1; -#else - /* more cryptic but faster */ - BMLoop **l_ptr_a = looptris[i++]; - BMLoop **l_ptr_b = looptris[i++]; - (l_ptr_a[0] = l_ptr_b[0] = l = BM_FACE_FIRST_LOOP(efa)); - (l_ptr_a[1] = l = l->next); - (l_ptr_a[2] = l_ptr_b[1] = l = l->next); - ( l_ptr_b[2] = l->next); -#endif - } - -#endif /* USE_TESSFACE_SPEEDUP */ - - else { - int j; - BMLoop *l_iter; - BMLoop *l_first; - - ScanFillVert *sf_vert, *sf_vert_last = NULL, *sf_vert_first = NULL; - /* ScanFillEdge *e; */ /* UNUSED */ - ScanFillFace *sf_tri; - int totfilltri; - - if (UNLIKELY(sf_arena == NULL)) { - sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__); - } - - BLI_scanfill_begin_arena(&sf_ctx, sf_arena); - - /* scanfill time */ - j = 0; - l_iter = l_first = BM_FACE_FIRST_LOOP(efa); - do { - sf_vert = BLI_scanfill_vert_add(&sf_ctx, l_iter->v->co); - sf_vert->tmp.p = l_iter; - - if (sf_vert_last) { - /* e = */ BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert); - } - - sf_vert_last = sf_vert; - if (sf_vert_first == NULL) { - sf_vert_first = sf_vert; - } - - /*mark order */ - BM_elem_index_set(l_iter, j++); /* set_loop */ - - } while ((l_iter = l_iter->next) != l_first); - - /* complete the loop */ - BLI_scanfill_edge_add(&sf_ctx, sf_vert_first, sf_vert); - - totfilltri = BLI_scanfill_calc_ex(&sf_ctx, 0, efa->no); - BLI_assert(totfilltri <= efa->len - 2); - (void)totfilltri; - - for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) { - BMLoop **l_ptr = looptris[i++]; - BMLoop *l1 = sf_tri->v1->tmp.p; - BMLoop *l2 = sf_tri->v2->tmp.p; - BMLoop *l3 = sf_tri->v3->tmp.p; - - if (BM_elem_index_get(l1) > BM_elem_index_get(l2)) { SWAP(BMLoop *, l1, l2); } - if (BM_elem_index_get(l2) > BM_elem_index_get(l3)) { SWAP(BMLoop *, l2, l3); } - if (BM_elem_index_get(l1) > BM_elem_index_get(l2)) { SWAP(BMLoop *, l1, l2); } - - l_ptr[0] = l1; - l_ptr[1] = l2; - l_ptr[2] = l3; - } - - BLI_scanfill_end_arena(&sf_ctx, sf_arena); - } - } - - if (sf_arena) { - BLI_memarena_free(sf_arena); - sf_arena = NULL; - } - - em->tottri = i; em->looptris = looptris; - BLI_assert(em->tottri <= looptris_tot); - -#undef USE_TESSFACE_SPEEDUP + /* after allocating the em->looptris, we're ready to tessellate */ + BM_bmesh_calc_tessellation(em->bm, em->looptris, &em->tottri); } diff --git a/source/blender/blenkernel/intern/editmesh_bvh.c b/source/blender/blenkernel/intern/editmesh_bvh.c index cb65fd80fc4..1c0e508e9e6 100644 --- a/source/blender/blenkernel/intern/editmesh_bvh.c +++ b/source/blender/blenkernel/intern/editmesh_bvh.c @@ -44,7 +44,9 @@ struct BMBVHTree { BVHTree *tree; - BMEditMesh *em; + BMLoop *(*looptris)[3]; + int looptris_tot; + BMesh *bm; const float (*cos_cage)[3]; @@ -53,33 +55,39 @@ struct BMBVHTree { int flag; }; -BMBVHTree *BKE_bmbvh_new(BMEditMesh *em, int flag, const float (*cos_cage)[3], const bool cos_cage_free) +BMBVHTree *BKE_bmbvh_new_from_editmesh(BMEditMesh *em, int flag, const float (*cos_cage)[3], const bool cos_cage_free) +{ + return BKE_bmbvh_new(em->bm, em->looptris, em->tottri, flag, cos_cage, cos_cage_free); +} + +BMBVHTree *BKE_bmbvh_new(BMesh *bm, BMLoop *(*looptris)[3], int looptris_tot, int flag, const float (*cos_cage)[3], +const bool cos_cage_free) { /* could become argument */ const float epsilon = FLT_EPSILON * 2.0f; - struct BMLoop *(*looptris)[3] = em->looptris; BMBVHTree *bmtree = MEM_callocN(sizeof(*bmtree), "BMBVHTree"); float cos[3][3]; int i; int tottri; /* BKE_editmesh_tessface_calc() must be called already */ - BLI_assert(em->tottri != 0 || em->bm->totface == 0); + BLI_assert(looptris_tot != 0 || bm->totface == 0); if (cos_cage) { - BM_mesh_elem_index_ensure(em->bm, BM_VERT); + BM_mesh_elem_index_ensure(bm, BM_VERT); } - bmtree->em = em; - bmtree->bm = em->bm; + bmtree->looptris = looptris; + bmtree->looptris_tot = looptris_tot; + bmtree->bm = bm; bmtree->cos_cage = cos_cage; bmtree->cos_cage_free = cos_cage_free; bmtree->flag = flag; if (flag & (BMBVH_RESPECT_SELECT)) { tottri = 0; - for (i = 0; i < em->tottri; i++) { + for (i = 0; i < looptris_tot; i++) { if (BM_elem_flag_test(looptris[i][0]->f, BM_ELEM_SELECT)) { tottri++; } @@ -87,23 +95,23 @@ BMBVHTree *BKE_bmbvh_new(BMEditMesh *em, int flag, const float (*cos_cage)[3], c } else if (flag & (BMBVH_RESPECT_HIDDEN)) { tottri = 0; - for (i = 0; i < em->tottri; i++) { + for (i = 0; i < looptris_tot; i++) { if (!BM_elem_flag_test(looptris[i][0]->f, BM_ELEM_HIDDEN)) { tottri++; } } } else { - tottri = em->tottri; + tottri = looptris_tot; } bmtree->tree = BLI_bvhtree_new(tottri, epsilon, 8, 8); - for (i = 0; i < em->tottri; i++) { + for (i = 0; i < looptris_tot; i++) { if (flag & BMBVH_RESPECT_SELECT) { /* note, the arrays wont align now! take care */ - if (!BM_elem_flag_test(em->looptris[i][0]->f, BM_ELEM_SELECT)) { + if (!BM_elem_flag_test(looptris[i][0]->f, BM_ELEM_SELECT)) { continue; } } @@ -231,14 +239,14 @@ BMFace *BKE_bmbvh_ray_cast(BMBVHTree *bmtree, const float co[3], const float dir hit.index = -1; /* ok to leave 'uv' uninitialized */ - bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->em->looptris; + bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->looptris; bmcb_data.cos_cage = (const float (*)[3])bmtree->cos_cage; BLI_bvhtree_ray_cast(bmtree->tree, co, dir, radius, &hit, bmbvh_ray_cast_cb, &bmcb_data); if (hit.index != -1 && hit.dist != dist) { if (r_hitout) { if (bmtree->flag & BMBVH_RETURN_ORIG) { - BMLoop **ltri = bmtree->em->looptris[hit.index]; + BMLoop **ltri = bmtree->looptris[hit.index]; interp_v3_v3v3v3_uv(r_hitout, ltri[0]->v->co, ltri[1]->v->co, ltri[2]->v->co, bmcb_data.uv); } else { @@ -254,7 +262,7 @@ BMFace *BKE_bmbvh_ray_cast(BMBVHTree *bmtree, const float co[3], const float dir *r_dist = hit.dist; } - return bmtree->em->looptris[hit.index][0]->f; + return bmtree->looptris[hit.index][0]->f; } return NULL; @@ -327,7 +335,7 @@ BMFace *BKE_bmbvh_find_face_segment(BMBVHTree *bmtree, const float co_a[3], cons hit.index = -1; /* ok to leave 'uv' uninitialized */ - bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->em->looptris; + bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->looptris; bmcb_data.cos_cage = (const float (*)[3])bmtree->cos_cage; bmcb_data.co_a = co_a; bmcb_data.co_b = co_b; @@ -337,7 +345,7 @@ BMFace *BKE_bmbvh_find_face_segment(BMBVHTree *bmtree, const float co_a[3], cons /* duplicate of BKE_bmbvh_ray_cast() */ if (r_hitout) { if (bmtree->flag & BMBVH_RETURN_ORIG) { - BMLoop **ltri = bmtree->em->looptris[hit.index]; + BMLoop **ltri = bmtree->looptris[hit.index]; interp_v3_v3v3v3_uv(r_hitout, ltri[0]->v->co, ltri[1]->v->co, ltri[2]->v->co, bmcb_data.uv); } else { @@ -354,7 +362,7 @@ BMFace *BKE_bmbvh_find_face_segment(BMBVHTree *bmtree, const float co_a[3], cons *r_fac = hit.dist / dist; } - return bmtree->em->looptris[hit.index][0]->f; + return bmtree->looptris[hit.index][0]->f; } return NULL; @@ -410,13 +418,13 @@ BMVert *BKE_bmbvh_find_vert_closest(BMBVHTree *bmtree, const float co[3], const hit.dist = maxdist_sq; hit.index = -1; - bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->em->looptris; + bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->looptris; bmcb_data.cos_cage = (const float (*)[3])bmtree->cos_cage; bmcb_data.maxdist = maxdist_sq; BLI_bvhtree_find_nearest(bmtree->tree, co, &hit, bmbvh_find_vert_closest_cb, &bmcb_data); if (hit.index != -1) { - BMLoop **ltri = bmtree->em->looptris[hit.index]; + BMLoop **ltri = bmtree->looptris[hit.index]; return ltri[bmcb_data.index_tri]->v; } diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index e88fdb8a7e8..3db6ba0e7c9 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -31,6 +31,8 @@ #include "DNA_listBase.h" #include "DNA_modifier_types.h" +#include "MEM_guardedalloc.h" + #include "BLI_alloca.h" #include "BLI_math.h" #include "BLI_memarena.h" @@ -1268,3 +1270,160 @@ void BM_face_as_array_loop_quad(BMFace *f, BMLoop *r_loops[4]) r_loops[2] = l; l = l->next; r_loops[3] = l; } + + +/** + * \brief BM_bmesh_calc_tessellation get the looptris and its number from a certain bmesh + * \param looptris + * + * \note \a looptris Must be pre-allocated to at least the size of given by: poly_to_tri_count + */ +void BM_bmesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot) +{ + /* use this to avoid locking pthread for _every_ polygon + * and calling the fill function */ +#define USE_TESSFACE_SPEEDUP + + /* this assumes all faces can be scan-filled, which isn't always true, + * worst case we over alloc a little which is acceptable */ + const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop); + + BMIter iter; + BMFace *efa; + BMLoop *l; + int i = 0; + + ScanFillContext sf_ctx; + MemArena *sf_arena = NULL; + + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { + /* don't consider two-edged faces */ + if (UNLIKELY(efa->len < 3)) { + /* do nothing */ + } + +#ifdef USE_TESSFACE_SPEEDUP + + /* no need to ensure the loop order, we know its ok */ + + else if (efa->len == 3) { +#if 0 + int j; + BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) { + looptris[i][j] = l; + } + i += 1; +#else + /* more cryptic but faster */ + BMLoop **l_ptr = looptris[i++]; + l_ptr[0] = l = BM_FACE_FIRST_LOOP(efa); + l_ptr[1] = l = l->next; + l_ptr[2] = l->next; +#endif + } + else if (efa->len == 4) { +#if 0 + BMLoop *ltmp[4]; + int j; + BLI_array_grow_items(looptris, 2); + BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) { + ltmp[j] = l; + } + + looptris[i][0] = ltmp[0]; + looptris[i][1] = ltmp[1]; + looptris[i][2] = ltmp[2]; + i += 1; + + looptris[i][0] = ltmp[0]; + looptris[i][1] = ltmp[2]; + looptris[i][2] = ltmp[3]; + i += 1; +#else + /* more cryptic but faster */ + BMLoop **l_ptr_a = looptris[i++]; + BMLoop **l_ptr_b = looptris[i++]; + (l_ptr_a[0] = l_ptr_b[0] = l = BM_FACE_FIRST_LOOP(efa)); + (l_ptr_a[1] = l = l->next); + (l_ptr_a[2] = l_ptr_b[1] = l = l->next); + ( l_ptr_b[2] = l->next); +#endif + } + +#endif /* USE_TESSFACE_SPEEDUP */ + + else { + int j; + BMLoop *l_iter; + BMLoop *l_first; + + ScanFillVert *sf_vert, *sf_vert_last = NULL, *sf_vert_first = NULL; + /* ScanFillEdge *e; */ /* UNUSED */ + ScanFillFace *sf_tri; + int totfilltri; + + if (UNLIKELY(sf_arena == NULL)) { + sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__); + } + + BLI_scanfill_begin_arena(&sf_ctx, sf_arena); + + /* scanfill time */ + j = 0; + l_iter = l_first = BM_FACE_FIRST_LOOP(efa); + do { + sf_vert = BLI_scanfill_vert_add(&sf_ctx, l_iter->v->co); + sf_vert->tmp.p = l_iter; + + if (sf_vert_last) { + /* e = */ BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert); + } + + sf_vert_last = sf_vert; + if (sf_vert_first == NULL) { + sf_vert_first = sf_vert; + } + + /*mark order */ + BM_elem_index_set(l_iter, j++); /* set_loop */ + + } while ((l_iter = l_iter->next) != l_first); + + /* complete the loop */ + BLI_scanfill_edge_add(&sf_ctx, sf_vert_first, sf_vert); + + totfilltri = BLI_scanfill_calc_ex(&sf_ctx, 0, efa->no); + BLI_assert(totfilltri <= efa->len - 2); + (void)totfilltri; + + for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) { + BMLoop **l_ptr = looptris[i++]; + BMLoop *l1 = sf_tri->v1->tmp.p; + BMLoop *l2 = sf_tri->v2->tmp.p; + BMLoop *l3 = sf_tri->v3->tmp.p; + + if (BM_elem_index_get(l1) > BM_elem_index_get(l2)) { SWAP(BMLoop *, l1, l2); } + if (BM_elem_index_get(l2) > BM_elem_index_get(l3)) { SWAP(BMLoop *, l2, l3); } + if (BM_elem_index_get(l1) > BM_elem_index_get(l2)) { SWAP(BMLoop *, l1, l2); } + + l_ptr[0] = l1; + l_ptr[1] = l2; + l_ptr[2] = l3; + } + + BLI_scanfill_end_arena(&sf_ctx, sf_arena); + } + } + + if (sf_arena) { + BLI_memarena_free(sf_arena); + sf_arena = NULL; + } + + *r_looptris_tot = looptris_tot; + + BLI_assert(i <= looptris_tot); + +#undef USE_TESSFACE_SPEEDUP + +} diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h index 4759c73cb4d..5d98a9a40db 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.h +++ b/source/blender/bmesh/intern/bmesh_polygon.h @@ -29,6 +29,8 @@ #include "BLI_compiler_attrs.h" +void BM_bmesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[], int *r_looptris_tot); + int BM_face_calc_tessellation(const BMFace *f, BMLoop **r_loops, int (*r_index)[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); void BM_face_calc_normal(const BMFace *f, float r_no[3]) ATTR_NONNULL(); void BM_face_calc_normal_vcos(BMesh *bm, BMFace *f, float r_no[3], diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index de57d24640f..6b99f53a5b8 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -2593,10 +2593,10 @@ static void knifetool_init(bContext *C, KnifeTool_OpData *kcd, kcd->cagecos = (const float (*)[3])BKE_editmesh_vertexCos_get(kcd->em, scene, NULL); - kcd->bmbvh = BKE_bmbvh_new(kcd->em, - BMBVH_RETURN_ORIG | - (only_select ? BMBVH_RESPECT_SELECT : BMBVH_RESPECT_HIDDEN), - kcd->cagecos, false); + kcd->bmbvh = BKE_bmbvh_new_from_editmesh(kcd->em, + BMBVH_RETURN_ORIG | + (only_select ? BMBVH_RESPECT_SELECT : BMBVH_RESPECT_HIDDEN), + kcd->cagecos, false); kcd->arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 15), "knife"); kcd->vthresh = KMAXDIST - 1; diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index ca8853fd3f5..697876a3877 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -1076,7 +1076,7 @@ void EDBM_verts_mirror_cache_begin_ex(BMEditMesh *em, const int axis, const bool ED_mesh_mirrtopo_init(me, -1, &mesh_topo_store, true); } else { - tree = BKE_bmbvh_new(em, 0, NULL, false); + tree = BKE_bmbvh_new_from_editmesh(em, 0, NULL, false); } #define VERT_INTPTR(_v, _i) r_index ? &r_index[_i] : BM_ELEM_CD_GET_VOID_P(_v, cd_vmirr_offset); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 2caf04e3143..ea5c86b5966 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -5502,7 +5502,7 @@ static bool createEdgeSlideVerts(TransInfo *t) use_btree_disp = (v3d && t->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE); if (use_btree_disp) { - btree = BKE_bmbvh_new(em, BMBVH_RESPECT_HIDDEN, NULL, false); + btree = BKE_bmbvh_new_from_editmesh(em, BMBVH_RESPECT_HIDDEN, NULL, false); } else { btree = NULL; -- cgit v1.2.3 From 6f67f7c18cf2c6224f3e3d796bf0d83d2f098b2e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 18 Nov 2013 13:36:13 +0600 Subject: Fix T37428: NurbsPath Mesh Deform "Binding" not available or not functional Seems to be a regression when Campbell was working on T24009. Bind operator exec handles curves nicely, could not see reason why to disable this with a poll function. From quick tests everything seems to be just fine. --- source/blender/editors/object/object_modifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index ec0423d7480..0c794a974ef 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1856,7 +1856,7 @@ void OBJECT_OT_skin_armature_create(wmOperatorType *ot) static int meshdeform_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, (1 << OB_MESH)); + return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, 0); } static int meshdeform_bind_exec(bContext *C, wmOperator *op) -- cgit v1.2.3 From c18712e86814d176433cea781fe1e68715c23bd4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 16 Nov 2013 00:17:10 +0100 Subject: Cycles: change __device and similar qualifiers to ccl_device in kernel code. This to avoids build conflicts with libc++ on FreeBSD, these __ prefixed values are reserved for compilers. I apologize to anyone who has patches or branches and has to go through the pain of merging this change, it may be easiest to do these same replacements in your code and then apply/merge the patch. Ref T37477. --- intern/cycles/kernel/closure/bsdf.h | 6 +- .../cycles/kernel/closure/bsdf_ashikhmin_velvet.h | 10 +- intern/cycles/kernel/closure/bsdf_diffuse.h | 22 +- intern/cycles/kernel/closure/bsdf_diffuse_ramp.h | 12 +- intern/cycles/kernel/closure/bsdf_hair.h | 20 +- intern/cycles/kernel/closure/bsdf_microfacet.h | 24 +- intern/cycles/kernel/closure/bsdf_oren_nayar.h | 12 +- intern/cycles/kernel/closure/bsdf_phong_ramp.h | 12 +- intern/cycles/kernel/closure/bsdf_reflection.h | 10 +- intern/cycles/kernel/closure/bsdf_refraction.h | 10 +- intern/cycles/kernel/closure/bsdf_toon.h | 24 +- intern/cycles/kernel/closure/bsdf_transparent.h | 10 +- intern/cycles/kernel/closure/bsdf_util.h | 8 +- intern/cycles/kernel/closure/bsdf_ward.h | 10 +- intern/cycles/kernel/closure/bsdf_westin.h | 20 +- intern/cycles/kernel/closure/bssrdf.h | 26 +- intern/cycles/kernel/closure/emissive.h | 6 +- intern/cycles/kernel/closure/volume.h | 10 +- intern/cycles/kernel/kernel.cl | 32 +-- intern/cycles/kernel/kernel_accumulate.h | 28 +- intern/cycles/kernel/kernel_bvh.h | 40 +-- intern/cycles/kernel/kernel_bvh_subsurface.h | 2 +- intern/cycles/kernel/kernel_bvh_traversal.h | 2 +- intern/cycles/kernel/kernel_camera.h | 16 +- intern/cycles/kernel/kernel_compat_cuda.h | 13 +- intern/cycles/kernel/kernel_compat_opencl.h | 14 +- intern/cycles/kernel/kernel_curve.h | 8 +- intern/cycles/kernel/kernel_differential.h | 10 +- intern/cycles/kernel/kernel_displace.h | 2 +- intern/cycles/kernel/kernel_emission.h | 10 +- intern/cycles/kernel/kernel_film.h | 18 +- intern/cycles/kernel/kernel_globals.h | 8 +- intern/cycles/kernel/kernel_jitter.h | 18 +- intern/cycles/kernel/kernel_light.h | 38 +-- intern/cycles/kernel/kernel_montecarlo.h | 24 +- intern/cycles/kernel/kernel_object.h | 52 ++-- intern/cycles/kernel/kernel_passes.h | 16 +- intern/cycles/kernel/kernel_path.h | 24 +- intern/cycles/kernel/kernel_path_state.h | 8 +- intern/cycles/kernel/kernel_primitive.h | 12 +- intern/cycles/kernel/kernel_projection.h | 24 +- intern/cycles/kernel/kernel_random.h | 34 +-- intern/cycles/kernel/kernel_shader.h | 58 ++-- intern/cycles/kernel/kernel_subsurface.h | 14 +- intern/cycles/kernel/kernel_triangle.h | 16 +- intern/cycles/kernel/svm/svm.h | 28 +- intern/cycles/kernel/svm/svm_attribute.h | 8 +- intern/cycles/kernel/svm/svm_blackbody.h | 2 +- intern/cycles/kernel/svm/svm_brick.h | 6 +- intern/cycles/kernel/svm/svm_brightness.h | 2 +- intern/cycles/kernel/svm/svm_camera.h | 2 +- intern/cycles/kernel/svm/svm_checker.h | 4 +- intern/cycles/kernel/svm/svm_closure.h | 34 +-- intern/cycles/kernel/svm/svm_convert.h | 2 +- intern/cycles/kernel/svm/svm_displace.h | 4 +- intern/cycles/kernel/svm/svm_fresnel.h | 4 +- intern/cycles/kernel/svm/svm_gamma.h | 2 +- intern/cycles/kernel/svm/svm_geometry.h | 12 +- intern/cycles/kernel/svm/svm_gradient.h | 4 +- intern/cycles/kernel/svm/svm_hsv.h | 2 +- intern/cycles/kernel/svm/svm_image.h | 18 +- intern/cycles/kernel/svm/svm_invert.h | 4 +- intern/cycles/kernel/svm/svm_light_path.h | 4 +- intern/cycles/kernel/svm/svm_magic.h | 4 +- intern/cycles/kernel/svm/svm_mapping.h | 4 +- intern/cycles/kernel/svm/svm_math.h | 10 +- intern/cycles/kernel/svm/svm_mix.h | 42 +-- intern/cycles/kernel/svm/svm_musgrave.h | 14 +- intern/cycles/kernel/svm/svm_noise.h | 36 +-- intern/cycles/kernel/svm/svm_noisetex.h | 4 +- intern/cycles/kernel/svm/svm_normal.h | 2 +- intern/cycles/kernel/svm/svm_ramp.h | 8 +- intern/cycles/kernel/svm/svm_sepcomb_hsv.h | 4 +- intern/cycles/kernel/svm/svm_sepcomb_rgb.h | 4 +- intern/cycles/kernel/svm/svm_sky.h | 12 +- intern/cycles/kernel/svm/svm_tex_coord.h | 10 +- intern/cycles/kernel/svm/svm_texture.h | 34 +-- intern/cycles/kernel/svm/svm_value.h | 4 +- intern/cycles/kernel/svm/svm_vector_transform.h | 2 +- intern/cycles/kernel/svm/svm_voronoi.h | 4 +- intern/cycles/kernel/svm/svm_wave.h | 4 +- intern/cycles/kernel/svm/svm_wavelength.h | 2 +- intern/cycles/kernel/svm/svm_wireframe.h | 2 +- intern/cycles/util/util_color.h | 18 +- intern/cycles/util/util_math.h | 302 ++++++++++----------- intern/cycles/util/util_transform.h | 60 ++-- intern/cycles/util/util_types.h | 88 +++--- 87 files changed, 804 insertions(+), 805 deletions(-) diff --git a/intern/cycles/kernel/closure/bsdf.h b/intern/cycles/kernel/closure/bsdf.h index 86fea48760f..b3141d1154f 100644 --- a/intern/cycles/kernel/closure/bsdf.h +++ b/intern/cycles/kernel/closure/bsdf.h @@ -35,7 +35,7 @@ CCL_NAMESPACE_BEGIN -__device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu, float randv, float3 *eval, float3 *omega_in, differential3 *domega_in, float *pdf) +ccl_device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu, float randv, float3 *eval, float3 *omega_in, differential3 *domega_in, float *pdf) { int label; @@ -132,7 +132,7 @@ __device int bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderCl return label; } -__device float3 bsdf_eval(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_eval(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, float *pdf) { float3 eval; @@ -275,7 +275,7 @@ __device float3 bsdf_eval(KernelGlobals *kg, const ShaderData *sd, const ShaderC return eval; } -__device void bsdf_blur(KernelGlobals *kg, ShaderClosure *sc, float roughness) +ccl_device void bsdf_blur(KernelGlobals *kg, ShaderClosure *sc, float roughness) { #ifdef __OSL__ if(kg->osl && sc->prim) { diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h index 94bc6eb0dc5..3631f90bf8c 100644 --- a/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h +++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h @@ -35,7 +35,7 @@ CCL_NAMESPACE_BEGIN -__device int bsdf_ashikhmin_velvet_setup(ShaderClosure *sc) +ccl_device int bsdf_ashikhmin_velvet_setup(ShaderClosure *sc) { float sigma = fmaxf(sc->data0, 0.01f); sc->data0 = 1.0f/(sigma * sigma); /* m_invsigma2 */ @@ -45,11 +45,11 @@ __device int bsdf_ashikhmin_velvet_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL; } -__device void bsdf_ashikhmin_velvet_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_ashikhmin_velvet_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float m_invsigma2 = sc->data0; float3 N = sc->N; @@ -87,12 +87,12 @@ __device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderClosure *sc, cons return make_float3(0, 0, 0); } -__device float3 bsdf_ashikhmin_velvet_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_ashikhmin_velvet_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_ashikhmin_velvet_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_ashikhmin_velvet_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float m_invsigma2 = sc->data0; float3 N = sc->N; diff --git a/intern/cycles/kernel/closure/bsdf_diffuse.h b/intern/cycles/kernel/closure/bsdf_diffuse.h index 46318ecd138..949fe869549 100644 --- a/intern/cycles/kernel/closure/bsdf_diffuse.h +++ b/intern/cycles/kernel/closure/bsdf_diffuse.h @@ -37,17 +37,17 @@ CCL_NAMESPACE_BEGIN /* DIFFUSE */ -__device int bsdf_diffuse_setup(ShaderClosure *sc) +ccl_device int bsdf_diffuse_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_DIFFUSE_ID; return SD_BSDF|SD_BSDF_HAS_EVAL; } -__device void bsdf_diffuse_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_diffuse_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_diffuse_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_diffuse_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float3 N = sc->N; @@ -56,12 +56,12 @@ __device float3 bsdf_diffuse_eval_reflect(const ShaderClosure *sc, const float3 return make_float3(cos_pi, cos_pi, cos_pi); } -__device float3 bsdf_diffuse_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_diffuse_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float3 N = sc->N; @@ -84,22 +84,22 @@ __device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I, f /* TRANSLUCENT */ -__device int bsdf_translucent_setup(ShaderClosure *sc) +ccl_device int bsdf_translucent_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_TRANSLUCENT_ID; return SD_BSDF|SD_BSDF_HAS_EVAL; } -__device void bsdf_translucent_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_translucent_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_translucent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_translucent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device float3 bsdf_translucent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_translucent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float3 N = sc->N; @@ -108,12 +108,12 @@ __device float3 bsdf_translucent_eval_transmit(const ShaderClosure *sc, const fl return make_float3 (cos_pi, cos_pi, cos_pi); } -__device float bsdf_translucent_albedo(const ShaderClosure *sc, const float3 I) +ccl_device float bsdf_translucent_albedo(const ShaderClosure *sc, const float3 I) { return 1.0f; } -__device int bsdf_translucent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_translucent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float3 N = sc->N; diff --git a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h index 2e43e16693f..b856774375f 100644 --- a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h +++ b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h @@ -35,7 +35,7 @@ CCL_NAMESPACE_BEGIN -__device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos) +ccl_device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos) { int MAXCOLORS = 8; @@ -49,17 +49,17 @@ __device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const float return colors[ipos] * (1.0f - offset) + colors[ipos+1] * offset; } -__device int bsdf_diffuse_ramp_setup(ShaderClosure *sc) +ccl_device int bsdf_diffuse_ramp_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_DIFFUSE_RAMP_ID; return SD_BSDF | SD_BSDF_HAS_EVAL; } -__device void bsdf_diffuse_ramp_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_diffuse_ramp_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_diffuse_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_diffuse_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf) { float3 N = sc->N; @@ -68,12 +68,12 @@ __device float3 bsdf_diffuse_ramp_eval_reflect(const ShaderClosure *sc, const fl return bsdf_diffuse_ramp_get_color(sc, colors, cos_pi) * M_1_PI_F; } -__device float3 bsdf_diffuse_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_diffuse_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_diffuse_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_diffuse_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float3 N = sc->N; diff --git a/intern/cycles/kernel/closure/bsdf_hair.h b/intern/cycles/kernel/closure/bsdf_hair.h index 5825d2637ba..163e7cc5ee2 100644 --- a/intern/cycles/kernel/closure/bsdf_hair.h +++ b/intern/cycles/kernel/closure/bsdf_hair.h @@ -36,15 +36,15 @@ CCL_NAMESPACE_BEGIN -__device void bsdf_hair_reflection_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_hair_reflection_blur(ShaderClosure *sc, float roughness) { } -__device void bsdf_hair_transmission_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_hair_transmission_blur(ShaderClosure *sc, float roughness) { } -__device int bsdf_hair_reflection_setup(ShaderClosure *sc) +ccl_device int bsdf_hair_reflection_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_HAIR_REFLECTION_ID; sc->data0 = clamp(sc->data0, 0.001f, 1.0f); @@ -52,7 +52,7 @@ __device int bsdf_hair_reflection_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } -__device int bsdf_hair_transmission_setup(ShaderClosure *sc) +ccl_device int bsdf_hair_transmission_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_HAIR_TRANSMISSION_ID; sc->data0 = clamp(sc->data0, 0.001f, 1.0f); @@ -60,7 +60,7 @@ __device int bsdf_hair_transmission_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } -__device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { #ifdef __HAIR__ float offset = sc->offset; @@ -106,18 +106,18 @@ __device float3 bsdf_hair_reflection_eval_reflect(const ShaderClosure *sc, const return make_float3(*pdf, *pdf, *pdf); } -__device float3 bsdf_hair_transmission_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_hair_transmission_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device float3 bsdf_hair_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_hair_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device float3 bsdf_hair_transmission_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_hair_transmission_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { #ifdef __HAIR__ float offset = sc->offset; @@ -163,7 +163,7 @@ __device float3 bsdf_hair_transmission_eval_transmit(const ShaderClosure *sc, co return make_float3(*pdf, *pdf, *pdf); } -__device int bsdf_hair_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_hair_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { #ifdef __HAIR__ float offset = sc->offset; @@ -218,7 +218,7 @@ __device int bsdf_hair_reflection_sample(const ShaderClosure *sc, float3 Ng, flo return LABEL_REFLECT|LABEL_GLOSSY; } -__device int bsdf_hair_transmission_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_hair_transmission_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { #ifdef __HAIR__ float offset = sc->offset; diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h index b159f585831..737cffb0f18 100644 --- a/intern/cycles/kernel/closure/bsdf_microfacet.h +++ b/intern/cycles/kernel/closure/bsdf_microfacet.h @@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN /* GGX */ -__device int bsdf_microfacet_ggx_setup(ShaderClosure *sc) +ccl_device int bsdf_microfacet_ggx_setup(ShaderClosure *sc) { sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ag */ @@ -46,7 +46,7 @@ __device int bsdf_microfacet_ggx_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } -__device int bsdf_microfacet_ggx_refraction_setup(ShaderClosure *sc) +ccl_device int bsdf_microfacet_ggx_refraction_setup(ShaderClosure *sc) { sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ag */ @@ -55,12 +55,12 @@ __device int bsdf_microfacet_ggx_refraction_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } -__device void bsdf_microfacet_ggx_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_microfacet_ggx_blur(ShaderClosure *sc, float roughness) { sc->data0 = fmaxf(roughness, sc->data0); /* m_ag */ } -__device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float m_ag = max(sc->data0, 1e-4f); int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID; @@ -97,7 +97,7 @@ __device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const return make_float3 (0, 0, 0); } -__device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float m_ag = max(sc->data0, 1e-4f); float m_eta = sc->data1; @@ -134,7 +134,7 @@ __device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const return make_float3 (out, out, out); } -__device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float m_ag = sc->data0; int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID; @@ -255,7 +255,7 @@ __device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, floa /* BECKMANN */ -__device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc) +ccl_device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc) { sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ab */ @@ -263,7 +263,7 @@ __device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } -__device int bsdf_microfacet_beckmann_refraction_setup(ShaderClosure *sc) +ccl_device int bsdf_microfacet_beckmann_refraction_setup(ShaderClosure *sc) { sc->data0 = clamp(sc->data0, 0.0f, 1.0f); /* m_ab */ @@ -271,12 +271,12 @@ __device int bsdf_microfacet_beckmann_refraction_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } -__device void bsdf_microfacet_beckmann_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_microfacet_beckmann_blur(ShaderClosure *sc, float roughness) { sc->data0 = fmaxf(roughness, sc->data0); /* m_ab */ } -__device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float m_ab = max(sc->data0, 1e-4f); int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID; @@ -315,7 +315,7 @@ __device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, c return make_float3 (0, 0, 0); } -__device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float m_ab = max(sc->data0, 1e-4f); float m_eta = sc->data1; @@ -354,7 +354,7 @@ __device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc, return make_float3 (out, out, out); } -__device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float m_ab = sc->data0; int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID; diff --git a/intern/cycles/kernel/closure/bsdf_oren_nayar.h b/intern/cycles/kernel/closure/bsdf_oren_nayar.h index c6c6811c007..6f685d5eeea 100644 --- a/intern/cycles/kernel/closure/bsdf_oren_nayar.h +++ b/intern/cycles/kernel/closure/bsdf_oren_nayar.h @@ -19,7 +19,7 @@ CCL_NAMESPACE_BEGIN -__device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 n, float3 v, float3 l) +ccl_device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 n, float3 v, float3 l) { float nl = max(dot(n, l), 0.0f); float nv = max(dot(n, v), 0.0f); @@ -31,7 +31,7 @@ __device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 n, return make_float3(is, is, is); } -__device int bsdf_oren_nayar_setup(ShaderClosure *sc) +ccl_device int bsdf_oren_nayar_setup(ShaderClosure *sc) { float sigma = sc->data0; @@ -47,11 +47,11 @@ __device int bsdf_oren_nayar_setup(ShaderClosure *sc) return SD_BSDF | SD_BSDF_HAS_EVAL; } -__device void bsdf_oren_nayar_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_oren_nayar_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { if (dot(sc->N, omega_in) > 0.0f) { *pdf = 0.5f * M_1_PI_F; @@ -63,12 +63,12 @@ __device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, const floa } } -__device float3 bsdf_oren_nayar_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_oren_nayar_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_oren_nayar_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_oren_nayar_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { sample_uniform_hemisphere(sc->N, randu, randv, omega_in, pdf); diff --git a/intern/cycles/kernel/closure/bsdf_phong_ramp.h b/intern/cycles/kernel/closure/bsdf_phong_ramp.h index 1e332933287..219c5aea159 100644 --- a/intern/cycles/kernel/closure/bsdf_phong_ramp.h +++ b/intern/cycles/kernel/closure/bsdf_phong_ramp.h @@ -35,7 +35,7 @@ CCL_NAMESPACE_BEGIN -__device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos) +ccl_device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3 colors[8], float pos) { int MAXCOLORS = 8; @@ -49,7 +49,7 @@ __device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float3 return colors[ipos] * (1.0f - offset) + colors[ipos+1] * offset; } -__device int bsdf_phong_ramp_setup(ShaderClosure *sc) +ccl_device int bsdf_phong_ramp_setup(ShaderClosure *sc) { sc->data0 = max(sc->data0, 0.0f); @@ -57,11 +57,11 @@ __device int bsdf_phong_ramp_setup(ShaderClosure *sc) return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY; } -__device void bsdf_phong_ramp_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_phong_ramp_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf) { float m_exponent = sc->data0; float cosNI = dot(sc->N, omega_in); @@ -83,12 +83,12 @@ __device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const floa return make_float3(0.0f, 0.0f, 0.0f); } -__device float3 bsdf_phong_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_phong_ramp_eval_transmit(const ShaderClosure *sc, const float3 colors[8], const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_phong_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc, const float3 colors[8], float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float cosNO = dot(sc->N, I); float m_exponent = sc->data0; diff --git a/intern/cycles/kernel/closure/bsdf_reflection.h b/intern/cycles/kernel/closure/bsdf_reflection.h index 7715aac936f..0baccdf155c 100644 --- a/intern/cycles/kernel/closure/bsdf_reflection.h +++ b/intern/cycles/kernel/closure/bsdf_reflection.h @@ -37,27 +37,27 @@ CCL_NAMESPACE_BEGIN /* REFLECTION */ -__device int bsdf_reflection_setup(ShaderClosure *sc) +ccl_device int bsdf_reflection_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_REFLECTION_ID; return SD_BSDF; } -__device void bsdf_reflection_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_reflection_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_reflection_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device float3 bsdf_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_reflection_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_reflection_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float3 N = sc->N; diff --git a/intern/cycles/kernel/closure/bsdf_refraction.h b/intern/cycles/kernel/closure/bsdf_refraction.h index 8565c99d04e..c4698b42060 100644 --- a/intern/cycles/kernel/closure/bsdf_refraction.h +++ b/intern/cycles/kernel/closure/bsdf_refraction.h @@ -37,27 +37,27 @@ CCL_NAMESPACE_BEGIN /* REFRACTION */ -__device int bsdf_refraction_setup(ShaderClosure *sc) +ccl_device int bsdf_refraction_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_REFRACTION_ID; return SD_BSDF; } -__device void bsdf_refraction_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_refraction_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_refraction_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_refraction_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device float3 bsdf_refraction_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_refraction_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float m_eta = sc->data0; float3 N = sc->N; diff --git a/intern/cycles/kernel/closure/bsdf_toon.h b/intern/cycles/kernel/closure/bsdf_toon.h index e69981dba77..797fa4227ae 100644 --- a/intern/cycles/kernel/closure/bsdf_toon.h +++ b/intern/cycles/kernel/closure/bsdf_toon.h @@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN /* DIFFUSE TOON */ -__device int bsdf_diffuse_toon_setup(ShaderClosure *sc) +ccl_device int bsdf_diffuse_toon_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_DIFFUSE_TOON_ID; sc->data0 = clamp(sc->data0, 0.0f, 1.0f); @@ -46,11 +46,11 @@ __device int bsdf_diffuse_toon_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL; } -__device void bsdf_diffuse_toon_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_diffuse_toon_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float angle) +ccl_device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float angle) { float is; @@ -64,12 +64,12 @@ __device float3 bsdf_toon_get_intensity(float max_angle, float smooth, float ang return make_float3(is, is, is); } -__device float bsdf_toon_get_sample_angle(float max_angle, float smooth) +ccl_device float bsdf_toon_get_sample_angle(float max_angle, float smooth) { return fminf(max_angle + smooth, M_PI_2_F); } -__device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float max_angle = sc->data0*M_PI_2_F; float smooth = sc->data1*M_PI_2_F; @@ -87,12 +87,12 @@ __device float3 bsdf_diffuse_toon_eval_reflect(const ShaderClosure *sc, const fl return make_float3(0.0f, 0.0f, 0.0f); } -__device float3 bsdf_diffuse_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_diffuse_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_diffuse_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_diffuse_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float max_angle = sc->data0*M_PI_2_F; float smooth = sc->data1*M_PI_2_F; @@ -121,7 +121,7 @@ __device int bsdf_diffuse_toon_sample(const ShaderClosure *sc, float3 Ng, float3 /* GLOSSY TOON */ -__device int bsdf_glossy_toon_setup(ShaderClosure *sc) +ccl_device int bsdf_glossy_toon_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_GLOSSY_TOON_ID; sc->data0 = clamp(sc->data0, 0.0f, 1.0f); @@ -130,11 +130,11 @@ __device int bsdf_glossy_toon_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL; } -__device void bsdf_glossy_toon_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_glossy_toon_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float max_angle = sc->data0*M_PI_2_F; float smooth = sc->data1*M_PI_2_F; @@ -158,12 +158,12 @@ __device float3 bsdf_glossy_toon_eval_reflect(const ShaderClosure *sc, const flo return make_float3(0.0f, 0.0f, 0.0f); } -__device float3 bsdf_glossy_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_glossy_toon_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_glossy_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_glossy_toon_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float max_angle = sc->data0*M_PI_2_F; float smooth = sc->data1*M_PI_2_F; diff --git a/intern/cycles/kernel/closure/bsdf_transparent.h b/intern/cycles/kernel/closure/bsdf_transparent.h index 81bc7690b50..e62aecf3da6 100644 --- a/intern/cycles/kernel/closure/bsdf_transparent.h +++ b/intern/cycles/kernel/closure/bsdf_transparent.h @@ -35,27 +35,27 @@ CCL_NAMESPACE_BEGIN -__device int bsdf_transparent_setup(ShaderClosure *sc) +ccl_device int bsdf_transparent_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_TRANSPARENT_ID; return SD_BSDF; } -__device void bsdf_transparent_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_transparent_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_transparent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_transparent_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device float3 bsdf_transparent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_transparent_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_transparent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_transparent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { // only one direction is possible *omega_in = -I; diff --git a/intern/cycles/kernel/closure/bsdf_util.h b/intern/cycles/kernel/closure/bsdf_util.h index 5ac26055e8d..f6dceb3ca82 100644 --- a/intern/cycles/kernel/closure/bsdf_util.h +++ b/intern/cycles/kernel/closure/bsdf_util.h @@ -35,7 +35,7 @@ CCL_NAMESPACE_BEGIN -__device float fresnel_dielectric(float eta, const float3 N, +ccl_device float fresnel_dielectric(float eta, const float3 N, const float3 I, float3 *R, float3 *T, #ifdef __RAY_DIFFERENTIALS__ const float3 dIdx, const float3 dIdy, @@ -95,7 +95,7 @@ __device float fresnel_dielectric(float eta, const float3 N, } } -__device float fresnel_dielectric_cos(float cosi, float eta) +ccl_device float fresnel_dielectric_cos(float cosi, float eta) { // compute fresnel reflectance without explicitly computing // the refracted direction @@ -110,7 +110,7 @@ __device float fresnel_dielectric_cos(float cosi, float eta) return 1.0f; // TIR(no refracted component) } -__device float fresnel_conductor(float cosi, float eta, float k) +ccl_device float fresnel_conductor(float cosi, float eta, float k) { float tmp_f = eta * eta + k * k; float tmp = tmp_f * cosi * cosi; @@ -121,7 +121,7 @@ __device float fresnel_conductor(float cosi, float eta, float k) return(Rparl2 + Rperp2) * 0.5f; } -__device float smooth_step(float edge0, float edge1, float x) +ccl_device float smooth_step(float edge0, float edge1, float x) { float result; if(x < edge0) result = 0.0f; diff --git a/intern/cycles/kernel/closure/bsdf_ward.h b/intern/cycles/kernel/closure/bsdf_ward.h index 0e5b0c544c7..c9de615a011 100644 --- a/intern/cycles/kernel/closure/bsdf_ward.h +++ b/intern/cycles/kernel/closure/bsdf_ward.h @@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN /* WARD */ -__device int bsdf_ward_setup(ShaderClosure *sc) +ccl_device int bsdf_ward_setup(ShaderClosure *sc) { sc->data0 = clamp(sc->data0, 1e-4f, 1.0f); /* m_ax */ sc->data1 = clamp(sc->data1, 1e-4f, 1.0f); /* m_ay */ @@ -46,13 +46,13 @@ __device int bsdf_ward_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } -__device void bsdf_ward_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_ward_blur(ShaderClosure *sc, float roughness) { sc->data0 = fmaxf(roughness, sc->data0); /* m_ax */ sc->data1 = fmaxf(roughness, sc->data1); /* m_ay */ } -__device float3 bsdf_ward_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_ward_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float m_ax = sc->data0; float m_ay = sc->data1; @@ -87,12 +87,12 @@ __device float3 bsdf_ward_eval_reflect(const ShaderClosure *sc, const float3 I, return make_float3 (0, 0, 0); } -__device float3 bsdf_ward_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_ward_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_ward_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_ward_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float m_ax = sc->data0; float m_ay = sc->data1; diff --git a/intern/cycles/kernel/closure/bsdf_westin.h b/intern/cycles/kernel/closure/bsdf_westin.h index e1a6b031d5e..ca4c05e91fe 100644 --- a/intern/cycles/kernel/closure/bsdf_westin.h +++ b/intern/cycles/kernel/closure/bsdf_westin.h @@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN /* WESTIN BACKSCATTER */ -__device int bsdf_westin_backscatter_setup(ShaderClosure *sc) +ccl_device int bsdf_westin_backscatter_setup(ShaderClosure *sc) { float roughness = sc->data0; roughness = clamp(roughness, 1e-5f, 1.0f); @@ -49,14 +49,14 @@ __device int bsdf_westin_backscatter_setup(ShaderClosure *sc) return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } -__device void bsdf_westin_backscatter_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_westin_backscatter_blur(ShaderClosure *sc, float roughness) { float m_invroughness = sc->data0; m_invroughness = min(1.0f/roughness, m_invroughness); sc->data0 = m_invroughness; } -__device float3 bsdf_westin_backscatter_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_westin_backscatter_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float m_invroughness = sc->data0; float3 N = sc->N; @@ -73,12 +73,12 @@ __device float3 bsdf_westin_backscatter_eval_reflect(const ShaderClosure *sc, co return make_float3 (0, 0, 0); } -__device float3 bsdf_westin_backscatter_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_westin_backscatter_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_westin_backscatter_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_westin_backscatter_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float m_invroughness = sc->data0; float3 N = sc->N; @@ -116,18 +116,18 @@ __device int bsdf_westin_backscatter_sample(const ShaderClosure *sc, float3 Ng, /* WESTIN SHEEN */ -__device int bsdf_westin_sheen_setup(ShaderClosure *sc) +ccl_device int bsdf_westin_sheen_setup(ShaderClosure *sc) { /* float edginess = sc->data0; */ sc->type = CLOSURE_BSDF_WESTIN_SHEEN_ID; return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } -__device void bsdf_westin_sheen_blur(ShaderClosure *sc, float roughness) +ccl_device void bsdf_westin_sheen_blur(ShaderClosure *sc, float roughness) { } -__device float3 bsdf_westin_sheen_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_westin_sheen_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { float m_edginess = sc->data0; float3 N = sc->N; @@ -144,12 +144,12 @@ __device float3 bsdf_westin_sheen_eval_reflect(const ShaderClosure *sc, const fl return make_float3 (0, 0, 0); } -__device float3 bsdf_westin_sheen_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) +ccl_device float3 bsdf_westin_sheen_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { return make_float3(0.0f, 0.0f, 0.0f); } -__device int bsdf_westin_sheen_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) +ccl_device int bsdf_westin_sheen_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float m_edginess = sc->data0; float3 N = sc->N; diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h index 4ceff655dd5..3849dedc3b6 100644 --- a/intern/cycles/kernel/closure/bssrdf.h +++ b/intern/cycles/kernel/closure/bssrdf.h @@ -19,7 +19,7 @@ CCL_NAMESPACE_BEGIN -__device int bssrdf_setup(ShaderClosure *sc, ClosureType type) +ccl_device int bssrdf_setup(ShaderClosure *sc, ClosureType type) { if(sc->data0 < BSSRDF_MIN_RADIUS) { /* revert to diffuse BSDF if radius too small */ @@ -47,7 +47,7 @@ __device int bssrdf_setup(ShaderClosure *sc, ClosureType type) /* paper suggests 1/12.46 which is much too small, suspect it's *12.46 */ #define GAUSS_TRUNCATE 12.46f -__device float bssrdf_gaussian_eval(ShaderClosure *sc, float r) +ccl_device float bssrdf_gaussian_eval(ShaderClosure *sc, float r) { /* integrate (2*pi*r * exp(-r*r/(2*v)))/(2*pi*v)) from 0 to Rm * = 1 - exp(-Rm*Rm/(2*v)) */ @@ -60,7 +60,7 @@ __device float bssrdf_gaussian_eval(ShaderClosure *sc, float r) return expf(-r*r/(2.0f*v))/(2.0f*M_PI_F*v); } -__device float bssrdf_gaussian_pdf(ShaderClosure *sc, float r) +ccl_device float bssrdf_gaussian_pdf(ShaderClosure *sc, float r) { /* 1.0 - expf(-Rm*Rm/(2*v)) simplified */ const float area_truncated = 1.0f - expf(-0.5f*GAUSS_TRUNCATE); @@ -68,7 +68,7 @@ __device float bssrdf_gaussian_pdf(ShaderClosure *sc, float r) return bssrdf_gaussian_eval(sc, r) * (1.0f/(area_truncated)); } -__device void bssrdf_gaussian_sample(ShaderClosure *sc, float xi, float *r, float *h) +ccl_device void bssrdf_gaussian_sample(ShaderClosure *sc, float xi, float *r, float *h) { /* xi = integrate (2*pi*r * exp(-r*r/(2*v)))/(2*pi*v)) = -exp(-r^2/(2*v)) * r = sqrt(-2*v*logf(xi)) */ @@ -94,7 +94,7 @@ __device void bssrdf_gaussian_sample(ShaderClosure *sc, float xi, float *r, floa * far as I can tell has no closed form solution. So we get an iterative solution * instead with newton-raphson. */ -__device float bssrdf_cubic_eval(ShaderClosure *sc, float r) +ccl_device float bssrdf_cubic_eval(ShaderClosure *sc, float r) { const float sharpness = sc->T.x; @@ -141,13 +141,13 @@ __device float bssrdf_cubic_eval(ShaderClosure *sc, float r) } } -__device float bssrdf_cubic_pdf(ShaderClosure *sc, float r) +ccl_device float bssrdf_cubic_pdf(ShaderClosure *sc, float r) { return bssrdf_cubic_eval(sc, r); } /* solve 10x^2 - 20x^3 + 15x^4 - 4x^5 - xi == 0 */ -__device float bssrdf_cubic_quintic_root_find(float xi) +ccl_device float bssrdf_cubic_quintic_root_find(float xi) { /* newton-raphson iteration, usually succeeds in 2-4 iterations, except * outside 0.02 ... 0.98 where it can go up to 10, so overall performance @@ -174,7 +174,7 @@ __device float bssrdf_cubic_quintic_root_find(float xi) return x; } -__device void bssrdf_cubic_sample(ShaderClosure *sc, float xi, float *r, float *h) +ccl_device void bssrdf_cubic_sample(ShaderClosure *sc, float xi, float *r, float *h) { float Rm = sc->data0; float r_ = bssrdf_cubic_quintic_root_find(xi); @@ -196,13 +196,13 @@ __device void bssrdf_cubic_sample(ShaderClosure *sc, float xi, float *r, float * * * Samples distributed over disk with no falloff, for reference. */ -__device float bssrdf_none_eval(ShaderClosure *sc, float r) +ccl_device float bssrdf_none_eval(ShaderClosure *sc, float r) { const float Rm = sc->data0; return (r < Rm)? 1.0f: 0.0f; } -__device float bssrdf_none_pdf(ShaderClosure *sc, float r) +ccl_device float bssrdf_none_pdf(ShaderClosure *sc, float r) { /* integrate (2*pi*r)/(pi*Rm*Rm) from 0 to Rm = 1 */ const float Rm = sc->data0; @@ -211,7 +211,7 @@ __device float bssrdf_none_pdf(ShaderClosure *sc, float r) return bssrdf_none_eval(sc, r) / area; } -__device void bssrdf_none_sample(ShaderClosure *sc, float xi, float *r, float *h) +ccl_device void bssrdf_none_sample(ShaderClosure *sc, float xi, float *r, float *h) { /* xi = integrate (2*pi*r)/(pi*Rm*Rm) = r^2/Rm^2 * r = sqrt(xi)*Rm */ @@ -226,7 +226,7 @@ __device void bssrdf_none_sample(ShaderClosure *sc, float xi, float *r, float *h /* Generic */ -__device void bssrdf_sample(ShaderClosure *sc, float xi, float *r, float *h) +ccl_device void bssrdf_sample(ShaderClosure *sc, float xi, float *r, float *h) { if(sc->type == CLOSURE_BSSRDF_CUBIC_ID) bssrdf_cubic_sample(sc, xi, r, h); @@ -234,7 +234,7 @@ __device void bssrdf_sample(ShaderClosure *sc, float xi, float *r, float *h) bssrdf_gaussian_sample(sc, xi, r, h); } -__device float bssrdf_pdf(ShaderClosure *sc, float r) +ccl_device float bssrdf_pdf(ShaderClosure *sc, float r) { if(sc->type == CLOSURE_BSSRDF_CUBIC_ID) return bssrdf_cubic_pdf(sc, r); diff --git a/intern/cycles/kernel/closure/emissive.h b/intern/cycles/kernel/closure/emissive.h index 33b1b695a9a..c534df373bd 100644 --- a/intern/cycles/kernel/closure/emissive.h +++ b/intern/cycles/kernel/closure/emissive.h @@ -37,19 +37,19 @@ CCL_NAMESPACE_BEGIN /* return the probability distribution function in the direction I, * given the parameters and the light's surface normal. This MUST match * the PDF computed by sample(). */ -__device float emissive_pdf(const float3 Ng, const float3 I) +ccl_device float emissive_pdf(const float3 Ng, const float3 I) { float cosNO = fabsf(dot(Ng, I)); return (cosNO > 0.0f)? 1.0f: 0.0f; } -__device void emissive_sample(const float3 Ng, float randu, float randv, +ccl_device void emissive_sample(const float3 Ng, float randu, float randv, float3 *omega_out, float *pdf) { /* todo: not implemented and used yet */ } -__device float3 emissive_simple_eval(const float3 Ng, const float3 I) +ccl_device float3 emissive_simple_eval(const float3 Ng, const float3 I) { float res = emissive_pdf(Ng, I); diff --git a/intern/cycles/kernel/closure/volume.h b/intern/cycles/kernel/closure/volume.h index ddaf939984e..f30b30c8c76 100644 --- a/intern/cycles/kernel/closure/volume.h +++ b/intern/cycles/kernel/closure/volume.h @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN /* ISOTROPIC VOLUME CLOSURE */ -__device int volume_isotropic_setup(ShaderClosure *sc, float density) +ccl_device int volume_isotropic_setup(ShaderClosure *sc, float density) { sc->type = CLOSURE_VOLUME_ISOTROPIC_ID; sc->data0 = density; @@ -29,14 +29,14 @@ __device int volume_isotropic_setup(ShaderClosure *sc, float density) return SD_VOLUME; } -__device float3 volume_isotropic_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out) +ccl_device float3 volume_isotropic_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out) { return make_float3(1.0f, 1.0f, 1.0f); } /* TRANSPARENT VOLUME CLOSURE */ -__device int volume_transparent_setup(ShaderClosure *sc, float density) +ccl_device int volume_transparent_setup(ShaderClosure *sc, float density) { sc->type = CLOSURE_VOLUME_TRANSPARENT_ID; sc->data0 = density; @@ -44,14 +44,14 @@ __device int volume_transparent_setup(ShaderClosure *sc, float density) return SD_VOLUME; } -__device float3 volume_transparent_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out) +ccl_device float3 volume_transparent_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out) { return make_float3(1.0f, 1.0f, 1.0f); } /* VOLUME CLOSURE */ -__device float3 volume_eval_phase(KernelGlobals *kg, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out) +ccl_device float3 volume_eval_phase(KernelGlobals *kg, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out) { #ifdef __OSL__ if(kg->osl && sc->prim) diff --git a/intern/cycles/kernel/kernel.cl b/intern/cycles/kernel/kernel.cl index 28e72d78731..6988ad6027f 100644 --- a/intern/cycles/kernel/kernel.cl +++ b/intern/cycles/kernel/kernel.cl @@ -26,12 +26,12 @@ #include "kernel_displace.h" __kernel void kernel_ocl_path_trace( - __constant KernelData *data, - __global float *buffer, - __global uint *rng_state, + ccl_constant KernelData *data, + ccl_global float *buffer, + ccl_global uint *rng_state, #define KERNEL_TEX(type, ttype, name) \ - __global type *name, + ccl_global type *name, #include "kernel_textures.h" int sample, @@ -53,12 +53,12 @@ __kernel void kernel_ocl_path_trace( } __kernel void kernel_ocl_convert_to_byte( - __constant KernelData *data, - __global uchar4 *rgba, - __global float *buffer, + ccl_constant KernelData *data, + ccl_global uchar4 *rgba, + ccl_global float *buffer, #define KERNEL_TEX(type, ttype, name) \ - __global type *name, + ccl_global type *name, #include "kernel_textures.h" float sample_scale, @@ -80,12 +80,12 @@ __kernel void kernel_ocl_convert_to_byte( } __kernel void kernel_ocl_convert_to_half_float( - __constant KernelData *data, - __global uchar4 *rgba, - __global float *buffer, + ccl_constant KernelData *data, + ccl_global uchar4 *rgba, + ccl_global float *buffer, #define KERNEL_TEX(type, ttype, name) \ - __global type *name, + ccl_global type *name, #include "kernel_textures.h" float sample_scale, @@ -107,12 +107,12 @@ __kernel void kernel_ocl_convert_to_half_float( } __kernel void kernel_ocl_shader( - __constant KernelData *data, - __global uint4 *input, - __global float4 *output, + ccl_constant KernelData *data, + ccl_global uint4 *input, + ccl_global float4 *output, #define KERNEL_TEX(type, ttype, name) \ - __global type *name, + ccl_global type *name, #include "kernel_textures.h" int type, int sx, int sw) diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h index d7531be0d8a..f4febd7cf2c 100644 --- a/intern/cycles/kernel/kernel_accumulate.h +++ b/intern/cycles/kernel/kernel_accumulate.h @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN * BSDF evaluation result, split per BSDF type. This is used to accumulate * render passes separately. */ -__device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 value, int use_light_pass) +ccl_device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 value, int use_light_pass) { #ifdef __PASSES__ eval->use_light_pass = use_light_pass; @@ -51,7 +51,7 @@ __device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 val #endif } -__device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 value) +ccl_device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 value) { #ifdef __PASSES__ if(eval->use_light_pass) { @@ -73,7 +73,7 @@ __device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 va #endif } -__device_inline bool bsdf_eval_is_zero(BsdfEval *eval) +ccl_device_inline bool bsdf_eval_is_zero(BsdfEval *eval) { #ifdef __PASSES__ if(eval->use_light_pass) { @@ -90,7 +90,7 @@ __device_inline bool bsdf_eval_is_zero(BsdfEval *eval) #endif } -__device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value) +ccl_device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value) { #ifdef __PASSES__ if(eval->use_light_pass) { @@ -115,7 +115,7 @@ __device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value) * visible as the first non-transparent hit, while indirectly visible are the * bounces after that. */ -__device_inline void path_radiance_init(PathRadiance *L, int use_light_pass) +ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass) { /* clear all */ #ifdef __PASSES__ @@ -159,7 +159,7 @@ __device_inline void path_radiance_init(PathRadiance *L, int use_light_pass) #endif } -__device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughput, +ccl_device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughput, BsdfEval *bsdf_eval, float bsdf_pdf, int bounce, int bsdf_label) { float inverse_pdf = 1.0f/bsdf_pdf; @@ -192,7 +192,7 @@ __device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughp #endif } -__device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throughput, float3 value, int bounce) +ccl_device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throughput, float3 value, int bounce) { #ifdef __PASSES__ if(L->use_light_pass) { @@ -210,7 +210,7 @@ __device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throug #endif } -__device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 alpha, float3 bsdf, float3 ao, int bounce) +ccl_device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 alpha, float3 bsdf, float3 ao, int bounce) { #ifdef __PASSES__ if(L->use_light_pass) { @@ -231,7 +231,7 @@ __device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, #endif } -__device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughput, BsdfEval *bsdf_eval, float3 shadow, float shadow_fac, int bounce, bool is_lamp) +ccl_device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughput, BsdfEval *bsdf_eval, float3 shadow, float shadow_fac, int bounce, bool is_lamp) { #ifdef __PASSES__ if(L->use_light_pass) { @@ -261,7 +261,7 @@ __device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughpu #endif } -__device_inline void path_radiance_accum_background(PathRadiance *L, float3 throughput, float3 value, int bounce) +ccl_device_inline void path_radiance_accum_background(PathRadiance *L, float3 throughput, float3 value, int bounce) { #ifdef __PASSES__ if(L->use_light_pass) { @@ -279,7 +279,7 @@ __device_inline void path_radiance_accum_background(PathRadiance *L, float3 thro #endif } -__device_inline void path_radiance_sum_indirect(PathRadiance *L) +ccl_device_inline void path_radiance_sum_indirect(PathRadiance *L) { #ifdef __PASSES__ /* this division is a bit ugly, but means we only have to keep track of @@ -301,7 +301,7 @@ __device_inline void path_radiance_sum_indirect(PathRadiance *L) #endif } -__device_inline void path_radiance_reset_indirect(PathRadiance *L) +ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L) { #ifdef __PASSES__ if(L->use_light_pass) { @@ -316,7 +316,7 @@ __device_inline void path_radiance_reset_indirect(PathRadiance *L) #endif } -__device_inline float3 path_radiance_sum(KernelGlobals *kg, PathRadiance *L) +ccl_device_inline float3 path_radiance_sum(KernelGlobals *kg, PathRadiance *L) { #ifdef __PASSES__ if(L->use_light_pass) { @@ -338,7 +338,7 @@ __device_inline float3 path_radiance_sum(KernelGlobals *kg, PathRadiance *L) #endif } -__device_inline void path_radiance_clamp(PathRadiance *L, float3 *L_sum, float clamp) +ccl_device_inline void path_radiance_clamp(PathRadiance *L, float3 *L_sum, float clamp) { float sum = fabsf((*L_sum).x) + fabsf((*L_sum).y) + fabsf((*L_sum).z); diff --git a/intern/cycles/kernel/kernel_bvh.h b/intern/cycles/kernel/kernel_bvh.h index 44a9822c103..5aae4111fca 100644 --- a/intern/cycles/kernel/kernel_bvh.h +++ b/intern/cycles/kernel/kernel_bvh.h @@ -42,7 +42,7 @@ CCL_NAMESPACE_BEGIN #define NO_EXTENDED_PRECISION volatile #endif -__device_inline float3 bvh_inverse_direction(float3 dir) +ccl_device_inline float3 bvh_inverse_direction(float3 dir) { /* avoid divide by zero (ooeps = exp2f(-80.0f)) */ float ooeps = 0.00000000000000000000000082718061255302767487140869206996285356581211090087890625f; @@ -55,7 +55,7 @@ __device_inline float3 bvh_inverse_direction(float3 dir) return idir; } -__device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax) +ccl_device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax) { Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM); @@ -72,7 +72,7 @@ __device_inline void bvh_instance_push(KernelGlobals *kg, int object, const Ray *t *= len; } -__device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax) +ccl_device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, const float tmax) { if(*t != FLT_MAX) { Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM); @@ -84,7 +84,7 @@ __device_inline void bvh_instance_pop(KernelGlobals *kg, int object, const Ray * } #ifdef __OBJECT_MOTION__ -__device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax) +ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax) { Transform itfm; *tfm = object_fetch_transform_motion_test(kg, object, ray->time, &itfm); @@ -102,7 +102,7 @@ __device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, con *t *= len; } -__device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax) +ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *idir, float *t, Transform *tfm, const float tmax) { if(*t != FLT_MAX) *t *= len(transform_direction(tfm, 1.0f/(*idir))); @@ -113,7 +113,7 @@ __device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, cons #endif /* Sven Woop's algorithm */ -__device_inline bool bvh_triangle_intersect(KernelGlobals *kg, Intersection *isect, +ccl_device_inline bool bvh_triangle_intersect(KernelGlobals *kg, Intersection *isect, float3 P, float3 idir, uint visibility, int object, int triAddr) { /* compute and check intersection t-value */ @@ -161,7 +161,7 @@ __device_inline bool bvh_triangle_intersect(KernelGlobals *kg, Intersection *ise } #ifdef __HAIR__ -__device_inline void curvebounds(float *lower, float *upper, float *extremta, float *extrema, float *extremtb, float *extremb, float p0, float p1, float p2, float p3) +ccl_device_inline void curvebounds(float *lower, float *upper, float *extremta, float *extrema, float *extremtb, float *extremb, float p0, float p1, float p2, float p3) { float halfdiscroot = (p2 * p2 - 3 * p3 * p1); float ta = -1.0f; @@ -211,7 +211,7 @@ __device_inline void curvebounds(float *lower, float *upper, float *extremta, fl } } -__device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect, +ccl_device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect, float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state, float difl, float extmax) { float epsilon = 0.0f; @@ -520,7 +520,7 @@ __device_inline bool bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio return hit; } -__device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect, +ccl_device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect, float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state, float difl, float extmax) { /* curve Intersection check */ @@ -689,7 +689,7 @@ __device_inline bool bvh_curve_intersect(KernelGlobals *kg, Intersection *isect, * only want to intersect with primitives in the same object, and if case of * multiple hits we pick a single random primitive as the intersection point. */ -__device_inline void bvh_triangle_intersect_subsurface(KernelGlobals *kg, Intersection *isect_array, +ccl_device_inline void bvh_triangle_intersect_subsurface(KernelGlobals *kg, Intersection *isect_array, float3 P, float3 idir, int object, int triAddr, float tmax, uint *num_hits, uint *lcg_state, int max_hits) { /* compute and check intersection t-value */ @@ -811,9 +811,9 @@ __device_inline void bvh_triangle_intersect_subsurface(KernelGlobals *kg, Inters /* to work around titan bug when using arrays instead of textures */ #if !defined(__KERNEL_CUDA__) || defined(__KERNEL_CUDA_TEX_STORAGE__) -__device_inline +ccl_device_inline #else -__device_noinline +ccl_device_noinline #endif #ifdef __HAIR__ bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, Intersection *isect, uint *lcg_state, float difl, float extmax) @@ -859,9 +859,9 @@ bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, I /* to work around titan bug when using arrays instead of textures */ #ifdef __SUBSURFACE__ #if !defined(__KERNEL_CUDA__) || defined(__KERNEL_CUDA_TEX_STORAGE__) -__device_inline +ccl_device_inline #else -__device_noinline +ccl_device_noinline #endif uint scene_intersect_subsurface(KernelGlobals *kg, const Ray *ray, Intersection *isect, int subsurface_object, uint *lcg_state, int max_hits) { @@ -903,7 +903,7 @@ uint scene_intersect_subsurface(KernelGlobals *kg, const Ray *ray, Intersection /* Ray offset to avoid self intersection */ -__device_inline float3 ray_offset(float3 P, float3 Ng) +ccl_device_inline float3 ray_offset(float3 P, float3 Ng) { #ifdef __INTERSECTION_REFINE__ const float epsilon_f = 1e-5f; @@ -955,7 +955,7 @@ __device_inline float3 ray_offset(float3 P, float3 Ng) * far the precision is often not so good, this reintersects the primitive from * a closer distance. */ -__device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray) +ccl_device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray) { float3 P = ray->P; float3 D = ray->D; @@ -1000,7 +1000,7 @@ __device_inline float3 bvh_triangle_refine(KernelGlobals *kg, ShaderData *sd, co } /* same as above, except that isect->t is assumed to be in object space for instancing */ -__device_inline float3 bvh_triangle_refine_subsurface(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray) +ccl_device_inline float3 bvh_triangle_refine_subsurface(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray) { float3 P = ray->P; float3 D = ray->D; @@ -1046,7 +1046,7 @@ __device_inline float3 bvh_triangle_refine_subsurface(KernelGlobals *kg, ShaderD #ifdef __HAIR__ -__device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3) +ccl_device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, float3 p3) { float fc = 0.71f; float data[4]; @@ -1058,7 +1058,7 @@ __device_inline float3 curvetangent(float t, float3 p0, float3 p1, float3 p2, fl return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3; } -__device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3) +ccl_device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, float3 p3) { float data[4]; float fc = 0.71f; @@ -1071,7 +1071,7 @@ __device_inline float3 curvepoint(float t, float3 p0, float3 p1, float3 p2, floa return data[0] * p0 + data[1] * p1 + data[2] * p2 + data[3] * p3; } -__device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray, float t) +ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray, float t) { int flag = kernel_data.curve.curveflags; float3 P = ray->P; diff --git a/intern/cycles/kernel/kernel_bvh_subsurface.h b/intern/cycles/kernel/kernel_bvh_subsurface.h index 4446c1821d5..fb41bdcfa37 100644 --- a/intern/cycles/kernel/kernel_bvh_subsurface.h +++ b/intern/cycles/kernel/kernel_bvh_subsurface.h @@ -28,7 +28,7 @@ #define FEATURE(f) (((BVH_FUNCTION_FEATURES) & (f)) != 0) -__device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersection *isect_array, +ccl_device uint BVH_FUNCTION_NAME(KernelGlobals *kg, const Ray *ray, Intersection *isect_array, int subsurface_object, uint *lcg_state, int max_hits) { /* todo: diff --git a/intern/cycles/kernel/kernel_bvh_traversal.h b/intern/cycles/kernel/kernel_bvh_traversal.h index a9264f318eb..8f69083575b 100644 --- a/intern/cycles/kernel/kernel_bvh_traversal.h +++ b/intern/cycles/kernel/kernel_bvh_traversal.h @@ -30,7 +30,7 @@ #define FEATURE(f) (((BVH_FUNCTION_FEATURES) & (f)) != 0) -__device bool BVH_FUNCTION_NAME +ccl_device bool BVH_FUNCTION_NAME (KernelGlobals *kg, const Ray *ray, Intersection *isect, const uint visibility #if FEATURE(BVH_HAIR_MINIMUM_WIDTH) , uint *lcg_state, float difl, float extmax diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index 966f28df05f..887b1afddd4 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Perspective Camera */ -__device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v) +ccl_device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v) { float blades = kernel_data.cam.blades; @@ -33,7 +33,7 @@ __device float2 camera_sample_aperture(KernelGlobals *kg, float u, float v) } } -__device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray) +ccl_device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray) { /* create ray form raster position */ Transform rastertocamera = kernel_data.cam.rastertocamera; @@ -91,7 +91,7 @@ __device void camera_sample_perspective(KernelGlobals *kg, float raster_x, float /* Orthographic Camera */ -__device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray) +ccl_device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray) { /* create ray form raster position */ Transform rastertocamera = kernel_data.cam.rastertocamera; @@ -147,7 +147,7 @@ __device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, floa /* Panorama Camera */ -__device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray) +ccl_device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray) { Transform rastertocamera = kernel_data.cam.rastertocamera; float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f)); @@ -216,7 +216,7 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra /* Common */ -__device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v, +ccl_device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v, float lens_u, float lens_v, float time, Ray *ray) { /* pixel filter */ @@ -243,13 +243,13 @@ __device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, flo /* Utilities */ -__device_inline float3 camera_position(KernelGlobals *kg) +ccl_device_inline float3 camera_position(KernelGlobals *kg) { Transform cameratoworld = kernel_data.cam.cameratoworld; return make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); } -__device_inline float camera_distance(KernelGlobals *kg, float3 P) +ccl_device_inline float camera_distance(KernelGlobals *kg, float3 P) { Transform cameratoworld = kernel_data.cam.cameratoworld; float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); @@ -262,7 +262,7 @@ __device_inline float camera_distance(KernelGlobals *kg, float3 P) return len(P - camP); } -__device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P) +ccl_device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P) { if(kernel_data.cam.type != CAMERA_PANORAMA) { /* perspective / ortho */ diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h index 44c2b9effe9..76f885aefe0 100644 --- a/intern/cycles/kernel/kernel_compat_cuda.h +++ b/intern/cycles/kernel/kernel_compat_cuda.h @@ -27,13 +27,12 @@ /* Qualifier wrappers for different names on different devices */ -#define __device __device__ __inline__ -#define __device_inline __device__ __inline__ -#define __device_noinline __device__ __noinline__ -#define __global -#define __shared __shared__ -#define __constant -#define __may_alias +#define ccl_device __device__ __inline__ +#define ccl_device_inline __device__ __inline__ +#define ccl_device_noinline __device__ __noinline__ +#define ccl_global +#define ccl_constant +#define ccl_may_alias /* No assert supported for CUDA */ diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h index e0102a01146..1ff3615e448 100644 --- a/intern/cycles/kernel/kernel_compat_opencl.h +++ b/intern/cycles/kernel/kernel_compat_opencl.h @@ -33,16 +33,18 @@ #endif #ifdef __CL_NOINLINE__ -#define __noinline __attribute__((noinline)) +#define ccl_noinline __attribute__((noinline)) #else -#define __noinline +#define ccl_noinline #endif /* in opencl all functions are device functions, so leave this empty */ -#define __device -#define __device_inline __device -#define __device_noinline __device __noinline -#define __may_alias +#define ccl_device +#define ccl_device_inline ccl_device +#define ccl_device_noinline ccl_device ccl_noinline +#define ccl_may_alias +#define ccl_constant __constant +#define ccl_global __global /* no assert in opencl */ #define kernel_assert(cond) diff --git a/intern/cycles/kernel/kernel_curve.h b/intern/cycles/kernel/kernel_curve.h index 9f7a1388a2b..821ac50eaa9 100644 --- a/intern/cycles/kernel/kernel_curve.h +++ b/intern/cycles/kernel/kernel_curve.h @@ -20,7 +20,7 @@ CCL_NAMESPACE_BEGIN /* curve attributes */ -__device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy) +ccl_device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy) { if(elem == ATTR_ELEMENT_CURVE) { #ifdef __RAY_DIFFERENTIALS__ @@ -55,7 +55,7 @@ __device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd, At } } -__device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy) +ccl_device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy) { if(elem == ATTR_ELEMENT_CURVE) { /* idea: we can't derive any useful differentials here, but for tiled @@ -96,7 +96,7 @@ __device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd, /* hair info node functions */ -__device float curve_thickness(KernelGlobals *kg, ShaderData *sd) +ccl_device float curve_thickness(KernelGlobals *kg, ShaderData *sd) { float r = 0.0f; @@ -113,7 +113,7 @@ __device float curve_thickness(KernelGlobals *kg, ShaderData *sd) return r*2.0f; } -__device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd) { float3 tgN = make_float3(0.0f,0.0f,0.0f); diff --git a/intern/cycles/kernel/kernel_differential.h b/intern/cycles/kernel/kernel_differential.h index 71d6e87a4d9..daba2d927b7 100644 --- a/intern/cycles/kernel/kernel_differential.h +++ b/intern/cycles/kernel/kernel_differential.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* See "Tracing Ray Differentials", Homan Igehy, 1999. */ -__device void differential_transfer(differential3 *dP_, const differential3 dP, float3 D, const differential3 dD, float3 Ng, float t) +ccl_device void differential_transfer(differential3 *dP_, const differential3 dP, float3 D, const differential3 dD, float3 Ng, float t) { /* ray differential transfer through homogeneous medium, to * compute dPdx/dy at a shading point from the incoming ray */ @@ -31,7 +31,7 @@ __device void differential_transfer(differential3 *dP_, const differential3 dP, dP_->dy = tmpy - dot(tmpy, Ng)*tmp; } -__device void differential_incoming(differential3 *dI, const differential3 dD) +ccl_device void differential_incoming(differential3 *dI, const differential3 dD) { /* compute dIdx/dy at a shading point, we just need to negate the * differential of the ray direction */ @@ -40,7 +40,7 @@ __device void differential_incoming(differential3 *dI, const differential3 dD) dI->dy = -dD.dy; } -__device void differential_dudv(differential *du, differential *dv, float3 dPdu, float3 dPdv, differential3 dP, float3 Ng) +ccl_device void differential_dudv(differential *du, differential *dv, float3 dPdu, float3 dPdv, differential3 dP, float3 Ng) { /* now we have dPdx/dy from the ray differential transfer, and dPdu/dv * from the primitive, we can compute dudx/dy and dvdx/dy. these are @@ -84,7 +84,7 @@ __device void differential_dudv(differential *du, differential *dv, float3 dPdu, dv->dy = (dP.dy.y*dPdu.x - dP.dy.x*dPdu.y)*det; } -__device differential differential_zero() +ccl_device differential differential_zero() { differential d; d.dx = 0.0f; @@ -93,7 +93,7 @@ __device differential differential_zero() return d; } -__device differential3 differential3_zero() +ccl_device differential3 differential3_zero() { differential3 d; d.dx = make_float3(0.0f, 0.0f, 0.0f); diff --git a/intern/cycles/kernel/kernel_displace.h b/intern/cycles/kernel/kernel_displace.h index 38152b5571e..c50e2166660 100644 --- a/intern/cycles/kernel/kernel_displace.h +++ b/intern/cycles/kernel/kernel_displace.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN -__device void kernel_shader_evaluate(KernelGlobals *kg, __global uint4 *input, __global float4 *output, ShaderEvalType type, int i) +ccl_device void kernel_shader_evaluate(KernelGlobals *kg, ccl_global uint4 *input, ccl_global float4 *output, ShaderEvalType type, int i) { ShaderData sd; uint4 in = input[i]; diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index 0c8d69fb594..2ce0b758972 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Direction Emission */ -__device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando, +ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando, LightSample *ls, float u, float v, float3 I, differential3 dI, float t, float time, int bounce) { /* setup shading at emitter */ @@ -70,7 +70,7 @@ __device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando, return eval; } -__device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex, +ccl_device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex, float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval, bool *is_lamp, int bounce) { @@ -160,7 +160,7 @@ __device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd, int li /* Indirect Primitive Emission */ -__device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf) +ccl_device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderData *sd, float t, int path_flag, float bsdf_pdf) { /* evaluate emissive closure */ float3 L = shader_emissive_eval(kg, sd); @@ -183,7 +183,7 @@ __device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderDa /* Indirect Lamp Emission */ -__device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission, int bounce) +ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, float randt, float3 *emission, int bounce) { LightSample ls; int lamp = lamp_light_eval_sample(kg, randt); @@ -222,7 +222,7 @@ __device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int p /* Indirect Background */ -__device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, int bounce) +ccl_device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf, int bounce) { #ifdef __BACKGROUND__ int shader = kernel_data.background.shader; diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h index 370c550a515..b4118666491 100644 --- a/intern/cycles/kernel/kernel_film.h +++ b/intern/cycles/kernel/kernel_film.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN -__device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale) +ccl_device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale) { float exposure = kernel_data.film.exposure; float4 result = irradiance*scale; @@ -32,7 +32,7 @@ __device float4 film_map(KernelGlobals *kg, float4 irradiance, float scale) return result; } -__device uchar4 film_float_to_byte(float4 color) +ccl_device uchar4 film_float_to_byte(float4 color) { uchar4 result; @@ -45,8 +45,8 @@ __device uchar4 film_float_to_byte(float4 color) return result; } -__device void kernel_film_convert_to_byte(KernelGlobals *kg, - __global uchar4 *rgba, __global float *buffer, +ccl_device void kernel_film_convert_to_byte(KernelGlobals *kg, + ccl_global uchar4 *rgba, ccl_global float *buffer, float sample_scale, int x, int y, int offset, int stride) { /* buffer offset */ @@ -56,22 +56,22 @@ __device void kernel_film_convert_to_byte(KernelGlobals *kg, buffer += index*kernel_data.film.pass_stride; /* map colors */ - float4 irradiance = *((__global float4*)buffer); + float4 irradiance = *((ccl_global float4*)buffer); float4 float_result = film_map(kg, irradiance, sample_scale); uchar4 byte_result = film_float_to_byte(float_result); *rgba = byte_result; } -__device void kernel_film_convert_to_half_float(KernelGlobals *kg, - __global uchar4 *rgba, __global float *buffer, +ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg, + ccl_global uchar4 *rgba, ccl_global float *buffer, float sample_scale, int x, int y, int offset, int stride) { /* buffer offset */ int index = offset + x + y*stride; - __global float4 *in = (__global float4*)(buffer + index*kernel_data.film.pass_stride); - __global half *out = (__global half*)rgba + index*4; + ccl_global float4 *in = (ccl_global float4*)(buffer + index*kernel_data.film.pass_stride); + ccl_global half *out = (ccl_global half*)rgba + index*4; float exposure = kernel_data.film.exposure; diff --git a/intern/cycles/kernel/kernel_globals.h b/intern/cycles/kernel/kernel_globals.h index b5e691eb615..e60bd6c0067 100644 --- a/intern/cycles/kernel/kernel_globals.h +++ b/intern/cycles/kernel/kernel_globals.h @@ -81,10 +81,10 @@ typedef struct KernelGlobals {} KernelGlobals; #ifdef __KERNEL_OPENCL__ typedef struct KernelGlobals { - __constant KernelData *data; + ccl_constant KernelData *data; #define KERNEL_TEX(type, ttype, name) \ - __global type *name; + ccl_global type *name; #include "kernel_textures.h" } KernelGlobals; @@ -92,7 +92,7 @@ typedef struct KernelGlobals { /* Interpolated lookup table access */ -__device float lookup_table_read(KernelGlobals *kg, float x, int offset, int size) +ccl_device float lookup_table_read(KernelGlobals *kg, float x, int offset, int size) { x = clamp(x, 0.0f, 1.0f)*(size-1); @@ -108,7 +108,7 @@ __device float lookup_table_read(KernelGlobals *kg, float x, int offset, int siz return (1.0f - t)*data0 + t*data1; } -__device float lookup_table_read_2D(KernelGlobals *kg, float x, float y, int offset, int xsize, int ysize) +ccl_device float lookup_table_read_2D(KernelGlobals *kg, float x, float y, int offset, int xsize, int ysize) { y = clamp(y, 0.0f, 1.0f)*(ysize-1); diff --git a/intern/cycles/kernel/kernel_jitter.h b/intern/cycles/kernel/kernel_jitter.h index 18666b51c0c..7a850844bf2 100644 --- a/intern/cycles/kernel/kernel_jitter.h +++ b/intern/cycles/kernel/kernel_jitter.h @@ -22,18 +22,18 @@ CCL_NAMESPACE_BEGIN /* todo: find good value, suggested 64 gives pattern on cornell box ceiling */ #define CMJ_RANDOM_OFFSET_LIMIT 4096 -__device_inline bool cmj_is_pow2(int i) +ccl_device_inline bool cmj_is_pow2(int i) { return (i & (i - 1)) == 0; } -__device_inline int cmj_fast_mod_pow2(int a, int b) +ccl_device_inline int cmj_fast_mod_pow2(int a, int b) { return (a & (b - 1)); } /* a must be > 0 and b must be > 1 */ -__device_inline int cmj_fast_div_pow2(int a, int b) +ccl_device_inline int cmj_fast_div_pow2(int a, int b) { #if defined(__KERNEL_SSE2__) && !defined(_MSC_VER) return a >> __builtin_ctz(b); @@ -42,7 +42,7 @@ __device_inline int cmj_fast_div_pow2(int a, int b) #endif } -__device_inline uint cmj_w_mask(uint w) +ccl_device_inline uint cmj_w_mask(uint w) { #if defined(__KERNEL_SSE2__) && !defined(_MSC_VER) return ((1 << (32 - __builtin_clz(w))) - 1); @@ -57,7 +57,7 @@ __device_inline uint cmj_w_mask(uint w) #endif } -__device_inline uint cmj_permute(uint i, uint l, uint p) +ccl_device_inline uint cmj_permute(uint i, uint l, uint p) { uint w = l - 1; @@ -113,7 +113,7 @@ __device_inline uint cmj_permute(uint i, uint l, uint p) } } -__device_inline uint cmj_hash(uint i, uint p) +ccl_device_inline uint cmj_hash(uint i, uint p) { i ^= p; i ^= i >> 17; @@ -129,13 +129,13 @@ __device_inline uint cmj_hash(uint i, uint p) return i; } -__device_inline float cmj_randfloat(uint i, uint p) +ccl_device_inline float cmj_randfloat(uint i, uint p) { return cmj_hash(i, p) * (1.0f / 4294967808.0f); } #ifdef __CMJ__ -__device float cmj_sample_1D(int s, int N, int p) +ccl_device float cmj_sample_1D(int s, int N, int p) { kernel_assert(s < N); @@ -146,7 +146,7 @@ __device float cmj_sample_1D(int s, int N, int p) return (x + jx)*invN; } -__device void cmj_sample_2D(int s, int N, int p, float *fx, float *fy) +ccl_device void cmj_sample_2D(int s, int N, int p, float *fx, float *fy) { kernel_assert(s < N); diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h index 6b00bd2ab01..9915cd2495f 100644 --- a/intern/cycles/kernel/kernel_light.h +++ b/intern/cycles/kernel/kernel_light.h @@ -36,7 +36,7 @@ typedef struct LightSample { #ifdef __BACKGROUND_MIS__ -__device float3 background_light_sample(KernelGlobals *kg, float randu, float randv, float *pdf) +ccl_device float3 background_light_sample(KernelGlobals *kg, float randu, float randv, float *pdf) { /* for the following, the CDF values are actually a pair of floats, with the * function value as X and the actual CDF as Y. The last entry's function @@ -112,7 +112,7 @@ __device float3 background_light_sample(KernelGlobals *kg, float randu, float ra return -equirectangular_to_direction(u, v); } -__device float background_light_pdf(KernelGlobals *kg, float3 direction) +ccl_device float background_light_pdf(KernelGlobals *kg, float3 direction) { float2 uv = direction_to_equirectangular(direction); int res = kernel_data.integrator.pdf_background_res; @@ -146,7 +146,7 @@ __device float background_light_pdf(KernelGlobals *kg, float3 direction) /* Regular Light */ -__device float3 disk_light_sample(float3 v, float randu, float randv) +ccl_device float3 disk_light_sample(float3 v, float randu, float randv) { float3 ru, rv; @@ -156,17 +156,17 @@ __device float3 disk_light_sample(float3 v, float randu, float randv) return ru*randu + rv*randv; } -__device float3 distant_light_sample(float3 D, float radius, float randu, float randv) +ccl_device float3 distant_light_sample(float3 D, float radius, float randu, float randv) { return normalize(D + disk_light_sample(D, randu, randv)*radius); } -__device float3 sphere_light_sample(float3 P, float3 center, float radius, float randu, float randv) +ccl_device float3 sphere_light_sample(float3 P, float3 center, float radius, float randu, float randv) { return disk_light_sample(normalize(P - center), randu, randv)*radius; } -__device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float randv) +ccl_device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float randv) { randu = randu - 0.5f; randv = randv - 0.5f; @@ -174,7 +174,7 @@ __device float3 area_light_sample(float3 axisu, float3 axisv, float randu, float return axisu*randu + axisv*randv; } -__device float spot_light_attenuation(float4 data1, float4 data2, LightSample *ls) +ccl_device float spot_light_attenuation(float4 data1, float4 data2, LightSample *ls) { float3 dir = make_float3(data2.y, data2.z, data2.w); float3 I = ls->Ng; @@ -197,7 +197,7 @@ __device float spot_light_attenuation(float4 data1, float4 data2, LightSample *l return attenuation; } -__device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I, float t) +ccl_device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I, float t) { float cos_pi = dot(Ng, I); @@ -207,7 +207,7 @@ __device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I return t*t/cos_pi; } -__device void lamp_light_sample(KernelGlobals *kg, int lamp, +ccl_device void lamp_light_sample(KernelGlobals *kg, int lamp, float randu, float randv, float3 P, LightSample *ls) { float4 data0 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 0); @@ -298,7 +298,7 @@ __device void lamp_light_sample(KernelGlobals *kg, int lamp, } } -__device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, float t, LightSample *ls) +ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, float t, LightSample *ls) { float4 data0 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 0); float4 data1 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 1); @@ -422,7 +422,7 @@ __device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, f /* Triangle Light */ -__device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls, int object, float time) +ccl_device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls, int object, float time) { #ifdef __INSTANCING__ /* instance transform */ @@ -440,7 +440,7 @@ __device void object_transform_light_sample(KernelGlobals *kg, LightSample *ls, #endif } -__device void triangle_light_sample(KernelGlobals *kg, int prim, int object, +ccl_device void triangle_light_sample(KernelGlobals *kg, int prim, int object, float randu, float randv, float time, LightSample *ls) { /* triangle, so get position, normal, shader */ @@ -457,7 +457,7 @@ __device void triangle_light_sample(KernelGlobals *kg, int prim, int object, object_transform_light_sample(kg, ls, object, time); } -__device float triangle_light_pdf(KernelGlobals *kg, +ccl_device float triangle_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 I, float t) { float pdf = kernel_data.integrator.pdf_triangles; @@ -473,7 +473,7 @@ __device float triangle_light_pdf(KernelGlobals *kg, #ifdef __HAIR__ -__device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object, +ccl_device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object, int segment, float randu, float randv, float time, LightSample *ls) { /* this strand code needs completion */ @@ -515,7 +515,7 @@ __device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object /* Light Distribution */ -__device int light_distribution_sample(KernelGlobals *kg, float randt) +ccl_device int light_distribution_sample(KernelGlobals *kg, float randt) { /* this is basically std::upper_bound as used by pbrt, to find a point light or * triangle to emit from, proportional to area. a good improvement would be to @@ -544,7 +544,7 @@ __device int light_distribution_sample(KernelGlobals *kg, float randt) /* Generic Light */ -__device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls) +ccl_device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls) { /* sample index */ int index = light_distribution_sample(kg, randt); @@ -577,18 +577,18 @@ __device void light_sample(KernelGlobals *kg, float randt, float randu, float ra } } -__device int light_select_num_samples(KernelGlobals *kg, int index) +ccl_device int light_select_num_samples(KernelGlobals *kg, int index) { float4 data3 = kernel_tex_fetch(__light_data, index*LIGHT_SIZE + 3); return __float_as_int(data3.x); } -__device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls) +ccl_device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls) { lamp_light_sample(kg, index, randu, randv, P, ls); } -__device int lamp_light_eval_sample(KernelGlobals *kg, float randt) +ccl_device int lamp_light_eval_sample(KernelGlobals *kg, float randt) { /* sample index */ int index = light_distribution_sample(kg, randt); diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index b3d53e00be7..92f3420a218 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -36,7 +36,7 @@ CCL_NAMESPACE_BEGIN /* distribute uniform xy on [0,1] over unit disk [-1,1] */ -__device void to_unit_disk(float *x, float *y) +ccl_device void to_unit_disk(float *x, float *y) { float phi = M_2PI_F * (*x); float r = sqrtf(*y); @@ -47,14 +47,14 @@ __device void to_unit_disk(float *x, float *y) /* return an orthogonal tangent and bitangent given a normal and tangent that * may not be exactly orthogonal */ -__device void make_orthonormals_tangent(const float3 N, const float3 T, float3 *a, float3 *b) +ccl_device void make_orthonormals_tangent(const float3 N, const float3 T, float3 *a, float3 *b) { *b = normalize(cross(N, T)); *a = cross(*b, N); } /* sample direction with cosine weighted distributed in hemisphere */ -__device_inline void sample_cos_hemisphere(const float3 N, +ccl_device_inline void sample_cos_hemisphere(const float3 N, float randu, float randv, float3 *omega_in, float *pdf) { to_unit_disk(&randu, &randv); @@ -66,7 +66,7 @@ __device_inline void sample_cos_hemisphere(const float3 N, } /* sample direction uniformly distributed in hemisphere */ -__device_inline void sample_uniform_hemisphere(const float3 N, +ccl_device_inline void sample_uniform_hemisphere(const float3 N, float randu, float randv, float3 *omega_in, float *pdf) { @@ -83,7 +83,7 @@ __device_inline void sample_uniform_hemisphere(const float3 N, } /* sample direction uniformly distributed in cone */ -__device_inline void sample_uniform_cone(const float3 N, float angle, +ccl_device_inline void sample_uniform_cone(const float3 N, float angle, float randu, float randv, float3 *omega_in, float *pdf) { @@ -100,7 +100,7 @@ __device_inline void sample_uniform_cone(const float3 N, float angle, } /* sample uniform point on the surface of a sphere */ -__device float3 sample_uniform_sphere(float u1, float u2) +ccl_device float3 sample_uniform_sphere(float u1, float u2) { float z = 1.0f - 2.0f*u1; float r = sqrtf(fmaxf(0.0f, 1.0f - z*z)); @@ -111,29 +111,29 @@ __device float3 sample_uniform_sphere(float u1, float u2) return make_float3(x, y, z); } -__device float balance_heuristic(float a, float b) +ccl_device float balance_heuristic(float a, float b) { return (a)/(a + b); } -__device float balance_heuristic_3(float a, float b, float c) +ccl_device float balance_heuristic_3(float a, float b, float c) { return (a)/(a + b + c); } -__device float power_heuristic(float a, float b) +ccl_device float power_heuristic(float a, float b) { return (a*a)/(a*a + b*b); } -__device float power_heuristic_3(float a, float b, float c) +ccl_device float power_heuristic_3(float a, float b, float c) { return (a*a)/(a*a + b*b + c*c); } /* distribute uniform xy on [0,1] over unit disk [-1,1], with concentric mapping * to better preserve stratification for some RNG sequences */ -__device float2 concentric_sample_disk(float u1, float u2) +ccl_device float2 concentric_sample_disk(float u1, float u2) { float phi, r; float a = 2.0f*u1 - 1.0f; @@ -155,7 +155,7 @@ __device float2 concentric_sample_disk(float u1, float u2) } /* sample point in unit polygon with given number of corners and rotation */ -__device float2 regular_polygon_sample(float corners, float rotation, float u, float v) +ccl_device float2 regular_polygon_sample(float corners, float rotation, float u, float v) { /* sample corner number and reuse u */ float corner = floorf(u*corners); diff --git a/intern/cycles/kernel/kernel_object.h b/intern/cycles/kernel/kernel_object.h index d0aae119476..a66277e10cd 100644 --- a/intern/cycles/kernel/kernel_object.h +++ b/intern/cycles/kernel/kernel_object.h @@ -30,7 +30,7 @@ enum ObjectVectorTransform { OBJECT_VECTOR_MOTION_POST = 3 }; -__device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, enum ObjectTransform type) +ccl_device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, enum ObjectTransform type) { int offset = object*OBJECT_SIZE + (int)type; @@ -43,7 +43,7 @@ __device_inline Transform object_fetch_transform(KernelGlobals *kg, int object, return tfm; } -__device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, int object, enum ObjectVectorTransform type) +ccl_device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, int object, enum ObjectVectorTransform type) { int offset = object*OBJECT_VECTOR_SIZE + (int)type; @@ -57,7 +57,7 @@ __device_inline Transform object_fetch_vector_transform(KernelGlobals *kg, int o } #ifdef __OBJECT_MOTION__ -__device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int object, float time) +ccl_device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int object, float time) { DecompMotionTransform motion; @@ -79,7 +79,7 @@ __device_inline Transform object_fetch_transform_motion(KernelGlobals *kg, int o return tfm; } -__device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg, int object, float time, Transform *itfm) +ccl_device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg, int object, float time, Transform *itfm) { int object_flag = kernel_tex_fetch(__object_flag, object); @@ -102,7 +102,7 @@ __device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg, } #endif -__device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P) +ccl_device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P) { #ifdef __OBJECT_MOTION__ *P = transform_point(&sd->ob_tfm, *P); @@ -112,7 +112,7 @@ __device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd #endif } -__device_inline void object_inverse_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P) +ccl_device_inline void object_inverse_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P) { #ifdef __OBJECT_MOTION__ *P = transform_point(&sd->ob_itfm, *P); @@ -122,7 +122,7 @@ __device_inline void object_inverse_position_transform(KernelGlobals *kg, Shader #endif } -__device_inline void object_inverse_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N) +ccl_device_inline void object_inverse_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N) { #ifdef __OBJECT_MOTION__ *N = normalize(transform_direction_transposed(&sd->ob_tfm, *N)); @@ -132,7 +132,7 @@ __device_inline void object_inverse_normal_transform(KernelGlobals *kg, ShaderDa #endif } -__device_inline void object_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N) +ccl_device_inline void object_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N) { #ifdef __OBJECT_MOTION__ *N = normalize(transform_direction_transposed(&sd->ob_itfm, *N)); @@ -142,7 +142,7 @@ __device_inline void object_normal_transform(KernelGlobals *kg, ShaderData *sd, #endif } -__device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D) +ccl_device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D) { #ifdef __OBJECT_MOTION__ *D = transform_direction(&sd->ob_tfm, *D); @@ -152,7 +152,7 @@ __device_inline void object_dir_transform(KernelGlobals *kg, ShaderData *sd, flo #endif } -__device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D) +ccl_device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData *sd, float3 *D) { #ifdef __OBJECT_MOTION__ *D = transform_direction(&sd->ob_itfm, *D); @@ -162,7 +162,7 @@ __device_inline void object_inverse_dir_transform(KernelGlobals *kg, ShaderData #endif } -__device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd) +ccl_device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd) { if(sd->object == ~0) return make_float3(0.0f, 0.0f, 0.0f); @@ -175,14 +175,14 @@ __device_inline float3 object_location(KernelGlobals *kg, ShaderData *sd) #endif } -__device_inline float object_surface_area(KernelGlobals *kg, int object) +ccl_device_inline float object_surface_area(KernelGlobals *kg, int object) { int offset = object*OBJECT_SIZE + OBJECT_PROPERTIES; float4 f = kernel_tex_fetch(__objects, offset); return f.x; } -__device_inline float object_pass_id(KernelGlobals *kg, int object) +ccl_device_inline float object_pass_id(KernelGlobals *kg, int object) { if(object == ~0) return 0.0f; @@ -192,7 +192,7 @@ __device_inline float object_pass_id(KernelGlobals *kg, int object) return f.y; } -__device_inline float object_random_number(KernelGlobals *kg, int object) +ccl_device_inline float object_random_number(KernelGlobals *kg, int object) { if(object == ~0) return 0.0f; @@ -202,7 +202,7 @@ __device_inline float object_random_number(KernelGlobals *kg, int object) return f.z; } -__device_inline uint object_particle_id(KernelGlobals *kg, int object) +ccl_device_inline uint object_particle_id(KernelGlobals *kg, int object) { if(object == ~0) return 0.0f; @@ -212,7 +212,7 @@ __device_inline uint object_particle_id(KernelGlobals *kg, int object) return __float_as_uint(f.w); } -__device_inline float3 object_dupli_generated(KernelGlobals *kg, int object) +ccl_device_inline float3 object_dupli_generated(KernelGlobals *kg, int object) { if(object == ~0) return make_float3(0.0f, 0.0f, 0.0f); @@ -222,7 +222,7 @@ __device_inline float3 object_dupli_generated(KernelGlobals *kg, int object) return make_float3(f.x, f.y, f.z); } -__device_inline float3 object_dupli_uv(KernelGlobals *kg, int object) +ccl_device_inline float3 object_dupli_uv(KernelGlobals *kg, int object) { if(object == ~0) return make_float3(0.0f, 0.0f, 0.0f); @@ -233,54 +233,54 @@ __device_inline float3 object_dupli_uv(KernelGlobals *kg, int object) } -__device int shader_pass_id(KernelGlobals *kg, ShaderData *sd) +ccl_device int shader_pass_id(KernelGlobals *kg, ShaderData *sd) { return kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2 + 1); } -__device_inline float particle_index(KernelGlobals *kg, int particle) +ccl_device_inline float particle_index(KernelGlobals *kg, int particle) { int offset = particle*PARTICLE_SIZE; float4 f = kernel_tex_fetch(__particles, offset + 0); return f.x; } -__device float particle_age(KernelGlobals *kg, int particle) +ccl_device float particle_age(KernelGlobals *kg, int particle) { int offset = particle*PARTICLE_SIZE; float4 f = kernel_tex_fetch(__particles, offset + 0); return f.y; } -__device float particle_lifetime(KernelGlobals *kg, int particle) +ccl_device float particle_lifetime(KernelGlobals *kg, int particle) { int offset = particle*PARTICLE_SIZE; float4 f = kernel_tex_fetch(__particles, offset + 0); return f.z; } -__device float particle_size(KernelGlobals *kg, int particle) +ccl_device float particle_size(KernelGlobals *kg, int particle) { int offset = particle*PARTICLE_SIZE; float4 f = kernel_tex_fetch(__particles, offset + 0); return f.w; } -__device float4 particle_rotation(KernelGlobals *kg, int particle) +ccl_device float4 particle_rotation(KernelGlobals *kg, int particle) { int offset = particle*PARTICLE_SIZE; float4 f = kernel_tex_fetch(__particles, offset + 1); return f; } -__device float3 particle_location(KernelGlobals *kg, int particle) +ccl_device float3 particle_location(KernelGlobals *kg, int particle) { int offset = particle*PARTICLE_SIZE; float4 f = kernel_tex_fetch(__particles, offset + 2); return make_float3(f.x, f.y, f.z); } -__device float3 particle_velocity(KernelGlobals *kg, int particle) +ccl_device float3 particle_velocity(KernelGlobals *kg, int particle) { int offset = particle*PARTICLE_SIZE; float4 f2 = kernel_tex_fetch(__particles, offset + 2); @@ -288,7 +288,7 @@ __device float3 particle_velocity(KernelGlobals *kg, int particle) return make_float3(f2.w, f3.x, f3.y); } -__device float3 particle_angular_velocity(KernelGlobals *kg, int particle) +ccl_device float3 particle_angular_velocity(KernelGlobals *kg, int particle) { int offset = particle*PARTICLE_SIZE; float4 f3 = kernel_tex_fetch(__particles, offset + 3); diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h index 5e91b13f90c..512db9ec392 100644 --- a/intern/cycles/kernel/kernel_passes.h +++ b/intern/cycles/kernel/kernel_passes.h @@ -16,25 +16,25 @@ CCL_NAMESPACE_BEGIN -__device_inline void kernel_write_pass_float(__global float *buffer, int sample, float value) +ccl_device_inline void kernel_write_pass_float(ccl_global float *buffer, int sample, float value) { - __global float *buf = buffer; + ccl_global float *buf = buffer; *buf = (sample == 0)? value: *buf + value; } -__device_inline void kernel_write_pass_float3(__global float *buffer, int sample, float3 value) +ccl_device_inline void kernel_write_pass_float3(ccl_global float *buffer, int sample, float3 value) { - __global float3 *buf = (__global float3*)buffer; + ccl_global float3 *buf = (ccl_global float3*)buffer; *buf = (sample == 0)? value: *buf + value; } -__device_inline void kernel_write_pass_float4(__global float *buffer, int sample, float4 value) +ccl_device_inline void kernel_write_pass_float4(ccl_global float *buffer, int sample, float4 value) { - __global float4 *buf = (__global float4*)buffer; + ccl_global float4 *buf = (ccl_global float4*)buffer; *buf = (sample == 0)? value: *buf + value; } -__device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, +ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L, ShaderData *sd, int sample, int path_flag, float3 throughput) { #ifdef __PASSES__ @@ -114,7 +114,7 @@ __device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float #endif } -__device_inline void kernel_write_light_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, int sample) +ccl_device_inline void kernel_write_light_passes(KernelGlobals *kg, ccl_global float *buffer, PathRadiance *L, int sample) { #ifdef __PASSES__ int flag = kernel_data.film.pass_flag; diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 5354738d378..4f3957b66ef 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -42,7 +42,7 @@ CCL_NAMESPACE_BEGIN -__device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, float3 *shadow) +ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, float3 *shadow) { *shadow = make_float3(1.0f, 1.0f, 1.0f); @@ -122,7 +122,7 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra #if defined(__BRANCHED_PATH__) || defined(__SUBSURFACE__) -__device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer, +ccl_device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer, float3 throughput, int num_samples, int num_total_samples, float min_ray_pdf, float ray_pdf, PathState state, int rng_offset, PathRadiance *L) { @@ -359,7 +359,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray #ifdef __SUBSURFACE__ -__device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rng, +ccl_device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rng, int sample, int num_samples, ShaderData *sd, float3 *throughput, float *min_ray_pdf, float *ray_pdf, PathState *state, @@ -452,7 +452,7 @@ __device_inline bool kernel_path_integrate_lighting(KernelGlobals *kg, RNG *rng, #endif -__device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer) +ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer) { /* initialize */ PathRadiance L; @@ -790,11 +790,11 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R #ifdef __BRANCHED_PATH__ -__device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg, RNG *rng, +ccl_device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg, RNG *rng, int sample, int aa_samples, ShaderData *sd, float3 throughput, float num_samples_adjust, float min_ray_pdf, float ray_pdf, PathState state, - int rng_offset, PathRadiance *L, __global float *buffer) + int rng_offset, PathRadiance *L, ccl_global float *buffer) { #ifdef __EMISSION__ /* sample illumination from lights to find path contribution */ @@ -941,7 +941,7 @@ __device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg } } -__device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer) +ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer) { /* initialize */ PathRadiance L; @@ -1166,7 +1166,7 @@ __device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int #endif -__device_inline void kernel_path_trace_setup(KernelGlobals *kg, __global uint *rng_state, int sample, int x, int y, RNG *rng, Ray *ray) +ccl_device_inline void kernel_path_trace_setup(KernelGlobals *kg, ccl_global uint *rng_state, int sample, int x, int y, RNG *rng, Ray *ray) { float filter_u; float filter_v; @@ -1195,8 +1195,8 @@ __device_inline void kernel_path_trace_setup(KernelGlobals *kg, __global uint *r camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, ray); } -__device void kernel_path_trace(KernelGlobals *kg, - __global float *buffer, __global uint *rng_state, +ccl_device void kernel_path_trace(KernelGlobals *kg, + ccl_global float *buffer, ccl_global uint *rng_state, int sample, int x, int y, int offset, int stride) { /* buffer offset */ @@ -1227,8 +1227,8 @@ __device void kernel_path_trace(KernelGlobals *kg, } #ifdef __BRANCHED_PATH__ -__device void kernel_branched_path_trace(KernelGlobals *kg, - __global float *buffer, __global uint *rng_state, +ccl_device void kernel_branched_path_trace(KernelGlobals *kg, + ccl_global float *buffer, ccl_global uint *rng_state, int sample, int x, int y, int offset, int stride) { /* buffer offset */ diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h index e0e0f43fd26..0ded332b3b9 100644 --- a/intern/cycles/kernel/kernel_path_state.h +++ b/intern/cycles/kernel/kernel_path_state.h @@ -26,7 +26,7 @@ typedef struct PathState { int transparent_bounce; } PathState; -__device_inline void path_state_init(PathState *state) +ccl_device_inline void path_state_init(PathState *state) { state->flag = PATH_RAY_CAMERA|PATH_RAY_SINGULAR|PATH_RAY_MIS_SKIP; state->bounce = 0; @@ -36,7 +36,7 @@ __device_inline void path_state_init(PathState *state) state->transparent_bounce = 0; } -__device_inline void path_state_next(KernelGlobals *kg, PathState *state, int label) +ccl_device_inline void path_state_next(KernelGlobals *kg, PathState *state, int label) { /* ray through transparent keeps same flags from previous ray and is * not counted as a regular bounce, transparent has separate max */ @@ -88,7 +88,7 @@ __device_inline void path_state_next(KernelGlobals *kg, PathState *state, int la } } -__device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state) +ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *state) { uint flag = state->flag & PATH_RAY_ALL_VISIBILITY; @@ -102,7 +102,7 @@ __device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *sta return flag; } -__device_inline float path_state_terminate_probability(KernelGlobals *kg, PathState *state, const float3 throughput) +ccl_device_inline float path_state_terminate_probability(KernelGlobals *kg, PathState *state, const float3 throughput) { if(state->flag & PATH_RAY_TRANSPARENT) { /* transparent rays treated separately */ diff --git a/intern/cycles/kernel/kernel_primitive.h b/intern/cycles/kernel/kernel_primitive.h index 636cfd06532..ababad28f35 100644 --- a/intern/cycles/kernel/kernel_primitive.h +++ b/intern/cycles/kernel/kernel_primitive.h @@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN /* attribute lookup */ -__device_inline int find_attribute(KernelGlobals *kg, ShaderData *sd, uint id, AttributeElement *elem) +ccl_device_inline int find_attribute(KernelGlobals *kg, ShaderData *sd, uint id, AttributeElement *elem) { if(sd->object == ~0) return (int)ATTR_STD_NOT_FOUND; @@ -52,7 +52,7 @@ __device_inline int find_attribute(KernelGlobals *kg, ShaderData *sd, uint id, A } } -__device float primitive_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy) +ccl_device float primitive_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy) { #ifdef __HAIR__ if(sd->segment == ~0) @@ -64,7 +64,7 @@ __device float primitive_attribute_float(KernelGlobals *kg, const ShaderData *sd #endif } -__device float3 primitive_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy) +ccl_device float3 primitive_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy) { #ifdef __HAIR__ if(sd->segment == ~0) @@ -76,7 +76,7 @@ __device float3 primitive_attribute_float3(KernelGlobals *kg, const ShaderData * #endif } -__device float3 primitive_uv(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 primitive_uv(KernelGlobals *kg, ShaderData *sd) { AttributeElement elem_uv; int offset_uv = find_attribute(kg, sd, ATTR_STD_UV, &elem_uv); @@ -89,7 +89,7 @@ __device float3 primitive_uv(KernelGlobals *kg, ShaderData *sd) return uv; } -__device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd) { #ifdef __HAIR__ if(sd->segment != ~0) @@ -122,7 +122,7 @@ __device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd) /* motion */ -__device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd) +ccl_device float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *sd) { float3 motion_pre = sd->P, motion_post = sd->P; diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h index d9520de7956..e2108604bc8 100644 --- a/intern/cycles/kernel/kernel_projection.h +++ b/intern/cycles/kernel/kernel_projection.h @@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN /* Spherical coordinates <-> Cartesian direction */ -__device float2 direction_to_spherical(float3 dir) +ccl_device float2 direction_to_spherical(float3 dir) { float theta = acosf(dir.z); float phi = atan2f(dir.x, dir.y); @@ -45,7 +45,7 @@ __device float2 direction_to_spherical(float3 dir) return make_float2(theta, phi); } -__device float3 spherical_to_direction(float theta, float phi) +ccl_device float3 spherical_to_direction(float theta, float phi) { return make_float3( sinf(theta)*cosf(phi), @@ -55,7 +55,7 @@ __device float3 spherical_to_direction(float theta, float phi) /* Equirectangular coordinates <-> Cartesian direction */ -__device float2 direction_to_equirectangular(float3 dir) +ccl_device float2 direction_to_equirectangular(float3 dir) { float u = -atan2f(dir.y, dir.x)/(M_2PI_F) + 0.5f; float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f; @@ -63,7 +63,7 @@ __device float2 direction_to_equirectangular(float3 dir) return make_float2(u, v); } -__device float3 equirectangular_to_direction(float u, float v) +ccl_device float3 equirectangular_to_direction(float u, float v) { float phi = M_PI_F*(1.0f - 2.0f*u); float theta = M_PI_F*(1.0f - v); @@ -76,7 +76,7 @@ __device float3 equirectangular_to_direction(float u, float v) /* Fisheye <-> Cartesian direction */ -__device float2 direction_to_fisheye(float3 dir, float fov) +ccl_device float2 direction_to_fisheye(float3 dir, float fov) { float r = atan2f(sqrtf(dir.y*dir.y + dir.z*dir.z), dir.x) / fov; float phi = atan2f(dir.z, dir.y); @@ -87,7 +87,7 @@ __device float2 direction_to_fisheye(float3 dir, float fov) return make_float2(u, v); } -__device float3 fisheye_to_direction(float u, float v, float fov) +ccl_device float3 fisheye_to_direction(float u, float v, float fov) { u = (u - 0.5f) * 2.0f; v = (v - 0.5f) * 2.0f; @@ -109,7 +109,7 @@ __device float3 fisheye_to_direction(float u, float v, float fov) ); } -__device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height) +ccl_device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height) { float theta = acosf(dir.x); float r = 2.0f * lens * sinf(theta * 0.5f); @@ -121,7 +121,7 @@ __device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float wid return make_float2(u, v); } -__device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height) +ccl_device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height) { u = (u - 0.5f) * width; v = (v - 0.5f) * height; @@ -146,7 +146,7 @@ __device float3 fisheye_equisolid_to_direction(float u, float v, float lens, flo /* Mirror Ball <-> Cartesion direction */ -__device float3 mirrorball_to_direction(float u, float v) +ccl_device float3 mirrorball_to_direction(float u, float v) { /* point on sphere */ float3 dir; @@ -161,7 +161,7 @@ __device float3 mirrorball_to_direction(float u, float v) return 2.0f*dot(dir, I)*dir - I; } -__device float2 direction_to_mirrorball(float3 dir) +ccl_device float2 direction_to_mirrorball(float3 dir) { /* inverse of mirrorball_to_direction */ dir.y -= 1.0f; @@ -176,7 +176,7 @@ __device float2 direction_to_mirrorball(float3 dir) return make_float2(u, v); } -__device float3 panorama_to_direction(KernelGlobals *kg, float u, float v) +ccl_device float3 panorama_to_direction(KernelGlobals *kg, float u, float v) { switch(kernel_data.cam.panorama_type) { case PANORAMA_EQUIRECTANGULAR: @@ -190,7 +190,7 @@ __device float3 panorama_to_direction(KernelGlobals *kg, float u, float v) } } -__device float2 direction_to_panorama(KernelGlobals *kg, float3 dir) +ccl_device float2 direction_to_panorama(KernelGlobals *kg, float3 dir) { switch(kernel_data.cam.panorama_type) { case PANORAMA_EQUIRECTANGULAR: diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h index dc977a8780f..69e7b439e1c 100644 --- a/intern/cycles/kernel/kernel_random.h +++ b/intern/cycles/kernel/kernel_random.h @@ -30,7 +30,7 @@ typedef uint RNG; /* High Dimensional Sobol */ /* van der corput radical inverse */ -__device uint van_der_corput(uint bits) +ccl_device uint van_der_corput(uint bits) { bits = (bits << 16) | (bits >> 16); bits = ((bits & 0x00ff00ff) << 8) | ((bits & 0xff00ff00) >> 8); @@ -41,7 +41,7 @@ __device uint van_der_corput(uint bits) } /* sobol radical inverse */ -__device uint sobol(uint i) +ccl_device uint sobol(uint i) { uint r = 0; @@ -53,7 +53,7 @@ __device uint sobol(uint i) } /* inverse of sobol radical inverse */ -__device uint sobol_inverse(uint i) +ccl_device uint sobol_inverse(uint i) { const uint msb = 1U << 31; uint r = 0; @@ -67,7 +67,7 @@ __device uint sobol_inverse(uint i) /* multidimensional sobol with generator matrices * dimension 0 and 1 are equal to van_der_corput() and sobol() respectively */ -__device uint sobol_dimension(KernelGlobals *kg, int index, int dimension) +ccl_device uint sobol_dimension(KernelGlobals *kg, int index, int dimension) { uint result = 0; uint i = index; @@ -80,7 +80,7 @@ __device uint sobol_dimension(KernelGlobals *kg, int index, int dimension) } /* lookup index and x/y coordinate, assumes m is a power of two */ -__device uint sobol_lookup(const uint m, const uint frame, const uint ex, const uint ey, uint *x, uint *y) +ccl_device uint sobol_lookup(const uint m, const uint frame, const uint ex, const uint ey, uint *x, uint *y) { /* shift is constant per frame */ const uint shift = frame << (m << 1); @@ -100,7 +100,7 @@ __device uint sobol_lookup(const uint m, const uint frame, const uint ex, const return index; } -__device_inline float path_rng_1D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension) +ccl_device_inline float path_rng_1D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension) { #ifdef __CMJ__ if(kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ) { @@ -131,7 +131,7 @@ __device_inline float path_rng_1D(KernelGlobals *kg, RNG *rng, int sample, int n #endif } -__device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension, float *fx, float *fy) +ccl_device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int num_samples, int dimension, float *fx, float *fy) { #ifdef __CMJ__ if(kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ) { @@ -148,7 +148,7 @@ __device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int nu } } -__device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy) +ccl_device_inline void path_rng_init(KernelGlobals *kg, ccl_global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy) { #ifdef __SOBOL_FULL_SCREEN__ uint px, py; @@ -183,7 +183,7 @@ __device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state, #endif } -__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng) +ccl_device void path_rng_end(KernelGlobals *kg, ccl_global uint *rng_state, RNG rng) { /* nothing to do */ } @@ -192,24 +192,24 @@ __device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng) /* Linear Congruential Generator */ -__device float path_rng(KernelGlobals *kg, RNG& rng, int sample, int dimension) +ccl_device float path_rng(KernelGlobals *kg, RNG& rng, int sample, int dimension) { } -__device_inline float path_rng_1D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension) +ccl_device_inline float path_rng_1D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension) { /* implicit mod 2^32 */ rng = (1103515245*(rng) + 12345); return (float)rng * (1.0f/(float)0xFFFFFFFF); } -__device_inline void path_rng_2D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension, float *fx, float *fy) +ccl_device_inline void path_rng_2D(KernelGlobals *kg, RNG& rng, int sample, int num_samples, int dimension, float *fx, float *fy) { *fx = path_rng_1D(kg, rng, sample, num_samples, dimension); *fy = path_rng_1D(kg, rng, sample, num_samples, dimension + 1); } -__device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy) +ccl_device void path_rng_init(KernelGlobals *kg, ccl_global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy) { /* load state */ *rng = *rng_state; @@ -225,7 +225,7 @@ __device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sam } } -__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng) +ccl_device void path_rng_end(KernelGlobals *kg, ccl_global uint *rng_state, RNG rng) { /* store state for next sample */ *rng_state = rng; @@ -233,21 +233,21 @@ __device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng) #endif -__device uint lcg_step_uint(uint *rng) +ccl_device uint lcg_step_uint(uint *rng) { /* implicit mod 2^32 */ *rng = (1103515245*(*rng) + 12345); return *rng; } -__device float lcg_step_float(uint *rng) +ccl_device float lcg_step_float(uint *rng) { /* implicit mod 2^32 */ *rng = (1103515245*(*rng) + 12345); return (float)*rng * (1.0f/(float)0xFFFFFFFF); } -__device uint lcg_init(uint seed) +ccl_device uint lcg_init(uint seed) { uint rng = seed; lcg_step_uint(&rng); diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index 81630caed9a..77154ce3aef 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -36,7 +36,7 @@ CCL_NAMESPACE_BEGIN /* ShaderData setup from incoming ray */ #ifdef __OBJECT_MOTION__ -__device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd, float time) +ccl_device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd, float time) { if(sd->flag & SD_OBJECT_MOTION) { sd->ob_tfm = object_fetch_transform_motion(kg, sd->object, time); @@ -49,7 +49,7 @@ __device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd, } #endif -__device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd, +ccl_device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray, int bounce) { #ifdef __INSTANCING__ @@ -161,7 +161,7 @@ __device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd, /* ShaderData setup from BSSRDF scatter */ #ifdef __SUBSURFACE__ -__device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderData *sd, +ccl_device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray) { bool backfacing = sd->flag & SD_BACKFACING; @@ -237,7 +237,7 @@ __device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderData /* ShaderData setup from position sampled on mesh */ -__device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, +ccl_device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, const float3 P, const float3 Ng, const float3 I, int shader, int object, int prim, float u, float v, float t, float time, int bounce, int segment) { @@ -357,7 +357,7 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, /* ShaderData setup for displacement */ -__device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd, +ccl_device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd, int object, int prim, float u, float v) { float3 P, Ng, I = make_float3(0.0f, 0.0f, 0.0f); @@ -376,7 +376,7 @@ __device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd, /* ShaderData setup from ray into background */ -__device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce) +ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray, int bounce) { /* vectors */ sd->P = ray->D; @@ -426,7 +426,7 @@ __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData #ifdef __MULTI_CLOSURE__ -__device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderData *sd, const float3 omega_in, float *pdf, +ccl_device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderData *sd, const float3 omega_in, float *pdf, int skip_bsdf, BsdfEval *result_eval, float sum_pdf, float sum_sample_weight) { /* this is the veach one-sample model with balance heuristic, some pdf @@ -455,7 +455,7 @@ __device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderData #endif -__device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd, +ccl_device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd, const float3 omega_in, BsdfEval *eval, float *pdf) { #ifdef __MULTI_CLOSURE__ @@ -470,7 +470,7 @@ __device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd, #endif } -__device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd, +ccl_device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd, float randu, float randv, BsdfEval *bsdf_eval, float3 *omega_in, differential3 *domega_in, float *pdf) { @@ -534,7 +534,7 @@ __device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd, #endif } -__device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *sd, +ccl_device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc, float randu, float randv, BsdfEval *bsdf_eval, float3 *omega_in, differential3 *domega_in, float *pdf) { @@ -550,7 +550,7 @@ __device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *sd, return label; } -__device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness) +ccl_device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness) { #ifdef __MULTI_CLOSURE__ for(int i = 0; i< sd->num_closure; i++) { @@ -564,7 +564,7 @@ __device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughnes #endif } -__device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd) { #ifdef __MULTI_CLOSURE__ float3 eval = make_float3(0.0f, 0.0f, 0.0f); @@ -585,7 +585,7 @@ __device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd) #endif } -__device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd) { float3 alpha = make_float3(1.0f, 1.0f, 1.0f) - shader_bsdf_transparency(kg, sd); @@ -595,7 +595,7 @@ __device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd) return alpha; } -__device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd) { #ifdef __MULTI_CLOSURE__ float3 eval = make_float3(0.0f, 0.0f, 0.0f); @@ -616,7 +616,7 @@ __device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd) #endif } -__device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd) { #ifdef __MULTI_CLOSURE__ float3 eval = make_float3(0.0f, 0.0f, 0.0f); @@ -637,7 +637,7 @@ __device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd) #endif } -__device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd) { #ifdef __MULTI_CLOSURE__ float3 eval = make_float3(0.0f, 0.0f, 0.0f); @@ -658,7 +658,7 @@ __device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd) #endif } -__device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd) { #ifdef __MULTI_CLOSURE__ float3 eval = make_float3(0.0f, 0.0f, 0.0f); @@ -679,7 +679,7 @@ __device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd) #endif } -__device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N_) +ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N_) { #ifdef __MULTI_CLOSURE__ float3 eval = make_float3(0.0f, 0.0f, 0.0f); @@ -717,7 +717,7 @@ __device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_facto #endif } -__device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blur_) +ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blur_) { #ifdef __MULTI_CLOSURE__ float3 eval = make_float3(0.0f, 0.0f, 0.0f); @@ -762,7 +762,7 @@ __device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blu /* Emission */ -__device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure *sc) +ccl_device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure *sc) { #ifdef __OSL__ if(kg->osl && sc->prim) @@ -772,7 +772,7 @@ __device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure * return emissive_simple_eval(sd->Ng, sd->I); } -__device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd) { float3 eval; #ifdef __MULTI_CLOSURE__ @@ -793,7 +793,7 @@ __device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd) /* Holdout */ -__device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd) +ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd) { #ifdef __MULTI_CLOSURE__ float3 weight = make_float3(0.0f, 0.0f, 0.0f); @@ -816,7 +816,7 @@ __device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd) /* Surface Evaluation */ -__device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, +ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, float randb, int path_flag, ShaderContext ctx) { #ifdef __OSL__ @@ -837,7 +837,7 @@ __device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, /* Background Evaluation */ -__device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int path_flag, ShaderContext ctx) +ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int path_flag, ShaderContext ctx) { #ifdef __OSL__ if (kg->osl) @@ -875,7 +875,7 @@ __device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int pa /* Volume */ -__device float3 shader_volume_eval_phase(KernelGlobals *kg, ShaderData *sd, +ccl_device float3 shader_volume_eval_phase(KernelGlobals *kg, ShaderData *sd, float3 omega_in, float3 omega_out) { #ifdef __MULTI_CLOSURE__ @@ -896,7 +896,7 @@ __device float3 shader_volume_eval_phase(KernelGlobals *kg, ShaderData *sd, /* Volume Evaluation */ -__device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd, +ccl_device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd, float randb, int path_flag, ShaderContext ctx) { #ifdef __SVM__ @@ -911,7 +911,7 @@ __device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd, /* Displacement Evaluation */ -__device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, ShaderContext ctx) +ccl_device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, ShaderContext ctx) { /* this will modify sd->P */ #ifdef __SVM__ @@ -927,7 +927,7 @@ __device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, Shader /* Transparent Shadows */ #ifdef __TRANSPARENT_SHADOWS__ -__device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect) +ccl_device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect) { int prim = kernel_tex_fetch(__prim_index, isect->prim); int shader = 0; @@ -953,7 +953,7 @@ __device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect) /* Merging */ #ifdef __BRANCHED_PATH__ -__device void shader_merge_closures(KernelGlobals *kg, ShaderData *sd) +ccl_device void shader_merge_closures(KernelGlobals *kg, ShaderData *sd) { /* merge identical closures, better when we sample a single closure at a time */ for(int i = 0; i < sd->num_closure; i++) { diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h index d16b9328bf2..2326ca18b55 100644 --- a/intern/cycles/kernel/kernel_subsurface.h +++ b/intern/cycles/kernel/kernel_subsurface.h @@ -25,7 +25,7 @@ CCL_NAMESPACE_BEGIN #define BSSRDF_MULTI_EVAL -__device ShaderClosure *subsurface_scatter_pick_closure(KernelGlobals *kg, ShaderData *sd, float *probability) +ccl_device ShaderClosure *subsurface_scatter_pick_closure(KernelGlobals *kg, ShaderData *sd, float *probability) { /* sum sample weights of bssrdf and bsdf */ float bsdf_sum = 0.0f; @@ -80,7 +80,7 @@ __device ShaderClosure *subsurface_scatter_pick_closure(KernelGlobals *kg, Shade return NULL; } -__device float3 subsurface_scatter_eval(ShaderData *sd, ShaderClosure *sc, float disk_r, float r, bool all) +ccl_device float3 subsurface_scatter_eval(ShaderData *sd, ShaderClosure *sc, float disk_r, float r, bool all) { #ifdef BSSRDF_MULTI_EVAL /* this is the veach one-sample model with balance heuristic, some pdf @@ -133,7 +133,7 @@ __device float3 subsurface_scatter_eval(ShaderData *sd, ShaderClosure *sc, float } /* replace closures with a single diffuse bsdf closure after scatter step */ -__device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, float3 weight, bool hit, float3 N) +ccl_device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, float3 weight, bool hit, float3 N) { sd->flag &= ~SD_CLOSURE_FLAGS; sd->randb_closure = 0.0f; @@ -158,7 +158,7 @@ __device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, float3 weigh } /* optionally do blurring of color and/or bump mapping, at the cost of a shader evaluation */ -__device float3 subsurface_color_pow(float3 color, float exponent) +ccl_device float3 subsurface_color_pow(float3 color, float exponent) { color = max(color, make_float3(0.0f, 0.0f, 0.0f)); @@ -179,7 +179,7 @@ __device float3 subsurface_color_pow(float3 color, float exponent) return color; } -__device void subsurface_color_bump_blur(KernelGlobals *kg, ShaderData *out_sd, ShaderData *in_sd, int state_flag, float3 *eval, float3 *N) +ccl_device void subsurface_color_bump_blur(KernelGlobals *kg, ShaderData *out_sd, ShaderData *in_sd, int state_flag, float3 *eval, float3 *N) { /* average color and texture blur at outgoing point */ float texture_blur; @@ -207,7 +207,7 @@ __device void subsurface_color_bump_blur(KernelGlobals *kg, ShaderData *out_sd, } /* subsurface scattering step, from a point on the surface to other nearby points on the same object */ -__device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, ShaderData bssrdf_sd[BSSRDF_MAX_HITS], +ccl_device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, ShaderData bssrdf_sd[BSSRDF_MAX_HITS], int state_flag, ShaderClosure *sc, uint *lcg_state, float disk_u, float disk_v, bool all) { /* pick random axis in local frame and point on disk */ @@ -313,7 +313,7 @@ __device int subsurface_scatter_multi_step(KernelGlobals *kg, ShaderData *sd, Sh } /* subsurface scattering step, from a point on the surface to another nearby point on the same object */ -__device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd, +ccl_device void subsurface_scatter_step(KernelGlobals *kg, ShaderData *sd, int state_flag, ShaderClosure *sc, uint *lcg_state, float disk_u, float disk_v, bool all) { float3 eval = make_float3(0.0f, 0.0f, 0.0f); diff --git a/intern/cycles/kernel/kernel_triangle.h b/intern/cycles/kernel/kernel_triangle.h index 71389e0ec32..d457b67e77e 100644 --- a/intern/cycles/kernel/kernel_triangle.h +++ b/intern/cycles/kernel/kernel_triangle.h @@ -17,7 +17,7 @@ CCL_NAMESPACE_BEGIN /* Point on triangle for Moller-Trumbore triangles */ -__device_inline float3 triangle_point_MT(KernelGlobals *kg, int tri_index, float u, float v) +ccl_device_inline float3 triangle_point_MT(KernelGlobals *kg, int tri_index, float u, float v) { /* load triangle vertices */ float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri_index)); @@ -32,7 +32,7 @@ __device_inline float3 triangle_point_MT(KernelGlobals *kg, int tri_index, float } /* Sample point on triangle */ -__device_inline float3 triangle_sample_MT(KernelGlobals *kg, int tri_index, float randu, float randv) +ccl_device_inline float3 triangle_sample_MT(KernelGlobals *kg, int tri_index, float randu, float randv) { /* compute point */ randu = sqrtf(randu); @@ -44,7 +44,7 @@ __device_inline float3 triangle_sample_MT(KernelGlobals *kg, int tri_index, floa } /* Normal for Moller-Trumbore triangles */ -__device_inline float3 triangle_normal_MT(KernelGlobals *kg, int tri_index, int *shader) +ccl_device_inline float3 triangle_normal_MT(KernelGlobals *kg, int tri_index, int *shader) { #if 0 /* load triangle vertices */ @@ -64,7 +64,7 @@ __device_inline float3 triangle_normal_MT(KernelGlobals *kg, int tri_index, int } /* Return 3 triangle vertex locations */ -__device_inline void triangle_vertices(KernelGlobals *kg, int tri_index, float3 P[3]) +ccl_device_inline void triangle_vertices(KernelGlobals *kg, int tri_index, float3 P[3]) { /* load triangle vertices */ float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri_index)); @@ -74,7 +74,7 @@ __device_inline void triangle_vertices(KernelGlobals *kg, int tri_index, float3 P[2] = float4_to_float3(kernel_tex_fetch(__tri_verts, __float_as_int(tri_vindex.z))); } -__device_inline float3 triangle_smooth_normal(KernelGlobals *kg, int tri_index, float u, float v) +ccl_device_inline float3 triangle_smooth_normal(KernelGlobals *kg, int tri_index, float u, float v) { /* load triangle vertices */ float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri_index)); @@ -86,7 +86,7 @@ __device_inline float3 triangle_smooth_normal(KernelGlobals *kg, int tri_index, return normalize((1.0f - u - v)*n2 + u*n0 + v*n1); } -__device_inline void triangle_dPdudv(KernelGlobals *kg, float3 *dPdu, float3 *dPdv, int tri) +ccl_device_inline void triangle_dPdudv(KernelGlobals *kg, float3 *dPdu, float3 *dPdv, int tri) { /* fetch triangle vertex coordinates */ float3 tri_vindex = float4_to_float3(kernel_tex_fetch(__tri_vindex, tri)); @@ -102,7 +102,7 @@ __device_inline void triangle_dPdudv(KernelGlobals *kg, float3 *dPdu, float3 *dP /* attributes */ -__device float triangle_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy) +ccl_device float triangle_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float *dx, float *dy) { if(elem == ATTR_ELEMENT_FACE) { if(dx) *dx = 0.0f; @@ -145,7 +145,7 @@ __device float triangle_attribute_float(KernelGlobals *kg, const ShaderData *sd, } } -__device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy) +ccl_device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int offset, float3 *dx, float3 *dy) { if(elem == ATTR_ELEMENT_FACE) { if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f); diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h index 168127c620c..b2be9deb938 100644 --- a/intern/cycles/kernel/svm/svm.h +++ b/intern/cycles/kernel/svm/svm.h @@ -45,14 +45,14 @@ CCL_NAMESPACE_BEGIN /* Stack */ -__device_inline float3 stack_load_float3(float *stack, uint a) +ccl_device_inline float3 stack_load_float3(float *stack, uint a) { kernel_assert(a+2 < SVM_STACK_SIZE); return make_float3(stack[a+0], stack[a+1], stack[a+2]); } -__device_inline void stack_store_float3(float *stack, uint a, float3 f) +ccl_device_inline void stack_store_float3(float *stack, uint a, float3 f) { kernel_assert(a+2 < SVM_STACK_SIZE); @@ -61,59 +61,59 @@ __device_inline void stack_store_float3(float *stack, uint a, float3 f) stack[a+2] = f.z; } -__device_inline float stack_load_float(float *stack, uint a) +ccl_device_inline float stack_load_float(float *stack, uint a) { kernel_assert(a < SVM_STACK_SIZE); return stack[a]; } -__device_inline float stack_load_float_default(float *stack, uint a, uint value) +ccl_device_inline float stack_load_float_default(float *stack, uint a, uint value) { return (a == (uint)SVM_STACK_INVALID)? __uint_as_float(value): stack_load_float(stack, a); } -__device_inline void stack_store_float(float *stack, uint a, float f) +ccl_device_inline void stack_store_float(float *stack, uint a, float f) { kernel_assert(a < SVM_STACK_SIZE); stack[a] = f; } -__device_inline int stack_load_int(float *stack, uint a) +ccl_device_inline int stack_load_int(float *stack, uint a) { kernel_assert(a < SVM_STACK_SIZE); return __float_as_int(stack[a]); } -__device_inline float stack_load_int_default(float *stack, uint a, uint value) +ccl_device_inline float stack_load_int_default(float *stack, uint a, uint value) { return (a == (uint)SVM_STACK_INVALID)? (int)value: stack_load_int(stack, a); } -__device_inline void stack_store_int(float *stack, uint a, int i) +ccl_device_inline void stack_store_int(float *stack, uint a, int i) { kernel_assert(a < SVM_STACK_SIZE); stack[a] = __int_as_float(i); } -__device_inline bool stack_valid(uint a) +ccl_device_inline bool stack_valid(uint a) { return a != (uint)SVM_STACK_INVALID; } /* Reading Nodes */ -__device_inline uint4 read_node(KernelGlobals *kg, int *offset) +ccl_device_inline uint4 read_node(KernelGlobals *kg, int *offset) { uint4 node = kernel_tex_fetch(__svm_nodes, *offset); (*offset)++; return node; } -__device_inline float4 read_node_float(KernelGlobals *kg, int *offset) +ccl_device_inline float4 read_node_float(KernelGlobals *kg, int *offset) { uint4 node = kernel_tex_fetch(__svm_nodes, *offset); float4 f = make_float4(__uint_as_float(node.x), __uint_as_float(node.y), __uint_as_float(node.z), __uint_as_float(node.w)); @@ -121,13 +121,13 @@ __device_inline float4 read_node_float(KernelGlobals *kg, int *offset) return f; } -__device_inline float4 fetch_node_float(KernelGlobals *kg, int offset) +ccl_device_inline float4 fetch_node_float(KernelGlobals *kg, int offset) { uint4 node = kernel_tex_fetch(__svm_nodes, offset); return make_float4(__uint_as_float(node.x), __uint_as_float(node.y), __uint_as_float(node.z), __uint_as_float(node.w)); } -__device_inline void decode_node_uchar4(uint i, uint *x, uint *y, uint *z, uint *w) +ccl_device_inline void decode_node_uchar4(uint i, uint *x, uint *y, uint *z, uint *w) { if(x) *x = (i & 0xFF); if(y) *y = ((i >> 8) & 0xFF); @@ -182,7 +182,7 @@ CCL_NAMESPACE_BEGIN /* Main Interpreter Loop */ -__device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderType type, float randb, int path_flag) +ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderType type, float randb, int path_flag) { float stack[SVM_STACK_SIZE]; float closure_weight = 1.0f; diff --git a/intern/cycles/kernel/svm/svm_attribute.h b/intern/cycles/kernel/svm/svm_attribute.h index 8e71e7cdd56..90409e16477 100644 --- a/intern/cycles/kernel/svm/svm_attribute.h +++ b/intern/cycles/kernel/svm/svm_attribute.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Attribute Node */ -__device void svm_node_attr_init(KernelGlobals *kg, ShaderData *sd, +ccl_device void svm_node_attr_init(KernelGlobals *kg, ShaderData *sd, uint4 node, NodeAttributeType *type, NodeAttributeType *mesh_type, AttributeElement *elem, int *offset, uint *out_offset) { @@ -52,7 +52,7 @@ __device void svm_node_attr_init(KernelGlobals *kg, ShaderData *sd, *type = (NodeAttributeType)node.w; } -__device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { NodeAttributeType type, mesh_type; AttributeElement elem; @@ -84,7 +84,7 @@ __device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uin } } -__device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { NodeAttributeType type, mesh_type; AttributeElement elem; @@ -120,7 +120,7 @@ __device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *st } } -__device void svm_node_attr_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_attr_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { NodeAttributeType type, mesh_type; AttributeElement elem; diff --git a/intern/cycles/kernel/svm/svm_blackbody.h b/intern/cycles/kernel/svm/svm_blackbody.h index 2fc2c770a83..63dbf27d35e 100644 --- a/intern/cycles/kernel/svm/svm_blackbody.h +++ b/intern/cycles/kernel/svm/svm_blackbody.h @@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN /* Blackbody Node */ -__device void svm_node_blackbody(KernelGlobals *kg, ShaderData *sd, float *stack, uint temperature_offset, uint col_offset) +ccl_device void svm_node_blackbody(KernelGlobals *kg, ShaderData *sd, float *stack, uint temperature_offset, uint col_offset) { /* Output */ float3 color_rgb = make_float3(0.0f, 0.0f, 0.0f); diff --git a/intern/cycles/kernel/svm/svm_brick.h b/intern/cycles/kernel/svm/svm_brick.h index 19b4b5e779f..7cac922d8a6 100644 --- a/intern/cycles/kernel/svm/svm_brick.h +++ b/intern/cycles/kernel/svm/svm_brick.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Brick */ -__device_noinline float brick_noise(int n) /* fast integer noise */ +ccl_device_noinline float brick_noise(int n) /* fast integer noise */ { int nn; n = (n >> 13) ^ n; @@ -26,7 +26,7 @@ __device_noinline float brick_noise(int n) /* fast integer noise */ return 0.5f * ((float)nn / 1073741824.0f); } -__device_noinline float2 svm_brick(float3 p, float scale, float mortar_size, float bias, +ccl_device_noinline float2 svm_brick(float3 p, float scale, float mortar_size, float bias, float brick_width, float row_height, float offset_amount, int offset_frequency, float squash_amount, int squash_frequency) { @@ -56,7 +56,7 @@ __device_noinline float2 svm_brick(float3 p, float scale, float mortar_size, flo y > (row_height - mortar_size)) ? 1.0f : 0.0f); } -__device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) +ccl_device void svm_node_tex_brick(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { uint4 node2 = read_node(kg, offset); uint4 node3 = read_node(kg, offset); diff --git a/intern/cycles/kernel/svm/svm_brightness.h b/intern/cycles/kernel/svm/svm_brightness.h index 3e977dcbe1b..9b330b3213f 100644 --- a/intern/cycles/kernel/svm/svm_brightness.h +++ b/intern/cycles/kernel/svm/svm_brightness.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN -__device void svm_node_brightness(ShaderData *sd, float *stack, uint in_color, uint out_color, uint node) +ccl_device void svm_node_brightness(ShaderData *sd, float *stack, uint in_color, uint out_color, uint node) { uint bright_offset, contrast_offset; float3 color = stack_load_float3(stack, in_color); diff --git a/intern/cycles/kernel/svm/svm_camera.h b/intern/cycles/kernel/svm/svm_camera.h index 76f50e196eb..bfe9289fa02 100644 --- a/intern/cycles/kernel/svm/svm_camera.h +++ b/intern/cycles/kernel/svm/svm_camera.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN -__device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_vector, uint out_zdepth, uint out_distance) +ccl_device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_vector, uint out_zdepth, uint out_distance) { float distance; float zdepth; diff --git a/intern/cycles/kernel/svm/svm_checker.h b/intern/cycles/kernel/svm/svm_checker.h index 70fe2ac5a92..ebc48e16d68 100644 --- a/intern/cycles/kernel/svm/svm_checker.h +++ b/intern/cycles/kernel/svm/svm_checker.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Checker */ -__device_noinline float svm_checker(float3 p, float scale) +ccl_device_noinline float svm_checker(float3 p, float scale) { p *= scale; @@ -34,7 +34,7 @@ __device_noinline float svm_checker(float3 p, float scale) return ((xi % 2 == yi % 2) == (zi % 2))? 1.0f: 0.0f; } -__device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_tex_checker(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { uint co_offset, color1_offset, color2_offset, scale_offset; uint color_offset, fac_offset; diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h index 0d4716ab078..2c6fb5deca4 100644 --- a/intern/cycles/kernel/svm/svm_closure.h +++ b/intern/cycles/kernel/svm/svm_closure.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Closure Nodes */ -__device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type, float eta, float roughness, bool refract) +ccl_device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type, float eta, float roughness, bool refract) { if(type == CLOSURE_BSDF_SHARP_GLASS_ID) { if(refract) { @@ -49,7 +49,7 @@ __device void svm_node_glass_setup(ShaderData *sd, ShaderClosure *sc, int type, } } -__device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, ClosureType type, float mix_weight) +ccl_device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, ClosureType type, float mix_weight) { #ifdef __MULTI_CLOSURE__ ShaderClosure *sc = &sd->closure[sd->num_closure]; @@ -70,7 +70,7 @@ __device_inline ShaderClosure *svm_node_closure_get_non_bsdf(ShaderData *sd, Clo #endif } -__device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float mix_weight) +ccl_device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float mix_weight) { #ifdef __MULTI_CLOSURE__ ShaderClosure *sc = &sd->closure[sd->num_closure]; @@ -93,7 +93,7 @@ __device_inline ShaderClosure *svm_node_closure_get_bsdf(ShaderData *sd, float m #endif } -__device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, float randb, int path_flag, int *offset) +ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, float randb, int path_flag, int *offset) { uint type, param1_offset, param2_offset; @@ -456,7 +456,7 @@ __device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *st } } -__device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int path_flag) +ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int path_flag) { uint type, param1_offset, param2_offset; @@ -499,7 +499,7 @@ __device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float * } } -__device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node) { #ifdef __MULTI_CLOSURE__ uint mix_weight_offset = node.y; @@ -522,7 +522,7 @@ __device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 node sd->flag |= SD_EMISSION; } -__device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 node) { #ifdef __MULTI_CLOSURE__ uint mix_weight_offset = node.y; @@ -543,7 +543,7 @@ __device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 no #endif } -__device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node) { #ifdef __MULTI_CLOSURE__ uint mix_weight_offset = node.y; @@ -566,7 +566,7 @@ __device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node) sd->flag |= SD_HOLDOUT; } -__device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, uint4 node) { #ifdef __MULTI_CLOSURE__ uint mix_weight_offset = node.y; @@ -591,7 +591,7 @@ __device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, u /* Closure Nodes */ -__device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight) +ccl_device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight) { #ifdef __MULTI_CLOSURE__ if(sd->num_closure < MAX_CLOSURE) @@ -601,13 +601,13 @@ __device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight #endif } -__device void svm_node_closure_set_weight(ShaderData *sd, uint r, uint g, uint b) +ccl_device void svm_node_closure_set_weight(ShaderData *sd, uint r, uint g, uint b) { float3 weight = make_float3(__uint_as_float(r), __uint_as_float(g), __uint_as_float(b)); svm_node_closure_store_weight(sd, weight); } -__device void svm_node_emission_set_weight_total(KernelGlobals *kg, ShaderData *sd, uint r, uint g, uint b) +ccl_device void svm_node_emission_set_weight_total(KernelGlobals *kg, ShaderData *sd, uint r, uint g, uint b) { float3 weight = make_float3(__uint_as_float(r), __uint_as_float(g), __uint_as_float(b)); @@ -617,14 +617,14 @@ __device void svm_node_emission_set_weight_total(KernelGlobals *kg, ShaderData * svm_node_closure_store_weight(sd, weight); } -__device void svm_node_closure_weight(ShaderData *sd, float *stack, uint weight_offset) +ccl_device void svm_node_closure_weight(ShaderData *sd, float *stack, uint weight_offset) { float3 weight = stack_load_float3(stack, weight_offset); svm_node_closure_store_weight(sd, weight); } -__device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { uint color_offset = node.y; uint strength_offset = node.z; @@ -639,7 +639,7 @@ __device void svm_node_emission_weight(KernelGlobals *kg, ShaderData *sd, float svm_node_closure_store_weight(sd, weight); } -__device void svm_node_mix_closure(ShaderData *sd, float *stack, +ccl_device void svm_node_mix_closure(ShaderData *sd, float *stack, uint4 node, int *offset, float *randb) { #ifdef __MULTI_CLOSURE__ @@ -675,7 +675,7 @@ __device void svm_node_mix_closure(ShaderData *sd, float *stack, #endif } -__device void svm_node_add_closure(ShaderData *sd, float *stack, uint unused, +ccl_device void svm_node_add_closure(ShaderData *sd, float *stack, uint unused, uint node_jump, int *offset, float *randb, float *closure_weight) { #ifdef __MULTI_CLOSURE__ @@ -699,7 +699,7 @@ __device void svm_node_add_closure(ShaderData *sd, float *stack, uint unused, /* (Bump) normal */ -__device void svm_node_set_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_direction, uint out_normal) +ccl_device void svm_node_set_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_direction, uint out_normal) { float3 normal = stack_load_float3(stack, in_direction); sd->N = normal; diff --git a/intern/cycles/kernel/svm/svm_convert.h b/intern/cycles/kernel/svm/svm_convert.h index 22f4651689d..2503912c5c6 100644 --- a/intern/cycles/kernel/svm/svm_convert.h +++ b/intern/cycles/kernel/svm/svm_convert.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Conversion Nodes */ -__device void svm_node_convert(ShaderData *sd, float *stack, uint type, uint from, uint to) +ccl_device void svm_node_convert(ShaderData *sd, float *stack, uint type, uint from, uint to) { switch(type) { case NODE_CONVERT_FI: { diff --git a/intern/cycles/kernel/svm/svm_displace.h b/intern/cycles/kernel/svm/svm_displace.h index d0bac647a7c..6cd5ee4b375 100644 --- a/intern/cycles/kernel/svm/svm_displace.h +++ b/intern/cycles/kernel/svm/svm_displace.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Bump Node */ -__device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { #ifdef __RAY_DIFFERENTIALS__ /* get normal input */ @@ -62,7 +62,7 @@ __device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack, /* Displacement Node */ -__device void svm_node_set_displacement(ShaderData *sd, float *stack, uint fac_offset) +ccl_device void svm_node_set_displacement(ShaderData *sd, float *stack, uint fac_offset) { float d = stack_load_float(stack, fac_offset); sd->P += sd->N*d*0.1f; /* todo: get rid of this factor */ diff --git a/intern/cycles/kernel/svm/svm_fresnel.h b/intern/cycles/kernel/svm/svm_fresnel.h index d97d6a3738f..bb70a3faa2a 100644 --- a/intern/cycles/kernel/svm/svm_fresnel.h +++ b/intern/cycles/kernel/svm/svm_fresnel.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Fresnel Node */ -__device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, uint ior_value, uint node) +ccl_device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, uint ior_value, uint node) { uint normal_offset, out_offset; decode_node_uchar4(node, &normal_offset, &out_offset, NULL, NULL); @@ -35,7 +35,7 @@ __device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, ui /* Layer Weight Node */ -__device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node) { uint blend_offset = node.y; uint blend_value = node.z; diff --git a/intern/cycles/kernel/svm/svm_gamma.h b/intern/cycles/kernel/svm/svm_gamma.h index ef1581fba8d..c4749e7b936 100644 --- a/intern/cycles/kernel/svm/svm_gamma.h +++ b/intern/cycles/kernel/svm/svm_gamma.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN -__device void svm_node_gamma(ShaderData *sd, float *stack, uint in_gamma, uint in_color, uint out_color) +ccl_device void svm_node_gamma(ShaderData *sd, float *stack, uint in_gamma, uint in_color, uint out_color) { float3 color = stack_load_float3(stack, in_color); float gamma = stack_load_float(stack, in_gamma); diff --git a/intern/cycles/kernel/svm/svm_geometry.h b/intern/cycles/kernel/svm/svm_geometry.h index 818d8694453..ad0cacb027a 100644 --- a/intern/cycles/kernel/svm/svm_geometry.h +++ b/intern/cycles/kernel/svm/svm_geometry.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Geometry Node */ -__device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) +ccl_device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) { float3 data; @@ -38,7 +38,7 @@ __device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack, stack_store_float3(stack, out_offset, data); } -__device void svm_node_geometry_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) +ccl_device void svm_node_geometry_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) { #ifdef __RAY_DIFFERENTIALS__ float3 data; @@ -55,7 +55,7 @@ __device void svm_node_geometry_bump_dx(KernelGlobals *kg, ShaderData *sd, float #endif } -__device void svm_node_geometry_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) +ccl_device void svm_node_geometry_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) { #ifdef __RAY_DIFFERENTIALS__ float3 data; @@ -74,7 +74,7 @@ __device void svm_node_geometry_bump_dy(KernelGlobals *kg, ShaderData *sd, float /* Object Info */ -__device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) +ccl_device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) { float data; @@ -94,7 +94,7 @@ __device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *sta /* Particle Info */ -__device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) +ccl_device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) { switch(type) { case NODE_INFO_PAR_INDEX: { @@ -146,7 +146,7 @@ __device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float *s /* Hair Info */ -__device void svm_node_hair_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) +ccl_device void svm_node_hair_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) { float data; float3 data3; diff --git a/intern/cycles/kernel/svm/svm_gradient.h b/intern/cycles/kernel/svm/svm_gradient.h index 1c0fe511f9b..a4b3c0583f7 100644 --- a/intern/cycles/kernel/svm/svm_gradient.h +++ b/intern/cycles/kernel/svm/svm_gradient.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Gradient */ -__device float svm_gradient(float3 p, NodeGradientType type) +ccl_device float svm_gradient(float3 p, NodeGradientType type) { float x, y, z; @@ -57,7 +57,7 @@ __device float svm_gradient(float3 p, NodeGradientType type) return 0.0f; } -__device void svm_node_tex_gradient(ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_tex_gradient(ShaderData *sd, float *stack, uint4 node) { uint type, co_offset, color_offset, fac_offset; diff --git a/intern/cycles/kernel/svm/svm_hsv.h b/intern/cycles/kernel/svm/svm_hsv.h index e16fb7582c1..11dfc4f096b 100644 --- a/intern/cycles/kernel/svm/svm_hsv.h +++ b/intern/cycles/kernel/svm/svm_hsv.h @@ -19,7 +19,7 @@ CCL_NAMESPACE_BEGIN -__device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_color_offset, uint fac_offset, uint out_color_offset, int *offset) +ccl_device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_color_offset, uint fac_offset, uint out_color_offset, int *offset) { /* read extra data */ uint4 node1 = read_node(kg, offset); diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h index e18fe7c53a7..58e5775265a 100644 --- a/intern/cycles/kernel/svm/svm_image.h +++ b/intern/cycles/kernel/svm/svm_image.h @@ -21,14 +21,14 @@ CCL_NAMESPACE_BEGIN /* For OpenCL all images are packed in a single array, and we do manual lookup * and interpolation. */ -__device_inline float4 svm_image_texture_read(KernelGlobals *kg, int offset) +ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int offset) { uchar4 r = kernel_tex_fetch(__tex_image_packed, offset); float f = 1.0f/255.0f; return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); } -__device_inline int svm_image_texture_wrap_periodic(int x, int width) +ccl_device_inline int svm_image_texture_wrap_periodic(int x, int width) { x %= width; if(x < 0) @@ -36,19 +36,19 @@ __device_inline int svm_image_texture_wrap_periodic(int x, int width) return x; } -__device_inline int svm_image_texture_wrap_clamp(int x, int width) +ccl_device_inline int svm_image_texture_wrap_clamp(int x, int width) { return clamp(x, 0, width-1); } -__device_inline float svm_image_texture_frac(float x, int *ix) +ccl_device_inline float svm_image_texture_frac(float x, int *ix) { int i = float_to_int(x) - ((x < 0.0f)? 1: 0); *ix = i; return x - (float)i; } -__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha) +ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha) { /* first slots are used by float textures, which are not supported here */ if(id < TEX_NUM_FLOAT_IMAGES) @@ -110,7 +110,7 @@ __device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, u #else -__device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha) +ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha) { float4 r; @@ -257,7 +257,7 @@ __device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, u #endif -__device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { uint id = node.y; uint co_offset, out_offset, alpha_offset, srgb; @@ -274,7 +274,7 @@ __device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *stack stack_store_float(stack, alpha_offset, f.w); } -__device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { /* get object space normal */ float3 N = sd->N; @@ -363,7 +363,7 @@ __device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *s } -__device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { uint id = node.y; uint co_offset, out_offset, alpha_offset, srgb; diff --git a/intern/cycles/kernel/svm/svm_invert.h b/intern/cycles/kernel/svm/svm_invert.h index 4c40afeadd9..eb47e9ad4ab 100644 --- a/intern/cycles/kernel/svm/svm_invert.h +++ b/intern/cycles/kernel/svm/svm_invert.h @@ -16,12 +16,12 @@ CCL_NAMESPACE_BEGIN -__device float invert(float color, float factor) +ccl_device float invert(float color, float factor) { return factor*(1.0f - color) + (1.0f - factor) * color; } -__device void svm_node_invert(ShaderData *sd, float *stack, uint in_fac, uint in_color, uint out_color) +ccl_device void svm_node_invert(ShaderData *sd, float *stack, uint in_fac, uint in_color, uint out_color) { float factor = stack_load_float(stack, in_fac); float3 color = stack_load_float3(stack, in_color); diff --git a/intern/cycles/kernel/svm/svm_light_path.h b/intern/cycles/kernel/svm/svm_light_path.h index ff6776d751e..e7afa2d2200 100644 --- a/intern/cycles/kernel/svm/svm_light_path.h +++ b/intern/cycles/kernel/svm/svm_light_path.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Light Path Node */ -__device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint out_offset, int path_flag) +ccl_device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint out_offset, int path_flag) { float info = 0.0f; @@ -40,7 +40,7 @@ __device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint /* Light Falloff Node */ -__device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node) { uint strength_offset, out_offset, smooth_offset; diff --git a/intern/cycles/kernel/svm/svm_magic.h b/intern/cycles/kernel/svm/svm_magic.h index 7a5eba3f564..b661f5cacf8 100644 --- a/intern/cycles/kernel/svm/svm_magic.h +++ b/intern/cycles/kernel/svm/svm_magic.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Magic */ -__device_noinline float3 svm_magic(float3 p, int n, float distortion) +ccl_device_noinline float3 svm_magic(float3 p, int n, float distortion) { float x = sinf((p.x + p.y + p.z)*5.0f); float y = cosf((-p.x + p.y - p.z)*5.0f); @@ -87,7 +87,7 @@ __device_noinline float3 svm_magic(float3 p, int n, float distortion) return make_float3(0.5f - x, 0.5f - y, 0.5f - z); } -__device void svm_node_tex_magic(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) +ccl_device void svm_node_tex_magic(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { uint depth; uint scale_offset, distortion_offset, co_offset, fac_offset, color_offset; diff --git a/intern/cycles/kernel/svm/svm_mapping.h b/intern/cycles/kernel/svm/svm_mapping.h index fcdd92dd575..c9fa8502dd1 100644 --- a/intern/cycles/kernel/svm/svm_mapping.h +++ b/intern/cycles/kernel/svm/svm_mapping.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Mapping Node */ -__device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset) +ccl_device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset) { float3 v = stack_load_float3(stack, vec_offset); @@ -32,7 +32,7 @@ __device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack, stack_store_float3(stack, out_offset, r); } -__device void svm_node_min_max(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset) +ccl_device void svm_node_min_max(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset) { float3 v = stack_load_float3(stack, vec_offset); diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h index d4863dd6216..bb46d443a6b 100644 --- a/intern/cycles/kernel/svm/svm_math.h +++ b/intern/cycles/kernel/svm/svm_math.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN -__device float svm_math(NodeMath type, float Fac1, float Fac2) +ccl_device float svm_math(NodeMath type, float Fac1, float Fac2) { float Fac; @@ -64,12 +64,12 @@ __device float svm_math(NodeMath type, float Fac1, float Fac2) return Fac; } -__device float average_fac(float3 v) +ccl_device float average_fac(float3 v) { return (fabsf(v.x) + fabsf(v.y) + fabsf(v.z))/3.0f; } -__device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, float3 Vector1, float3 Vector2) +ccl_device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, float3 Vector1, float3 Vector2) { if(type == NODE_VECTOR_MATH_ADD) { *Vector = Vector1 + Vector2; @@ -104,7 +104,7 @@ __device void svm_vector_math(float *Fac, float3 *Vector, NodeVectorMath type, f /* Nodes */ -__device void svm_node_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint f1_offset, uint f2_offset, int *offset) +ccl_device void svm_node_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint f1_offset, uint f2_offset, int *offset) { NodeMath type = (NodeMath)itype; float f1 = stack_load_float(stack, f1_offset); @@ -116,7 +116,7 @@ __device void svm_node_math(KernelGlobals *kg, ShaderData *sd, float *stack, uin stack_store_float(stack, node1.y, f); } -__device void svm_node_vector_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint v1_offset, uint v2_offset, int *offset) +ccl_device void svm_node_vector_math(KernelGlobals *kg, ShaderData *sd, float *stack, uint itype, uint v1_offset, uint v2_offset, int *offset) { NodeVectorMath type = (NodeVectorMath)itype; float3 v1 = stack_load_float3(stack, v1_offset); diff --git a/intern/cycles/kernel/svm/svm_mix.h b/intern/cycles/kernel/svm/svm_mix.h index 506f772dba5..0eeb4cf9b05 100644 --- a/intern/cycles/kernel/svm/svm_mix.h +++ b/intern/cycles/kernel/svm/svm_mix.h @@ -16,22 +16,22 @@ CCL_NAMESPACE_BEGIN -__device float3 svm_mix_blend(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_blend(float t, float3 col1, float3 col2) { return interp(col1, col2, t); } -__device float3 svm_mix_add(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_add(float t, float3 col1, float3 col2) { return interp(col1, col1 + col2, t); } -__device float3 svm_mix_mul(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_mul(float t, float3 col1, float3 col2) { return interp(col1, col1 * col2, t); } -__device float3 svm_mix_screen(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_screen(float t, float3 col1, float3 col2) { float tm = 1.0f - t; float3 one = make_float3(1.0f, 1.0f, 1.0f); @@ -40,7 +40,7 @@ __device float3 svm_mix_screen(float t, float3 col1, float3 col2) return one - (tm3 + t*(one - col2))*(one - col1); } -__device float3 svm_mix_overlay(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_overlay(float t, float3 col1, float3 col2) { float tm = 1.0f - t; @@ -64,12 +64,12 @@ __device float3 svm_mix_overlay(float t, float3 col1, float3 col2) return outcol; } -__device float3 svm_mix_sub(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_sub(float t, float3 col1, float3 col2) { return interp(col1, col1 - col2, t); } -__device float3 svm_mix_div(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_div(float t, float3 col1, float3 col2) { float tm = 1.0f - t; @@ -82,22 +82,22 @@ __device float3 svm_mix_div(float t, float3 col1, float3 col2) return outcol; } -__device float3 svm_mix_diff(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_diff(float t, float3 col1, float3 col2) { return interp(col1, fabs(col1 - col2), t); } -__device float3 svm_mix_dark(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_dark(float t, float3 col1, float3 col2) { return min(col1, col2*t); } -__device float3 svm_mix_light(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_light(float t, float3 col1, float3 col2) { return max(col1, col2*t); } -__device float3 svm_mix_dodge(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_dodge(float t, float3 col1, float3 col2) { float3 outcol = col1; @@ -132,7 +132,7 @@ __device float3 svm_mix_dodge(float t, float3 col1, float3 col2) return outcol; } -__device float3 svm_mix_burn(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_burn(float t, float3 col1, float3 col2) { float tmp, tm = 1.0f - t; @@ -171,7 +171,7 @@ __device float3 svm_mix_burn(float t, float3 col1, float3 col2) return outcol; } -__device float3 svm_mix_hue(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_hue(float t, float3 col1, float3 col2) { float3 outcol = col1; @@ -188,7 +188,7 @@ __device float3 svm_mix_hue(float t, float3 col1, float3 col2) return outcol; } -__device float3 svm_mix_sat(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_sat(float t, float3 col1, float3 col2) { float tm = 1.0f - t; @@ -206,7 +206,7 @@ __device float3 svm_mix_sat(float t, float3 col1, float3 col2) return outcol; } -__device float3 svm_mix_val(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_val(float t, float3 col1, float3 col2) { float tm = 1.0f - t; @@ -218,7 +218,7 @@ __device float3 svm_mix_val(float t, float3 col1, float3 col2) return hsv_to_rgb(hsv); } -__device float3 svm_mix_color(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_color(float t, float3 col1, float3 col2) { float3 outcol = col1; float3 hsv2 = rgb_to_hsv(col2); @@ -235,7 +235,7 @@ __device float3 svm_mix_color(float t, float3 col1, float3 col2) return outcol; } -__device float3 svm_mix_soft(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_soft(float t, float3 col1, float3 col2) { float tm = 1.0f - t; @@ -245,7 +245,7 @@ __device float3 svm_mix_soft(float t, float3 col1, float3 col2) return tm*col1 + t*((one - col1)*col2*col1 + col1*scr); } -__device float3 svm_mix_linear(float t, float3 col1, float3 col2) +ccl_device float3 svm_mix_linear(float t, float3 col1, float3 col2) { float3 outcol = col1; @@ -267,7 +267,7 @@ __device float3 svm_mix_linear(float t, float3 col1, float3 col2) return outcol; } -__device float3 svm_mix_clamp(float3 col) +ccl_device float3 svm_mix_clamp(float3 col) { float3 outcol = col; @@ -278,7 +278,7 @@ __device float3 svm_mix_clamp(float3 col) return outcol; } -__device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2) +ccl_device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2) { float t = clamp(fac, 0.0f, 1.0f); @@ -309,7 +309,7 @@ __device float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2) /* Node */ -__device void svm_node_mix(KernelGlobals *kg, ShaderData *sd, float *stack, uint fac_offset, uint c1_offset, uint c2_offset, int *offset) +ccl_device void svm_node_mix(KernelGlobals *kg, ShaderData *sd, float *stack, uint fac_offset, uint c1_offset, uint c2_offset, int *offset) { /* read extra data */ uint4 node1 = read_node(kg, offset); diff --git a/intern/cycles/kernel/svm/svm_musgrave.h b/intern/cycles/kernel/svm/svm_musgrave.h index 65dcf1a9f83..c67dc8297e4 100644 --- a/intern/cycles/kernel/svm/svm_musgrave.h +++ b/intern/cycles/kernel/svm/svm_musgrave.h @@ -25,7 +25,7 @@ CCL_NAMESPACE_BEGIN * from "Texturing and Modelling: A procedural approach" */ -__device_noinline float noise_musgrave_fBm(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves) +ccl_device_noinline float noise_musgrave_fBm(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves) { float rmd; float value = 0.0f; @@ -53,7 +53,7 @@ __device_noinline float noise_musgrave_fBm(float3 p, NodeNoiseBasis basis, float * octaves: number of frequencies in the fBm */ -__device_noinline float noise_musgrave_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves) +ccl_device_noinline float noise_musgrave_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves) { float rmd; float value = 1.0f; @@ -82,7 +82,7 @@ __device_noinline float noise_musgrave_multi_fractal(float3 p, NodeNoiseBasis ba * offset: raises the terrain from `sea level' */ -__device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset) +ccl_device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset) { float value, increment, rmd; float pwHL = powf(lacunarity, -H); @@ -117,7 +117,7 @@ __device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis b * offset: raises the terrain from `sea level' */ -__device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain) +ccl_device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain) { float result, signal, weight, rmd; float pwHL = powf(lacunarity, -H); @@ -154,7 +154,7 @@ __device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseB * offset: raises the terrain from `sea level' */ -__device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain) +ccl_device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseBasis basis, float H, float lacunarity, float octaves, float offset, float gain) { float result, signal, weight; float pwHL = powf(lacunarity, -H); @@ -181,7 +181,7 @@ __device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseB /* Shader */ -__device float svm_musgrave(NodeMusgraveType type, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float scale, float3 p) +ccl_device float svm_musgrave(NodeMusgraveType type, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float scale, float3 p) { NodeNoiseBasis basis = NODE_NOISE_PERLIN; p *= scale; @@ -200,7 +200,7 @@ __device float svm_musgrave(NodeMusgraveType type, float dimension, float lacuna return 0.0f; } -__device void svm_node_tex_musgrave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) +ccl_device void svm_node_tex_musgrave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { uint4 node2 = read_node(kg, offset); uint4 node3 = read_node(kg, offset); diff --git a/intern/cycles/kernel/svm/svm_noise.h b/intern/cycles/kernel/svm/svm_noise.h index a55c635b679..2055b0e3ec7 100644 --- a/intern/cycles/kernel/svm/svm_noise.h +++ b/intern/cycles/kernel/svm/svm_noise.h @@ -32,17 +32,17 @@ CCL_NAMESPACE_BEGIN -__device int quick_floor(float x) +ccl_device int quick_floor(float x) { return float_to_int(x) - ((x < 0) ? 1 : 0); } -__device float bits_to_01(uint bits) +ccl_device float bits_to_01(uint bits) { return bits * (1.0f/(float)0xFFFFFFFF); } -__device uint hash(uint kx, uint ky, uint kz) +ccl_device uint hash(uint kx, uint ky, uint kz) { // define some handy macros #define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) @@ -71,34 +71,34 @@ __device uint hash(uint kx, uint ky, uint kz) #undef final } -__device int imod(int a, int b) +ccl_device int imod(int a, int b) { a %= b; return a < 0 ? a + b : a; } -__device uint phash(int kx, int ky, int kz, int3 p) +ccl_device uint phash(int kx, int ky, int kz, int3 p) { return hash(imod(kx, p.x), imod(ky, p.y), imod(kz, p.z)); } -__device float floorfrac(float x, int* i) +ccl_device float floorfrac(float x, int* i) { *i = quick_floor(x); return x - *i; } -__device float fade(float t) +ccl_device float fade(float t) { return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f); } -__device float nerp(float t, float a, float b) +ccl_device float nerp(float t, float a, float b) { return (1.0f - t) * a + t * b; } -__device float grad(int hash, float x, float y, float z) +ccl_device float grad(int hash, float x, float y, float z) { // use vectors pointing to the edges of the cube int h = hash & 15; @@ -107,12 +107,12 @@ __device float grad(int hash, float x, float y, float z) return ((h&1) ? -u : u) + ((h&2) ? -v : v); } -__device float scale3(float result) +ccl_device float scale3(float result) { return 0.9820f * result; } -__device_noinline float perlin(float x, float y, float z) +ccl_device_noinline float perlin(float x, float y, float z) { int X; float fx = floorfrac(x, &X); int Y; float fy = floorfrac(y, &Y); @@ -138,7 +138,7 @@ __device_noinline float perlin(float x, float y, float z) return (isfinite(r))? r: 0.0f; } -__device_noinline float perlin_periodic(float x, float y, float z, float3 pperiod) +ccl_device_noinline float perlin_periodic(float x, float y, float z, float3 pperiod) { int X; float fx = floorfrac(x, &X); int Y; float fy = floorfrac(y, &Y); @@ -171,20 +171,20 @@ __device_noinline float perlin_periodic(float x, float y, float z, float3 pperio } /* perlin noise in range 0..1 */ -__device float noise(float3 p) +ccl_device float noise(float3 p) { float r = perlin(p.x, p.y, p.z); return 0.5f*r + 0.5f; } /* perlin noise in range -1..1 */ -__device float snoise(float3 p) +ccl_device float snoise(float3 p) { return perlin(p.x, p.y, p.z); } /* cell noise */ -__device_noinline float cellnoise(float3 p) +ccl_device_noinline float cellnoise(float3 p) { uint ix = quick_floor(p.x); uint iy = quick_floor(p.y); @@ -193,7 +193,7 @@ __device_noinline float cellnoise(float3 p) return bits_to_01(hash(ix, iy, iz)); } -__device float3 cellnoise_color(float3 p) +ccl_device float3 cellnoise_color(float3 p) { float r = cellnoise(p); float g = cellnoise(make_float3(p.y, p.x, p.z)); @@ -203,14 +203,14 @@ __device float3 cellnoise_color(float3 p) } /* periodic perlin noise in range 0..1 */ -__device float pnoise(float3 p, float3 pperiod) +ccl_device float pnoise(float3 p, float3 pperiod) { float r = perlin_periodic(p.x, p.y, p.z, pperiod); return 0.5f*r + 0.5f; } /* periodic perlin noise in range -1..1 */ -__device float psnoise(float3 p, float3 pperiod) +ccl_device float psnoise(float3 p, float3 pperiod) { return perlin_periodic(p.x, p.y, p.z, pperiod); } diff --git a/intern/cycles/kernel/svm/svm_noisetex.h b/intern/cycles/kernel/svm/svm_noisetex.h index acb3f20246e..02583131704 100644 --- a/intern/cycles/kernel/svm/svm_noisetex.h +++ b/intern/cycles/kernel/svm/svm_noisetex.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Noise */ -__device_inline void svm_noise(float3 p, float scale, float detail, float distortion, float *fac, float3 *color) +ccl_device_inline void svm_noise(float3 p, float scale, float detail, float distortion, float *fac, float3 *color) { NodeNoiseBasis basis = NODE_NOISE_PERLIN; int hard = 0; @@ -41,7 +41,7 @@ __device_inline void svm_noise(float3 p, float scale, float detail, float distor noise_turbulence(make_float3(p.y, p.z, p.x), basis, detail, hard)); } -__device void svm_node_tex_noise(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) +ccl_device void svm_node_tex_noise(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { uint co_offset, scale_offset, detail_offset, distortion_offset, fac_offset, color_offset; diff --git a/intern/cycles/kernel/svm/svm_normal.h b/intern/cycles/kernel/svm/svm_normal.h index dd7506bb5fc..8695031b8b9 100644 --- a/intern/cycles/kernel/svm/svm_normal.h +++ b/intern/cycles/kernel/svm/svm_normal.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN -__device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_normal_offset, uint out_normal_offset, uint out_dot_offset, int *offset) +ccl_device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_normal_offset, uint out_normal_offset, uint out_dot_offset, int *offset) { /* read extra data */ uint4 node1 = read_node(kg, offset); diff --git a/intern/cycles/kernel/svm/svm_ramp.h b/intern/cycles/kernel/svm/svm_ramp.h index 3cb23a2b2dd..55eee3d24c3 100644 --- a/intern/cycles/kernel/svm/svm_ramp.h +++ b/intern/cycles/kernel/svm/svm_ramp.h @@ -19,7 +19,7 @@ CCL_NAMESPACE_BEGIN -__device float4 rgb_ramp_lookup(KernelGlobals *kg, int offset, float f, bool interpolate) +ccl_device float4 rgb_ramp_lookup(KernelGlobals *kg, int offset, float f, bool interpolate) { f = clamp(f, 0.0f, 1.0f)*(RAMP_TABLE_SIZE-1); @@ -35,7 +35,7 @@ __device float4 rgb_ramp_lookup(KernelGlobals *kg, int offset, float f, bool int return a; } -__device void svm_node_rgb_ramp(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) +ccl_device void svm_node_rgb_ramp(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { uint fac_offset, color_offset, alpha_offset; uint interpolate = node.z; @@ -53,7 +53,7 @@ __device void svm_node_rgb_ramp(KernelGlobals *kg, ShaderData *sd, float *stack, *offset += RAMP_TABLE_SIZE; } -__device void svm_node_rgb_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) +ccl_device void svm_node_rgb_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { uint fac_offset = node.y; uint color_offset = node.z; @@ -72,7 +72,7 @@ __device void svm_node_rgb_curves(KernelGlobals *kg, ShaderData *sd, float *stac *offset += RAMP_TABLE_SIZE; } -__device void svm_node_vector_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) +ccl_device void svm_node_vector_curves(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { uint fac_offset = node.y; uint color_offset = node.z; diff --git a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h index 130890fdc8e..0f68ecbea03 100644 --- a/intern/cycles/kernel/svm/svm_sepcomb_hsv.h +++ b/intern/cycles/kernel/svm/svm_sepcomb_hsv.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN -__device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint hue_in, uint saturation_in, uint value_in, int *offset) +ccl_device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint hue_in, uint saturation_in, uint value_in, int *offset) { uint4 node1 = read_node(kg, offset); uint color_out = node1.y; @@ -32,7 +32,7 @@ __device void svm_node_combine_hsv(KernelGlobals *kg, ShaderData *sd, float *sta stack_store_float3(stack, color_out, color); } -__device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint color_in, uint hue_out, uint saturation_out, int *offset) +ccl_device void svm_node_separate_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint color_in, uint hue_out, uint saturation_out, int *offset) { uint4 node1 = read_node(kg, offset); uint value_out = node1.y; diff --git a/intern/cycles/kernel/svm/svm_sepcomb_rgb.h b/intern/cycles/kernel/svm/svm_sepcomb_rgb.h index 5c3d95435f2..34c4449ecdb 100644 --- a/intern/cycles/kernel/svm/svm_sepcomb_rgb.h +++ b/intern/cycles/kernel/svm/svm_sepcomb_rgb.h @@ -16,7 +16,7 @@ CCL_NAMESPACE_BEGIN -__device void svm_node_combine_rgb(ShaderData *sd, float *stack, uint in_offset, uint color_index, uint out_offset) +ccl_device void svm_node_combine_rgb(ShaderData *sd, float *stack, uint in_offset, uint color_index, uint out_offset) { float color = stack_load_float(stack, in_offset); @@ -24,7 +24,7 @@ __device void svm_node_combine_rgb(ShaderData *sd, float *stack, uint in_offset, stack_store_float(stack, out_offset+color_index, color); } -__device void svm_node_separate_rgb(ShaderData *sd, float *stack, uint icolor_offset, uint color_index, uint out_offset) +ccl_device void svm_node_separate_rgb(ShaderData *sd, float *stack, uint icolor_offset, uint color_index, uint out_offset) { float3 color = stack_load_float3(stack, icolor_offset); diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h index 81b5f1a201f..1e3552647bd 100644 --- a/intern/cycles/kernel/svm/svm_sky.h +++ b/intern/cycles/kernel/svm/svm_sky.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Sky texture */ -__device float sky_angle_between(float thetav, float phiv, float theta, float phi) +ccl_device float sky_angle_between(float thetav, float phiv, float theta, float phi) { float cospsi = sinf(thetav)*sinf(theta)*cosf(phi - phiv) + cosf(thetav)*cosf(theta); return safe_acosf(cospsi); @@ -28,7 +28,7 @@ __device float sky_angle_between(float thetav, float phiv, float theta, float ph * "A Practical Analytic Model for Daylight" * A. J. Preetham, Peter Shirley, Brian Smits */ -__device float sky_perez_function(float *lam, float theta, float gamma) +ccl_device float sky_perez_function(float *lam, float theta, float gamma) { float ctheta = cosf(theta); float cgamma = cosf(gamma); @@ -36,7 +36,7 @@ __device float sky_perez_function(float *lam, float theta, float gamma) return (1.0f + lam[0]*expf(lam[1]/ctheta)) * (1.0f + lam[2]*expf(lam[3]*gamma) + lam[4]*cgamma*cgamma); } -__device float3 sky_radiance_old(KernelGlobals *kg, float3 dir, +ccl_device float3 sky_radiance_old(KernelGlobals *kg, float3 dir, float sunphi, float suntheta, float radiance_x, float radiance_y, float radiance_z, float *config_x, float *config_y, float *config_z) @@ -66,7 +66,7 @@ __device float3 sky_radiance_old(KernelGlobals *kg, float3 dir, * "An Analytic Model for Full Spectral Sky-Dome Radiance" * Lukas Hosek, Alexander Wilkie */ -__device float sky_radiance_internal(float *configuration, float theta, float gamma) +ccl_device float sky_radiance_internal(float *configuration, float theta, float gamma) { float ctheta = cosf(theta); float cgamma = cosf(gamma); @@ -80,7 +80,7 @@ __device float sky_radiance_internal(float *configuration, float theta, float ga (configuration[2] + configuration[3] * expM + configuration[5] * rayM + configuration[6] * mieM + configuration[7] * zenith); } -__device float3 sky_radiance_new(KernelGlobals *kg, float3 dir, +ccl_device float3 sky_radiance_new(KernelGlobals *kg, float3 dir, float sunphi, float suntheta, float radiance_x, float radiance_y, float radiance_z, float *config_x, float *config_y, float *config_z) @@ -105,7 +105,7 @@ __device float3 sky_radiance_new(KernelGlobals *kg, float3 dir, return xyz_to_rgb(x, y, z) * (M_2PI_F/683); } -__device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) +ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { /* Define variables */ float sunphi, suntheta, radiance_x, radiance_y, radiance_z; diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h index 9f88389fcb1..3044cbf81e0 100644 --- a/intern/cycles/kernel/svm/svm_tex_coord.h +++ b/intern/cycles/kernel/svm/svm_tex_coord.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Texture Coordinate Node */ -__device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset) +ccl_device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset) { float3 data; @@ -78,7 +78,7 @@ __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_fla stack_store_float3(stack, out_offset, data); } -__device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset) +ccl_device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset) { #ifdef __RAY_DIFFERENTIALS__ float3 data; @@ -142,7 +142,7 @@ __device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, int #endif } -__device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset) +ccl_device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset) { #ifdef __RAY_DIFFERENTIALS__ float3 data; @@ -206,7 +206,7 @@ __device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, int #endif } -__device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { uint color_offset, strength_offset, normal_offset, space; decode_node_uchar4(node.y, &color_offset, &strength_offset, &normal_offset, &space); @@ -280,7 +280,7 @@ __device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *stac stack_store_float3(stack, normal_offset, N); } -__device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { uint tangent_offset, direction_type, axis; decode_node_uchar4(node.y, &tangent_offset, &direction_type, &axis, NULL); diff --git a/intern/cycles/kernel/svm/svm_texture.h b/intern/cycles/kernel/svm/svm_texture.h index 7f3e09a481d..8ced8390b0b 100644 --- a/intern/cycles/kernel/svm/svm_texture.h +++ b/intern/cycles/kernel/svm/svm_texture.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Voronoi Distances */ -__device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, float e) +ccl_device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, float e) { #if 0 if(distance_metric == NODE_VORONOI_DISTANCE_SQUARED) @@ -44,7 +44,7 @@ __device float voronoi_distance(NodeDistanceMetric distance_metric, float3 d, fl /* Voronoi / Worley like */ -__device_noinline float4 voronoi_Fn(float3 p, float e, int n1, int n2) +ccl_device_noinline float4 voronoi_Fn(float3 p, float e, int n1, int n2) { float da[4]; float3 pa[4]; @@ -120,29 +120,29 @@ __device_noinline float4 voronoi_Fn(float3 p, float e, int n1, int n2) return result; } -__device float voronoi_F1(float3 p) { return voronoi_Fn(p, 0.0f, 0, -1).w; } -__device float voronoi_F2(float3 p) { return voronoi_Fn(p, 0.0f, 1, -1).w; } -__device float voronoi_F3(float3 p) { return voronoi_Fn(p, 0.0f, 2, -1).w; } -__device float voronoi_F4(float3 p) { return voronoi_Fn(p, 0.0f, 3, -1).w; } -__device float voronoi_F1F2(float3 p) { return voronoi_Fn(p, 0.0f, 0, 1).w; } +ccl_device float voronoi_F1(float3 p) { return voronoi_Fn(p, 0.0f, 0, -1).w; } +ccl_device float voronoi_F2(float3 p) { return voronoi_Fn(p, 0.0f, 1, -1).w; } +ccl_device float voronoi_F3(float3 p) { return voronoi_Fn(p, 0.0f, 2, -1).w; } +ccl_device float voronoi_F4(float3 p) { return voronoi_Fn(p, 0.0f, 3, -1).w; } +ccl_device float voronoi_F1F2(float3 p) { return voronoi_Fn(p, 0.0f, 0, 1).w; } -__device float voronoi_Cr(float3 p) +ccl_device float voronoi_Cr(float3 p) { /* crackle type pattern, just a scale/clamp of F2-F1 */ float t = 10.0f*voronoi_F1F2(p); return (t > 1.0f)? 1.0f: t; } -__device float voronoi_F1S(float3 p) { return 2.0f*voronoi_F1(p) - 1.0f; } -__device float voronoi_F2S(float3 p) { return 2.0f*voronoi_F2(p) - 1.0f; } -__device float voronoi_F3S(float3 p) { return 2.0f*voronoi_F3(p) - 1.0f; } -__device float voronoi_F4S(float3 p) { return 2.0f*voronoi_F4(p) - 1.0f; } -__device float voronoi_F1F2S(float3 p) { return 2.0f*voronoi_F1F2(p) - 1.0f; } -__device float voronoi_CrS(float3 p) { return 2.0f*voronoi_Cr(p) - 1.0f; } +ccl_device float voronoi_F1S(float3 p) { return 2.0f*voronoi_F1(p) - 1.0f; } +ccl_device float voronoi_F2S(float3 p) { return 2.0f*voronoi_F2(p) - 1.0f; } +ccl_device float voronoi_F3S(float3 p) { return 2.0f*voronoi_F3(p) - 1.0f; } +ccl_device float voronoi_F4S(float3 p) { return 2.0f*voronoi_F4(p) - 1.0f; } +ccl_device float voronoi_F1F2S(float3 p) { return 2.0f*voronoi_F1F2(p) - 1.0f; } +ccl_device float voronoi_CrS(float3 p) { return 2.0f*voronoi_Cr(p) - 1.0f; } /* Noise Bases */ -__device float noise_basis(float3 p, NodeNoiseBasis basis) +ccl_device float noise_basis(float3 p, NodeNoiseBasis basis) { /* Only Perlin enabled for now, others break CUDA compile by making kernel * too big, with compile using > 4GB, due to everything being inlined. */ @@ -173,7 +173,7 @@ __device float noise_basis(float3 p, NodeNoiseBasis basis) /* Soft/Hard Noise */ -__device float noise_basis_hard(float3 p, NodeNoiseBasis basis, int hard) +ccl_device float noise_basis_hard(float3 p, NodeNoiseBasis basis, int hard) { float t = noise_basis(p, basis); return (hard)? fabsf(2.0f*t - 1.0f): t; @@ -181,7 +181,7 @@ __device float noise_basis_hard(float3 p, NodeNoiseBasis basis, int hard) /* Turbulence */ -__device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, float octaves, int hard) +ccl_device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, float octaves, int hard) { float fscale = 1.0f; float amp = 1.0f; diff --git a/intern/cycles/kernel/svm/svm_value.h b/intern/cycles/kernel/svm/svm_value.h index cd5a2e0d871..7beed065288 100644 --- a/intern/cycles/kernel/svm/svm_value.h +++ b/intern/cycles/kernel/svm/svm_value.h @@ -18,12 +18,12 @@ CCL_NAMESPACE_BEGIN /* Value Nodes */ -__device void svm_node_value_f(KernelGlobals *kg, ShaderData *sd, float *stack, uint ivalue, uint out_offset) +ccl_device void svm_node_value_f(KernelGlobals *kg, ShaderData *sd, float *stack, uint ivalue, uint out_offset) { stack_store_float(stack, out_offset, __uint_as_float(ivalue)); } -__device void svm_node_value_v(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_offset, int *offset) +ccl_device void svm_node_value_v(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_offset, int *offset) { /* read extra data */ uint4 node1 = read_node(kg, offset); diff --git a/intern/cycles/kernel/svm/svm_vector_transform.h b/intern/cycles/kernel/svm/svm_vector_transform.h index 95ef8e3e558..1e3fc2fa03b 100644 --- a/intern/cycles/kernel/svm/svm_vector_transform.h +++ b/intern/cycles/kernel/svm/svm_vector_transform.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Vector Transform */ -__device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) +ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) { uint itype, ifrom, ito; uint vector_in, vector_out; diff --git a/intern/cycles/kernel/svm/svm_voronoi.h b/intern/cycles/kernel/svm/svm_voronoi.h index c9ebea2bceb..604fd3404c5 100644 --- a/intern/cycles/kernel/svm/svm_voronoi.h +++ b/intern/cycles/kernel/svm/svm_voronoi.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Voronoi */ -__device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale, float3 p) +ccl_device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale, float3 p) { /* compute distance and point coordinate of 4 nearest neighbours */ float4 dpa0 = voronoi_Fn(p*scale, 1.0f, 0, -1); @@ -39,7 +39,7 @@ __device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale, return make_float4(color.x, color.y, color.z, fac); } -__device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) +ccl_device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { uint coloring = node.y; uint scale_offset, co_offset, fac_offset, color_offset; diff --git a/intern/cycles/kernel/svm/svm_wave.h b/intern/cycles/kernel/svm/svm_wave.h index d906266bcf9..3749135f8c7 100644 --- a/intern/cycles/kernel/svm/svm_wave.h +++ b/intern/cycles/kernel/svm/svm_wave.h @@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN /* Wave */ -__device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float detail, float distortion, float dscale) +ccl_device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float detail, float distortion, float dscale) { float n; @@ -35,7 +35,7 @@ __device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float return 0.5f + 0.5f * sinf(n); } -__device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) +ccl_device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset) { uint4 node2 = read_node(kg, offset); diff --git a/intern/cycles/kernel/svm/svm_wavelength.h b/intern/cycles/kernel/svm/svm_wavelength.h index f9dd24dacef..dca4003b89a 100644 --- a/intern/cycles/kernel/svm/svm_wavelength.h +++ b/intern/cycles/kernel/svm/svm_wavelength.h @@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN /* Wavelength to RGB */ -__device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelength, uint color_out) +ccl_device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelength, uint color_out) { // CIE colour matching functions xBar, yBar, and zBar for // wavelengths from 380 through 780 nanometers, every 5 diff --git a/intern/cycles/kernel/svm/svm_wireframe.h b/intern/cycles/kernel/svm/svm_wireframe.h index 9ecb81847d7..e560e6303cc 100644 --- a/intern/cycles/kernel/svm/svm_wireframe.h +++ b/intern/cycles/kernel/svm/svm_wireframe.h @@ -34,7 +34,7 @@ CCL_NAMESPACE_BEGIN /* Wireframe Node */ -__device void svm_node_wireframe(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_size, uint out_fac, uint use_pixel_size) +ccl_device void svm_node_wireframe(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_size, uint out_fac, uint use_pixel_size) { /* Input Data */ float size = stack_load_float(stack, in_size); diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h index 9bdd5b29a8e..8b13a006673 100644 --- a/intern/cycles/util/util_color.h +++ b/intern/cycles/util/util_color.h @@ -22,7 +22,7 @@ CCL_NAMESPACE_BEGIN -__device float color_srgb_to_scene_linear(float c) +ccl_device float color_srgb_to_scene_linear(float c) { if(c < 0.04045f) return (c < 0.0f)? 0.0f: c * (1.0f/12.92f); @@ -30,7 +30,7 @@ __device float color_srgb_to_scene_linear(float c) return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f); } -__device float color_scene_linear_to_srgb(float c) +ccl_device float color_scene_linear_to_srgb(float c) { if(c < 0.0031308f) return (c < 0.0f)? 0.0f: c * 12.92f; @@ -38,7 +38,7 @@ __device float color_scene_linear_to_srgb(float c) return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f; } -__device float3 rgb_to_hsv(float3 rgb) +ccl_device float3 rgb_to_hsv(float3 rgb) { float cmax, cmin, h, s, v, cdelta; float3 c; @@ -77,7 +77,7 @@ __device float3 rgb_to_hsv(float3 rgb) return make_float3(h, s, v); } -__device float3 hsv_to_rgb(float3 hsv) +ccl_device float3 hsv_to_rgb(float3 hsv) { float i, f, p, q, t, h, s, v; float3 rgb; @@ -112,7 +112,7 @@ __device float3 hsv_to_rgb(float3 hsv) return rgb; } -__device float3 xyY_to_xyz(float x, float y, float Y) +ccl_device float3 xyY_to_xyz(float x, float y, float Y) { float X, Z; @@ -125,7 +125,7 @@ __device float3 xyY_to_xyz(float x, float y, float Y) return make_float3(X, Y, Z); } -__device float3 xyz_to_rgb(float x, float y, float z) +ccl_device float3 xyz_to_rgb(float x, float y, float z) { return make_float3(3.240479f * x + -1.537150f * y + -0.498535f * z, -0.969256f * x + 1.875991f * y + 0.041556f * z, @@ -134,7 +134,7 @@ __device float3 xyz_to_rgb(float x, float y, float z) #ifndef __KERNEL_OPENCL__ -__device float3 color_srgb_to_scene_linear(float3 c) +ccl_device float3 color_srgb_to_scene_linear(float3 c) { return make_float3( color_srgb_to_scene_linear(c.x), @@ -142,7 +142,7 @@ __device float3 color_srgb_to_scene_linear(float3 c) color_srgb_to_scene_linear(c.z)); } -__device float3 color_scene_linear_to_srgb(float3 c) +ccl_device float3 color_scene_linear_to_srgb(float3 c) { return make_float3( color_scene_linear_to_srgb(c.x), @@ -152,7 +152,7 @@ __device float3 color_scene_linear_to_srgb(float3 c) #endif -__device float linear_rgb_to_gray(float3 c) +ccl_device float linear_rgb_to_gray(float3 c) { return c.x*0.2126f + c.y*0.7152f + c.z*0.0722f; } diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 987ef4f17ac..6db532faf74 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -89,12 +89,12 @@ CCL_NAMESPACE_BEGIN #ifndef __KERNEL_OPENCL__ -__device_inline float fmaxf(float a, float b) +ccl_device_inline float fmaxf(float a, float b) { return (a > b)? a: b; } -__device_inline float fminf(float a, float b) +ccl_device_inline float fminf(float a, float b) { return (a < b)? a: b; } @@ -105,63 +105,63 @@ __device_inline float fminf(float a, float b) #ifndef __KERNEL_GPU__ -__device_inline int max(int a, int b) +ccl_device_inline int max(int a, int b) { return (a > b)? a: b; } -__device_inline int min(int a, int b) +ccl_device_inline int min(int a, int b) { return (a < b)? a: b; } -__device_inline float max(float a, float b) +ccl_device_inline float max(float a, float b) { return (a > b)? a: b; } -__device_inline float min(float a, float b) +ccl_device_inline float min(float a, float b) { return (a < b)? a: b; } -__device_inline double max(double a, double b) +ccl_device_inline double max(double a, double b) { return (a > b)? a: b; } -__device_inline double min(double a, double b) +ccl_device_inline double min(double a, double b) { return (a < b)? a: b; } #endif -__device_inline float min4(float a, float b, float c, float d) +ccl_device_inline float min4(float a, float b, float c, float d) { return min(min(a, b), min(c, d)); } -__device_inline float max4(float a, float b, float c, float d) +ccl_device_inline float max4(float a, float b, float c, float d) { return max(max(a, b), max(c, d)); } #ifndef __KERNEL_OPENCL__ -__device_inline int clamp(int a, int mn, int mx) +ccl_device_inline int clamp(int a, int mn, int mx) { return min(max(a, mn), mx); } -__device_inline float clamp(float a, float mn, float mx) +ccl_device_inline float clamp(float a, float mn, float mx) { return min(max(a, mn), mx); } #endif -__device_inline int float_to_int(float f) +ccl_device_inline int float_to_int(float f) { #if defined(__KERNEL_SSE2__) && !defined(_MSC_VER) return _mm_cvtt_ss2si(_mm_load_ss(&f)); @@ -170,22 +170,22 @@ __device_inline int float_to_int(float f) #endif } -__device_inline int floor_to_int(float f) +ccl_device_inline int floor_to_int(float f) { return float_to_int(floorf(f)); } -__device_inline int ceil_to_int(float f) +ccl_device_inline int ceil_to_int(float f) { return float_to_int(ceilf(f)); } -__device_inline float signf(float f) +ccl_device_inline float signf(float f) { return (f < 0.0f)? -1.0f: 1.0f; } -__device_inline float nonzerof(float f, float eps) +ccl_device_inline float nonzerof(float f, float eps) { if(fabsf(f) < eps) return signf(f)*eps; @@ -193,7 +193,7 @@ __device_inline float nonzerof(float f, float eps) return f; } -__device_inline float smoothstepf(float f) +ccl_device_inline float smoothstepf(float f) { float ff = f*f; return (3.0f*ff - 2.0f*ff*f); @@ -203,7 +203,7 @@ __device_inline float smoothstepf(float f) #ifndef __KERNEL_OPENCL__ -__device_inline bool is_zero(const float2 a) +ccl_device_inline bool is_zero(const float2 a) { return (a.x == 0.0f && a.y == 0.0f); } @@ -212,7 +212,7 @@ __device_inline bool is_zero(const float2 a) #ifndef __KERNEL_OPENCL__ -__device_inline float average(const float2 a) +ccl_device_inline float average(const float2 a) { return (a.x + a.y)*(1.0f/2.0f); } @@ -221,85 +221,85 @@ __device_inline float average(const float2 a) #ifndef __KERNEL_OPENCL__ -__device_inline float2 operator-(const float2 a) +ccl_device_inline float2 operator-(const float2 a) { return make_float2(-a.x, -a.y); } -__device_inline float2 operator*(const float2 a, const float2 b) +ccl_device_inline float2 operator*(const float2 a, const float2 b) { return make_float2(a.x*b.x, a.y*b.y); } -__device_inline float2 operator*(const float2 a, float f) +ccl_device_inline float2 operator*(const float2 a, float f) { return make_float2(a.x*f, a.y*f); } -__device_inline float2 operator*(float f, const float2 a) +ccl_device_inline float2 operator*(float f, const float2 a) { return make_float2(a.x*f, a.y*f); } -__device_inline float2 operator/(float f, const float2 a) +ccl_device_inline float2 operator/(float f, const float2 a) { return make_float2(f/a.x, f/a.y); } -__device_inline float2 operator/(const float2 a, float f) +ccl_device_inline float2 operator/(const float2 a, float f) { float invf = 1.0f/f; return make_float2(a.x*invf, a.y*invf); } -__device_inline float2 operator/(const float2 a, const float2 b) +ccl_device_inline float2 operator/(const float2 a, const float2 b) { return make_float2(a.x/b.x, a.y/b.y); } -__device_inline float2 operator+(const float2 a, const float2 b) +ccl_device_inline float2 operator+(const float2 a, const float2 b) { return make_float2(a.x+b.x, a.y+b.y); } -__device_inline float2 operator-(const float2 a, const float2 b) +ccl_device_inline float2 operator-(const float2 a, const float2 b) { return make_float2(a.x-b.x, a.y-b.y); } -__device_inline float2 operator+=(float2& a, const float2 b) +ccl_device_inline float2 operator+=(float2& a, const float2 b) { return a = a + b; } -__device_inline float2 operator*=(float2& a, const float2 b) +ccl_device_inline float2 operator*=(float2& a, const float2 b) { return a = a * b; } -__device_inline float2 operator*=(float2& a, float f) +ccl_device_inline float2 operator*=(float2& a, float f) { return a = a * f; } -__device_inline float2 operator/=(float2& a, const float2 b) +ccl_device_inline float2 operator/=(float2& a, const float2 b) { return a = a / b; } -__device_inline float2 operator/=(float2& a, float f) +ccl_device_inline float2 operator/=(float2& a, float f) { float invf = 1.0f/f; return a = a * invf; } -__device_inline float dot(const float2 a, const float2 b) +ccl_device_inline float dot(const float2 a, const float2 b) { return a.x*b.x + a.y*b.y; } -__device_inline float cross(const float2 a, const float2 b) +ccl_device_inline float cross(const float2 a, const float2 b) { return (a.x*b.y - a.y*b.x); } @@ -308,58 +308,58 @@ __device_inline float cross(const float2 a, const float2 b) #ifndef __KERNEL_OPENCL__ -__device_inline bool operator==(const int2 a, const int2 b) +ccl_device_inline bool operator==(const int2 a, const int2 b) { return (a.x == b.x && a.y == b.y); } -__device_inline float len(const float2 a) +ccl_device_inline float len(const float2 a) { return sqrtf(dot(a, a)); } -__device_inline float2 normalize(const float2 a) +ccl_device_inline float2 normalize(const float2 a) { return a/len(a); } -__device_inline float2 normalize_len(const float2 a, float *t) +ccl_device_inline float2 normalize_len(const float2 a, float *t) { *t = len(a); return a/(*t); } -__device_inline bool operator==(const float2 a, const float2 b) +ccl_device_inline bool operator==(const float2 a, const float2 b) { return (a.x == b.x && a.y == b.y); } -__device_inline bool operator!=(const float2 a, const float2 b) +ccl_device_inline bool operator!=(const float2 a, const float2 b) { return !(a == b); } -__device_inline float2 min(float2 a, float2 b) +ccl_device_inline float2 min(float2 a, float2 b) { return make_float2(min(a.x, b.x), min(a.y, b.y)); } -__device_inline float2 max(float2 a, float2 b) +ccl_device_inline float2 max(float2 a, float2 b) { return make_float2(max(a.x, b.x), max(a.y, b.y)); } -__device_inline float2 clamp(float2 a, float2 mn, float2 mx) +ccl_device_inline float2 clamp(float2 a, float2 mn, float2 mx) { return min(max(a, mn), mx); } -__device_inline float2 fabs(float2 a) +ccl_device_inline float2 fabs(float2 a) { return make_float2(fabsf(a.x), fabsf(a.y)); } -__device_inline float2 as_float2(const float4 a) +ccl_device_inline float2 as_float2(const float4 a) { return make_float2(a.x, a.y); } @@ -368,7 +368,7 @@ __device_inline float2 as_float2(const float4 a) #ifndef __KERNEL_GPU__ -__device_inline void print_float2(const char *label, const float2& a) +ccl_device_inline void print_float2(const char *label, const float2& a) { printf("%s: %.8f %.8f\n", label, (double)a.x, (double)a.y); } @@ -377,7 +377,7 @@ __device_inline void print_float2(const char *label, const float2& a) #ifndef __KERNEL_OPENCL__ -__device_inline float2 interp(float2 a, float2 b, float t) +ccl_device_inline float2 interp(float2 a, float2 b, float t) { return a + t*(b - a); } @@ -388,84 +388,84 @@ __device_inline float2 interp(float2 a, float2 b, float t) #ifndef __KERNEL_OPENCL__ -__device_inline float3 operator-(const float3 a) +ccl_device_inline float3 operator-(const float3 a) { return make_float3(-a.x, -a.y, -a.z); } -__device_inline float3 operator*(const float3 a, const float3 b) +ccl_device_inline float3 operator*(const float3 a, const float3 b) { return make_float3(a.x*b.x, a.y*b.y, a.z*b.z); } -__device_inline float3 operator*(const float3 a, float f) +ccl_device_inline float3 operator*(const float3 a, float f) { return make_float3(a.x*f, a.y*f, a.z*f); } -__device_inline float3 operator*(float f, const float3 a) +ccl_device_inline float3 operator*(float f, const float3 a) { return make_float3(a.x*f, a.y*f, a.z*f); } -__device_inline float3 operator/(float f, const float3 a) +ccl_device_inline float3 operator/(float f, const float3 a) { return make_float3(f/a.x, f/a.y, f/a.z); } -__device_inline float3 operator/(const float3 a, float f) +ccl_device_inline float3 operator/(const float3 a, float f) { float invf = 1.0f/f; return make_float3(a.x*invf, a.y*invf, a.z*invf); } -__device_inline float3 operator/(const float3 a, const float3 b) +ccl_device_inline float3 operator/(const float3 a, const float3 b) { return make_float3(a.x/b.x, a.y/b.y, a.z/b.z); } -__device_inline float3 operator+(const float3 a, const float3 b) +ccl_device_inline float3 operator+(const float3 a, const float3 b) { return make_float3(a.x+b.x, a.y+b.y, a.z+b.z); } -__device_inline float3 operator-(const float3 a, const float3 b) +ccl_device_inline float3 operator-(const float3 a, const float3 b) { return make_float3(a.x-b.x, a.y-b.y, a.z-b.z); } -__device_inline float3 operator+=(float3& a, const float3 b) +ccl_device_inline float3 operator+=(float3& a, const float3 b) { return a = a + b; } -__device_inline float3 operator*=(float3& a, const float3 b) +ccl_device_inline float3 operator*=(float3& a, const float3 b) { return a = a * b; } -__device_inline float3 operator*=(float3& a, float f) +ccl_device_inline float3 operator*=(float3& a, float f) { return a = a * f; } -__device_inline float3 operator/=(float3& a, const float3 b) +ccl_device_inline float3 operator/=(float3& a, const float3 b) { return a = a / b; } -__device_inline float3 operator/=(float3& a, float f) +ccl_device_inline float3 operator/=(float3& a, float f) { float invf = 1.0f/f; return a = a * invf; } -__device_inline float dot(const float3 a, const float3 b) +ccl_device_inline float dot(const float3 a, const float3 b) { return a.x*b.x + a.y*b.y + a.z*b.z; } -__device_inline float3 cross(const float3 a, const float3 b) +ccl_device_inline float3 cross(const float3 a, const float3 b) { float3 r = make_float3(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x); return r; @@ -473,26 +473,26 @@ __device_inline float3 cross(const float3 a, const float3 b) #endif -__device_inline float len(const float3 a) +ccl_device_inline float len(const float3 a) { return sqrtf(dot(a, a)); } -__device_inline float len_squared(const float3 a) +ccl_device_inline float len_squared(const float3 a) { return dot(a, a); } #ifndef __KERNEL_OPENCL__ -__device_inline float3 normalize(const float3 a) +ccl_device_inline float3 normalize(const float3 a) { return a/len(a); } #endif -__device_inline float3 normalize_len(const float3 a, float *t) +ccl_device_inline float3 normalize_len(const float3 a, float *t) { *t = len(a); return a/(*t); @@ -500,7 +500,7 @@ __device_inline float3 normalize_len(const float3 a, float *t) #ifndef __KERNEL_OPENCL__ -__device_inline bool operator==(const float3 a, const float3 b) +ccl_device_inline bool operator==(const float3 a, const float3 b) { #ifdef __KERNEL_SSE__ return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 7) == 7; @@ -509,12 +509,12 @@ __device_inline bool operator==(const float3 a, const float3 b) #endif } -__device_inline bool operator!=(const float3 a, const float3 b) +ccl_device_inline bool operator!=(const float3 a, const float3 b) { return !(a == b); } -__device_inline float3 min(float3 a, float3 b) +ccl_device_inline float3 min(float3 a, float3 b) { #ifdef __KERNEL_SSE__ return _mm_min_ps(a.m128, b.m128); @@ -523,7 +523,7 @@ __device_inline float3 min(float3 a, float3 b) #endif } -__device_inline float3 max(float3 a, float3 b) +ccl_device_inline float3 max(float3 a, float3 b) { #ifdef __KERNEL_SSE__ return _mm_max_ps(a.m128, b.m128); @@ -532,12 +532,12 @@ __device_inline float3 max(float3 a, float3 b) #endif } -__device_inline float3 clamp(float3 a, float3 mn, float3 mx) +ccl_device_inline float3 clamp(float3 a, float3 mn, float3 mx) { return min(max(a, mn), mx); } -__device_inline float3 fabs(float3 a) +ccl_device_inline float3 fabs(float3 a) { #ifdef __KERNEL_SSE__ __m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)); @@ -549,29 +549,29 @@ __device_inline float3 fabs(float3 a) #endif -__device_inline float3 float2_to_float3(const float2 a) +ccl_device_inline float3 float2_to_float3(const float2 a) { return make_float3(a.x, a.y, 0.0f); } -__device_inline float3 float4_to_float3(const float4 a) +ccl_device_inline float3 float4_to_float3(const float4 a) { return make_float3(a.x, a.y, a.z); } -__device_inline float4 float3_to_float4(const float3 a) +ccl_device_inline float4 float3_to_float4(const float3 a) { return make_float4(a.x, a.y, a.z, 1.0f); } #ifndef __KERNEL_GPU__ -__device_inline void print_float3(const char *label, const float3& a) +ccl_device_inline void print_float3(const char *label, const float3& a) { printf("%s: %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z); } -__device_inline float3 rcp(const float3& a) +ccl_device_inline float3 rcp(const float3& a) { #ifdef __KERNEL_SSE__ float4 r = _mm_rcp_ps(a.m128); @@ -583,12 +583,12 @@ __device_inline float3 rcp(const float3& a) #endif -__device_inline float3 interp(float3 a, float3 b, float t) +ccl_device_inline float3 interp(float3 a, float3 b, float t) { return a + t*(b - a); } -__device_inline bool is_zero(const float3 a) +ccl_device_inline bool is_zero(const float3 a) { #ifdef __KERNEL_SSE__ return a == make_float3(0.0f); @@ -597,7 +597,7 @@ __device_inline bool is_zero(const float3 a) #endif } -__device_inline float reduce_add(const float3 a) +ccl_device_inline float reduce_add(const float3 a) { #ifdef __KERNEL_SSE__ return (a.x + a.y + a.z); @@ -606,7 +606,7 @@ __device_inline float reduce_add(const float3 a) #endif } -__device_inline float average(const float3 a) +ccl_device_inline float average(const float3 a) { return reduce_add(a)*(1.0f/3.0f); } @@ -639,7 +639,7 @@ template<> __forceinline const float4 shuffle<0, 1, 0, 1>(const float4& b) #ifndef __KERNEL_OPENCL__ -__device_inline float4 operator-(const float4& a) +ccl_device_inline float4 operator-(const float4& a) { #ifdef __KERNEL_SSE__ __m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x80000000)); @@ -649,7 +649,7 @@ __device_inline float4 operator-(const float4& a) #endif } -__device_inline float4 operator*(const float4& a, const float4& b) +ccl_device_inline float4 operator*(const float4& a, const float4& b) { #ifdef __KERNEL_SSE__ return _mm_mul_ps(a.m128, b.m128); @@ -658,7 +658,7 @@ __device_inline float4 operator*(const float4& a, const float4& b) #endif } -__device_inline float4 operator*(const float4& a, float f) +ccl_device_inline float4 operator*(const float4& a, float f) { #ifdef __KERNEL_SSE__ return a * make_float4(f); @@ -667,12 +667,12 @@ __device_inline float4 operator*(const float4& a, float f) #endif } -__device_inline float4 operator*(float f, const float4& a) +ccl_device_inline float4 operator*(float f, const float4& a) { return a * f; } -__device_inline float4 rcp(const float4& a) +ccl_device_inline float4 rcp(const float4& a) { #ifdef __KERNEL_SSE__ float4 r = _mm_rcp_ps(a.m128); @@ -682,12 +682,12 @@ __device_inline float4 rcp(const float4& a) #endif } -__device_inline float4 operator/(const float4& a, float f) +ccl_device_inline float4 operator/(const float4& a, float f) { return a * (1.0f/f); } -__device_inline float4 operator/(const float4& a, const float4& b) +ccl_device_inline float4 operator/(const float4& a, const float4& b) { #ifdef __KERNEL_SSE__ return a * rcp(b); @@ -697,7 +697,7 @@ __device_inline float4 operator/(const float4& a, const float4& b) } -__device_inline float4 operator+(const float4& a, const float4& b) +ccl_device_inline float4 operator+(const float4& a, const float4& b) { #ifdef __KERNEL_SSE__ return _mm_add_ps(a.m128, b.m128); @@ -706,7 +706,7 @@ __device_inline float4 operator+(const float4& a, const float4& b) #endif } -__device_inline float4 operator-(const float4& a, const float4& b) +ccl_device_inline float4 operator-(const float4& a, const float4& b) { #ifdef __KERNEL_SSE__ return _mm_sub_ps(a.m128, b.m128); @@ -715,22 +715,22 @@ __device_inline float4 operator-(const float4& a, const float4& b) #endif } -__device_inline float4 operator+=(float4& a, const float4& b) +ccl_device_inline float4 operator+=(float4& a, const float4& b) { return a = a + b; } -__device_inline float4 operator*=(float4& a, const float4& b) +ccl_device_inline float4 operator*=(float4& a, const float4& b) { return a = a * b; } -__device_inline float4 operator/=(float4& a, float f) +ccl_device_inline float4 operator/=(float4& a, float f) { return a = a / f; } -__device_inline int4 operator<(const float4& a, const float4& b) +ccl_device_inline int4 operator<(const float4& a, const float4& b) { #ifdef __KERNEL_SSE__ return _mm_cvtps_epi32(_mm_cmplt_ps(a.m128, b.m128)); /* todo: avoid cvt */ @@ -739,7 +739,7 @@ __device_inline int4 operator<(const float4& a, const float4& b) #endif } -__device_inline int4 operator>=(float4 a, float4 b) +ccl_device_inline int4 operator>=(float4 a, float4 b) { #ifdef __KERNEL_SSE__ return _mm_cvtps_epi32(_mm_cmpge_ps(a.m128, b.m128)); /* todo: avoid cvt */ @@ -748,7 +748,7 @@ __device_inline int4 operator>=(float4 a, float4 b) #endif } -__device_inline int4 operator<=(const float4& a, const float4& b) +ccl_device_inline int4 operator<=(const float4& a, const float4& b) { #ifdef __KERNEL_SSE__ return _mm_cvtps_epi32(_mm_cmple_ps(a.m128, b.m128)); /* todo: avoid cvt */ @@ -757,7 +757,7 @@ __device_inline int4 operator<=(const float4& a, const float4& b) #endif } -__device_inline bool operator==(const float4 a, const float4 b) +ccl_device_inline bool operator==(const float4 a, const float4 b) { #ifdef __KERNEL_SSE__ return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 15) == 15; @@ -766,7 +766,7 @@ __device_inline bool operator==(const float4 a, const float4 b) #endif } -__device_inline float4 cross(const float4& a, const float4& b) +ccl_device_inline float4 cross(const float4& a, const float4& b) { #ifdef __KERNEL_SSE__ return (shuffle<1,2,0,0>(a)*shuffle<2,0,1,0>(b)) - (shuffle<2,0,1,0>(a)*shuffle<1,2,0,0>(b)); @@ -775,7 +775,7 @@ __device_inline float4 cross(const float4& a, const float4& b) #endif } -__device_inline bool is_zero(const float4& a) +ccl_device_inline bool is_zero(const float4& a) { #ifdef __KERNEL_SSE__ return a == make_float4(0.0f); @@ -784,7 +784,7 @@ __device_inline bool is_zero(const float4& a) #endif } -__device_inline float reduce_add(const float4& a) +ccl_device_inline float reduce_add(const float4& a) { #ifdef __KERNEL_SSE__ float4 h = shuffle<1,0,3,2>(a) + a; @@ -794,27 +794,27 @@ __device_inline float reduce_add(const float4& a) #endif } -__device_inline float average(const float4& a) +ccl_device_inline float average(const float4& a) { return reduce_add(a) * 0.25f; } -__device_inline float dot(const float4& a, const float4& b) +ccl_device_inline float dot(const float4& a, const float4& b) { return reduce_add(a * b); } -__device_inline float len(const float4 a) +ccl_device_inline float len(const float4 a) { return sqrtf(dot(a, a)); } -__device_inline float4 normalize(const float4 a) +ccl_device_inline float4 normalize(const float4 a) { return a/len(a); } -__device_inline float4 min(float4 a, float4 b) +ccl_device_inline float4 min(float4 a, float4 b) { #ifdef __KERNEL_SSE__ return _mm_min_ps(a.m128, b.m128); @@ -823,7 +823,7 @@ __device_inline float4 min(float4 a, float4 b) #endif } -__device_inline float4 max(float4 a, float4 b) +ccl_device_inline float4 max(float4 a, float4 b) { #ifdef __KERNEL_SSE__ return _mm_max_ps(a.m128, b.m128); @@ -836,7 +836,7 @@ __device_inline float4 max(float4 a, float4 b) #ifndef __KERNEL_GPU__ -__device_inline float4 select(const int4& mask, const float4& a, const float4& b) +ccl_device_inline float4 select(const int4& mask, const float4& a, const float4& b) { #ifdef __KERNEL_SSE__ /* blendv is sse4, and apparently broken on vs2008 */ @@ -846,7 +846,7 @@ __device_inline float4 select(const int4& mask, const float4& a, const float4& b #endif } -__device_inline float4 reduce_min(const float4& a) +ccl_device_inline float4 reduce_min(const float4& a) { #ifdef __KERNEL_SSE__ float4 h = min(shuffle<1,0,3,2>(a), a); @@ -856,7 +856,7 @@ __device_inline float4 reduce_min(const float4& a) #endif } -__device_inline float4 reduce_max(const float4& a) +ccl_device_inline float4 reduce_max(const float4& a) { #ifdef __KERNEL_SSE__ float4 h = max(shuffle<1,0,3,2>(a), a); @@ -867,7 +867,7 @@ __device_inline float4 reduce_max(const float4& a) } #if 0 -__device_inline float4 reduce_add(const float4& a) +ccl_device_inline float4 reduce_add(const float4& a) { #ifdef __KERNEL_SSE__ float4 h = shuffle<1,0,3,2>(a) + a; @@ -878,7 +878,7 @@ __device_inline float4 reduce_add(const float4& a) } #endif -__device_inline void print_float4(const char *label, const float4& a) +ccl_device_inline void print_float4(const char *label, const float4& a) { printf("%s: %.8f %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z, (double)a.w); } @@ -889,7 +889,7 @@ __device_inline void print_float4(const char *label, const float4& a) #ifndef __KERNEL_OPENCL__ -__device_inline int3 min(int3 a, int3 b) +ccl_device_inline int3 min(int3 a, int3 b) { #ifdef __KERNEL_SSE__ return _mm_min_epi32(a.m128, b.m128); @@ -898,7 +898,7 @@ __device_inline int3 min(int3 a, int3 b) #endif } -__device_inline int3 max(int3 a, int3 b) +ccl_device_inline int3 max(int3 a, int3 b) { #ifdef __KERNEL_SSE__ return _mm_max_epi32(a.m128, b.m128); @@ -907,7 +907,7 @@ __device_inline int3 max(int3 a, int3 b) #endif } -__device_inline int3 clamp(const int3& a, int mn, int mx) +ccl_device_inline int3 clamp(const int3& a, int mn, int mx) { #ifdef __KERNEL_SSE__ return min(max(a, make_int3(mn)), make_int3(mx)); @@ -916,7 +916,7 @@ __device_inline int3 clamp(const int3& a, int mn, int mx) #endif } -__device_inline int3 clamp(const int3& a, int3& mn, int mx) +ccl_device_inline int3 clamp(const int3& a, int3& mn, int mx) { #ifdef __KERNEL_SSE__ return min(max(a, mn), make_int3(mx)); @@ -929,7 +929,7 @@ __device_inline int3 clamp(const int3& a, int3& mn, int mx) #ifndef __KERNEL_GPU__ -__device_inline void print_int3(const char *label, const int3& a) +ccl_device_inline void print_int3(const char *label, const int3& a) { printf("%s: %d %d %d\n", label, a.x, a.y, a.z); } @@ -940,7 +940,7 @@ __device_inline void print_int3(const char *label, const int3& a) #ifndef __KERNEL_GPU__ -__device_inline int4 operator+(const int4& a, const int4& b) +ccl_device_inline int4 operator+(const int4& a, const int4& b) { #ifdef __KERNEL_SSE__ return _mm_add_epi32(a.m128, b.m128); @@ -949,12 +949,12 @@ __device_inline int4 operator+(const int4& a, const int4& b) #endif } -__device_inline int4 operator+=(int4& a, const int4& b) +ccl_device_inline int4 operator+=(int4& a, const int4& b) { return a = a + b; } -__device_inline int4 operator>>(const int4& a, int i) +ccl_device_inline int4 operator>>(const int4& a, int i) { #ifdef __KERNEL_SSE__ return _mm_srai_epi32(a.m128, i); @@ -963,7 +963,7 @@ __device_inline int4 operator>>(const int4& a, int i) #endif } -__device_inline int4 min(int4 a, int4 b) +ccl_device_inline int4 min(int4 a, int4 b) { #ifdef __KERNEL_SSE__ return _mm_min_epi32(a.m128, b.m128); @@ -972,7 +972,7 @@ __device_inline int4 min(int4 a, int4 b) #endif } -__device_inline int4 max(int4 a, int4 b) +ccl_device_inline int4 max(int4 a, int4 b) { #ifdef __KERNEL_SSE__ return _mm_max_epi32(a.m128, b.m128); @@ -981,12 +981,12 @@ __device_inline int4 max(int4 a, int4 b) #endif } -__device_inline int4 clamp(const int4& a, const int4& mn, const int4& mx) +ccl_device_inline int4 clamp(const int4& a, const int4& mn, const int4& mx) { return min(max(a, mn), mx); } -__device_inline int4 select(const int4& mask, const int4& a, const int4& b) +ccl_device_inline int4 select(const int4& mask, const int4& a, const int4& b) { #ifdef __KERNEL_SSE__ __m128 m = _mm_cvtepi32_ps(mask); @@ -996,7 +996,7 @@ __device_inline int4 select(const int4& mask, const int4& a, const int4& b) #endif } -__device_inline void print_int4(const char *label, const int4& a) +ccl_device_inline void print_int4(const char *label, const int4& a) { printf("%s: %d %d %d %d\n", label, a.x, a.y, a.z, a.w); } @@ -1007,49 +1007,49 @@ __device_inline void print_int4(const char *label, const int4& a) #ifndef __KERNEL_OPENCL__ -__device_inline int as_int(uint i) +ccl_device_inline int as_int(uint i) { union { uint ui; int i; } u; u.ui = i; return u.i; } -__device_inline uint as_uint(int i) +ccl_device_inline uint as_uint(int i) { union { uint ui; int i; } u; u.i = i; return u.ui; } -__device_inline uint as_uint(float f) +ccl_device_inline uint as_uint(float f) { union { uint i; float f; } u; u.f = f; return u.i; } -__device_inline int __float_as_int(float f) +ccl_device_inline int __float_as_int(float f) { union { int i; float f; } u; u.f = f; return u.i; } -__device_inline float __int_as_float(int i) +ccl_device_inline float __int_as_float(int i) { union { int i; float f; } u; u.i = i; return u.f; } -__device_inline uint __float_as_uint(float f) +ccl_device_inline uint __float_as_uint(float f) { union { uint i; float f; } u; u.f = f; return u.i; } -__device_inline float __uint_as_float(uint i) +ccl_device_inline float __uint_as_float(uint i) { union { uint i; float f; } u; u.i = i; @@ -1065,7 +1065,7 @@ template A lerp(const A& a, const A& b, const B& t) /* Triangle */ -__device_inline float triangle_area(const float3 v1, const float3 v2, const float3 v3) +ccl_device_inline float triangle_area(const float3 v1, const float3 v2, const float3 v3) { return len(cross(v3 - v2, v1 - v2))*0.5f; } @@ -1074,7 +1074,7 @@ __device_inline float triangle_area(const float3 v1, const float3 v2, const floa /* Orthonormal vectors */ -__device_inline void make_orthonormals(const float3 N, float3 *a, float3 *b) +ccl_device_inline void make_orthonormals(const float3 N, float3 *a, float3 *b) { #if 0 if(fabsf(N.y) >= 0.999f) { @@ -1100,7 +1100,7 @@ __device_inline void make_orthonormals(const float3 N, float3 *a, float3 *b) /* Color division */ -__device_inline float3 safe_divide_color(float3 a, float3 b) +ccl_device_inline float3 safe_divide_color(float3 a, float3 b) { float x, y, z; @@ -1111,7 +1111,7 @@ __device_inline float3 safe_divide_color(float3 a, float3 b) return make_float3(x, y, z); } -__device_inline float3 safe_divide_even_color(float3 a, float3 b) +ccl_device_inline float3 safe_divide_even_color(float3 a, float3 b) { float x, y, z; @@ -1149,7 +1149,7 @@ __device_inline float3 safe_divide_even_color(float3 a, float3 b) /* Rotation of point around axis and angle */ -__device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle) +ccl_device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle) { float costheta = cosf(angle); float sintheta = sinf(angle); @@ -1172,12 +1172,12 @@ __device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle) /* NaN-safe math ops */ -__device_inline float safe_sqrtf(float f) +ccl_device_inline float safe_sqrtf(float f) { return sqrtf(max(f, 0.0f)); } -__device float safe_asinf(float a) +ccl_device float safe_asinf(float a) { if(a <= -1.0f) return -M_PI_2_F; @@ -1187,7 +1187,7 @@ __device float safe_asinf(float a) return asinf(a); } -__device float safe_acosf(float a) +ccl_device float safe_acosf(float a) { if(a <= -1.0f) return M_PI_F; @@ -1197,7 +1197,7 @@ __device float safe_acosf(float a) return acosf(a); } -__device float compatible_powf(float x, float y) +ccl_device float compatible_powf(float x, float y) { /* GPU pow doesn't accept negative x, do manual checks here */ if(x < 0.0f) { @@ -1212,7 +1212,7 @@ __device float compatible_powf(float x, float y) return powf(x, y); } -__device float safe_powf(float a, float b) +ccl_device float safe_powf(float a, float b) { if(b == 0.0f) return 1.0f; @@ -1224,7 +1224,7 @@ __device float safe_powf(float a, float b) return compatible_powf(a, b); } -__device float safe_logf(float a, float b) +ccl_device float safe_logf(float a, float b) { if(a < 0.0f || b < 0.0f) return 0.0f; @@ -1232,19 +1232,19 @@ __device float safe_logf(float a, float b) return logf(a)/logf(b); } -__device float safe_divide(float a, float b) +ccl_device float safe_divide(float a, float b) { return (b != 0.0f)? a/b: 0.0f; } -__device float safe_modulo(float a, float b) +ccl_device float safe_modulo(float a, float b) { return (b != 0.0f)? fmodf(a, b): 0.0f; } /* Ray Intersection */ -__device bool ray_sphere_intersect( +ccl_device bool ray_sphere_intersect( float3 ray_P, float3 ray_D, float ray_t, float3 sphere_P, float sphere_radius, float3 *isect_P, float *isect_t) @@ -1276,7 +1276,7 @@ __device bool ray_sphere_intersect( return false; } -__device bool ray_aligned_disk_intersect( +ccl_device bool ray_aligned_disk_intersect( float3 ray_P, float3 ray_D, float ray_t, float3 disk_P, float disk_radius, float3 *isect_P, float *isect_t) @@ -1305,7 +1305,7 @@ __device bool ray_aligned_disk_intersect( return true; } -__device bool ray_triangle_intersect( +ccl_device bool ray_triangle_intersect( float3 ray_P, float3 ray_D, float ray_t, float3 v0, float3 v1, float3 v2, float3 *isect_P, float *isect_t) @@ -1348,7 +1348,7 @@ __device bool ray_triangle_intersect( return true; } -__device bool ray_quad_intersect( +ccl_device bool ray_quad_intersect( float3 ray_P, float3 ray_D, float ray_t, float3 quad_P, float3 quad_u, float3 quad_v, float3 *isect_P, float *isect_t) diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h index 01655bdf9bc..1b6315ba484 100644 --- a/intern/cycles/util/util_transform.h +++ b/intern/cycles/util/util_transform.h @@ -43,7 +43,7 @@ typedef struct Transform { * * For the DecompMotionTransform we drop scale from pre/post. */ -typedef struct __may_alias MotionTransform { +typedef struct ccl_may_alias MotionTransform { Transform pre; Transform mid; Transform post; @@ -57,7 +57,7 @@ typedef struct DecompMotionTransform { /* Functions */ -__device_inline float3 transform_perspective(const Transform *t, const float3 a) +ccl_device_inline float3 transform_perspective(const Transform *t, const float3 a) { float4 b = make_float4(a.x, a.y, a.z, 1.0f); float3 c = make_float3(dot(t->x, b), dot(t->y, b), dot(t->z, b)); @@ -66,7 +66,7 @@ __device_inline float3 transform_perspective(const Transform *t, const float3 a) return (w != 0.0f)? c/w: make_float3(0.0f, 0.0f, 0.0f); } -__device_inline float3 transform_point(const Transform *t, const float3 a) +ccl_device_inline float3 transform_point(const Transform *t, const float3 a) { float3 c = make_float3( a.x*t->x.x + a.y*t->x.y + a.z*t->x.z + t->x.w, @@ -76,7 +76,7 @@ __device_inline float3 transform_point(const Transform *t, const float3 a) return c; } -__device_inline float3 transform_direction(const Transform *t, const float3 a) +ccl_device_inline float3 transform_direction(const Transform *t, const float3 a) { float3 c = make_float3( a.x*t->x.x + a.y*t->x.y + a.z*t->x.z, @@ -86,7 +86,7 @@ __device_inline float3 transform_direction(const Transform *t, const float3 a) return c; } -__device_inline float3 transform_direction_transposed(const Transform *t, const float3 a) +ccl_device_inline float3 transform_direction_transposed(const Transform *t, const float3 a) { float3 x = make_float3(t->x.x, t->y.x, t->z.x); float3 y = make_float3(t->x.y, t->y.y, t->z.y); @@ -95,7 +95,7 @@ __device_inline float3 transform_direction_transposed(const Transform *t, const return make_float3(dot(x, a), dot(y, a), dot(z, a)); } -__device_inline Transform transform_transpose(const Transform a) +ccl_device_inline Transform transform_transpose(const Transform a) { Transform t; @@ -107,7 +107,7 @@ __device_inline Transform transform_transpose(const Transform a) return t; } -__device_inline Transform make_transform(float a, float b, float c, float d, +ccl_device_inline Transform make_transform(float a, float b, float c, float d, float e, float f, float g, float h, float i, float j, float k, float l, float m, float n, float o, float p) @@ -124,7 +124,7 @@ __device_inline Transform make_transform(float a, float b, float c, float d, #ifndef __KERNEL_GPU__ -__device_inline Transform operator*(const Transform a, const Transform b) +ccl_device_inline Transform operator*(const Transform a, const Transform b) { Transform c = transform_transpose(b); Transform t; @@ -137,7 +137,7 @@ __device_inline Transform operator*(const Transform a, const Transform b) return t; } -__device_inline void print_transform(const char *label, const Transform& t) +ccl_device_inline void print_transform(const char *label, const Transform& t) { print_float4(label, t.x); print_float4(label, t.y); @@ -146,7 +146,7 @@ __device_inline void print_transform(const char *label, const Transform& t) printf("\n"); } -__device_inline Transform transform_translate(float3 t) +ccl_device_inline Transform transform_translate(float3 t) { return make_transform( 1, 0, 0, t.x, @@ -155,12 +155,12 @@ __device_inline Transform transform_translate(float3 t) 0, 0, 0, 1); } -__device_inline Transform transform_translate(float x, float y, float z) +ccl_device_inline Transform transform_translate(float x, float y, float z) { return transform_translate(make_float3(x, y, z)); } -__device_inline Transform transform_scale(float3 s) +ccl_device_inline Transform transform_scale(float3 s) { return make_transform( s.x, 0, 0, 0, @@ -169,12 +169,12 @@ __device_inline Transform transform_scale(float3 s) 0, 0, 0, 1); } -__device_inline Transform transform_scale(float x, float y, float z) +ccl_device_inline Transform transform_scale(float x, float y, float z) { return transform_scale(make_float3(x, y, z)); } -__device_inline Transform transform_perspective(float fov, float n, float f) +ccl_device_inline Transform transform_perspective(float fov, float n, float f) { Transform persp = make_transform( 1, 0, 0, 0, @@ -189,7 +189,7 @@ __device_inline Transform transform_perspective(float fov, float n, float f) return scale * persp; } -__device_inline Transform transform_rotate(float angle, float3 axis) +ccl_device_inline Transform transform_rotate(float angle, float3 axis) { float s = sinf(angle); float c = cosf(angle); @@ -216,7 +216,7 @@ __device_inline Transform transform_rotate(float angle, float3 axis) 0.0f, 0.0f, 0.0f, 1.0f); } -__device_inline Transform transform_euler(float3 euler) +ccl_device_inline Transform transform_euler(float3 euler) { return transform_rotate(euler.x, make_float3(1.0f, 0.0f, 0.0f)) * @@ -224,33 +224,33 @@ __device_inline Transform transform_euler(float3 euler) transform_rotate(euler.z, make_float3(0.0f, 0.0f, 1.0f)); } -__device_inline Transform transform_orthographic(float znear, float zfar) +ccl_device_inline Transform transform_orthographic(float znear, float zfar) { return transform_scale(1.0f, 1.0f, 1.0f / (zfar-znear)) * transform_translate(0.0f, 0.0f, -znear); } -__device_inline Transform transform_identity() +ccl_device_inline Transform transform_identity() { return transform_scale(1.0f, 1.0f, 1.0f); } -__device_inline bool operator==(const Transform& A, const Transform& B) +ccl_device_inline bool operator==(const Transform& A, const Transform& B) { return memcmp(&A, &B, sizeof(Transform)) == 0; } -__device_inline bool operator!=(const Transform& A, const Transform& B) +ccl_device_inline bool operator!=(const Transform& A, const Transform& B) { return !(A == B); } -__device_inline float3 transform_get_column(const Transform *t, int column) +ccl_device_inline float3 transform_get_column(const Transform *t, int column) { return make_float3(t->x[column], t->y[column], t->z[column]); } -__device_inline void transform_set_column(Transform *t, int column, float3 value) +ccl_device_inline void transform_set_column(Transform *t, int column, float3 value) { t->x[column] = value.x; t->y[column] = value.y; @@ -259,7 +259,7 @@ __device_inline void transform_set_column(Transform *t, int column, float3 value Transform transform_inverse(const Transform& a); -__device_inline bool transform_uniform_scale(const Transform& tfm, float& scale) +ccl_device_inline bool transform_uniform_scale(const Transform& tfm, float& scale) { /* the epsilon here is quite arbitrary, but this function is only used for * surface area and bump, where we except it to not be so sensitive */ @@ -283,7 +283,7 @@ __device_inline bool transform_uniform_scale(const Transform& tfm, float& scale) return false; } -__device_inline bool transform_negative_scale(const Transform& tfm) +ccl_device_inline bool transform_negative_scale(const Transform& tfm) { float3 c0 = transform_get_column(&tfm, 0); float3 c1 = transform_get_column(&tfm, 1); @@ -292,7 +292,7 @@ __device_inline bool transform_negative_scale(const Transform& tfm) return (dot(cross(c0, c1), c2) < 0.0f); } -__device_inline Transform transform_clear_scale(const Transform& tfm) +ccl_device_inline Transform transform_clear_scale(const Transform& tfm) { Transform ntfm = tfm; @@ -307,7 +307,7 @@ __device_inline Transform transform_clear_scale(const Transform& tfm) /* Motion Transform */ -__device_inline float4 quat_interpolate(float4 q1, float4 q2, float t) +ccl_device_inline float4 quat_interpolate(float4 q1, float4 q2, float t) { /* use simpe nlerp instead of slerp. it's faster and almost the same */ return normalize((1.0f - t)*q1 + t*q2); @@ -333,7 +333,7 @@ __device_inline float4 quat_interpolate(float4 q1, float4 q2, float t) #endif } -__device_inline Transform transform_quick_inverse(Transform M) +ccl_device_inline Transform transform_quick_inverse(Transform M) { /* possible optimization: can we avoid doing this altogether and construct * the inverse matrix directly from negated translation, transposed rotation, @@ -356,7 +356,7 @@ __device_inline Transform transform_quick_inverse(Transform M) return R; } -__device_inline void transform_compose(Transform *tfm, const Transform *decomp) +ccl_device_inline void transform_compose(Transform *tfm, const Transform *decomp) { /* rotation */ float q0, q1, q2, q3, qda, qdb, qdc, qaa, qab, qac, qbb, qbc, qcc; @@ -395,7 +395,7 @@ __device_inline void transform_compose(Transform *tfm, const Transform *decomp) /* Disabled for now, need arc-length parametrization for constant speed motion. * #define CURVED_MOTION_INTERPOLATE */ -__device void transform_motion_interpolate(Transform *tfm, const DecompMotionTransform *motion, float t) +ccl_device void transform_motion_interpolate(Transform *tfm, const DecompMotionTransform *motion, float t) { /* possible optimization: is it worth it adding a check to skip scaling? * it's probably quite uncommon to have scaling objects. or can we skip @@ -447,7 +447,7 @@ __device void transform_motion_interpolate(Transform *tfm, const DecompMotionTra #ifndef __KERNEL_GPU__ -__device_inline bool operator==(const MotionTransform& A, const MotionTransform& B) +ccl_device_inline bool operator==(const MotionTransform& A, const MotionTransform& B) { return (A.pre == B.pre && A.post == B.post); } diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index a8f514864db..c53d67235f6 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -27,24 +27,22 @@ #ifndef __KERNEL_GPU__ -#define __device static inline -#define __device_noinline static -#define __global -#define __local -#define __shared -#define __constant +#define ccl_device static inline +#define ccl_device_noinline static +#define ccl_global +#define ccl_constant #if defined(_WIN32) && !defined(FREE_WINDOWS) -#define __device_inline static __forceinline -#define __align(...) __declspec(align(__VA_ARGS__)) -#define __may_alias +#define ccl_device_inline static __forceinline +#define ccl_align(...) __declspec(align(__VA_ARGS__)) +#define ccl_may_alias #else -#define __device_inline static inline __attribute__((always_inline)) +#define ccl_device_inline static inline __attribute__((always_inline)) #ifndef FREE_WINDOWS64 #define __forceinline inline __attribute__((always_inline)) #endif -#define __align(...) __attribute__((aligned(__VA_ARGS__))) -#define __may_alias __attribute__((__may_alias__)) +#define ccl_align(...) __attribute__((aligned(__VA_ARGS__))) +#define ccl_may_alias __attribute__((__may_alias__)) #endif #endif @@ -190,7 +188,7 @@ struct int2 { }; #ifdef __KERNEL_SSE__ -struct __align(16) int3 { +struct ccl_align(16) int3 { union { __m128i m128; struct { int x, y, z, w; }; @@ -210,7 +208,7 @@ struct int3 { }; #ifdef __KERNEL_SSE__ -struct __align(16) int4 { +struct ccl_align(16) int4 { union { __m128i m128; struct { int x, y, z, w; }; @@ -258,7 +256,7 @@ struct float2 { }; #ifdef __KERNEL_SSE__ -struct __align(16) float3 { +struct ccl_align(16) float3 { union { __m128 m128; struct { float x, y, z, w; }; @@ -278,7 +276,7 @@ struct float3 { }; #ifdef __KERNEL_SSE__ -struct __align(16) float4 { +struct ccl_align(16) float4 { union { __m128 m128; struct { float x, y, z, w; }; @@ -305,31 +303,31 @@ struct float4 { * * OpenCL does not support C++ class, so we use these instead. */ -__device_inline uchar2 make_uchar2(uchar x, uchar y) +ccl_device_inline uchar2 make_uchar2(uchar x, uchar y) { uchar2 a = {x, y}; return a; } -__device_inline uchar3 make_uchar3(uchar x, uchar y, uchar z) +ccl_device_inline uchar3 make_uchar3(uchar x, uchar y, uchar z) { uchar3 a = {x, y, z}; return a; } -__device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w) +ccl_device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w) { uchar4 a = {x, y, z, w}; return a; } -__device_inline int2 make_int2(int x, int y) +ccl_device_inline int2 make_int2(int x, int y) { int2 a = {x, y}; return a; } -__device_inline int3 make_int3(int x, int y, int z) +ccl_device_inline int3 make_int3(int x, int y, int z) { #ifdef __KERNEL_SSE__ int3 a; @@ -341,7 +339,7 @@ __device_inline int3 make_int3(int x, int y, int z) return a; } -__device_inline int4 make_int4(int x, int y, int z, int w) +ccl_device_inline int4 make_int4(int x, int y, int z, int w) { #ifdef __KERNEL_SSE__ int4 a; @@ -353,31 +351,31 @@ __device_inline int4 make_int4(int x, int y, int z, int w) return a; } -__device_inline uint2 make_uint2(uint x, uint y) +ccl_device_inline uint2 make_uint2(uint x, uint y) { uint2 a = {x, y}; return a; } -__device_inline uint3 make_uint3(uint x, uint y, uint z) +ccl_device_inline uint3 make_uint3(uint x, uint y, uint z) { uint3 a = {x, y, z}; return a; } -__device_inline uint4 make_uint4(uint x, uint y, uint z, uint w) +ccl_device_inline uint4 make_uint4(uint x, uint y, uint z, uint w) { uint4 a = {x, y, z, w}; return a; } -__device_inline float2 make_float2(float x, float y) +ccl_device_inline float2 make_float2(float x, float y) { float2 a = {x, y}; return a; } -__device_inline float3 make_float3(float x, float y, float z) +ccl_device_inline float3 make_float3(float x, float y, float z) { #ifdef __KERNEL_SSE__ float3 a; @@ -389,7 +387,7 @@ __device_inline float3 make_float3(float x, float y, float z) return a; } -__device_inline float4 make_float4(float x, float y, float z, float w) +ccl_device_inline float4 make_float4(float x, float y, float z, float w) { #ifdef __KERNEL_SSE__ float4 a; @@ -401,12 +399,12 @@ __device_inline float4 make_float4(float x, float y, float z, float w) return a; } -__device_inline int align_up(int offset, int alignment) +ccl_device_inline int align_up(int offset, int alignment) { return (offset + alignment - 1) & ~(alignment - 1); } -__device_inline int3 make_int3(int i) +ccl_device_inline int3 make_int3(int i) { #ifdef __KERNEL_SSE__ int3 a; @@ -418,7 +416,7 @@ __device_inline int3 make_int3(int i) return a; } -__device_inline int4 make_int4(int i) +ccl_device_inline int4 make_int4(int i) { #ifdef __KERNEL_SSE__ int4 a; @@ -430,7 +428,7 @@ __device_inline int4 make_int4(int i) return a; } -__device_inline float3 make_float3(float f) +ccl_device_inline float3 make_float3(float f) { #ifdef __KERNEL_SSE__ float3 a; @@ -442,7 +440,7 @@ __device_inline float3 make_float3(float f) return a; } -__device_inline float4 make_float4(float f) +ccl_device_inline float4 make_float4(float f) { #ifdef __KERNEL_SSE__ float4 a; @@ -454,7 +452,7 @@ __device_inline float4 make_float4(float f) return a; } -__device_inline float4 make_float4(const int4& i) +ccl_device_inline float4 make_float4(const int4& i) { #ifdef __KERNEL_SSE__ float4 a; @@ -466,7 +464,7 @@ __device_inline float4 make_float4(const int4& i) return a; } -__device_inline int4 make_int4(const float3& f) +ccl_device_inline int4 make_int4(const float3& f) { #ifdef __KERNEL_SSE__ int4 a; @@ -489,17 +487,17 @@ __device_inline int4 make_int4(const float3& f) /* faster version for SSSE3 */ typedef __m128i shuffle_swap_t; -__device_inline const shuffle_swap_t shuffle_swap_identity(void) +ccl_device_inline const shuffle_swap_t shuffle_swap_identity(void) { return _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); } -__device_inline const shuffle_swap_t shuffle_swap_swap(void) +ccl_device_inline const shuffle_swap_t shuffle_swap_swap(void) { return _mm_set_epi8(7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8); } -__device_inline const __m128 shuffle_swap(const __m128& a, const shuffle_swap_t& shuf) +ccl_device_inline const __m128 shuffle_swap(const __m128& a, const shuffle_swap_t& shuf) { return _mm_castsi128_ps(_mm_shuffle_epi8(_mm_castps_si128(a), shuf)); } @@ -509,17 +507,17 @@ __device_inline const __m128 shuffle_swap(const __m128& a, const shuffle_swap_t& /* somewhat slower version for SSE2 */ typedef int shuffle_swap_t; -__device_inline const shuffle_swap_t shuffle_swap_identity(void) +ccl_device_inline const shuffle_swap_t shuffle_swap_identity(void) { return 0; } -__device_inline const shuffle_swap_t shuffle_swap_swap(void) +ccl_device_inline const shuffle_swap_t shuffle_swap_swap(void) { return 1; } -__device_inline const __m128 shuffle_swap(const __m128& a, shuffle_swap_t shuf) +ccl_device_inline const __m128 shuffle_swap(const __m128& a, shuffle_swap_t shuf) { /* shuffle value must be a constant, so we need to branch */ if(shuf) @@ -530,12 +528,12 @@ __device_inline const __m128 shuffle_swap(const __m128& a, shuffle_swap_t shuf) #endif -template __device_inline const __m128 shuffle(const __m128& a, const __m128& b) +template ccl_device_inline const __m128 shuffle(const __m128& a, const __m128& b) { return _mm_shuffle_ps(a, b, _MM_SHUFFLE(i3, i2, i1, i0)); } -template __device_inline const __m128 shuffle(const __m128& b) +template ccl_device_inline const __m128 shuffle(const __m128& b) { return _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(b), _MM_SHUFFLE(i3, i2, i1, i0))); } @@ -554,7 +552,7 @@ struct half4 { half x, y, z, w; }; #ifdef __KERNEL_CUDA__ -__device_inline void float4_store_half(half *h, const float4 *f, float scale) +ccl_device_inline void float4_store_half(half *h, const float4 *f, float scale) { h[0] = __float2half_rn(f->x * scale); h[1] = __float2half_rn(f->y * scale); @@ -564,7 +562,7 @@ __device_inline void float4_store_half(half *h, const float4 *f, float scale) #else -__device_inline void float4_store_half(half *h, const float4 *f, float scale) +ccl_device_inline void float4_store_half(half *h, const float4 *f, float scale) { #ifndef __KERNEL_SSE2__ for(int i = 0; i < 4; i++) { -- cgit v1.2.3 From 8948d53d986a72ade101bc5d163dc20b5fa67af7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 18 Nov 2013 14:02:58 +0600 Subject: Fix T37345: Image baking progress bar wrongly appears in node editor Baking job is owned by scene but only need to update image space contexts. This leads to job progress bar stuck in node editor. Made it so node editor does not display baking jobs now. --- source/blender/editors/interface/interface_templates.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 46cff2fb458..ef9b16f5445 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -3239,6 +3239,16 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) handle_event = B_STOPCOMPO; break; } + else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE)) { + /* Skip bake jobs in compositor to avoid compo header displaying + * progress bar which is not being updated (bake jobs only need + * to update NC_IMAGE context. + */ + if (sa->spacetype != SPACE_NODE) { + handle_event = B_STOPOTHER; + break; + } + } else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) { handle_event = B_STOPOTHER; break; -- cgit v1.2.3 From b492f85c52344aba2b779f7553638f0e6d933d38 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 18 Nov 2013 14:18:01 +0600 Subject: Fix part of T37326: IMAGE_OT_invert won't update if buffer is float Need to mark display buffer as out-of-date. --- source/blender/editors/space_image/image_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index ebcc8c2ebee..b7d3407b826 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1900,7 +1900,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - ibuf->userflags |= IB_BITMAPDIRTY; + ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID; if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; -- cgit v1.2.3 From 37f6bfb810f7087d1773d3712c50875cb822a9b2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 18 Nov 2013 14:27:10 +0600 Subject: Fix bug in maya/3dsmax keymaps caused by removed operator Once again, when you remove operator make sure keymaps we've got in master branch keeps working. --- release/scripts/presets/keyconfig/3dsmax.py | 1 - release/scripts/presets/keyconfig/maya.py | 1 - 2 files changed, 2 deletions(-) diff --git a/release/scripts/presets/keyconfig/3dsmax.py b/release/scripts/presets/keyconfig/3dsmax.py index e4b8659a521..e18624461a2 100644 --- a/release/scripts/presets/keyconfig/3dsmax.py +++ b/release/scripts/presets/keyconfig/3dsmax.py @@ -1063,7 +1063,6 @@ kmi = km.keymap_items.new('node.hide_toggle', 'H', 'PRESS') kmi = km.keymap_items.new('node.mute_toggle', 'M', 'PRESS') kmi = km.keymap_items.new('node.preview_toggle', 'H', 'PRESS', shift=True) kmi = km.keymap_items.new('node.hide_socket_toggle', 'H', 'PRESS', ctrl=True) -kmi = km.keymap_items.new('node.show_cyclic_dependencies', 'C', 'PRESS') kmi = km.keymap_items.new('node.view_all', 'HOME', 'PRESS') kmi = km.keymap_items.new('node.view_selected', 'NUMPAD_PERIOD', 'PRESS') kmi = km.keymap_items.new('node.select_border', 'B', 'PRESS') diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index fb2871aec3e..1b8648731aa 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -1477,7 +1477,6 @@ kmi = km.keymap_items.new('node.hide_toggle', 'H', 'PRESS', ctrl=True) kmi = km.keymap_items.new('node.mute_toggle', 'M', 'PRESS') kmi = km.keymap_items.new('node.preview_toggle', 'H', 'PRESS', shift=True) kmi = km.keymap_items.new('node.hide_socket_toggle', 'H', 'PRESS', shift=True, ctrl=True) -kmi = km.keymap_items.new('node.show_cyclic_dependencies', 'C', 'PRESS') kmi = km.keymap_items.new('node.view_all', 'A', 'PRESS') kmi = km.keymap_items.new('node.delete', 'BACK_SPACE', 'PRESS') kmi = km.keymap_items.new('node.delete', 'DEL', 'PRESS') -- cgit v1.2.3 From 106699ecd7c904dedd1a25606c072d5570faa629 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 18 Nov 2013 14:36:28 +0600 Subject: Fix T37301: Command line render gives seg fault 11 on OS X Issue was caused by wm->defaultconf being NULL when in background mode which made keymap modifications from a script crash. Reviewed by Brecht, thanks! --- source/blender/windowmanager/intern/wm_keymap.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index ed27228f107..8e202eb93f0 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -710,11 +710,13 @@ wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, EnumPrope if (!items) { /* init modal items from default config */ wmWindowManager *wm = G.main->wm.first; - wmKeyMap *defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0); + if (wm->defaultconf) { + wmKeyMap *defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0); - if (defaultkm) { - km->modal_items = defaultkm->modal_items; - km->poll = defaultkm->poll; + if (defaultkm) { + km->modal_items = defaultkm->modal_items; + km->poll = defaultkm->poll; + } } } @@ -803,6 +805,10 @@ static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km) int propvalue; if (km && (km->flag & KEYMAP_MODAL) && !km->modal_items) { + if (wm->defaultconf == NULL) { + return; + } + defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0); if (!defaultkm) @@ -1115,7 +1121,7 @@ static wmKeyMap *wm_keymap_preset(wmWindowManager *wm, wmKeyMap *km) wmKeyMap *keymap; keymap = WM_keymap_list_find(&keyconf->keymaps, km->idname, km->spaceid, km->regionid); - if (!keymap) + if (!keymap && wm->defaultconf) keymap = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, km->spaceid, km->regionid); return keymap; -- cgit v1.2.3 From 995d4d803aa889513a2d1ad4b7e26140217f3a5a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Nov 2013 20:38:53 +1100 Subject: Maintenance: Shebang lines fix for some python scripts --- release/bin/blender-thumbnailer.py | 2 +- release/scripts/modules/bl_i18n_utils/merge_po.py | 2 +- release/scripts/modules/bl_i18n_utils/utils_rtl.py | 2 +- release/scripts/modules/blend_render_info.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/release/bin/blender-thumbnailer.py b/release/bin/blender-thumbnailer.py index 8b93eebdeec..22e811c538e 100755 --- a/release/bin/blender-thumbnailer.py +++ b/release/bin/blender-thumbnailer.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # ##### BEGIN GPL LICENSE BLOCK ##### # diff --git a/release/scripts/modules/bl_i18n_utils/merge_po.py b/release/scripts/modules/bl_i18n_utils/merge_po.py index 610be0f15bd..d7dade22ffd 100755 --- a/release/scripts/modules/bl_i18n_utils/merge_po.py +++ b/release/scripts/modules/bl_i18n_utils/merge_po.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # ***** BEGIN GPL LICENSE BLOCK ***** # diff --git a/release/scripts/modules/bl_i18n_utils/utils_rtl.py b/release/scripts/modules/bl_i18n_utils/utils_rtl.py index 0544f93a262..f08d7efdb8e 100755 --- a/release/scripts/modules/bl_i18n_utils/utils_rtl.py +++ b/release/scripts/modules/bl_i18n_utils/utils_rtl.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # ***** BEGIN GPL LICENSE BLOCK ***** # diff --git a/release/scripts/modules/blend_render_info.py b/release/scripts/modules/blend_render_info.py index d08b9e09dda..a62eaeea143 100755 --- a/release/scripts/modules/blend_render_info.py +++ b/release/scripts/modules/blend_render_info.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # ##### BEGIN GPL LICENSE BLOCK ##### # -- cgit v1.2.3 From ea79dcebe2303b0b58a0791cd8b531ecc45a2394 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 18 Nov 2013 11:26:37 +0100 Subject: Fix T37468: image empties now use no interpolation when mipmaps are disabled. Image empties don't actually support mipmaps right now, but the user preference doubles as a way to disable any kind of interpolating in texture filter and just show nearest neighbour filter, so for this is a bit more consistent. --- source/blender/editors/space_view3d/drawobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 3ed1d15a9ee..2083da2d64f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -610,6 +610,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char if (ibuf && ibuf->rect) { const bool use_clip = (U.glalphaclip != 1.0f); + int zoomfilter = (U.gameflags & USER_DISABLE_MIPMAP )? GL_NEAREST : GL_LINEAR; /* Setup GL params */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -623,7 +624,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char glColor4fv(ob->col); /* Draw the Image on the screen */ - glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect); + glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_RGBA, GL_UNSIGNED_BYTE, zoomfilter, ibuf->rect); glPixelTransferf(GL_ALPHA_SCALE, 1.0f); glDisable(GL_BLEND); -- cgit v1.2.3 From 2b0162b6226df9dcb9b6819ce93f2d434afc69c4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 18 Nov 2013 17:17:43 +0600 Subject: Fix T37289: ID User decrement error for Shapes on Bones when playing in BGE GE was copying the pose channels without increasing user counter for a custom bone shape object. Freeing copied pose will for give decrement errors. The same increment issue seems to happen in BKE_pose_copy_data, which is also solved now. --- source/blender/blenkernel/intern/action.c | 10 +++++++++- source/gameengine/Converter/BL_ArmatureObject.cpp | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index fe0e3da605f..c91fae2adbc 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -589,7 +589,15 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, const bool copy_constraints) outPose = MEM_callocN(sizeof(bPose), "pose"); BLI_duplicatelist(&outPose->chanbase, &src->chanbase); - + if (outPose->chanbase.first) { + bPoseChannel *pchan; + for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) { + if (pchan->custom) { + id_us_plus(&pchan->custom->id); + } + } + } + outPose->iksolver = src->iksolver; outPose->ikdata = NULL; outPose->ikparam = MEM_dupallocN(src->ikparam); diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index d8ddb33ddc4..7ce1c7c815a 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -42,6 +42,7 @@ #include "BIK_api.h" #include "BKE_action.h" #include "BKE_armature.h" +#include "BKE_library.h" #include "BKE_constraint.h" #include "CTR_Map.h" @@ -120,6 +121,10 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) pchan->constraints.last = NULL; } + if (pchan->custom) { + id_us_plus(&pchan->custom->id); + } + // fails to link, props are not used in the BGE yet. #if 0 if (pchan->prop) -- cgit v1.2.3 From 53753c0ddc947aa74246492fb76466198a28db58 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 18 Nov 2013 18:13:23 +0600 Subject: Fix T37488: Crash with --debug reading userpref.blend Issue was in fact caused by wrong DNA storage, which apparently was considering unsigned long as just 4 bytes here. Now use uint64_t to be sure timestamp does fit into storage on all the platforms. Thanks Campbell for help looking in the issue. --- source/blender/blenkernel/BKE_main.h | 2 +- source/blender/makesdna/DNA_fileglobal_types.h | 4 ++-- source/gameengine/Ketsji/KX_PythonMain.h | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 629eda3b583..7b7b69034a9 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -53,7 +53,7 @@ typedef struct Main { char name[1024]; /* 1024 = FILE_MAX */ short versionfile, subversionfile; /* see BLENDER_VERSION, BLENDER_SUBVERSION */ short minversionfile, minsubversionfile; - unsigned long build_commit_timestamp; /* commit's timestamp from buildinfo */ + uint64_t build_commit_timestamp; /* commit's timestamp from buildinfo */ char build_hash[16]; /* hash from buildinfo */ short recovered; /* indicate the main->name (file) is the recovered one */ diff --git a/source/blender/makesdna/DNA_fileglobal_types.h b/source/blender/makesdna/DNA_fileglobal_types.h index f0f8fe7d40c..040b55d9eb6 100644 --- a/source/blender/makesdna/DNA_fileglobal_types.h +++ b/source/blender/makesdna/DNA_fileglobal_types.h @@ -48,8 +48,8 @@ typedef struct FileGlobal { struct Scene *curscene; int fileflags; int globalf; - unsigned long build_commit_timestamp; /* commit timestamp from buildinfo */ - char build_hash[12]; /* hash from buildinfo */ + uint64_t build_commit_timestamp; /* commit timestamp from buildinfo */ + char build_hash[16]; /* hash from buildinfo */ /* file path where this was saved, for recover */ char filename[1024]; /* 1024 = FILE_MAX */ } FileGlobal; diff --git a/source/gameengine/Ketsji/KX_PythonMain.h b/source/gameengine/Ketsji/KX_PythonMain.h index e638fa9094e..c627a4a147a 100644 --- a/source/gameengine/Ketsji/KX_PythonMain.h +++ b/source/gameengine/Ketsji/KX_PythonMain.h @@ -32,6 +32,7 @@ #ifndef __KX_PYTHON_MAIN__ #define __KX_PYTHON_MAIN__ +#include "BLI_sys_types.h" #include "BKE_main.h" #include "DNA_scene_types.h" extern "C" char *KX_GetPythonMain(struct Scene* scene); -- cgit v1.2.3 From 0b01cc131650c25ec41ad2f2354c1d6c711c3664 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Nov 2013 23:54:07 +1100 Subject: Compile Fix: fix for gcc4.8 with bmesh header. --- source/blender/bmesh/intern/bmesh_polygon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h index 5d98a9a40db..4b3b7f4b837 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.h +++ b/source/blender/bmesh/intern/bmesh_polygon.h @@ -29,7 +29,7 @@ #include "BLI_compiler_attrs.h" -void BM_bmesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[], int *r_looptris_tot); +void BM_bmesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptris_tot); int BM_face_calc_tessellation(const BMFace *f, BMLoop **r_loops, int (*r_index)[3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); void BM_face_calc_normal(const BMFace *f, float r_no[3]) ATTR_NONNULL(); -- cgit v1.2.3 From 5eb1dba6e0d0308de7ae2b549029c0bbced22631 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Mon, 18 Nov 2013 14:30:38 +0100 Subject: Cmake: after lot of times commit checking missed including collada, set on by default now --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8195785a372..fdea7e35012 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,7 +227,7 @@ endif() # 3D format support # disable opencollada on non-apple unix because opencollada has no package for debian -option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" OFF) +option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" ON) # Sound output option(WITH_SDL "Enable SDL for sound and joystick support" ON) -- cgit v1.2.3 From b6b4aabf041e34a76b79ff6cfad3fd739b3bb090 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 02:28:21 +1100 Subject: Fix T37511: toggle-drag feature was crashing with menu items. --- source/blender/editors/interface/interface_handlers.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index bb129c1ec9f..cff7500e6ef 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -859,6 +859,13 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void } } +static bool ui_is_but_drag_toggle(uiBut *but) +{ + return ((ui_is_but_bool(but) == true) && + /* menu check is importnt so the button dragged over isn't removed instantly */ + (ui_block_is_menu(but->block) == false)); +} + #endif /* USE_DRAG_TOGGLE */ @@ -2748,7 +2755,7 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, cons { #ifdef USE_DRAG_TOGGLE if (data->state == BUTTON_STATE_HIGHLIGHT) { - if (event->type == LEFTMOUSE && event->val == KM_PRESS && ui_is_but_bool(but)) { + if (event->type == LEFTMOUSE && event->val == KM_PRESS && ui_is_but_drag_toggle(but)) { #if 0 /* UNUSED */ data->togdual = event->ctrl; data->togonly = !event->shift; @@ -2797,7 +2804,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con } } #ifdef USE_DRAG_TOGGLE - if (event->type == LEFTMOUSE && ui_is_but_bool(but)) { + if (event->type == LEFTMOUSE && ui_is_but_drag_toggle(but)) { button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG); data->dragstartx = event->x; data->dragstarty = event->y; @@ -3623,7 +3630,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co } } #ifdef USE_DRAG_TOGGLE - if (event->type == LEFTMOUSE && ui_is_but_bool(but)) { + if (event->type == LEFTMOUSE && ui_is_but_drag_toggle(but)) { button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG); data->dragstartx = event->x; data->dragstarty = event->y; -- cgit v1.2.3 From 67aff56c01337919b60c88c31416349c172c77b1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 02:52:34 +1100 Subject: Fix T37506: Duplicate Area into New, was disabled on fullscreen but works ok. --- source/blender/editors/screen/screen_ops.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index b226104a356..93923c24c84 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -915,14 +915,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) sa = sad->sa1; } - - /* poll() checks area context, but we don't accept full-area windows */ - if (sc->full != SCREENNORMAL) { - if (event->type == EVT_ACTIONZONE_AREA) - actionzone_exit(op); - return OPERATOR_CANCELLED; - } - + /* adds window to WM */ rect = sa->totrct; BLI_rcti_translate(&rect, win->posx, win->posy); -- cgit v1.2.3 From 2d4bfc5e60e50474e8fc66a44fde3b0bca93edaf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 03:27:47 +1100 Subject: Fix T37495: Duplis weren't handling negative scaled objects properly. --- source/blender/editors/space_view3d/view3d_draw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 8b7d5756429..1bf137e5787 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2037,8 +2037,11 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas /* negative scale flag has to propagate */ transflag = tbase.object->transflag; - if (base->object->transflag & OB_NEG_SCALE) - tbase.object->transflag ^= OB_NEG_SCALE; + + if (is_negative_m4(dob->mat)) + tbase.object->transflag |= OB_NEG_SCALE; + else + tbase.object->transflag &= ~OB_NEG_SCALE; UI_ThemeColorBlend(color, TH_BACK, 0.5); -- cgit v1.2.3 From c73f82b6f07c76705be52d7bb40ee866aea98b9c Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 18 Nov 2013 09:30:46 -0800 Subject: Fix T37040: Removing vehicles in BGE causes a crash The vehicle constraint is now properly removed if bge.constraints.removeConstraint() is used or the object is deleted. This also fixes a memory leak with the vehicle wrapper. --- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 71ed6af2f99..cddc12cc754 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -83,6 +83,11 @@ public: { } + ~WrapperVehicle() + { + delete m_vehicle; + } + btRaycastVehicle* GetVehicle() { return m_vehicle; @@ -440,6 +445,19 @@ bool CcdPhysicsEnvironment::RemoveCcdPhysicsController(CcdPhysicsController* ctr //delete con; //might be kept by python KX_ConstraintWrapper } m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody()); + + // Handle potential vehicle constraints + int numVehicles = m_wrapperVehicles.size(); + int vehicle_constraint = 0; + for (int i=0;iGetChassis() == ctrl) + vehicle_constraint = wrapperVehicle->GetVehicle()->getUserConstraintId(); + } + + if (vehicle_constraint > 0) + RemoveConstraint(vehicle_constraint); } else { //if a softbody @@ -984,6 +1002,14 @@ void CcdPhysicsEnvironment::RemoveConstraint(int constraintId) break; } } + + WrapperVehicle *vehicle; + if ((vehicle = (WrapperVehicle*)GetVehicleConstraint(constraintId))) + { + m_dynamicsWorld->removeVehicle(vehicle->GetVehicle()); + m_wrapperVehicles.erase(std::remove(m_wrapperVehicles.begin(), m_wrapperVehicles.end(), vehicle)); + delete vehicle; + } } -- cgit v1.2.3 From 6f3f107c5973cd68699f90256e5c0a7fc2dfb8fe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 05:18:57 +1100 Subject: Fix T37336: Toggle selecting a pose-bone from object mode would de-select all others. --- source/blender/editors/armature/pose_select.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index b3277c185d4..765437f3622 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -129,9 +129,16 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor * note, special exception for armature mode so we can do multi-select * we could check for multi-select explicitly but think its fine to * always give predictable behavior in weight paint mode - campbell */ - if ((!extend && !deselect && !toggle) || - ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) - { + if ((ob_act == NULL) || ((ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0)) { + /* when we are entering into posemode via toggle-select, + * frop another active object - always select the bone. */ + if (!extend && !deselect && toggle) { + /* re-select below */ + nearBone->flag &= ~BONE_SELECTED; + } + } + + if (!extend && !deselect && !toggle) { ED_pose_deselectall(ob, 0); nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); arm->act_bone = nearBone; -- cgit v1.2.3 From df060e5d21787420ebf10df35d25d61b5ff57999 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 05:49:39 +1100 Subject: Fix T37088: Crash with eyedropper (shortcut E) --- source/blender/editors/interface/interface_handlers.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index cff7500e6ef..05d7700f634 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -6729,6 +6729,8 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) // retval = WM_UI_HANDLER_BREAK; XXX why ? } + /* may have been re-allocated above (eyedropper for eg) */ + data = but->active; if (data->state == BUTTON_STATE_EXIT) { uiBut *post_but = data->postbut; uiButtonActivateType post_type = data->posttype; -- cgit v1.2.3 From bea9c3ab30b5946d84298bc6fd85d38ed4a6802f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 07:00:18 +1100 Subject: Fix T36998: Bisect would operate on unselected vertices. --- source/blender/bmesh/tools/bmesh_bisect_plane.c | 49 ++++++++++++++++++------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c index c3c2924ea8e..6aeb26435ac 100644 --- a/source/blender/bmesh/tools/bmesh_bisect_plane.c +++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c @@ -300,31 +300,26 @@ void BM_mesh_bisect_plane(BMesh *bm, float plane[4], BMIter iter; - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - vert_is_center_disable(v); - - BM_VERT_DIR(v) = plane_point_test_v3(plane, v->co, eps, &(BM_VERT_DIST(v))); - if (BM_VERT_DIR(v) == 0) { - if (oflag_center) { - BMO_elem_flag_enable(bm, v, oflag_center); - } - if (use_snap_center) { - closest_to_plane_v3(v->co, plane, v->co); - } - } - } - if (use_tag) { /* build tagged edge array */ BMEdge *e; einput_len = 0; + + /* flush edge tags to verts */ + BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false); + /* keep face tags as is */ BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) { if (edge_is_cut_test(e)) { edges_arr[einput_len++] = e; + + /* flush edge tags to verts */ + BM_elem_flag_enable(e->v1, BM_ELEM_TAG); + BM_elem_flag_enable(e->v2, BM_ELEM_TAG); } } + /* face tags are set by caller */ } else { BMEdge *e; @@ -339,6 +334,32 @@ void BM_mesh_bisect_plane(BMesh *bm, float plane[4], } } + + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + + if (use_tag && !BM_elem_flag_test(v, BM_ELEM_TAG)) { + vert_is_center_disable(v); + + /* these should never be accessed */ + BM_VERT_DIR(v) = 0; + BM_VERT_DIST(v) = 0.0f; + + continue; + } + + vert_is_center_disable(v); + BM_VERT_DIR(v) = plane_point_test_v3(plane, v->co, eps, &(BM_VERT_DIST(v))); + + if (BM_VERT_DIR(v) == 0) { + if (oflag_center) { + BMO_elem_flag_enable(bm, v, oflag_center); + } + if (use_snap_center) { + closest_to_plane_v3(v->co, plane, v->co); + } + } + } + /* store a stack of faces to be evaluated for splitting */ BLI_LINKSTACK_INIT(face_stack); -- cgit v1.2.3 From 3bc0552c5b16bdf1469d64d761ebd0b45e72060b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 07:10:56 +1100 Subject: Fix for running datablock eyedropper outside of a button. --- source/blender/editors/interface/interface_eyedropper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index 01e53d5e721..a01c7eecda1 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -439,7 +439,9 @@ static void datadropper_exit(bContext *C, wmOperator *op) if (op->customdata) { DataDropper *ddr = (DataDropper *)op->customdata; - ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel); + if (ddr->art) { + ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel); + } MEM_freeN(op->customdata); -- cgit v1.2.3 From 55e3be560e5895be593dcf93a50dcd09631729b8 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 18 Nov 2013 14:18:46 -0800 Subject: Fix T36756: Use Frame Rate option toolip was unclear about which FPS value to respect --- source/blender/makesrna/intern/rna_scene.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2a68f0afc35..4d8592e7d7a 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3428,7 +3428,8 @@ static void rna_def_scene_game_data(BlenderRNA *brna) prop = RNA_def_property(srna, "use_frame_rate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_ENABLE_ALL_FRAMES); RNA_def_property_ui_text(prop, "Use Frame Rate", - "Respect the frame rate rather than rendering as many frames as possible"); + "Respect the frame rate from the Physics panel in the world properties " + "rather than rendering as many frames as possible"); prop = RNA_def_property(srna, "use_display_lists", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_DISPLAY_LISTS); -- cgit v1.2.3 From 0f32bc49ecb54911eea705d661443fbb09d0ff9d Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 18 Nov 2013 14:52:07 -0800 Subject: Fix T37171: Camera parented to a bone doesn't move with the bone, unless another object is parented too Armatures used to check if any of their meshes were culled to see if they needed to be updated. However, this meant armatures with no meshes would never update, since non-mesh objects are always considered culled. Instead, if a non-culled child was not found, we now check to see if the armature contained only non-mesh objects. If this is the case, always update the armature. If this becomes a problem, we can look into being able to cull non-mesh objects. --- source/gameengine/Ketsji/KX_Scene.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 5a956ffc048..2f23bdaccb7 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1613,16 +1613,29 @@ void KX_Scene::UpdateAnimations(double curtime) CListValue *children = gameobj->GetChildren(); KX_GameObject *child; + bool has_mesh = false, has_non_mesh = false; + // Check for meshes that haven't been culled for (int j=0; jGetCount(); ++j) { child = (KX_GameObject*)children->GetValue(j); - if (child->GetMeshCount() > 0 && !child->GetCulled()) { + if (!child->GetCulled()) { needs_update = true; break; } + + if (child->GetMeshCount() == 0) + has_non_mesh = true; + else + has_mesh = true; } + // If we didn't find a non-culled mesh, check to see + // if we even have any meshes, and update if this + // armature has only non-mesh children. + if (!needs_update && !has_mesh && has_non_mesh) + needs_update = true; + children->Release(); } -- cgit v1.2.3 From 965c1357c4ef78142dee73b09e52f5d86a5e840f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 18 Nov 2013 17:12:19 +0100 Subject: CMake: only enable opencollada by default on OS X and Windows, consistent with scons. --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fdea7e35012..d3a4d65e0ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,8 +226,12 @@ else() endif() # 3D format support -# disable opencollada on non-apple unix because opencollada has no package for debian -option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" ON) +# Disable opencollada when we don't have precompiled libs +if(APPLE OR WIN32) + option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" ON) +else() + option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" OFF) +endif() # Sound output option(WITH_SDL "Enable SDL for sound and joystick support" ON) -- cgit v1.2.3 From 4da651c8f0ffc3b0cc21752cbcaed5e10f228a86 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 11:18:00 +1100 Subject: Fix T37472: crash when packing UV islands. --- source/blender/blenlib/intern/convexhull2d.c | 4 +++- source/blender/python/mathutils/mathutils_geometry.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/blenlib/intern/convexhull2d.c b/source/blender/blenlib/intern/convexhull2d.c index 5669a302bd8..2c29ef042a1 100644 --- a/source/blender/blenlib/intern/convexhull2d.c +++ b/source/blender/blenlib/intern/convexhull2d.c @@ -191,6 +191,8 @@ static int pointref_cmp_y(const void *a_, const void *b_) * \param points An array of 2D points. * \param n The number of points in points. * \param r_points An array of the convex hull vertex indices (max is n). + * _must_ be allocated as ``n * 2`` becauise of how its used internally, + * even though the final result will be no more then \a n in size. * \returns the number of points in r_points. */ int BLI_convexhull_2d(const float (*points)[2], const int n, int r_points[]) @@ -310,7 +312,7 @@ float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], unsigned int n float angle; - index_map = MEM_mallocN(sizeof(*index_map) * n, __func__); + index_map = MEM_mallocN(sizeof(*index_map) * n * 2, __func__); tot = BLI_convexhull_2d((const float (*)[2])points, (int)n, index_map); diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 8b5b74c480a..584861d4c49 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1563,7 +1563,7 @@ static PyObject *M_Geometry_convex_hull_2d(PyObject *UNUSED(self), PyObject *poi int *index_map; Py_ssize_t len_ret, i; - index_map = MEM_mallocN(sizeof(*index_map) * len, __func__); + index_map = MEM_mallocN(sizeof(*index_map) * len * 2, __func__); /* Non Python function */ len_ret = BLI_convexhull_2d((const float (*)[2])points, len, index_map); -- cgit v1.2.3 From 74a1e4dcf23c0ba2b3ed84888e8c7225f872e9f9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 13:11:31 +1100 Subject: Fix T37519: Screw Modifier ignores material setup This was more a missing feature then a bug, the modifier never handled existing faces however with ngons its possible to get more useful results. Also order edges from the faces (if available), gives control over the face-winding-direction. --- release/scripts/addons | 2 +- source/blender/modifiers/intern/MOD_screw.c | 44 +++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/release/scripts/addons b/release/scripts/addons index c50944e808d..2bfbbe4182d 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit c50944e808d6c74148237e85866e893628f0fee6 +Subproject commit 2bfbbe4182d7e5d5332d963054f298c9fddc5f09 diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 0dd2f2770a4..f3d5157a6ef 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -151,6 +151,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, int maxVerts = 0, maxEdges = 0, maxPolys = 0; const unsigned int totvert = dm->getNumVerts(dm); const unsigned int totedge = dm->getNumEdges(dm); + const unsigned int totpoly = dm->getNumPolys(dm); + int *edge_poly_map = NULL; char axis_char = 'X', close; float angle = ltmd->angle; @@ -168,8 +170,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, int edge_offset; - MPoly *mpoly_new, *mp_new; - MLoop *mloop_new, *ml_new; + MPoly *mpoly_orig, *mpoly_new, *mp_new; + MLoop *mloop_orig, *mloop_new, *ml_new; MEdge *medge_orig, *med_orig, *med_new, *med_new_firstloop, *medge_new; MVert *mvert_new, *mvert_orig, *mv_orig, *mv_new, *mv_new_base; @@ -333,6 +335,29 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, med_new->flag = med_orig->flag & ~ME_LOOSEEDGE; } + /* build polygon -> edge map */ + if (totpoly) { + MPoly *mp_orig; + + mpoly_orig = dm->getPolyArray(dm); + mloop_orig = dm->getLoopArray(dm); + edge_poly_map = MEM_mallocN(sizeof(*edge_poly_map) * totedge, __func__); + fill_vn_i(edge_poly_map, totedge, -1); + + for (i = 0, mp_orig = mpoly_orig; i < totpoly; i++, mp_orig++) { + MLoop *ml_orig = &mloop_orig[mp_orig->loopstart]; + int j; + for (j = 0; j < mp_orig->totloop; j++, ml_orig++) { + edge_poly_map[ml_orig->e] = i; + + /* also order edges based on faces */ + if (medge_new[ml_orig->e].v1 != ml_orig->v) { + SWAP(unsigned int, medge_new[ml_orig->e].v1, medge_new[ml_orig->e].v2); + } + } + } + } + if (ltmd->flag & MOD_SCREW_NORMAL_CALC) { /* * Normal Calculation (for face flipping) @@ -775,10 +800,19 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, edge_offset = totedge + (totvert * (step_tot - (close ? 0 : 1))); for (i = 0; i < totedge; i++, med_new_firstloop++) { + short mat_nr; + /* for each edge, make a cylinder of quads */ i1 = med_new_firstloop->v1; i2 = med_new_firstloop->v2; + if (totpoly && (edge_poly_map[i] != -1)) { + mat_nr = mpoly_orig[edge_poly_map[i]].mat_nr; + } + else { + mat_nr = 0; + } + for (step = 0; step < step_tot - 1; step++) { /* new face */ @@ -808,6 +842,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mp_new->loopstart = mpoly_index * 4; mp_new->totloop = 4; + mp_new->mat_nr = mat_nr; mp_new->flag = mpoly_flag; origindex[mpoly_index] = ORIGINDEX_NONE; mp_new++; @@ -853,6 +888,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mp_new->loopstart = mpoly_index * 4; mp_new->totloop = 4; + mp_new->mat_nr = mat_nr; mp_new->flag = mpoly_flag; origindex[mpoly_index] = ORIGINDEX_NONE; mp_new++; @@ -896,6 +932,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } #endif + if (edge_poly_map) { + MEM_freeN(edge_poly_map); + } + if ((ltmd->flag & MOD_SCREW_NORMAL_CALC) == 0) { result->dirty |= DM_DIRTY_NORMALS; } -- cgit v1.2.3 From 95d3286c65e034d9801c2623e81ef92a06e6cc8c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 13:34:16 +1100 Subject: Fix T37464: Crash when pressing "V" in UV/Image editor Also fix for missing draw-handler free. Delay activating until we know 'stitch_init' succeeds. --- source/blender/editors/uvedit/uvedit_smart_stitch.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index c234d1769b3..28e28238ca9 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1613,10 +1613,7 @@ static int stitch_init(bContext *C, wmOperator *op) if (!ar) return 0; - state = MEM_mallocN(sizeof(StitchState), "stitch state"); - - if (!state) - return 0; + state = MEM_callocN(sizeof(StitchState), "stitch state"); op->customdata = state; @@ -1648,7 +1645,6 @@ static int stitch_init(bContext *C, wmOperator *op) } } - state->draw_handle = ED_region_draw_cb_activate(ar->type, stitch_draw, state, REGION_DRAW_POST_VIEW); /* in uv synch selection, all uv's are visible */ if (ts->uv_flag & UV_SYNC_SELECTION) { state->element_map = BM_uv_element_map_create(state->em->bm, false, true); @@ -1926,6 +1922,8 @@ static int stitch_init(bContext *C, wmOperator *op) return 0; } + state->draw_handle = ED_region_draw_cb_activate(ar->type, stitch_draw, state, REGION_DRAW_POST_VIEW); + stitch_update_header(state, C); return 1; } -- cgit v1.2.3 From 2b946f42970bf4f3b8ce8e5c9b79451745309d89 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 14:31:26 +1100 Subject: Fix T37445: Crash with snapping and shrink-wrap modifier. Developer note: BVHTREE_FROM_FACES was being used for both edit-mesh and derived-mesh bvh-trees, this could cause index lookup errors in editmode. Fix by adding a new type for editmesh so theres no confusion. --- source/blender/blenkernel/BKE_bvhutils.h | 2 ++ source/blender/blenkernel/intern/bvhutils.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h index 8d4c9e782db..9e1bca45432 100644 --- a/source/blender/blenkernel/BKE_bvhutils.h +++ b/source/blender/blenkernel/BKE_bvhutils.h @@ -116,6 +116,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f #define BVHTREE_FROM_VERTICES 1 #define BVHTREE_FROM_EDGES 2 +#define BVHTREE_FROM_FACES_EDITMESH 3 + typedef struct LinkNode *BVHCache; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index dba7a291a46..cce511aedcb 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -573,8 +573,9 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *dm, float e /* Builds a bvh tree.. where nodes are the faces of the given dm. */ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *dm, float epsilon, int tree_type, int axis) { - BVHTree *tree = bvhcache_find(&dm->bvhCache, BVHTREE_FROM_FACES); BMEditMesh *em = data->em_evil; + const int bvhcache_type = em ? BVHTREE_FROM_FACES_EDITMESH : BVHTREE_FROM_FACES; + BVHTree *tree = bvhcache_find(&dm->bvhCache, bvhcache_type); /* Not in cache */ if (tree == NULL) { @@ -682,7 +683,7 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *dm, float e /* Save on cache for later use */ // printf("BVHTree built and saved on cache\n"); - bvhcache_insert(&dm->bvhCache, tree, BVHTREE_FROM_FACES); + bvhcache_insert(&dm->bvhCache, tree, bvhcache_type); } } } -- cgit v1.2.3 From 4c42e73a9d398ccebb110d0c4cefc93e099fcfcb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 16:45:21 +1100 Subject: Fix T37399: Crash with wireframe (wasn't clearing edge tag) --- source/blender/bmesh/operators/bmo_wireframe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c index 7f1008813ad..94b35426e2b 100644 --- a/source/blender/bmesh/operators/bmo_wireframe.c +++ b/source/blender/bmesh/operators/bmo_wireframe.c @@ -210,7 +210,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) } /* setup tags, all faces and verts will be tagged which will be duplicated */ - BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, false); + BM_mesh_elem_hflag_disable_all(bm, BM_FACE | BM_EDGE, BM_ELEM_TAG, false); BMO_ITER (f_src, &oiter, op->slots_in, "faces", BM_FACE) { verts_loop_tot += f_src->len; -- cgit v1.2.3 From 1968612e5b48299a0c03de807e242f36b41c68c8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Nov 2013 17:16:15 +1100 Subject: View3D: Add menu in the header is now context sensitive (like shift+a). --- release/scripts/startup/bl_ui/space_view3d.py | 29 +++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 16cef7cf6fb..ec9c7ae9ffc 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -54,9 +54,17 @@ class VIEW3D_HT_header(Header): elif mode_string not in {'EDIT_TEXT', 'SCULPT'}: sub.menu("VIEW3D_MT_select_%s" % mode_string.lower()) - if mode_string in {'OBJECT', 'EDIT_MESH', 'EDIT_CURVE', 'EDIT_SURFACE', 'EDIT_METABALL'}: - sub.menu("INFO_MT_add") - + if mode_string == 'OBJECT': + sub.menu("INFO_MT_add", text="Add") + elif mode_string == 'EDIT_MESH': + sub.menu("INFO_MT_mesh_add", text="Add") + elif mode_string == 'EDIT_CURVE': + sub.menu("INFO_MT_curve_add", text="Add") + elif mode_string == 'EDIT_SURFACE': + sub.menu("INFO_MT_surface_add", text="Add") + elif mode_string == 'EDIT_METABALL': + sub.menu("INFO_MT_metaball_add", text="Add") + if edit_object: sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower()) elif obj: @@ -877,6 +885,17 @@ class INFO_MT_surface_add(Menu): layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus") +class INFO_MT_metaball_add(Menu): + bl_idname = "INFO_MT_metaball_add" + bl_label = "Metaball" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'INVOKE_REGION_WIN' + layout.operator_enum("object.metaball_add", "type") + + class INFO_MT_edit_curve_add(Menu): bl_idname = "INFO_MT_edit_curve_add" bl_label = "Add" @@ -923,9 +942,7 @@ class INFO_MT_add(Menu): layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE') #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE') layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE') - layout.operator_context = 'INVOKE_REGION_WIN' - layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META') - layout.operator_context = 'EXEC_REGION_WIN' + layout.menu("INFO_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META') layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT') layout.separator() -- cgit v1.2.3 From 1e479d1722df16fe62ed244ef248eb5f528bc908 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Nov 2013 13:15:17 +0600 Subject: Potential fix for T37525: Viewer node causes crash LOCK_DRAW_IMAGE used to be unlocked twice. Now made it so all the thread-unsafe code is inside a single lock/ unlock section. --- source/blender/compositor/operations/COM_ViewerOperation.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index 468aec64a56..97be44e2be0 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -147,8 +147,6 @@ void ViewerOperation::initImage() ima->ok = IMA_OK_LOADED; ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; - - BLI_unlock_thread(LOCK_DRAW_IMAGE); } if (m_doDepthBuffer) { -- cgit v1.2.3 From 46684d1ad2a9ea6c6eea2a2e4baf3c7c4aa3ecb5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Nov 2013 15:01:00 +0600 Subject: Initial tweaks to buildbot configuration Pretty much sure more tweaks would be needed, but need this to get started. --- build_files/scons/tools/btools.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 607b761261c..f7a5eb8cf06 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -55,12 +55,12 @@ def get_version(): raise Exception("%s: missing version string" % fname) -def get_revision(): - build_rev = os.popen('svnversion').read()[:-1] # remove \n - if build_rev == '' or build_rev==None: - build_rev = 'UNKNOWN' +def get_hash(): + build_hash = os.popen('git rev-parse --short HEAD').read().strip() + if build_hash == '' or build_hash == None: + build_hash = 'UNKNOWN' - return 'r' + build_rev + return build_hash # copied from: http://www.scons.org/wiki/AutoconfRecipes @@ -80,7 +80,7 @@ def checkEndian(): # This is used in creating the local config directories VERSION, VERSION_DISPLAY, VERSION_RELEASE_CYCLE = get_version() -REVISION = get_revision() +HASH = get_hash() ENDIAN = checkEndian() @@ -693,7 +693,7 @@ def buildslave(target=None, source=None, env=None): branch = env['BUILDBOT_BRANCH'] outdir = os.path.abspath(env['BF_INSTALLDIR']) - package_name = 'blender-' + VERSION+'-'+REVISION + '-' + platform + package_name = 'blender-' + VERSION+'-'+HASH + '-' + platform if branch != '': package_name = branch + '-' + package_name package_dir = os.path.normpath(outdir + os.sep + '..' + os.sep + package_name) -- cgit v1.2.3 From 998fe530761a72ebbea85368634c152297dc4ca2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Nov 2013 15:27:28 +0600 Subject: Buildbot: tweaks for source directory Need this so checkout of existing svn does not interferes with new git checkout which would need to be done. --- build_files/buildbot/slave_compile.py | 2 +- build_files/buildbot/slave_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index f9aa45a4023..e45b4f1971f 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -31,7 +31,7 @@ if len(sys.argv) < 2: builder = sys.argv[1] # we run from build/ directory -blender_dir = '../blender' +blender_dir = '../blender.git' if builder.find('cmake') != -1: # cmake diff --git a/build_files/buildbot/slave_test.py b/build_files/buildbot/slave_test.py index d5acc8fd7a6..ef7a4b23d04 100644 --- a/build_files/buildbot/slave_test.py +++ b/build_files/buildbot/slave_test.py @@ -29,7 +29,7 @@ if len(sys.argv) < 2: builder = sys.argv[1] # we run from build/ directory -blender_dir = '../blender' +blender_dir = '../blender.git' if "cmake" in builder: # cmake -- cgit v1.2.3 From 631ae088ffa077a3c8916ce453076a2396b79b4a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 19 Nov 2013 11:00:53 +0100 Subject: Fix T37535: Hebrew charset was missing two chars. --- release/datafiles/fonts/droidsans.ttf.gz | Bin 2644825 -> 2644887 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/release/datafiles/fonts/droidsans.ttf.gz b/release/datafiles/fonts/droidsans.ttf.gz index 81683e6379f..c76cf67992c 100644 Binary files a/release/datafiles/fonts/droidsans.ttf.gz and b/release/datafiles/fonts/droidsans.ttf.gz differ -- cgit v1.2.3 From 3c662efee33be215092255dd23e4f4f0dc71b502 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Nov 2013 16:01:45 +0600 Subject: Buildbot: fix path got pack step --- build_files/buildbot/slave_pack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py index 3e8ae939dd5..b6e817b2e6f 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -40,7 +40,7 @@ if len(sys.argv) >= 3: # scons does own packaging if builder.find('scons') != -1: - os.chdir('../blender') + os.chdir('../blender.git') scons_options = ['BF_QUICK=slnt', 'BUILDBOT_BRANCH=' + branch, 'buildslave', 'BF_FANCY=False'] buildbot_dir = os.path.dirname(os.path.realpath(__file__)) -- cgit v1.2.3 From c566e408e42836c136d8818cbea93ce870be09ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Tue, 19 Nov 2013 11:06:16 +0100 Subject: Cleanup: Renamed compositor executePixel functions and their 'read' wrappers in SocketReader. Distinguish the 3 different methods for acquiring pixel color values (executePixel, executePixelSampled, executePixelFiltered). This makes it easier to keep track of the different sampling methods (and works nicer with IDEs that do code parsing). Differential Revision: http://developer.blender.org/D7 --- .../blender/compositor/intern/COM_SocketReader.h | 14 +- .../operations/COM_AlphaOverKeyOperation.cpp | 8 +- .../operations/COM_AlphaOverKeyOperation.h | 2 +- .../operations/COM_AlphaOverMixedOperation.cpp | 8 +- .../operations/COM_AlphaOverMixedOperation.h | 2 +- .../COM_AlphaOverPremultiplyOperation.cpp | 8 +- .../operations/COM_AlphaOverPremultiplyOperation.h | 2 +- .../operations/COM_BlurBaseOperation.cpp | 2 +- .../operations/COM_BokehBlurOperation.cpp | 10 +- .../operations/COM_BokehImageOperation.cpp | 2 +- .../operations/COM_BokehImageOperation.h | 2 +- .../compositor/operations/COM_BoxMaskOperation.cpp | 6 +- .../compositor/operations/COM_BoxMaskOperation.h | 2 +- .../operations/COM_BrightnessOperation.cpp | 8 +- .../operations/COM_BrightnessOperation.h | 2 +- .../operations/COM_ChangeHSVOperation.cpp | 4 +- .../compositor/operations/COM_ChangeHSVOperation.h | 2 +- .../operations/COM_ChannelMatteOperation.cpp | 4 +- .../operations/COM_ChannelMatteOperation.h | 2 +- .../operations/COM_ChromaMatteOperation.cpp | 6 +- .../operations/COM_ChromaMatteOperation.h | 2 +- .../operations/COM_ColorBalanceASCCDLOperation.cpp | 6 +- .../operations/COM_ColorBalanceASCCDLOperation.h | 2 +- .../operations/COM_ColorBalanceLGGOperation.cpp | 6 +- .../operations/COM_ColorBalanceLGGOperation.h | 2 +- .../operations/COM_ColorCorrectionOperation.cpp | 6 +- .../operations/COM_ColorCorrectionOperation.h | 2 +- .../operations/COM_ColorCurveOperation.cpp | 16 +-- .../operations/COM_ColorCurveOperation.h | 4 +- .../operations/COM_ColorMatteOperation.cpp | 6 +- .../operations/COM_ColorMatteOperation.h | 2 +- .../operations/COM_ColorRampOperation.cpp | 4 +- .../compositor/operations/COM_ColorRampOperation.h | 2 +- .../operations/COM_ColorSpillOperation.cpp | 6 +- .../operations/COM_ColorSpillOperation.h | 2 +- .../operations/COM_CompositorOperation.cpp | 6 +- .../COM_ConvertColorProfileOperation.cpp | 4 +- .../operations/COM_ConvertColorProfileOperation.h | 2 +- .../COM_ConvertDepthToRadiusOperation.cpp | 4 +- .../operations/COM_ConvertDepthToRadiusOperation.h | 2 +- .../compositor/operations/COM_ConvertOperation.cpp | 74 +++++----- .../compositor/operations/COM_ConvertOperation.h | 34 ++--- .../compositor/operations/COM_CropOperation.cpp | 8 +- .../compositor/operations/COM_CropOperation.h | 4 +- .../operations/COM_DifferenceMatteOperation.cpp | 6 +- .../operations/COM_DifferenceMatteOperation.h | 2 +- .../operations/COM_DirectionalBlurOperation.cpp | 4 +- .../operations/COM_DisplaceOperation.cpp | 12 +- .../operations/COM_DisplaceSimpleOperation.cpp | 10 +- .../operations/COM_DisplaceSimpleOperation.h | 2 +- .../operations/COM_DistanceRGBMatteOperation.cpp | 6 +- .../operations/COM_DistanceRGBMatteOperation.h | 2 +- .../operations/COM_DotproductOperation.cpp | 6 +- .../operations/COM_DotproductOperation.h | 2 +- .../operations/COM_EllipseMaskOperation.cpp | 6 +- .../operations/COM_EllipseMaskOperation.h | 2 +- .../compositor/operations/COM_FlipOperation.cpp | 4 +- .../compositor/operations/COM_FlipOperation.h | 2 +- .../operations/COM_GammaCorrectOperation.cpp | 8 +- .../operations/COM_GammaCorrectOperation.h | 4 +- .../compositor/operations/COM_GammaOperation.cpp | 6 +- .../compositor/operations/COM_GammaOperation.h | 2 +- .../operations/COM_GlareThresholdOperation.cpp | 4 +- .../operations/COM_GlareThresholdOperation.h | 2 +- .../COM_HueSaturationValueCorrectOperation.cpp | 4 +- .../COM_HueSaturationValueCorrectOperation.h | 2 +- .../compositor/operations/COM_IDMaskOperation.cpp | 4 +- .../compositor/operations/COM_IDMaskOperation.h | 2 +- .../compositor/operations/COM_ImageOperation.cpp | 6 +- .../compositor/operations/COM_ImageOperation.h | 6 +- .../compositor/operations/COM_InvertOperation.cpp | 6 +- .../compositor/operations/COM_InvertOperation.h | 2 +- .../operations/COM_KeyingDespillOperation.cpp | 6 +- .../operations/COM_KeyingDespillOperation.h | 2 +- .../compositor/operations/COM_KeyingOperation.cpp | 6 +- .../compositor/operations/COM_KeyingOperation.h | 2 +- .../operations/COM_LuminanceMatteOperation.cpp | 4 +- .../operations/COM_LuminanceMatteOperation.h | 2 +- .../operations/COM_MapRangeOperation.cpp | 12 +- .../compositor/operations/COM_MapRangeOperation.h | 2 +- .../compositor/operations/COM_MapUVOperation.cpp | 14 +- .../compositor/operations/COM_MapUVOperation.h | 2 +- .../operations/COM_MapValueOperation.cpp | 4 +- .../compositor/operations/COM_MapValueOperation.h | 2 +- .../compositor/operations/COM_MaskOperation.cpp | 2 +- .../compositor/operations/COM_MaskOperation.h | 2 +- .../operations/COM_MathBaseOperation.cpp | 108 +++++++------- .../compositor/operations/COM_MathBaseOperation.h | 38 ++--- .../compositor/operations/COM_MixOperation.cpp | 160 ++++++++++----------- .../compositor/operations/COM_MixOperation.h | 40 +++--- .../operations/COM_MovieClipAttributeOperation.cpp | 2 +- .../operations/COM_MovieClipAttributeOperation.h | 2 +- .../operations/COM_MovieClipOperation.cpp | 6 +- .../compositor/operations/COM_MovieClipOperation.h | 4 +- .../operations/COM_MovieDistortionOperation.cpp | 6 +- .../operations/COM_MovieDistortionOperation.h | 2 +- .../operations/COM_MultilayerImageOperation.cpp | 6 +- .../operations/COM_MultilayerImageOperation.h | 6 +- .../operations/COM_OutputFileOperation.cpp | 2 +- .../operations/COM_PixelateOperation.cpp | 4 +- .../compositor/operations/COM_PixelateOperation.h | 2 +- .../operations/COM_PlaneTrackMaskOperation.cpp | 2 +- .../operations/COM_PlaneTrackMaskOperation.h | 2 +- .../COM_PlaneTrackWarpImageOperation.cpp | 4 +- .../operations/COM_PlaneTrackWarpImageOperation.h | 2 +- .../compositor/operations/COM_PreviewOperation.cpp | 2 +- .../COM_ProjectorLensDistortionOperation.cpp | 2 +- .../operations/COM_ReadBufferOperation.cpp | 4 +- .../operations/COM_ReadBufferOperation.h | 4 +- .../compositor/operations/COM_RenderLayersProg.cpp | 6 +- .../compositor/operations/COM_RenderLayersProg.h | 6 +- .../compositor/operations/COM_RotateOperation.cpp | 6 +- .../compositor/operations/COM_RotateOperation.h | 2 +- .../compositor/operations/COM_ScaleOperation.cpp | 30 ++-- .../compositor/operations/COM_ScaleOperation.h | 6 +- .../COM_ScreenLensDistortionOperation.cpp | 4 +- .../operations/COM_SetAlphaOperation.cpp | 6 +- .../compositor/operations/COM_SetAlphaOperation.h | 2 +- .../operations/COM_SetColorOperation.cpp | 2 +- .../compositor/operations/COM_SetColorOperation.h | 2 +- .../operations/COM_SetSamplerOperation.cpp | 4 +- .../operations/COM_SetSamplerOperation.h | 2 +- .../operations/COM_SetValueOperation.cpp | 2 +- .../compositor/operations/COM_SetValueOperation.h | 2 +- .../operations/COM_SetVectorOperation.cpp | 2 +- .../compositor/operations/COM_SetVectorOperation.h | 2 +- .../operations/COM_SocketProxyOperation.cpp | 4 +- .../operations/COM_SocketProxyOperation.h | 2 +- .../compositor/operations/COM_SplitOperation.cpp | 6 +- .../compositor/operations/COM_SplitOperation.h | 2 +- .../compositor/operations/COM_TextureOperation.cpp | 12 +- .../compositor/operations/COM_TextureOperation.h | 4 +- .../operations/COM_TrackPositionOperation.cpp | 2 +- .../operations/COM_TrackPositionOperation.h | 2 +- .../operations/COM_TranslateOperation.cpp | 4 +- .../compositor/operations/COM_TranslateOperation.h | 6 +- .../COM_VariableSizeBokehBlurOperation.cpp | 2 +- .../COM_VariableSizeBokehBlurOperation.h | 2 +- .../operations/COM_VectorCurveOperation.cpp | 4 +- .../operations/COM_VectorCurveOperation.h | 2 +- .../compositor/operations/COM_ViewerOperation.cpp | 6 +- .../compositor/operations/COM_WrapOperation.cpp | 2 +- .../compositor/operations/COM_WrapOperation.h | 2 +- .../operations/COM_WriteBufferOperation.cpp | 6 +- .../operations/COM_WriteBufferOperation.h | 2 +- .../operations/COM_ZCombineOperation.cpp | 40 +++--- .../compositor/operations/COM_ZCombineOperation.h | 8 +- 147 files changed, 552 insertions(+), 552 deletions(-) diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h index b7aae8b92f0..2eaeb664c67 100644 --- a/source/blender/compositor/intern/COM_SocketReader.h +++ b/source/blender/compositor/intern/COM_SocketReader.h @@ -63,7 +63,7 @@ protected: * @param y the y-coordinate of the pixel to calculate in image space * @param inputBuffers chunks that can be read by their ReadBufferOperation. */ - virtual void executePixel(float output[4], float x, float y, PixelSampler sampler) {} + virtual void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) {} /** * @brief calculate a single pixel @@ -75,7 +75,7 @@ protected: * @param chunkData chunk specific data a during execution time. */ virtual void executePixel(float output[4], int x, int y, void *chunkData) { - executePixel(output, x, y, COM_PS_NEAREST); + executePixelSampled(output, x, y, COM_PS_NEAREST); } /** @@ -88,17 +88,17 @@ protected: * @param dy * @param inputBuffers chunks that can be read by their ReadBufferOperation. */ - virtual void executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) {} + virtual void executePixelFiltered(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) {} public: - inline void read(float result[4], float x, float y, PixelSampler sampler) { - executePixel(result, x, y, sampler); + inline void readSampled(float result[4], float x, float y, PixelSampler sampler) { + executePixelSampled(result, x, y, sampler); } inline void read(float result[4], int x, int y, void *chunkData) { executePixel(result, x, y, chunkData); } - inline void read(float result[4], float x, float y, float dx, float dy, PixelSampler sampler) { - executePixel(result, x, y, dx, dy, sampler); + inline void readFiltered(float result[4], float x, float y, float dx, float dy, PixelSampler sampler) { + executePixelFiltered(result, x, y, dx, dy, sampler); } virtual void *initializeTileData(rcti *rect) { return 0; } diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp index 6cc9aae4553..d4103a61685 100644 --- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp @@ -27,15 +27,15 @@ AlphaOverKeyOperation::AlphaOverKeyOperation() : MixBaseOperation() /* pass */ } -void AlphaOverKeyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void AlphaOverKeyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputOverColor[4]; float value[4]; - this->m_inputValueOperation->read(value, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputOverColor, x, y, sampler); + this->m_inputValueOperation->readSampled(value, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler); if (inputOverColor[3] <= 0.0f) { copy_v4_v4(output, inputColor1); diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h index 31b0422918a..eceee43e600 100644 --- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h @@ -39,6 +39,6 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp index 111dc899e1d..1dba542e142 100644 --- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp @@ -27,15 +27,15 @@ AlphaOverMixedOperation::AlphaOverMixedOperation() : MixBaseOperation() this->m_x = 0.0f; } -void AlphaOverMixedOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void AlphaOverMixedOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputOverColor[4]; float value[4]; - this->m_inputValueOperation->read(value, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputOverColor, x, y, sampler); + this->m_inputValueOperation->readSampled(value, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler); if (inputOverColor[3] <= 0.0f) { copy_v4_v4(output, inputColor1); diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h index 14e7325ec1d..ff6d1a978b8 100644 --- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h @@ -41,7 +41,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void setX(float x) { this->m_x = x; } }; diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp index ac7906f2f98..60a2fd6a442 100644 --- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp @@ -27,15 +27,15 @@ AlphaOverPremultiplyOperation::AlphaOverPremultiplyOperation() : MixBaseOperatio /* pass */ } -void AlphaOverPremultiplyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void AlphaOverPremultiplyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputOverColor[4]; float value[4]; - this->m_inputValueOperation->read(value, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputOverColor, x, y, sampler); + this->m_inputValueOperation->readSampled(value, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler); /* Zero alpha values should still permit an add of RGB data */ if (inputOverColor[3] < 0.0f) { diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h index 16bd2aeaeed..db68583baa6 100644 --- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index cc91210a385..dfff2bfeafb 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -152,7 +152,7 @@ void BlurBaseOperation::updateSize() { if (!this->m_sizeavailable) { float result[4]; - this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST); + this->getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST); this->m_size = result[0]; this->m_sizeavailable = true; } diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp index 1c91af2a7a3..7f17db1d31b 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp @@ -80,7 +80,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data) float tempBoundingBox[4]; float bokeh[4]; - this->m_inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST); + this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, COM_PS_NEAREST); if (tempBoundingBox[0] > 0.0f) { float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; @@ -93,7 +93,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data) zero_v4(color_accum); if (pixelSize < 2) { - this->m_inputProgram->read(color_accum, x, y, COM_PS_NEAREST); + this->m_inputProgram->readSampled(color_accum, x, y, COM_PS_NEAREST); multiplier_accum[0] = 1.0f; multiplier_accum[1] = 1.0f; multiplier_accum[2] = 1.0f; @@ -118,7 +118,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data) for (int nx = minx; nx < maxx; nx += step) { float u = this->m_bokehMidX - (nx - x) * m; float v = this->m_bokehMidY - (ny - y) * m; - this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST); + this->m_inputBokehProgram->readSampled(bokeh, u, v, COM_PS_NEAREST); madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]); add_v4_v4(multiplier_accum, bokeh); bufferindex += offsetadd; @@ -130,7 +130,7 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data) output[3] = color_accum[3] * (1.0f / multiplier_accum[3]); } else { - this->m_inputProgram->read(output, x, y, COM_PS_NEAREST); + this->m_inputProgram->readSampled(output, x, y, COM_PS_NEAREST); } } @@ -220,7 +220,7 @@ void BokehBlurOperation::updateSize() { if (!this->m_sizeavailable) { float result[4]; - this->getInputSocketReader(3)->read(result, 0, 0, COM_PS_NEAREST); + this->getInputSocketReader(3)->readSampled(result, 0, 0, COM_PS_NEAREST); this->m_size = result[0]; CLAMP(this->m_size, 0.0f, 10.0f); this->m_sizeavailable = true; diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp index b87be33eca1..82de750de72 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp @@ -85,7 +85,7 @@ float BokehImageOperation::isInsideBokeh(float distance, float x, float y) } return insideBokeh; } -void BokehImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void BokehImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float shift = this->m_data->lensshift; float shift2 = shift / 2.0f; diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h index 44c4c0cfe27..f1f0f1ed11c 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.h +++ b/source/blender/compositor/operations/COM_BokehImageOperation.h @@ -111,7 +111,7 @@ public: /** * @brief the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * @brief Initialize the execution diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp index 52f84462761..4dd92aec4c8 100644 --- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp @@ -44,7 +44,7 @@ void BoxMaskOperation::initExecution() this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight(); } -void BoxMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void BoxMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputMask[4]; float inputValue[4]; @@ -57,8 +57,8 @@ void BoxMaskOperation::executePixel(float output[4], float x, float y, PixelSamp rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy); ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy); - this->m_inputMask->read(inputMask, x, y, sampler); - this->m_inputValue->read(inputValue, x, y, sampler); + this->m_inputMask->readSampled(inputMask, x, y, sampler); + this->m_inputValue->readSampled(inputValue, x, y, sampler); float halfHeight = this->m_data->height / 2.0f; float halfWidth = this->m_data->width / 2.0f; diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.h b/source/blender/compositor/operations/COM_BoxMaskOperation.h index f39d74829d4..04dc8a90fd7 100644 --- a/source/blender/compositor/operations/COM_BoxMaskOperation.h +++ b/source/blender/compositor/operations/COM_BoxMaskOperation.h @@ -45,7 +45,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp index 0613540250c..33e35c3fe3b 100644 --- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp +++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp @@ -37,15 +37,15 @@ void BrightnessOperation::initExecution() this->m_inputContrastProgram = this->getInputSocketReader(2); } -void BrightnessOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void BrightnessOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue[4]; float a, b; float inputBrightness[4]; float inputContrast[4]; - this->m_inputProgram->read(inputValue, x, y, sampler); - this->m_inputBrightnessProgram->read(inputBrightness, x, y, sampler); - this->m_inputContrastProgram->read(inputContrast, x, y, sampler); + this->m_inputProgram->readSampled(inputValue, x, y, sampler); + this->m_inputBrightnessProgram->readSampled(inputBrightness, x, y, sampler); + this->m_inputContrastProgram->readSampled(inputContrast, x, y, sampler); float brightness = inputBrightness[0]; float contrast = inputContrast[0]; brightness /= 100.0f; diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.h b/source/blender/compositor/operations/COM_BrightnessOperation.h index 1c8eda63e94..22086ae11e8 100644 --- a/source/blender/compositor/operations/COM_BrightnessOperation.h +++ b/source/blender/compositor/operations/COM_BrightnessOperation.h @@ -40,7 +40,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp index e6e93774685..964f1d64667 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp @@ -39,11 +39,11 @@ void ChangeHSVOperation::deinitExecution() this->m_inputOperation = NULL; } -void ChangeHSVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ChangeHSVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; - this->m_inputOperation->read(inputColor1, x, y, sampler); + this->m_inputOperation->readSampled(inputColor1, x, y, sampler); output[0] = inputColor1[0] + (this->m_hue - 0.5f); if (output[0] > 1.0f) output[0] -= 1.0f; diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h index 01852084e41..76025e86b7a 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h @@ -49,7 +49,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void setHue(float hue) { this->m_hue = hue; } void setSaturation(float saturation) { this->m_saturation = saturation; } diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp index 84cc8aad950..14494841c49 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp @@ -88,7 +88,7 @@ void ChannelMatteOperation::deinitExecution() this->m_inputImageProgram = NULL; } -void ChannelMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ChannelMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inColor[4]; float alpha; @@ -97,7 +97,7 @@ void ChannelMatteOperation::executePixel(float output[4], float x, float y, Pixe const float limit_min = this->m_limit_min; const float limit_range = this->m_limit_range; - this->m_inputImageProgram->read(inColor, x, y, sampler); + this->m_inputImageProgram->readSampled(inColor, x, y, sampler); /* matte operation */ alpha = inColor[this->m_ids[0]] - max(inColor[this->m_ids[1]], inColor[this->m_ids[2]]); diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h index efb4f7427ca..58b467e7892 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h @@ -59,7 +59,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp index c2406abaa65..3329093882d 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp @@ -44,7 +44,7 @@ void ChromaMatteOperation::deinitExecution() this->m_inputKeyProgram = NULL; } -void ChromaMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ChromaMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inKey[4]; float inImage[4]; @@ -57,8 +57,8 @@ void ChromaMatteOperation::executePixel(float output[4], float x, float y, Pixel float theta, beta; float kfg; - this->m_inputKeyProgram->read(inKey, x, y, sampler); - this->m_inputImageProgram->read(inImage, x, y, sampler); + this->m_inputKeyProgram->readSampled(inKey, x, y, sampler); + this->m_inputImageProgram->readSampled(inImage, x, y, sampler); /* store matte(alpha) value in [0] to go with * COM_SetAlphaOperation and the Value output diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h index 9557faec855..a68790838c0 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h @@ -42,7 +42,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp index 1456aaf6a55..2846642570c 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp @@ -49,13 +49,13 @@ void ColorBalanceASCCDLOperation::initExecution() this->m_inputColorOperation = this->getInputSocketReader(1); } -void ColorBalanceASCCDLOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ColorBalanceASCCDLOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; float value[4]; - this->m_inputValueOperation->read(value, x, y, sampler); - this->m_inputColorOperation->read(inputColor, x, y, sampler); + this->m_inputValueOperation->readSampled(value, x, y, sampler); + this->m_inputColorOperation->readSampled(inputColor, x, y, sampler); float fac = value[0]; fac = min(1.0f, fac); diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h index ee0b89f7f70..bf3495869b0 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h @@ -49,7 +49,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp index 7e9c10df0a9..9588687372e 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp @@ -54,13 +54,13 @@ void ColorBalanceLGGOperation::initExecution() this->m_inputColorOperation = this->getInputSocketReader(1); } -void ColorBalanceLGGOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ColorBalanceLGGOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; float value[4]; - this->m_inputValueOperation->read(value, x, y, sampler); - this->m_inputColorOperation->read(inputColor, x, y, sampler); + this->m_inputValueOperation->readSampled(value, x, y, sampler); + this->m_inputColorOperation->readSampled(inputColor, x, y, sampler); float fac = value[0]; fac = min(1.0f, fac); diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h index edc824475c2..da3a141e3c2 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h @@ -50,7 +50,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp index b7a3f43237a..19209951005 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp @@ -40,12 +40,12 @@ void ColorCorrectionOperation::initExecution() this->m_inputMask = this->getInputSocketReader(1); } -void ColorCorrectionOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ColorCorrectionOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputImageColor[4]; float inputMask[4]; - this->m_inputImage->read(inputImageColor, x, y, sampler); - this->m_inputMask->read(inputMask, x, y, sampler); + this->m_inputImage->readSampled(inputImageColor, x, y, sampler); + this->m_inputMask->readSampled(inputMask, x, y, sampler); float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2]) / 3.0f; float contrast = this->m_data->master.contrast; diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h index 018e67b7ada..2b47d6a8034 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index 2f13a90c072..1115b2ab239 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -58,7 +58,7 @@ void ColorCurveOperation::initExecution() } -void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ColorCurveOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { CurveMapping *cumap = this->m_curveMapping; @@ -70,15 +70,15 @@ void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelS float white[4]; float bwmul[3]; - this->m_inputBlackProgram->read(black, x, y, sampler); - this->m_inputWhiteProgram->read(white, x, y, sampler); + this->m_inputBlackProgram->readSampled(black, x, y, sampler); + this->m_inputWhiteProgram->readSampled(white, x, y, sampler); /* get our own local bwmul value, * since we can't be threadsafe and use cumap->bwmul & friends */ curvemapping_set_black_white_ex(black, white, bwmul); - this->m_inputFacProgram->read(fac, x, y, sampler); - this->m_inputImageProgram->read(image, x, y, sampler); + this->m_inputFacProgram->readSampled(fac, x, y, sampler); + this->m_inputImageProgram->readSampled(image, x, y, sampler); if (*fac >= 1.0f) { curvemapping_evaluate_premulRGBF_ex(cumap, output, image, @@ -130,13 +130,13 @@ void ConstantLevelColorCurveOperation::initExecution() curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white); } -void ConstantLevelColorCurveOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConstantLevelColorCurveOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float fac[4]; float image[4]; - this->m_inputFacProgram->read(fac, x, y, sampler); - this->m_inputImageProgram->read(image, x, y, sampler); + this->m_inputFacProgram->readSampled(fac, x, y, sampler); + this->m_inputImageProgram->readSampled(image, x, y, sampler); if (*fac >= 1.0f) { curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image); diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h index 7dc1913b85a..1eb77553953 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.h +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h @@ -41,7 +41,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution @@ -70,7 +70,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp index d73196e42f5..b928141f41d 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp @@ -44,7 +44,7 @@ void ColorMatteOperation::deinitExecution() this->m_inputKeyProgram = NULL; } -void ColorMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ColorMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inColor[4]; float inKey[4]; @@ -55,8 +55,8 @@ void ColorMatteOperation::executePixel(float output[4], float x, float y, PixelS float h_wrap; - this->m_inputImageProgram->read(inColor, x, y, sampler); - this->m_inputKeyProgram->read(inKey, x, y, sampler); + this->m_inputImageProgram->readSampled(inColor, x, y, sampler); + this->m_inputKeyProgram->readSampled(inKey, x, y, sampler); /* store matte(alpha) value in [0] to go with diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h index f065a5f7e89..53bbe8f6466 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.h +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h @@ -42,7 +42,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp index 1618c83aece..fd3380d594e 100644 --- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp @@ -43,11 +43,11 @@ void ColorRampOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void ColorRampOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ColorRampOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float values[4]; - this->m_inputProgram->read(values, x, y, sampler); + this->m_inputProgram->readSampled(values, x, y, sampler); do_colorband(this->m_colorBand, values[0], output); } diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.h b/source/blender/compositor/operations/COM_ColorRampOperation.h index 96d9a525e1e..333e6c36d97 100644 --- a/source/blender/compositor/operations/COM_ColorRampOperation.h +++ b/source/blender/compositor/operations/COM_ColorRampOperation.h @@ -38,7 +38,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp index a8e8cb98564..873ec72d9e9 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp @@ -84,12 +84,12 @@ void ColorSpillOperation::deinitExecution() this->m_inputFacReader = NULL; } -void ColorSpillOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ColorSpillOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float fac[4]; float input[4]; - this->m_inputFacReader->read(fac, x, y, sampler); - this->m_inputImageReader->read(input, x, y, sampler); + this->m_inputFacReader->readSampled(fac, x, y, sampler); + this->m_inputImageReader->readSampled(input, x, y, sampler); float rfac = min(1.0f, fac[0]); float map = calculateMapValue(rfac, input); if (map > 0.0f) { diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h index 94ff78c37b2..f9dc9ef7e25 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.h +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h @@ -46,7 +46,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 383682b1474..3d4b771fecc 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -188,20 +188,20 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber) for (x = x1; x < x2 && (!breaked); x++) { int input_x = x + dx, input_y = y + dy; - this->m_imageInput->read(color, input_x, input_y, COM_PS_NEAREST); + this->m_imageInput->readSampled(color, input_x, input_y, COM_PS_NEAREST); if (this->m_ignoreAlpha) { color[3] = 1.0f; } else { if (this->m_alphaInput != NULL) { - this->m_alphaInput->read(&(color[3]), input_x, input_y, COM_PS_NEAREST); + this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, COM_PS_NEAREST); } } copy_v4_v4(buffer + offset4, color); if (this->m_depthInput != NULL) { - this->m_depthInput->read(color, input_x, input_y, COM_PS_NEAREST); + this->m_depthInput->readSampled(color, input_x, input_y, COM_PS_NEAREST); zbuffer[offset] = color[0]; } offset4 += COM_NUMBER_OF_CHANNELS; diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp index 79ce149e790..cb269b16bf4 100644 --- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp @@ -38,10 +38,10 @@ void ConvertColorProfileOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertColorProfileOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertColorProfileOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float color[4]; - this->m_inputOperation->read(color, x, y, sampler); + this->m_inputOperation->readSampled(color, x, y, sampler); IMB_buffer_float_from_float(output, color, 4, this->m_toProfile, this->m_fromProfile, this->m_predivided, 1, 1, 0, 0); } diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h index a8cbc613fb8..e68a9bdf7c1 100644 --- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h @@ -59,7 +59,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp index f39a28b87a8..ea1443598a9 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp @@ -72,12 +72,12 @@ void ConvertDepthToRadiusOperation::initExecution() } } -void ConvertDepthToRadiusOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertDepthToRadiusOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue[4]; float z; float radius; - this->m_inputOperation->read(inputValue, x, y, sampler); + this->m_inputOperation->readSampled(inputValue, x, y, sampler); z = inputValue[0]; if (z != 0.f) { float iZ = (1.f / z); diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h index d5a1fd72cbf..b92eb65d01e 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h @@ -54,7 +54,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ConvertOperation.cpp b/source/blender/compositor/operations/COM_ConvertOperation.cpp index d72aabb078e..6b3e4067b18 100644 --- a/source/blender/compositor/operations/COM_ConvertOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertOperation.cpp @@ -47,10 +47,10 @@ ConvertValueToColorOperation::ConvertValueToColorOperation() : ConvertBaseOperat this->addOutputSocket(COM_DT_COLOR); } -void ConvertValueToColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertValueToColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue[4]; - this->m_inputOperation->read(inputValue, x, y, sampler); + this->m_inputOperation->readSampled(inputValue, x, y, sampler); output[0] = output[1] = output[2] = inputValue[0]; output[3] = 1.0f; } @@ -64,10 +64,10 @@ ConvertColorToValueOperation::ConvertColorToValueOperation() : ConvertBaseOperat this->addOutputSocket(COM_DT_VALUE); } -void ConvertColorToValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertColorToValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler); + this->m_inputOperation->readSampled(inputColor, x, y, sampler); output[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f; } @@ -80,10 +80,10 @@ ConvertColorToBWOperation::ConvertColorToBWOperation() : ConvertBaseOperation() this->addOutputSocket(COM_DT_VALUE); } -void ConvertColorToBWOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertColorToBWOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler); + this->m_inputOperation->readSampled(inputColor, x, y, sampler); output[0] = rgb_to_bw(inputColor); } @@ -96,9 +96,9 @@ ConvertColorToVectorOperation::ConvertColorToVectorOperation() : ConvertBaseOper this->addOutputSocket(COM_DT_VECTOR); } -void ConvertColorToVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertColorToVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { - this->m_inputOperation->read(output, x, y, sampler); + this->m_inputOperation->readSampled(output, x, y, sampler); } @@ -110,10 +110,10 @@ ConvertValueToVectorOperation::ConvertValueToVectorOperation() : ConvertBaseOper this->addOutputSocket(COM_DT_VECTOR); } -void ConvertValueToVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertValueToVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float input[4]; - this->m_inputOperation->read(input, x, y, sampler); + this->m_inputOperation->readSampled(input, x, y, sampler); output[0] = input[0]; output[1] = input[0]; output[2] = input[0]; @@ -129,9 +129,9 @@ ConvertVectorToColorOperation::ConvertVectorToColorOperation() : ConvertBaseOper this->addOutputSocket(COM_DT_COLOR); } -void ConvertVectorToColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertVectorToColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { - this->m_inputOperation->read(output, x, y, sampler); + this->m_inputOperation->readSampled(output, x, y, sampler); output[3] = 1.0f; } @@ -144,10 +144,10 @@ ConvertVectorToValueOperation::ConvertVectorToValueOperation() : ConvertBaseOper this->addOutputSocket(COM_DT_VALUE); } -void ConvertVectorToValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertVectorToValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float input[4]; - this->m_inputOperation->read(input, x, y, sampler); + this->m_inputOperation->readSampled(input, x, y, sampler); output[0] = (input[0] + input[1] + input[2]) / 3.0f; } @@ -176,12 +176,12 @@ void ConvertRGBToYCCOperation::setMode(int mode) } } -void ConvertRGBToYCCOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertRGBToYCCOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; float color[3]; - this->m_inputOperation->read(inputColor, x, y, sampler); + this->m_inputOperation->readSampled(inputColor, x, y, sampler); rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->m_mode); /* divided by 255 to normalize for viewing in */ @@ -214,10 +214,10 @@ void ConvertYCCToRGBOperation::setMode(int mode) } } -void ConvertYCCToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertYCCToRGBOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler); + this->m_inputOperation->readSampled(inputColor, x, y, sampler); /* need to un-normalize the data */ /* R,G,B --> Y,Cb,Cr */ @@ -236,10 +236,10 @@ ConvertRGBToYUVOperation::ConvertRGBToYUVOperation() : ConvertBaseOperation() this->addOutputSocket(COM_DT_COLOR); } -void ConvertRGBToYUVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertRGBToYUVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler); + this->m_inputOperation->readSampled(inputColor, x, y, sampler); rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2]); output[3] = inputColor[3]; } @@ -253,10 +253,10 @@ ConvertYUVToRGBOperation::ConvertYUVToRGBOperation() : ConvertBaseOperation() this->addOutputSocket(COM_DT_COLOR); } -void ConvertYUVToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertYUVToRGBOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler); + this->m_inputOperation->readSampled(inputColor, x, y, sampler); yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2]); output[3] = inputColor[3]; } @@ -270,10 +270,10 @@ ConvertRGBToHSVOperation::ConvertRGBToHSVOperation() : ConvertBaseOperation() this->addOutputSocket(COM_DT_COLOR); } -void ConvertRGBToHSVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertRGBToHSVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler); + this->m_inputOperation->readSampled(inputColor, x, y, sampler); rgb_to_hsv_v(inputColor, output); output[3] = inputColor[3]; } @@ -287,10 +287,10 @@ ConvertHSVToRGBOperation::ConvertHSVToRGBOperation() : ConvertBaseOperation() this->addOutputSocket(COM_DT_COLOR); } -void ConvertHSVToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertHSVToRGBOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputOperation->read(inputColor, x, y, sampler); + this->m_inputOperation->readSampled(inputColor, x, y, sampler); hsv_to_rgb_v(inputColor, output); output[3] = inputColor[3]; } @@ -304,12 +304,12 @@ ConvertPremulToStraightOperation::ConvertPremulToStraightOperation() : ConvertBa this->addOutputSocket(COM_DT_COLOR); } -void ConvertPremulToStraightOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertPremulToStraightOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue[4]; float alpha; - this->m_inputOperation->read(inputValue, x, y, sampler); + this->m_inputOperation->readSampled(inputValue, x, y, sampler); alpha = inputValue[3]; if (fabsf(alpha) < 1e-5f) { @@ -332,12 +332,12 @@ ConvertStraightToPremulOperation::ConvertStraightToPremulOperation() : ConvertBa this->addOutputSocket(COM_DT_COLOR); } -void ConvertStraightToPremulOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ConvertStraightToPremulOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue[4]; float alpha; - this->m_inputOperation->read(inputValue, x, y, sampler); + this->m_inputOperation->readSampled(inputValue, x, y, sampler); alpha = inputValue[3]; mul_v3_v3fl(output, inputValue, alpha); @@ -366,10 +366,10 @@ void SeparateChannelOperation::deinitExecution() } -void SeparateChannelOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void SeparateChannelOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float input[4]; - this->m_inputOperation->read(input, x, y, sampler); + this->m_inputOperation->readSampled(input, x, y, sampler); output[0] = input[this->m_channel]; } @@ -407,23 +407,23 @@ void CombineChannelsOperation::deinitExecution() } -void CombineChannelsOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void CombineChannelsOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float input[4]; if (this->m_inputChannel1Operation) { - this->m_inputChannel1Operation->read(input, x, y, sampler); + this->m_inputChannel1Operation->readSampled(input, x, y, sampler); output[0] = input[0]; } if (this->m_inputChannel2Operation) { - this->m_inputChannel2Operation->read(input, x, y, sampler); + this->m_inputChannel2Operation->readSampled(input, x, y, sampler); output[1] = input[0]; } if (this->m_inputChannel3Operation) { - this->m_inputChannel3Operation->read(input, x, y, sampler); + this->m_inputChannel3Operation->readSampled(input, x, y, sampler); output[2] = input[0]; } if (this->m_inputChannel4Operation) { - this->m_inputChannel4Operation->read(input, x, y, sampler); + this->m_inputChannel4Operation->readSampled(input, x, y, sampler); output[3] = input[0]; } } diff --git a/source/blender/compositor/operations/COM_ConvertOperation.h b/source/blender/compositor/operations/COM_ConvertOperation.h index 06aeb2e52d7..957df812a2e 100644 --- a/source/blender/compositor/operations/COM_ConvertOperation.h +++ b/source/blender/compositor/operations/COM_ConvertOperation.h @@ -42,7 +42,7 @@ class ConvertValueToColorOperation : public ConvertBaseOperation { public: ConvertValueToColorOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -50,7 +50,7 @@ class ConvertColorToValueOperation : public ConvertBaseOperation { public: ConvertColorToValueOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -58,7 +58,7 @@ class ConvertColorToBWOperation : public ConvertBaseOperation { public: ConvertColorToBWOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -66,7 +66,7 @@ class ConvertColorToVectorOperation : public ConvertBaseOperation { public: ConvertColorToVectorOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -74,7 +74,7 @@ class ConvertValueToVectorOperation : public ConvertBaseOperation { public: ConvertValueToVectorOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -82,7 +82,7 @@ class ConvertVectorToColorOperation : public ConvertBaseOperation { public: ConvertVectorToColorOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -90,7 +90,7 @@ class ConvertVectorToValueOperation : public ConvertBaseOperation { public: ConvertVectorToValueOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -101,7 +101,7 @@ private: public: ConvertRGBToYCCOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** Set the YCC mode */ void setMode(int mode); @@ -115,7 +115,7 @@ private: public: ConvertYCCToRGBOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** Set the YCC mode */ void setMode(int mode); @@ -126,7 +126,7 @@ class ConvertRGBToYUVOperation : public ConvertBaseOperation { public: ConvertRGBToYUVOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -134,7 +134,7 @@ class ConvertYUVToRGBOperation : public ConvertBaseOperation { public: ConvertYUVToRGBOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -142,7 +142,7 @@ class ConvertRGBToHSVOperation : public ConvertBaseOperation { public: ConvertRGBToHSVOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -150,7 +150,7 @@ class ConvertHSVToRGBOperation : public ConvertBaseOperation { public: ConvertHSVToRGBOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -158,7 +158,7 @@ class ConvertPremulToStraightOperation : public ConvertBaseOperation { public: ConvertPremulToStraightOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -166,7 +166,7 @@ class ConvertStraightToPremulOperation : public ConvertBaseOperation { public: ConvertStraightToPremulOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; @@ -176,7 +176,7 @@ private: int m_channel; public: SeparateChannelOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); @@ -193,7 +193,7 @@ private: SocketReader *m_inputChannel4Operation; public: CombineChannelsOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp index 844d23db2ac..c514b576dcf 100644 --- a/source/blender/compositor/operations/COM_CropOperation.cpp +++ b/source/blender/compositor/operations/COM_CropOperation.cpp @@ -82,10 +82,10 @@ CropOperation::CropOperation() : CropBaseOperation() /* pass */ } -void CropOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void CropOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { if ((x < this->m_xmax && x >= this->m_xmin) && (y < this->m_ymax && y >= this->m_ymin)) { - this->m_inputOperation->read(output, x, y, sampler); + this->m_inputOperation->readSampled(output, x, y, sampler); } else { zero_v4(output); @@ -117,10 +117,10 @@ void CropImageOperation::determineResolution(unsigned int resolution[2], unsigne resolution[1] = this->m_ymax - this->m_ymin; } -void CropImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void CropImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) { - this->m_inputOperation->read(output, (x + this->m_xmin), (y + this->m_ymin), sampler); + this->m_inputOperation->readSampled(output, (x + this->m_xmin), (y + this->m_ymin), sampler); } else { zero_v4(output); diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h index d2f2b15aa36..4890ede18a9 100644 --- a/source/blender/compositor/operations/COM_CropOperation.h +++ b/source/blender/compositor/operations/COM_CropOperation.h @@ -48,7 +48,7 @@ class CropOperation : public CropBaseOperation { private: public: CropOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class CropImageOperation : public CropBaseOperation { @@ -57,7 +57,7 @@ public: CropImageOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void determineResolution(unsigned int resolution[2], unsigned int preferedResolution[2]); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp index e23eb26f527..325ef83a529 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp @@ -44,7 +44,7 @@ void DifferenceMatteOperation::deinitExecution() this->m_inputImage2Program = NULL; } -void DifferenceMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void DifferenceMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inColor1[4]; float inColor2[4]; @@ -54,8 +54,8 @@ void DifferenceMatteOperation::executePixel(float output[4], float x, float y, P float difference; float alpha; - this->m_inputImage1Program->read(inColor1, x, y, sampler); - this->m_inputImage2Program->read(inColor2, x, y, sampler); + this->m_inputImage1Program->readSampled(inColor1, x, y, sampler); + this->m_inputImage2Program->readSampled(inColor2, x, y, sampler); difference = (fabsf(inColor2[0] - inColor1[0]) + fabsf(inColor2[1] - inColor1[1]) + diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h index e0a38f703ed..a3647e1e5db 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h @@ -43,7 +43,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp index 23289429bfd..d6c25574d01 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp @@ -71,7 +71,7 @@ void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void const int iterations = pow(2.0f, this->m_data->iter); float col[4] = {0, 0, 0, 0}; float col2[4] = {0, 0, 0, 0}; - this->m_inputProgram->read(col2, x, y, COM_PS_NEAREST); + this->m_inputProgram->readSampled(col2, x, y, COM_PS_NEAREST); float ltx = this->m_tx; float lty = this->m_ty; float lsc = this->m_sc; @@ -84,7 +84,7 @@ void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void const float v = isc * (y - this->m_center_y_pix) + lty; const float u = isc * (x - this->m_center_x_pix) + ltx; - this->m_inputProgram->read(col, + this->m_inputProgram->readSampled(col, cs * u + ss * v + this->m_center_x_pix, cs * v - ss * u + this->m_center_y_pix, COM_PS_NEAREST); diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp index 1723da11f21..17692bd18ef 100644 --- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp @@ -64,9 +64,9 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data) float dxt, dyt; float u, v; - this->m_inputScaleXProgram->read(inScale, x, y, COM_PS_NEAREST); + this->m_inputScaleXProgram->readSampled(inScale, x, y, COM_PS_NEAREST); float xs = inScale[0]; - this->m_inputScaleYProgram->read(inScale, x, y, COM_PS_NEAREST); + this->m_inputScaleYProgram->readSampled(inScale, x, y, COM_PS_NEAREST); float ys = inScale[0]; /* clamp x and y displacement to triple image resolution - @@ -74,7 +74,7 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data) CLAMP(xs, -this->m_width_x4, this->m_width_x4); CLAMP(ys, -this->m_height_x4, this->m_height_x4); - this->m_inputVectorProgram->read(inVector, x, y, COM_PS_NEAREST); + this->m_inputVectorProgram->readSampled(inVector, x, y, COM_PS_NEAREST); p_dx = inVector[0] * xs; p_dy = inVector[1] * ys; @@ -83,9 +83,9 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data) v = y - p_dy + 0.5f; /* calc derivatives */ - this->m_inputVectorProgram->read(inVector, x + 1, y, COM_PS_NEAREST); + this->m_inputVectorProgram->readSampled(inVector, x + 1, y, COM_PS_NEAREST); d_dx = inVector[0] * xs; - this->m_inputVectorProgram->read(inVector, x, y + 1, COM_PS_NEAREST); + this->m_inputVectorProgram->readSampled(inVector, x, y + 1, COM_PS_NEAREST); d_dy = inVector[1] * ys; /* clamp derivatives to minimum displacement distance in UV space */ @@ -96,7 +96,7 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data) dyt = signf(dyt) * max_ff(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight(); /* EWA filtering (without nearest it gets blurry with NO distortion) */ - this->m_inputColorProgram->read(output, u, v, dxt, dyt, COM_PS_NEAREST); + this->m_inputColorProgram->readFiltered(output, u, v, dxt, dyt, COM_PS_NEAREST); } void DisplaceOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp index c8ebb845bb6..48160d5db2c 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp @@ -53,7 +53,7 @@ void DisplaceSimpleOperation::initExecution() * in order to take effect */ // #define DISPLACE_EPSILON 0.01f -void DisplaceSimpleOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void DisplaceSimpleOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inVector[4]; float inScale[4]; @@ -61,9 +61,9 @@ void DisplaceSimpleOperation::executePixel(float output[4], float x, float y, Pi float p_dx, p_dy; /* main displacement in pixel space */ float u, v; - this->m_inputScaleXProgram->read(inScale, x, y, sampler); + this->m_inputScaleXProgram->readSampled(inScale, x, y, sampler); float xs = inScale[0]; - this->m_inputScaleYProgram->read(inScale, x, y, sampler); + this->m_inputScaleYProgram->readSampled(inScale, x, y, sampler); float ys = inScale[0]; /* clamp x and y displacement to triple image resolution - @@ -71,7 +71,7 @@ void DisplaceSimpleOperation::executePixel(float output[4], float x, float y, Pi CLAMP(xs, -this->m_width_x4, this->m_width_x4); CLAMP(ys, -this->m_height_x4, this->m_height_x4); - this->m_inputVectorProgram->read(inVector, x, y, sampler); + this->m_inputVectorProgram->readSampled(inVector, x, y, sampler); p_dx = inVector[0] * xs; p_dy = inVector[1] * ys; @@ -82,7 +82,7 @@ void DisplaceSimpleOperation::executePixel(float output[4], float x, float y, Pi CLAMP(u, 0.f, this->getWidth() - 1.f); CLAMP(v, 0.f, this->getHeight() - 1.f); - this->m_inputColorProgram->read(output, u, v, sampler); + this->m_inputColorProgram->readSampled(output, u, v, sampler); } void DisplaceSimpleOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h index 989cf8a1f67..6e52dfe86e9 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h @@ -48,7 +48,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp index d3309e0c978..072ca1022e7 100644 --- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp @@ -49,7 +49,7 @@ float DistanceRGBMatteOperation::calculateDistance(float key[4], float image[4]) return len_v3v3(key, image); } -void DistanceRGBMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void DistanceRGBMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inKey[4]; float inImage[4]; @@ -60,8 +60,8 @@ void DistanceRGBMatteOperation::executePixel(float output[4], float x, float y, float distance; float alpha; - this->m_inputKeyProgram->read(inKey, x, y, sampler); - this->m_inputImageProgram->read(inImage, x, y, sampler); + this->m_inputKeyProgram->readSampled(inKey, x, y, sampler); + this->m_inputImageProgram->readSampled(inImage, x, y, sampler); distance = this->calculateDistance(inKey, inImage); diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h index 43299486f60..a815caa5ef5 100644 --- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h +++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h @@ -45,7 +45,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cpp b/source/blender/compositor/operations/COM_DotproductOperation.cpp index 1439dfa404a..368db185adc 100644 --- a/source/blender/compositor/operations/COM_DotproductOperation.cpp +++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp @@ -45,11 +45,11 @@ void DotproductOperation::deinitExecution() /** @todo: current implementation is the inverse of a dotproduct. not 'logically' correct */ -void DotproductOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void DotproductOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float input1[4]; float input2[4]; - this->m_input1Operation->read(input1, x, y, sampler); - this->m_input2Operation->read(input2, x, y, sampler); + this->m_input1Operation->readSampled(input1, x, y, sampler); + this->m_input2Operation->readSampled(input2, x, y, sampler); output[0] = -(input1[0] * input2[0] + input1[1] * input2[1] + input1[2] * input2[2]); } diff --git a/source/blender/compositor/operations/COM_DotproductOperation.h b/source/blender/compositor/operations/COM_DotproductOperation.h index 31588207504..4378e280d17 100644 --- a/source/blender/compositor/operations/COM_DotproductOperation.h +++ b/source/blender/compositor/operations/COM_DotproductOperation.h @@ -31,7 +31,7 @@ private: SocketReader *m_input2Operation; public: DotproductOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp index 9ab21e2d5bd..d7cc2ec9272 100644 --- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp @@ -44,7 +44,7 @@ void EllipseMaskOperation::initExecution() this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight(); } -void EllipseMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void EllipseMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputMask[4]; float inputValue[4]; @@ -57,8 +57,8 @@ void EllipseMaskOperation::executePixel(float output[4], float x, float y, Pixel rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy); ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy); - this->m_inputMask->read(inputMask, x, y, sampler); - this->m_inputValue->read(inputValue, x, y, sampler); + this->m_inputMask->readSampled(inputMask, x, y, sampler); + this->m_inputValue->readSampled(inputValue, x, y, sampler); const float halfHeight = (this->m_data->height) / 2.0f; const float halfWidth = this->m_data->width / 2.0f; diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.h b/source/blender/compositor/operations/COM_EllipseMaskOperation.h index ed74e6b43db..753615df370 100644 --- a/source/blender/compositor/operations/COM_EllipseMaskOperation.h +++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.h @@ -45,7 +45,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp index 526eba34d86..3de2ae9dabc 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.cpp +++ b/source/blender/compositor/operations/COM_FlipOperation.cpp @@ -42,12 +42,12 @@ void FlipOperation::deinitExecution() } -void FlipOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void FlipOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float nx = this->m_flipX ? this->getWidth() - 1 - x : x; float ny = this->m_flipY ? this->getHeight() - 1 - y : y; - this->m_inputOperation->read(output, nx, ny, sampler); + this->m_inputOperation->readSampled(output, nx, ny, sampler); } bool FlipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h index 018617cea8a..a1fcde19876 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.h +++ b/source/blender/compositor/operations/COM_FlipOperation.h @@ -33,7 +33,7 @@ private: public: FlipOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp index 8f92dc02a57..357677d6832 100644 --- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp @@ -34,10 +34,10 @@ void GammaCorrectOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void GammaCorrectOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void GammaCorrectOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputProgram->read(inputColor, x, y, sampler); + this->m_inputProgram->readSampled(inputColor, x, y, sampler); if (inputColor[3] > 0.0f) { inputColor[0] /= inputColor[3]; inputColor[1] /= inputColor[3]; @@ -73,10 +73,10 @@ void GammaUncorrectOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void GammaUncorrectOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void GammaUncorrectOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor[4]; - this->m_inputProgram->read(inputColor, x, y, sampler); + this->m_inputProgram->readSampled(inputColor, x, y, sampler); if (inputColor[3] > 0.0f) { inputColor[0] /= inputColor[3]; diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.h b/source/blender/compositor/operations/COM_GammaCorrectOperation.h index 514855b4f56..68eaab83c99 100644 --- a/source/blender/compositor/operations/COM_GammaCorrectOperation.h +++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.h @@ -38,7 +38,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution @@ -64,7 +64,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp index 326031c5984..d98f2c4663f 100644 --- a/source/blender/compositor/operations/COM_GammaOperation.cpp +++ b/source/blender/compositor/operations/COM_GammaOperation.cpp @@ -37,13 +37,13 @@ void GammaOperation::initExecution() this->m_inputGammaProgram = this->getInputSocketReader(1); } -void GammaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void GammaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue[4]; float inputGamma[4]; - this->m_inputProgram->read(inputValue, x, y, sampler); - this->m_inputGammaProgram->read(inputGamma, x, y, sampler); + this->m_inputProgram->readSampled(inputValue, x, y, sampler); + this->m_inputGammaProgram->readSampled(inputGamma, x, y, sampler); const float gamma = inputGamma[0]; /* check for negative to avoid nan's */ output[0] = inputValue[0] > 0.0f ? powf(inputValue[0], gamma) : inputValue[0]; diff --git a/source/blender/compositor/operations/COM_GammaOperation.h b/source/blender/compositor/operations/COM_GammaOperation.h index 4482f7be34a..d8e08457812 100644 --- a/source/blender/compositor/operations/COM_GammaOperation.h +++ b/source/blender/compositor/operations/COM_GammaOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp index 1c7d2659c39..78e1e80cafc 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp @@ -42,11 +42,11 @@ void GlareThresholdOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void GlareThresholdOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void GlareThresholdOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { const float threshold = this->m_settings->threshold; - this->m_inputProgram->read(output, x, y, sampler); + this->m_inputProgram->readSampled(output, x, y, sampler); if (rgb_to_luma_y(output) >= threshold) { output[0] -= threshold, output[1] -= threshold, output[2] -= threshold; output[0] = max(output[0], 0.0f); diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h index 44f9db6a483..7760a19251b 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h @@ -42,7 +42,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp index 8f58942fbe2..6bbaac8e303 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp @@ -45,11 +45,11 @@ void HueSaturationValueCorrectOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void HueSaturationValueCorrectOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void HueSaturationValueCorrectOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float hsv[4], f; - this->m_inputProgram->read(hsv, x, y, sampler); + this->m_inputProgram->readSampled(hsv, x, y, sampler); /* adjust hue, scaling returned default 0.5 up to 1 */ f = curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]); diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h index 5e57d09a51e..0a0e82bf168 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h @@ -37,7 +37,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp index 4b9bcb118e7..a021f07d2a7 100644 --- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp @@ -33,11 +33,11 @@ void IDMaskOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void IDMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void IDMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue[4]; - this->m_inputProgram->read(inputValue, x, y, sampler); + this->m_inputProgram->readSampled(inputValue, x, y, sampler); const float a = (inputValue[0] == this->m_objectIndex) ? 1.0f : 0.0f; output[0] = a; } diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h index 68c5cf4c1dc..dfddc489ca4 100644 --- a/source/blender/compositor/operations/COM_IDMaskOperation.h +++ b/source/blender/compositor/operations/COM_IDMaskOperation.h @@ -39,7 +39,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp index cface29fdca..adc325de377 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cpp +++ b/source/blender/compositor/operations/COM_ImageOperation.cpp @@ -146,7 +146,7 @@ static void sampleImageAtLocation(ImBuf *ibuf, float x, float y, PixelSampler sa } } -void ImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { if ((this->m_imageFloatBuffer == NULL && this->m_imageByteBuffer == NULL) || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { zero_v4(output); @@ -156,7 +156,7 @@ void ImageOperation::executePixel(float output[4], float x, float y, PixelSample } } -void ImageAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ImageAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float tempcolor[4]; @@ -170,7 +170,7 @@ void ImageAlphaOperation::executePixel(float output[4], float x, float y, PixelS } } -void ImageDepthOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ImageDepthOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { if (this->m_depthBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { output[0] = 0.0f; diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h index b51f11edd04..a9e2ed9ff64 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.h +++ b/source/blender/compositor/operations/COM_ImageOperation.h @@ -73,7 +73,7 @@ public: * Constructor */ ImageOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class ImageAlphaOperation : public BaseImageOperation { public: @@ -81,7 +81,7 @@ public: * Constructor */ ImageAlphaOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class ImageDepthOperation : public BaseImageOperation { public: @@ -89,6 +89,6 @@ public: * Constructor */ ImageDepthOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp index 9c2dd825709..dc5a2653129 100644 --- a/source/blender/compositor/operations/COM_InvertOperation.cpp +++ b/source/blender/compositor/operations/COM_InvertOperation.cpp @@ -39,12 +39,12 @@ void InvertOperation::initExecution() this->m_inputColorProgram = this->getInputSocketReader(1); } -void InvertOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void InvertOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue[4]; float inputColor[4]; - this->m_inputValueProgram->read(inputValue, x, y, sampler); - this->m_inputColorProgram->read(inputColor, x, y, sampler); + this->m_inputValueProgram->readSampled(inputValue, x, y, sampler); + this->m_inputColorProgram->readSampled(inputColor, x, y, sampler); const float value = inputValue[0]; const float invertedValue = 1.0f - value; diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h index 7fded7bb1e4..be1e933f1e9 100644 --- a/source/blender/compositor/operations/COM_InvertOperation.h +++ b/source/blender/compositor/operations/COM_InvertOperation.h @@ -42,7 +42,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp index 01f5c032730..c4b821f998f 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp @@ -53,13 +53,13 @@ void KeyingDespillOperation::deinitExecution() this->m_screenReader = NULL; } -void KeyingDespillOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void KeyingDespillOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float pixelColor[4]; float screenColor[4]; - this->m_pixelReader->read(pixelColor, x, y, sampler); - this->m_screenReader->read(screenColor, x, y, sampler); + this->m_pixelReader->readSampled(pixelColor, x, y, sampler); + this->m_screenReader->readSampled(screenColor, x, y, sampler); const int screen_primary_channel = max_axis_v3(screenColor); const int other_1 = (screen_primary_channel + 1) % 3; diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h index 18e771b14f1..da9924d5b4b 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.h +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h @@ -45,7 +45,7 @@ public: void setDespillFactor(float value) {this->m_despillFactor = value;} void setColorBalance(float value) {this->m_colorBalance = value;} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index baeacb56744..e2566d2f4f0 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -65,13 +65,13 @@ void KeyingOperation::deinitExecution() this->m_screenReader = NULL; } -void KeyingOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void KeyingOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float pixelColor[4]; float screenColor[4]; - this->m_pixelReader->read(pixelColor, x, y, sampler); - this->m_screenReader->read(screenColor, x, y, sampler); + this->m_pixelReader->readSampled(pixelColor, x, y, sampler); + this->m_screenReader->readSampled(screenColor, x, y, sampler); const int primary_channel = max_axis_v3(screenColor); diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h index fcff9243dfc..e4542e2c6dd 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.h +++ b/source/blender/compositor/operations/COM_KeyingOperation.h @@ -49,7 +49,7 @@ public: void setScreenBalance(float value) {this->m_screenBalance = value;} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp index 4c65113ee70..0e48d5963c6 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp @@ -40,7 +40,7 @@ void LuminanceMatteOperation::deinitExecution() this->m_inputImageProgram = NULL; } -void LuminanceMatteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void LuminanceMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inColor[4]; @@ -49,7 +49,7 @@ void LuminanceMatteOperation::executePixel(float output[4], float x, float y, Pi float alpha; - this->m_inputImageProgram->read(inColor, x, y, sampler); + this->m_inputImageProgram->readSampled(inColor, x, y, sampler); /* one line thread-friend algorithm: * output[0] = max(inputValue[3], min(high, max(low, ((inColor[0]-low)/(high-low)))) diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h index cb8cc01efea..93051f52228 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h @@ -41,7 +41,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp index 1fe74ade0fc..2e80d4f1ba3 100644 --- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp +++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp @@ -46,18 +46,18 @@ void MapRangeOperation::initExecution() /* The code below assumes all data is inside range +- this, and that input buffer is single channel */ #define BLENDER_ZMAX 10000.0f -void MapRangeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MapRangeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputs[8]; /* includes the 5 inputs + 3 pads */ float value; float source_min, source_max; float dest_min, dest_max; - this->m_inputOperation->read(inputs, x, y, sampler); - this->m_sourceMinOperation->read(inputs + 1, x, y, sampler); - this->m_sourceMaxOperation->read(inputs + 2, x, y, sampler); - this->m_destMinOperation->read(inputs + 3, x, y, sampler); - this->m_destMaxOperation->read(inputs + 4, x, y, sampler); + this->m_inputOperation->readSampled(inputs, x, y, sampler); + this->m_sourceMinOperation->readSampled(inputs + 1, x, y, sampler); + this->m_sourceMaxOperation->readSampled(inputs + 2, x, y, sampler); + this->m_destMinOperation->readSampled(inputs + 3, x, y, sampler); + this->m_destMaxOperation->readSampled(inputs + 4, x, y, sampler); value = inputs[0]; source_min = inputs[1]; diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.h b/source/blender/compositor/operations/COM_MapRangeOperation.h index 00dfc68168c..a232f89ea9d 100644 --- a/source/blender/compositor/operations/COM_MapRangeOperation.h +++ b/source/blender/compositor/operations/COM_MapRangeOperation.h @@ -50,7 +50,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp index a9b6ad3edc1..289b447dec7 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.cpp +++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp @@ -40,7 +40,7 @@ void MapUVOperation::initExecution() this->m_inputUVProgram = this->getInputSocketReader(1); } -void MapUVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MapUVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputUV[4]; float uv_a[4], uv_b[4]; @@ -50,22 +50,22 @@ void MapUVOperation::executePixel(float output[4], float x, float y, PixelSample float uv_l, uv_r; float uv_u, uv_d; - this->m_inputUVProgram->read(inputUV, x, y, sampler); + this->m_inputUVProgram->readSampled(inputUV, x, y, sampler); if (inputUV[2] == 0.f) { zero_v4(output); return; } /* adaptive sampling, red (U) channel */ - this->m_inputUVProgram->read(uv_a, x - 1, y, COM_PS_NEAREST); - this->m_inputUVProgram->read(uv_b, x + 1, y, COM_PS_NEAREST); + this->m_inputUVProgram->readSampled(uv_a, x - 1, y, COM_PS_NEAREST); + this->m_inputUVProgram->readSampled(uv_b, x + 1, y, COM_PS_NEAREST); uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f; uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f; dx = 0.5f * (uv_l + uv_r); /* adaptive sampling, green (V) channel */ - this->m_inputUVProgram->read(uv_a, x, y - 1, COM_PS_NEAREST); - this->m_inputUVProgram->read(uv_b, x, y + 1, COM_PS_NEAREST); + this->m_inputUVProgram->readSampled(uv_a, x, y - 1, COM_PS_NEAREST); + this->m_inputUVProgram->readSampled(uv_b, x, y + 1, COM_PS_NEAREST); uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f; uv_d = uv_b[2] != 0.f ? fabsf(inputUV[1] - uv_b[1]) : 0.f; @@ -81,7 +81,7 @@ void MapUVOperation::executePixel(float output[4], float x, float y, PixelSample u = inputUV[0] * this->m_inputColorProgram->getWidth(); v = inputUV[1] * this->m_inputColorProgram->getHeight(); - this->m_inputColorProgram->read(output, u, v, dx, dy, COM_PS_NEAREST); + this->m_inputColorProgram->readFiltered(output, u, v, dx, dy, COM_PS_NEAREST); /* "premul" */ if (alpha < 1.0f) { diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h index c8356c1a7ad..fe8bfd2a9ac 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.h +++ b/source/blender/compositor/operations/COM_MapUVOperation.h @@ -45,7 +45,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp index 7acc431f7b5..d6aaf560fce 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.cpp +++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp @@ -34,10 +34,10 @@ void MapValueOperation::initExecution() this->m_inputOperation = this->getInputSocketReader(0); } -void MapValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MapValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float src[4]; - this->m_inputOperation->read(src, x, y, sampler); + this->m_inputOperation->readSampled(src, x, y, sampler); TexMapping *texmap = this->m_settings; float value = (src[0] + texmap->loc[0]) * texmap->size[0]; if (texmap->flag & TEXMAP_CLIP_MIN) diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h index 418d6d9bf4d..a9a59d6633a 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.h +++ b/source/blender/compositor/operations/COM_MapValueOperation.h @@ -45,7 +45,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index 85df691ee29..a5b1987d4b3 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -127,7 +127,7 @@ void MaskOperation::determineResolution(unsigned int resolution[2], unsigned int } } -void MaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { const float xy[2] = {x * this->m_maskWidthInv, y * this->m_maskHeightInv}; diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index 2de71afcfa7..18d7e594104 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -83,7 +83,7 @@ public: void setMotionBlurSamples(int samples) { this->m_rasterMaskHandleTot = min(max(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX); } void setMotionBlurShutter(float shutter) { this->m_frame_shutter = shutter; } - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp index fa0c480eb70..cc7511bb9fc 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp @@ -72,52 +72,52 @@ void MathBaseOperation::clampIfNeeded(float *color) } } -void MathAddOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathAddOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = inputValue1[0] + inputValue2[0]; clampIfNeeded(output); } -void MathSubtractOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathSubtractOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = inputValue1[0] - inputValue2[0]; clampIfNeeded(output); } -void MathMultiplyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathMultiplyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = inputValue1[0] * inputValue2[0]; clampIfNeeded(output); } -void MathDivideOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathDivideOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue2[0] == 0) /* We don't want to divide by zero. */ output[0] = 0.0; @@ -127,52 +127,52 @@ void MathDivideOperation::executePixel(float output[4], float x, float y, PixelS clampIfNeeded(output); } -void MathSineOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathSineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = sin(inputValue1[0]); clampIfNeeded(output); } -void MathCosineOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathCosineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = cos(inputValue1[0]); clampIfNeeded(output); } -void MathTangentOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathTangentOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = tan(inputValue1[0]); clampIfNeeded(output); } -void MathArcSineOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathArcSineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue1[0] <= 1 && inputValue1[0] >= -1) output[0] = asin(inputValue1[0]); @@ -182,13 +182,13 @@ void MathArcSineOperation::executePixel(float output[4], float x, float y, Pixel clampIfNeeded(output); } -void MathArcCosineOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathArcCosineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue1[0] <= 1 && inputValue1[0] >= -1) output[0] = acos(inputValue1[0]); @@ -198,26 +198,26 @@ void MathArcCosineOperation::executePixel(float output[4], float x, float y, Pix clampIfNeeded(output); } -void MathArcTangentOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathArcTangentOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = atan(inputValue1[0]); clampIfNeeded(output); } -void MathPowerOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathPowerOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue1[0] >= 0) { output[0] = pow(inputValue1[0], inputValue2[0]); @@ -236,13 +236,13 @@ void MathPowerOperation::executePixel(float output[4], float x, float y, PixelSa clampIfNeeded(output); } -void MathLogarithmOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathLogarithmOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue1[0] > 0 && inputValue2[0] > 0) output[0] = log(inputValue1[0]) / log(inputValue2[0]); @@ -252,78 +252,78 @@ void MathLogarithmOperation::executePixel(float output[4], float x, float y, Pix clampIfNeeded(output); } -void MathMinimumOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathMinimumOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = min(inputValue1[0], inputValue2[0]); clampIfNeeded(output); } -void MathMaximumOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathMaximumOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = max(inputValue1[0], inputValue2[0]); clampIfNeeded(output); } -void MathRoundOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathRoundOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = round(inputValue1[0]); clampIfNeeded(output); } -void MathLessThanOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathLessThanOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f; clampIfNeeded(output); } -void MathGreaterThanOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathGreaterThanOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f; clampIfNeeded(output); } -void MathModuloOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MathModuloOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; - this->m_inputValue1Operation->read(inputValue1, x, y, sampler); - this->m_inputValue2Operation->read(inputValue2, x, y, sampler); + this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); + this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue2[0] == 0) output[0] = 0.0; diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h index 649a9688037..4ea7c43a67d 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.h +++ b/source/blender/compositor/operations/COM_MathBaseOperation.h @@ -50,7 +50,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler) = 0; + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) = 0; /** * Initialize the execution @@ -73,94 +73,94 @@ public: class MathAddOperation : public MathBaseOperation { public: MathAddOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathSubtractOperation : public MathBaseOperation { public: MathSubtractOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathMultiplyOperation : public MathBaseOperation { public: MathMultiplyOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathDivideOperation : public MathBaseOperation { public: MathDivideOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathSineOperation : public MathBaseOperation { public: MathSineOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathCosineOperation : public MathBaseOperation { public: MathCosineOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathTangentOperation : public MathBaseOperation { public: MathTangentOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathArcSineOperation : public MathBaseOperation { public: MathArcSineOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathArcCosineOperation : public MathBaseOperation { public: MathArcCosineOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathArcTangentOperation : public MathBaseOperation { public: MathArcTangentOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathPowerOperation : public MathBaseOperation { public: MathPowerOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathLogarithmOperation : public MathBaseOperation { public: MathLogarithmOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathMinimumOperation : public MathBaseOperation { public: MathMinimumOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathMaximumOperation : public MathBaseOperation { public: MathMaximumOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathRoundOperation : public MathBaseOperation { public: MathRoundOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathLessThanOperation : public MathBaseOperation { public: MathLessThanOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathGreaterThanOperation : public MathBaseOperation { public: MathGreaterThanOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MathModuloOperation : public MathBaseOperation { public: MathModuloOperation() : MathBaseOperation() {} - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MixOperation.cpp b/source/blender/compositor/operations/COM_MixOperation.cpp index f094e93f147..9781cb4e162 100644 --- a/source/blender/compositor/operations/COM_MixOperation.cpp +++ b/source/blender/compositor/operations/COM_MixOperation.cpp @@ -48,15 +48,15 @@ void MixBaseOperation::initExecution() this->m_inputColor2Operation = this->getInputSocketReader(2); } -void MixBaseOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -107,15 +107,15 @@ MixAddOperation::MixAddOperation() : MixBaseOperation() /* pass */ } -void MixAddOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixAddOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -136,16 +136,16 @@ MixBlendOperation::MixBlendOperation() : MixBaseOperation() /* pass */ } -void MixBlendOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixBlendOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; float value; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -167,16 +167,16 @@ MixBurnOperation::MixBurnOperation() : MixBaseOperation() /* pass */ } -void MixBurnOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixBurnOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; float tmp; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -235,15 +235,15 @@ MixColorOperation::MixColorOperation() : MixBaseOperation() /* pass */ } -void MixColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -277,15 +277,15 @@ MixDarkenOperation::MixDarkenOperation() : MixBaseOperation() /* pass */ } -void MixDarkenOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixDarkenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -315,15 +315,15 @@ MixDifferenceOperation::MixDifferenceOperation() : MixBaseOperation() /* pass */ } -void MixDifferenceOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixDifferenceOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -345,15 +345,15 @@ MixDivideOperation::MixDivideOperation() : MixBaseOperation() /* pass */ } -void MixDivideOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixDivideOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -386,16 +386,16 @@ MixDodgeOperation::MixDodgeOperation() : MixBaseOperation() /* pass */ } -void MixDodgeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixDodgeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; float tmp; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -459,16 +459,16 @@ MixGlareOperation::MixGlareOperation() : MixBaseOperation() /* pass */ } -void MixGlareOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixGlareOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; float value; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); value = inputValue[0]; float mf = 2.f - 2.f * fabsf(value - 0.5f); @@ -491,15 +491,15 @@ MixHueOperation::MixHueOperation() : MixBaseOperation() /* pass */ } -void MixHueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixHueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -533,15 +533,15 @@ MixLightenOperation::MixLightenOperation() : MixBaseOperation() /* pass */ } -void MixLightenOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixLightenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -569,15 +569,15 @@ MixLinearLightOperation::MixLinearLightOperation() : MixBaseOperation() /* pass */ } -void MixLinearLightOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixLinearLightOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -608,15 +608,15 @@ MixMultiplyOperation::MixMultiplyOperation() : MixBaseOperation() /* pass */ } -void MixMultiplyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixMultiplyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -638,15 +638,15 @@ MixOverlayOperation::MixOverlayOperation() : MixBaseOperation() /* pass */ } -void MixOverlayOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixOverlayOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -685,15 +685,15 @@ MixSaturationOperation::MixSaturationOperation() : MixBaseOperation() /* pass */ } -void MixSaturationOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixSaturationOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -724,15 +724,15 @@ MixScreenOperation::MixScreenOperation() : MixBaseOperation() /* pass */ } -void MixScreenOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixScreenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -755,15 +755,15 @@ MixSoftLightOperation::MixSoftLightOperation() : MixBaseOperation() /* pass */ } -void MixSoftLightOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) \ +void MixSoftLightOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) \ { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -792,15 +792,15 @@ MixSubtractOperation::MixSubtractOperation() : MixBaseOperation() /* pass */ } -void MixSubtractOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixSubtractOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { @@ -821,15 +821,15 @@ MixValueOperation::MixValueOperation() : MixBaseOperation() /* pass */ } -void MixValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MixValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; - this->m_inputValueOperation->read(inputValue, x, y, sampler); - this->m_inputColor1Operation->read(inputColor1, x, y, sampler); - this->m_inputColor2Operation->read(inputColor2, x, y, sampler); + this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); + this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); + this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { diff --git a/source/blender/compositor/operations/COM_MixOperation.h b/source/blender/compositor/operations/COM_MixOperation.h index 93dbe6f36a6..479ce161eea 100644 --- a/source/blender/compositor/operations/COM_MixOperation.h +++ b/source/blender/compositor/operations/COM_MixOperation.h @@ -60,7 +60,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution @@ -83,115 +83,115 @@ public: class MixAddOperation : public MixBaseOperation { public: MixAddOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixBlendOperation : public MixBaseOperation { public: MixBlendOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixBurnOperation : public MixBaseOperation { public: MixBurnOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixColorOperation : public MixBaseOperation { public: MixColorOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixDarkenOperation : public MixBaseOperation { public: MixDarkenOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixDifferenceOperation : public MixBaseOperation { public: MixDifferenceOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixDivideOperation : public MixBaseOperation { public: MixDivideOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixDodgeOperation : public MixBaseOperation { public: MixDodgeOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixGlareOperation : public MixBaseOperation { public: MixGlareOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixHueOperation : public MixBaseOperation { public: MixHueOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixLightenOperation : public MixBaseOperation { public: MixLightenOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixLinearLightOperation : public MixBaseOperation { public: MixLinearLightOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixMultiplyOperation : public MixBaseOperation { public: MixMultiplyOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixOverlayOperation : public MixBaseOperation { public: MixOverlayOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixSaturationOperation : public MixBaseOperation { public: MixSaturationOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixScreenOperation : public MixBaseOperation { public: MixScreenOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixSoftLightOperation : public MixBaseOperation { public: MixSoftLightOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixSubtractOperation : public MixBaseOperation { public: MixSubtractOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MixValueOperation : public MixBaseOperation { public: MixValueOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp index 0d2de47bc4f..fbbfa8fd65e 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp @@ -33,7 +33,7 @@ MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation() this->m_attribute = MCA_X; } -void MovieClipAttributeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MovieClipAttributeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { if (!this->m_valueSet) { float loc[2], scale, angle; diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h index f894626d534..49c86c7fafc 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h @@ -51,7 +51,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); void setMovieClip(MovieClip *clip) { this->m_clip = clip; } diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp index 76dc093035c..5b75113e7f3 100644 --- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp @@ -86,7 +86,7 @@ void MovieClipBaseOperation::determineResolution(unsigned int resolution[2], uns } } -void MovieClipBaseOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MovieClipBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { ImBuf *ibuf = this->m_movieClipBuffer; @@ -122,9 +122,9 @@ MovieClipAlphaOperation::MovieClipAlphaOperation() : MovieClipBaseOperation() this->addOutputSocket(COM_DT_VALUE); } -void MovieClipAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MovieClipAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { - MovieClipBaseOperation::executePixel(output, x, y, sampler); + MovieClipBaseOperation::executePixelSampled(output, x, y, sampler); output[0] = output[3]; output[1] = 0.0f; output[2] = 0.0f; diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h index a368dca423c..c16262cbd02 100644 --- a/source/blender/compositor/operations/COM_MovieClipOperation.h +++ b/source/blender/compositor/operations/COM_MovieClipOperation.h @@ -57,7 +57,7 @@ public: void setCacheFrame(bool value) { this->m_cacheFrame = value; } void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MovieClipOperation : public MovieClipBaseOperation { @@ -68,7 +68,7 @@ public: class MovieClipAlphaOperation : public MovieClipBaseOperation { public: MovieClipAlphaOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp index 863a404ba67..a8c7728160d 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp @@ -122,16 +122,16 @@ void MovieDistortionOperation::deinitExecution() } -void MovieDistortionOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MovieDistortionOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { if (this->m_cache != NULL) { float u, v; this->m_cache->getUV(&this->m_movieClip->tracking, x, y, &u, &v); - this->m_inputOperation->read(output, u, v, COM_PS_BILINEAR); + this->m_inputOperation->readSampled(output, u, v, COM_PS_BILINEAR); } else { - this->m_inputOperation->read(output, x, y, COM_PS_BILINEAR); + this->m_inputOperation->readSampled(output, x, y, COM_PS_BILINEAR); } } diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h index c9629451992..42c4a84f9b2 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h @@ -156,7 +156,7 @@ protected: public: MovieDistortionOperation(bool distortion); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp index e2a95b2e33b..84c1fdfb6f5 100644 --- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp +++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp @@ -42,7 +42,7 @@ ImBuf *MultilayerBaseOperation::getImBuf() return NULL; } -void MultilayerColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MultilayerColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { int yi = y; int xi = x; @@ -70,7 +70,7 @@ void MultilayerColorOperation::executePixel(float output[4], float x, float y, P } } -void MultilayerValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MultilayerValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { int yi = y; int xi = x; @@ -83,7 +83,7 @@ void MultilayerValueOperation::executePixel(float output[4], float x, float y, P } } -void MultilayerVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void MultilayerVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { int yi = y; int xi = x; diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h index 065bcc7da1e..37bee1b6a8c 100644 --- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h +++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h @@ -46,7 +46,7 @@ public: MultilayerColorOperation(int passindex) : MultilayerBaseOperation(passindex) { this->addOutputSocket(COM_DT_COLOR); } - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MultilayerValueOperation : public MultilayerBaseOperation { @@ -54,7 +54,7 @@ public: MultilayerValueOperation(int passindex) : MultilayerBaseOperation(passindex) { this->addOutputSocket(COM_DT_VALUE); } - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class MultilayerVectorOperation : public MultilayerBaseOperation { @@ -62,7 +62,7 @@ public: MultilayerVectorOperation(int passindex) : MultilayerBaseOperation(passindex) { this->addOutputSocket(COM_DT_VECTOR); } - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index a5be993f241..c94387337c3 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -79,7 +79,7 @@ static void write_buffer_rect(rcti *rect, const bNodeTree *tree, for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2 && (!breaked); x++) { - reader->read(color, x, y, COM_PS_NEAREST); + reader->readSampled(color, x, y, COM_PS_NEAREST); for (i = 0; i < size; ++i) buffer[offset + i] = color[i]; diff --git a/source/blender/compositor/operations/COM_PixelateOperation.cpp b/source/blender/compositor/operations/COM_PixelateOperation.cpp index 89e7f0093a1..eed6d1d01b9 100644 --- a/source/blender/compositor/operations/COM_PixelateOperation.cpp +++ b/source/blender/compositor/operations/COM_PixelateOperation.cpp @@ -40,10 +40,10 @@ void PixelateOperation::deinitExecution() this->m_inputOperation = NULL; } -void PixelateOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void PixelateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float nx = round(x); float ny = round(y); - this->m_inputOperation->read(output, nx, ny, sampler); + this->m_inputOperation->readSampled(output, nx, ny, sampler); } diff --git a/source/blender/compositor/operations/COM_PixelateOperation.h b/source/blender/compositor/operations/COM_PixelateOperation.h index 83603a59331..8e60baf7f05 100644 --- a/source/blender/compositor/operations/COM_PixelateOperation.h +++ b/source/blender/compositor/operations/COM_PixelateOperation.h @@ -62,7 +62,7 @@ public: * @param y y-coordinate * @param sampler sampler */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp index 8aa1324d8e2..58fa4bd08dc 100644 --- a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.cpp @@ -50,7 +50,7 @@ void PlaneTrackMaskOperation::initExecution() BLI_jitter_init(this->m_jitter[0], this->m_osa); } -void PlaneTrackMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void PlaneTrackMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float point[2]; diff --git a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h index db32f9830e0..7f763954079 100644 --- a/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h +++ b/source/blender/compositor/operations/COM_PlaneTrackMaskOperation.h @@ -43,7 +43,7 @@ public: void initExecution(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif diff --git a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp index df487a766f3..e3788f89b2d 100644 --- a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp +++ b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp @@ -125,7 +125,7 @@ void PlaneTrackWarpImageOperation::deinitExecution() this->m_pixelReader = NULL; } -void PlaneTrackWarpImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void PlaneTrackWarpImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float color_accum[4]; @@ -142,7 +142,7 @@ void PlaneTrackWarpImageOperation::executePixel(float output[4], float x, float u *= this->m_pixelReader->getWidth(); v *= this->m_pixelReader->getHeight(); - this->m_pixelReader->read(current_color, u, v, dx, dy, COM_PS_NEAREST); + this->m_pixelReader->readFiltered(current_color, u, v, dx, dy, COM_PS_NEAREST); add_v4_v4(color_accum, current_color); } } diff --git a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h index a92ff3f9ddf..4d73a01cad0 100644 --- a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h +++ b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h @@ -45,7 +45,7 @@ public: void initExecution(); void deinitExecution(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp index ba158fb2509..add9e8b959e 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cpp +++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp @@ -104,7 +104,7 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber) color[1] = 0.0f; color[2] = 0.0f; color[3] = 1.0f; - this->m_input->read(color, rx, ry, COM_PS_NEAREST); + this->m_input->readSampled(color, rx, ry, COM_PS_NEAREST); IMB_colormanagement_processor_apply_v4(cm_processor, color); F4TOCHAR4(color, this->m_outputBuffer + offset); offset += 4; diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp index e8b900b9a85..7f6079c55aa 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp @@ -102,7 +102,7 @@ void ProjectorLensDistortionOperation::updateDispersion() this->lockMutex(); if (!this->m_dispersionAvailable) { float result[4]; - this->getInputSocketReader(1)->read(result, 1, 1, COM_PS_NEAREST); + this->getInputSocketReader(1)->readSampled(result, 1, 1, COM_PS_NEAREST); this->m_dispersion = result[0]; this->m_kr = 0.25f * max_ff(min_ff(this->m_dispersion, 1.0f), 0.0f); this->m_kr2 = this->m_kr * 20; diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index 3aeef6bf409..b93e338ad6c 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -52,7 +52,7 @@ void ReadBufferOperation::determineResolution(unsigned int resolution[2], unsign m_single_value = operation->isSingleValue(); } } -void ReadBufferOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ReadBufferOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { if (m_single_value) { /* write buffer has a single value stored at (0,0) */ @@ -81,7 +81,7 @@ void ReadBufferOperation::executePixelExtend(float output[4], float x, float y, } } -void ReadBufferOperation::executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) +void ReadBufferOperation::executePixelFiltered(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) { if (m_single_value) { /* write buffer has a single value stored at (0,0) */ diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h index 7a67056eda6..cdc6e50f6d4 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.h +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h @@ -40,10 +40,10 @@ public: void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); void *initializeTileData(rcti *rect); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void executePixelExtend(float output[4], float x, float y, PixelSampler sampler, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y); - void executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler); + void executePixelFiltered(float output[4], float x, float y, float dx, float dy, PixelSampler sampler); const bool isReadBufferOperation() const { return true; } void setOffset(unsigned int offset) { this->m_offset = offset; } unsigned int getOffset() const { return this->m_offset; } diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp index a8382dd1746..2c2a4c6f180 100644 --- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp @@ -112,7 +112,7 @@ void RenderLayersBaseProg::doInterpolation(float output[4], float x, float y, Pi } } -void RenderLayersBaseProg::executePixel(float output[4], float x, float y, PixelSampler sampler) +void RenderLayersBaseProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { #if 0 const RenderData *rd = this->m_rd; @@ -192,7 +192,7 @@ RenderLayersAlphaProg::RenderLayersAlphaProg() : RenderLayersBaseProg(SCE_PASS_C this->addOutputSocket(COM_DT_VALUE); } -void RenderLayersAlphaProg::executePixel(float output[4], float x, float y, PixelSampler sampler) +void RenderLayersAlphaProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { int ix = x; int iy = y; @@ -234,7 +234,7 @@ RenderLayersDepthProg::RenderLayersDepthProg() : RenderLayersBaseProg(SCE_PASS_Z this->addOutputSocket(COM_DT_VALUE); } -void RenderLayersDepthProg::executePixel(float output[4], float x, float y, PixelSampler sampler) +void RenderLayersDepthProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { int ix = x; int iy = y; diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h index 04861174387..b76a8621b19 100644 --- a/source/blender/compositor/operations/COM_RenderLayersProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersProg.h @@ -99,7 +99,7 @@ public: short getLayerId() { return this->m_layerId; } void initExecution(); void deinitExecution(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class RenderLayersAOOperation : public RenderLayersBaseProg { @@ -110,7 +110,7 @@ public: class RenderLayersAlphaProg : public RenderLayersBaseProg { public: RenderLayersAlphaProg(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class RenderLayersColorOperation : public RenderLayersBaseProg { @@ -126,7 +126,7 @@ public: class RenderLayersDepthProg : public RenderLayersBaseProg { public: RenderLayersDepthProg(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class RenderLayersDiffuseOperation : public RenderLayersBaseProg { diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp index 422c5b93484..c6ad87bbf97 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.cpp +++ b/source/blender/compositor/operations/COM_RotateOperation.cpp @@ -52,7 +52,7 @@ inline void RotateOperation::ensureDegree() { if (!this->m_isDegreeSet) { float degree[4]; - this->m_degreeSocket->read(degree, 0, 0, COM_PS_NEAREST); + this->m_degreeSocket->readSampled(degree, 0, 0, COM_PS_NEAREST); double rad; if (this->m_doDegree2RadConversion) { rad = DEG2RAD((double)degree[0]); @@ -68,14 +68,14 @@ inline void RotateOperation::ensureDegree() } -void RotateOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void RotateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { ensureDegree(); const float dy = y - this->m_centerY; const float dx = x - this->m_centerX; const float nx = this->m_centerX + (this->m_cosine * dx + this->m_sine * dy); const float ny = this->m_centerY + (-this->m_sine * dx + this->m_cosine * dy); - this->m_imageSocket->read(output, nx, ny, sampler); + this->m_imageSocket->readSampled(output, nx, ny, sampler); } bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h index 292f0743a44..40acad1abe6 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.h +++ b/source/blender/compositor/operations/COM_RotateOperation.h @@ -38,7 +38,7 @@ private: public: RotateOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); void setDoDegree2RadConversion(bool abool) { this->m_doDegree2RadConversion = abool; } diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp index 9e8f5af0ef0..452765a5ab7 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.cpp +++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp @@ -66,22 +66,22 @@ void ScaleOperation::deinitExecution() } -void ScaleOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ScaleOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { PixelSampler effective_sampler = getEffectiveSampler(sampler); float scaleX[4]; float scaleY[4]; - this->m_inputXOperation->read(scaleX, x, y, effective_sampler); - this->m_inputYOperation->read(scaleY, x, y, effective_sampler); + this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler); + this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler); const float scx = scaleX[0]; const float scy = scaleY[0]; float nx = this->m_centerX + (x - this->m_centerX) / scx; float ny = this->m_centerY + (y - this->m_centerY) / scy; - this->m_inputOperation->read(output, nx, ny, effective_sampler); + this->m_inputOperation->readSampled(output, nx, ny, effective_sampler); } bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -90,8 +90,8 @@ bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe float scaleX[4]; float scaleY[4]; - this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST); - this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST); + this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST); + this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST); const float scx = scaleX[0]; const float scy = scaleY[0]; @@ -134,15 +134,15 @@ void ScaleAbsoluteOperation::deinitExecution() } -void ScaleAbsoluteOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ScaleAbsoluteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { PixelSampler effective_sampler = getEffectiveSampler(sampler); float scaleX[4]; float scaleY[4]; - this->m_inputXOperation->read(scaleX, x, y, effective_sampler); - this->m_inputYOperation->read(scaleY, x, y, effective_sampler); + this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler); + this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler); const float scx = scaleX[0]; // target absolute scale const float scy = scaleY[0]; // target absolute scale @@ -156,7 +156,7 @@ void ScaleAbsoluteOperation::executePixel(float output[4], float x, float y, Pix float nx = this->m_centerX + (x - this->m_centerX) / relativeXScale; float ny = this->m_centerY + (y - this->m_centerY) / relativeYScale; - this->m_inputOperation->read(output, nx, ny, effective_sampler); + this->m_inputOperation->readSampled(output, nx, ny, effective_sampler); } bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -165,8 +165,8 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB float scaleX[4]; float scaleY[4]; - this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST); - this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST); + this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST); + this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST); const float scx = scaleX[0]; const float scy = scaleY[0]; @@ -253,17 +253,17 @@ void ScaleFixedSizeOperation::deinitExecution() } -void ScaleFixedSizeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ScaleFixedSizeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { PixelSampler effective_sampler = getEffectiveSampler(sampler); if (this->m_is_offset) { float nx = ((x - this->m_offsetX) * this->m_relX); float ny = ((y - this->m_offsetY) * this->m_relY); - this->m_inputOperation->read(output, nx, ny, effective_sampler); + this->m_inputOperation->readSampled(output, nx, ny, effective_sampler); } else { - this->m_inputOperation->read(output, x * this->m_relX, y * this->m_relY, effective_sampler); + this->m_inputOperation->readSampled(output, x * this->m_relX, y * this->m_relY, effective_sampler); } } diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h index f42cdbd78ed..706a5898027 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.h +++ b/source/blender/compositor/operations/COM_ScaleOperation.h @@ -47,7 +47,7 @@ private: public: ScaleOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); @@ -63,7 +63,7 @@ class ScaleAbsoluteOperation : public BaseScaleOperation { public: ScaleAbsoluteOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); @@ -88,7 +88,7 @@ public: ScaleFixedSizeOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index d1060224444..5d2977d361b 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -291,9 +291,9 @@ void ScreenLensDistortionOperation::updateDispersionAndDistortion() this->lockMutex(); if (!this->m_valuesAvailable) { float result[4]; - this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST); + this->getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST); this->m_distortion = result[0]; - this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST); + this->getInputSocketReader(2)->readSampled(result, 0, 0, COM_PS_NEAREST); this->m_dispersion = result[0]; updateVariables(this->m_distortion, this->m_dispersion); this->m_valuesAvailable = true; diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp index fc6cfa455f3..efdc844704a 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp +++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp @@ -38,12 +38,12 @@ void SetAlphaOperation::initExecution() this->m_inputAlpha = getInputSocketReader(1); } -void SetAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void SetAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float alphaInput[4]; - this->m_inputColor->read(output, x, y, sampler); - this->m_inputAlpha->read(alphaInput, x, y, sampler); + this->m_inputColor->readSampled(output, x, y, sampler); + this->m_inputAlpha->readSampled(alphaInput, x, y, sampler); output[3] = alphaInput[0]; } diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h index 1ec4a7aeacf..a0869ec90b2 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.h +++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h @@ -43,7 +43,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_SetColorOperation.cpp b/source/blender/compositor/operations/COM_SetColorOperation.cpp index 44c29b3befd..94a863e628b 100644 --- a/source/blender/compositor/operations/COM_SetColorOperation.cpp +++ b/source/blender/compositor/operations/COM_SetColorOperation.cpp @@ -27,7 +27,7 @@ SetColorOperation::SetColorOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); } -void SetColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void SetColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { copy_v4_v4(output, this->m_color); } diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h index 8377decdd7b..7dfed6b570b 100644 --- a/source/blender/compositor/operations/COM_SetColorOperation.h +++ b/source/blender/compositor/operations/COM_SetColorOperation.h @@ -55,7 +55,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); bool isSetOperation() const { return true; } diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp index 343b5973f7e..be72ffd0336 100644 --- a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp +++ b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp @@ -37,7 +37,7 @@ void SetSamplerOperation::deinitExecution() this->m_reader = NULL; } -void SetSamplerOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void SetSamplerOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { - this->m_reader->read(output, x, y, this->m_sampler); + this->m_reader->readSampled(output, x, y, this->m_sampler); } diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h index c94e174fc81..145d82bd407 100644 --- a/source/blender/compositor/operations/COM_SetSamplerOperation.h +++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h @@ -44,7 +44,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); }; diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cpp b/source/blender/compositor/operations/COM_SetValueOperation.cpp index c5ce3e4c09c..51e09a63051 100644 --- a/source/blender/compositor/operations/COM_SetValueOperation.cpp +++ b/source/blender/compositor/operations/COM_SetValueOperation.cpp @@ -27,7 +27,7 @@ SetValueOperation::SetValueOperation() : NodeOperation() this->addOutputSocket(COM_DT_VALUE); } -void SetValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void SetValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { output[0] = this->m_value; } diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h index b88b85d66f2..7cb914ffa48 100644 --- a/source/blender/compositor/operations/COM_SetValueOperation.h +++ b/source/blender/compositor/operations/COM_SetValueOperation.h @@ -46,7 +46,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); bool isSetOperation() const { return true; } diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp index d5c665e81f5..17212d78e15 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp @@ -28,7 +28,7 @@ SetVectorOperation::SetVectorOperation() : NodeOperation() this->addOutputSocket(COM_DT_VECTOR); } -void SetVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void SetVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { output[0] = this->m_x; output[1] = this->m_y; diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h index d15da58e58e..6fd1b9768fc 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.h +++ b/source/blender/compositor/operations/COM_SetVectorOperation.h @@ -54,7 +54,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); bool isSetOperation() const { return true; } diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp index ac2cee8eb44..d047198ac93 100644 --- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp +++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp @@ -39,9 +39,9 @@ void SocketProxyOperation::deinitExecution() this->m_inputOperation = NULL; } -void SocketProxyOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void SocketProxyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { if (this->m_inputOperation) { - this->m_inputOperation->read(output, x, y, sampler); + this->m_inputOperation->readSampled(output, x, y, sampler); } } diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h index a37384455ca..6a6a0b351b0 100644 --- a/source/blender/compositor/operations/COM_SocketProxyOperation.h +++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h @@ -30,7 +30,7 @@ private: SocketReader *m_inputOperation; public: SocketProxyOperation(DataType type); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_SplitOperation.cpp b/source/blender/compositor/operations/COM_SplitOperation.cpp index a7dbccfc2f7..210095f3bf1 100644 --- a/source/blender/compositor/operations/COM_SplitOperation.cpp +++ b/source/blender/compositor/operations/COM_SplitOperation.cpp @@ -57,15 +57,15 @@ void SplitOperation::deinitExecution() this->m_image2Input = NULL; } -void SplitOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void SplitOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f : this->m_splitPercentage * this->getHeight() / 100.0f; bool image1 = this->m_xSplit ? x > perc : y > perc; if (image1) { - this->m_image1Input->read(output, x, y, COM_PS_NEAREST); + this->m_image1Input->readSampled(output, x, y, COM_PS_NEAREST); } else { - this->m_image2Input->read(output, x, y, COM_PS_NEAREST); + this->m_image2Input->readSampled(output, x, y, COM_PS_NEAREST); } } diff --git a/source/blender/compositor/operations/COM_SplitOperation.h b/source/blender/compositor/operations/COM_SplitOperation.h index 5a042b789d8..2853c845d03 100644 --- a/source/blender/compositor/operations/COM_SplitOperation.h +++ b/source/blender/compositor/operations/COM_SplitOperation.h @@ -35,7 +35,7 @@ public: SplitOperation(); void initExecution(); void deinitExecution(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); void setSplitPercentage(float splitPercentage) { this->m_splitPercentage = splitPercentage; } void setXSplit(bool xsplit) { this->m_xSplit = xsplit; } diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp index bbb7c8b5289..96aea56050f 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cpp +++ b/source/blender/compositor/operations/COM_TextureOperation.cpp @@ -75,16 +75,16 @@ void TextureBaseOperation::determineResolution(unsigned int resolution[2], unsig } } -void TextureAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void TextureAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { - TextureBaseOperation::executePixel(output, x, y, sampler); + TextureBaseOperation::executePixelSampled(output, x, y, sampler); output[0] = output[3]; output[1] = 0.0f; output[2] = 0.0f; output[3] = 0.0f; } -void TextureBaseOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void TextureBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; float textureSize[4]; @@ -96,8 +96,8 @@ void TextureBaseOperation::executePixel(float output[4], float x, float y, Pixel const float u = (x - cx) / this->getWidth() * 2; const float v = (y - cy) / this->getHeight() * 2; - this->m_inputSize->read(textureSize, x, y, sampler); - this->m_inputOffset->read(textureOffset, x, y, sampler); + this->m_inputSize->readSampled(textureSize, x, y, sampler); + this->m_inputOffset->readSampled(textureOffset, x, y, sampler); vec[0] = textureSize[0] * (u + textureOffset[0]); vec[1] = textureSize[1] * (v + textureOffset[1]); @@ -136,7 +136,7 @@ MemoryBuffer *TextureBaseOperation::createMemoryBuffer(rcti *rect2) for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++, data += 4) { - this->executePixel(data, x, y, COM_PS_NEAREST); + this->executePixelSampled(data, x, y, COM_PS_NEAREST); } } diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h index b776f6f2493..064e63c025a 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.h +++ b/source/blender/compositor/operations/COM_TextureOperation.h @@ -62,7 +62,7 @@ protected: MemoryBuffer *createMemoryBuffer(rcti *rect2); public: - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void setTexture(Tex *texture) { this->m_texture = texture; } void initExecution(); @@ -79,7 +79,7 @@ public: class TextureAlphaOperation : public TextureBaseOperation { public: TextureAlphaOperation(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp index 4f00358633a..721b17bcff0 100644 --- a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp +++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp @@ -102,7 +102,7 @@ void TrackPositionOperation::initExecution() } } -void TrackPositionOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void TrackPositionOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { output[0] = this->m_markerPos[this->m_axis] - this->m_relativePos[this->m_axis]; diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.h b/source/blender/compositor/operations/COM_TrackPositionOperation.h index 7a4ce9f9213..10dbaf96646 100644 --- a/source/blender/compositor/operations/COM_TrackPositionOperation.h +++ b/source/blender/compositor/operations/COM_TrackPositionOperation.h @@ -70,7 +70,7 @@ public: void initExecution(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); bool isSetOperation() const { return true; } }; diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp index e2582c3b67b..64da954a2e1 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.cpp +++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp @@ -52,14 +52,14 @@ void TranslateOperation::deinitExecution() } -void TranslateOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void TranslateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { ensureDelta(); float originalXPos = x - this->getDeltaX(); float originalYPos = y - this->getDeltaY(); - this->m_inputOperation->read(output, originalXPos, originalYPos, sampler); + this->m_inputOperation->readSampled(output, originalXPos, originalYPos, sampler); } bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h index a638ae7ce69..f2ae976e2ef 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.h +++ b/source/blender/compositor/operations/COM_TranslateOperation.h @@ -38,7 +38,7 @@ private: public: TranslateOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void initExecution(); void deinitExecution(); @@ -49,9 +49,9 @@ public: inline void ensureDelta() { if (!this->m_isDeltaSet) { float tempDelta[4]; - this->m_inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST); + this->m_inputXOperation->readSampled(tempDelta, 0, 0, COM_PS_NEAREST); this->m_deltaX = tempDelta[0]; - this->m_inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST); + this->m_inputYOperation->readSampled(tempDelta, 0, 0, COM_PS_NEAREST); this->m_deltaY = tempDelta[0]; this->m_isDeltaSet = true; } diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index 03031e0f764..8bdaa0f486e 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -338,7 +338,7 @@ voi *InverseSearchRadiusOperation::initializeTileData(rcti *rect) return data; } -void InverseSearchRadiusOperation::executePixel(float output[4], int x, int y, void *data) +void InverseSearchRadiusOperation::executePixelChunk(float output[4], int x, int y, void *data) { MemoryBuffer *buffer = (MemoryBuffer *)data; buffer->readNoCheck(color, x, y); diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index 7ba8df16795..cab38698296 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -85,7 +85,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], int x, int y, MemoryBuffer *inputBuffers[], void *data); + void executePixelChunk(float output[4], int x, int y, void *data); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp index 6450b0716a3..204b0f2011b 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp @@ -43,12 +43,12 @@ void VectorCurveOperation::initExecution() this->m_inputProgram = this->getInputSocketReader(0); } -void VectorCurveOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void VectorCurveOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float input[4]; - this->m_inputProgram->read(input, x, y, sampler); + this->m_inputProgram->readSampled(input, x, y, sampler); curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input); output[3] = input[3]; diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.h b/source/blender/compositor/operations/COM_VectorCurveOperation.h index 6a1f916c60b..677af77b05e 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.h +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.h @@ -37,7 +37,7 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); /** * Initialize the execution diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index 97be44e2be0..13b50910b50 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -101,18 +101,18 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2; x++) { - this->m_imageInput->read(&(buffer[offset4]), x, y, COM_PS_NEAREST); + this->m_imageInput->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST); if (this->m_ignoreAlpha) { buffer[offset4 + 3] = 1.0f; } else { if (this->m_alphaInput != NULL) { - this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST); + this->m_alphaInput->readSampled(alpha, x, y, COM_PS_NEAREST); buffer[offset4 + 3] = alpha[0]; } } if (m_depthInput) { - this->m_depthInput->read(depth, x, y, COM_PS_NEAREST); + this->m_depthInput->readSampled(depth, x, y, COM_PS_NEAREST); depthbuffer[offset] = depth[0]; } diff --git a/source/blender/compositor/operations/COM_WrapOperation.cpp b/source/blender/compositor/operations/COM_WrapOperation.cpp index ea19952f60c..e6cde05eae2 100644 --- a/source/blender/compositor/operations/COM_WrapOperation.cpp +++ b/source/blender/compositor/operations/COM_WrapOperation.cpp @@ -42,7 +42,7 @@ inline float WrapOperation::getWrappedOriginalYPos(float y) return fmodf(y, this->getHeight()); } -void WrapOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void WrapOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float nx, ny; nx = x; diff --git a/source/blender/compositor/operations/COM_WrapOperation.h b/source/blender/compositor/operations/COM_WrapOperation.h index ddd5fa8032d..33ea1280564 100644 --- a/source/blender/compositor/operations/COM_WrapOperation.h +++ b/source/blender/compositor/operations/COM_WrapOperation.h @@ -31,7 +31,7 @@ private: public: WrapOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); void setWrapping(int wrapping_type); float getWrappedOriginalXPos(float x); diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index c73cb3ae325..832864b399d 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -40,9 +40,9 @@ WriteBufferOperation::~WriteBufferOperation() } } -void WriteBufferOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void WriteBufferOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { - this->m_input->read(output, x, y, sampler); + this->m_input->readSampled(output, x, y, sampler); } void WriteBufferOperation::initExecution() @@ -98,7 +98,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber) for (y = y1; y < y2 && (!breaked); y++) { int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS; for (x = x1; x < x2; x++) { - this->m_input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST); + this->m_input->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST); offset4 += COM_NUMBER_OF_CHANNELS; } if (isBreaked()) { diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h index 157543fcb72..1f1f58b18f1 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.h +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h @@ -39,7 +39,7 @@ public: ~WriteBufferOperation(); int isBufferOperation() { return true; } MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; } - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); const bool isWriteBufferOperation() const { return true; } bool isSingleValue() const { return m_single_value; } diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp index 7db91a40fb7..6cb88919b1b 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp +++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp @@ -46,36 +46,36 @@ void ZCombineOperation::initExecution() this->m_depth2Reader = this->getInputSocketReader(3); } -void ZCombineOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ZCombineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float depth1[4]; float depth2[4]; - this->m_depth1Reader->read(depth1, x, y, sampler); - this->m_depth2Reader->read(depth2, x, y, sampler); + this->m_depth1Reader->readSampled(depth1, x, y, sampler); + this->m_depth2Reader->readSampled(depth2, x, y, sampler); if (depth1[0] < depth2[0]) { - this->m_image1Reader->read(output, x, y, sampler); + this->m_image1Reader->readSampled(output, x, y, sampler); } else { - this->m_image2Reader->read(output, x, y, sampler); + this->m_image2Reader->readSampled(output, x, y, sampler); } } -void ZCombineAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ZCombineAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float depth1[4]; float depth2[4]; float color1[4]; float color2[4]; - this->m_depth1Reader->read(depth1, x, y, sampler); - this->m_depth2Reader->read(depth2, x, y, sampler); + this->m_depth1Reader->readSampled(depth1, x, y, sampler); + this->m_depth2Reader->readSampled(depth2, x, y, sampler); if (depth1[0] <= depth2[0]) { - this->m_image1Reader->read(color1, x, y, sampler); - this->m_image2Reader->read(color2, x, y, sampler); + this->m_image1Reader->readSampled(color1, x, y, sampler); + this->m_image2Reader->readSampled(color2, x, y, sampler); } else { - this->m_image1Reader->read(color2, x, y, sampler); - this->m_image2Reader->read(color1, x, y, sampler); + this->m_image1Reader->readSampled(color2, x, y, sampler); + this->m_image2Reader->readSampled(color1, x, y, sampler); } float fac = color1[3]; float ifac = 1.0f - fac; @@ -113,28 +113,28 @@ void ZCombineMaskOperation::initExecution() this->m_image2Reader = this->getInputSocketReader(2); } -void ZCombineMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ZCombineMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float mask[4]; float color1[4]; float color2[4]; - this->m_maskReader->read(mask, x, y, sampler); - this->m_image1Reader->read(color1, x, y, sampler); - this->m_image2Reader->read(color2, x, y, sampler); + this->m_maskReader->readSampled(mask, x, y, sampler); + this->m_image1Reader->readSampled(color1, x, y, sampler); + this->m_image2Reader->readSampled(color2, x, y, sampler); interp_v4_v4v4(output, color1, color2, 1.0f - mask[0]); } -void ZCombineMaskAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +void ZCombineMaskAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float mask[4]; float color1[4]; float color2[4]; - this->m_maskReader->read(mask, x, y, sampler); - this->m_image1Reader->read(color1, x, y, sampler); - this->m_image2Reader->read(color2, x, y, sampler); + this->m_maskReader->readSampled(mask, x, y, sampler); + this->m_image1Reader->readSampled(color1, x, y, sampler); + this->m_image2Reader->readSampled(color2, x, y, sampler); float fac = (1.0f - mask[0]) * (1.0f - color1[3]) + mask[0] * color2[3]; float mfac = 1.0f - fac; diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h index eeeb29d330f..199120fa3be 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.h +++ b/source/blender/compositor/operations/COM_ZCombineOperation.h @@ -47,11 +47,11 @@ public: /** * the inner loop of this program */ - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class ZCombineAlphaOperation : public ZCombineOperation { - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class ZCombineMaskOperation : public NodeOperation { @@ -64,10 +64,10 @@ public: void initExecution(); void deinitExecution(); - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; class ZCombineMaskAlphaOperation : public ZCombineMaskOperation { - void executePixel(float output[4], float x, float y, PixelSampler sampler); + void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); }; #endif -- cgit v1.2.3 From 000312ab515b77f00725a91b235685ff0c774e57 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Nov 2013 17:19:06 +0600 Subject: Remove Surface modifier when removing force field from object Summary: Before this adding Surface type of force field and removing this field would leave Surface modifier alive in the stack. This might be really misleading and annoying. Now removing force field will ensure no modifiers needed for it are remained in the stack. This also fixes missing notifier to redraw modifier stack when changing force field type. Reviewers: brecht, campbellbarton Reviewed By: brecht Differential Revision: http://developer.blender.org/D13 --- release/scripts/addons | 2 +- source/blender/editors/include/ED_object.h | 2 ++ source/blender/editors/object/object_edit.c | 21 ++++++++++++++++++++- source/blender/editors/object/object_modifier.c | 3 --- source/blender/makesrna/intern/rna_object_force.c | 16 ++-------------- source/blenderplayer/bad_level_call_stubs/stubs.c | 1 + 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/release/scripts/addons b/release/scripts/addons index 2bfbbe4182d..3adbc8f30b2 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 2bfbbe4182d7e5d5332d963054f298c9fddc5f09 +Subproject commit 3adbc8f30b229e7c9ff465183d5ab0acbbdf921a diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 0d11108d81f..4155dbb5565 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -219,6 +219,8 @@ struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( int *free, const unsigned int selection_mask); +void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object); + #ifdef __cplusplus } #endif diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index bd4c2e997fe..02cbc1060df 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1110,6 +1110,23 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, View3D * /* ******************* force field toggle operator ***************** */ +void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object) +{ + PartDeflect *pd = object->pd; + ModifierData *md = modifiers_findByType(object, eModifierType_Surface); + + /* add/remove modifier as needed */ + if (!md) { + if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) && ELEM(pd->forcefield, PFIELD_GUIDE, PFIELD_TEXTURE) == 0) + if (ELEM4(object->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE)) + ED_object_modifier_add(NULL, bmain, scene, object, NULL, eModifierType_Surface); + } + else { + if (!pd || pd->shape != PFIELD_SHAPE_SURFACE || pd->forcefield != PFIELD_FORCE) + ED_object_modifier_remove(NULL, bmain, object, md); + } +} + static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = CTX_data_active_object(C); @@ -1122,7 +1139,9 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) else ob->pd->forcefield = 0; - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); + ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 0c794a974ef..01dafe69d31 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -298,9 +298,6 @@ static int object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, *sort_depsgraph = 1; } else if (md->type == eModifierType_Surface) { - if (ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE) - ob->pd->shape = PFIELD_SHAPE_PLANE; - *sort_depsgraph = 1; } else if (md->type == eModifierType_Multires) { diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 33ae256c042..2a93925a8e5 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -517,21 +517,9 @@ static void rna_FieldSettings_shape_update(Main *bmain, Scene *scene, PointerRNA { if (!particle_id_check(ptr)) { Object *ob = (Object *)ptr->id.data; - PartDeflect *pd = ob->pd; - ModifierData *md = modifiers_findByType(ob, eModifierType_Surface); - - /* add/remove modifier as needed */ - if (!md) { - if (pd && (pd->shape == PFIELD_SHAPE_SURFACE) && ELEM(pd->forcefield, PFIELD_GUIDE, PFIELD_TEXTURE) == 0) - if (ELEM4(ob->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE)) - ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Surface); - } - else { - if (!pd || pd->shape != PFIELD_SHAPE_SURFACE) - ED_object_modifier_remove(NULL, bmain, ob, md); - } - + ED_object_check_force_modifiers(bmain, scene, ob); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); + WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); } } diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 80f3a617bac..f61b54ac360 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -353,6 +353,7 @@ void ED_object_modifier_clear(struct Main *bmain, struct Object *ob) {STUB_ASSER void ED_object_editmode_enter(struct bContext *C, int flag) {STUB_ASSERT(0);} void ED_object_editmode_exit(struct bContext *C, int flag) {STUB_ASSERT(0);} bool ED_object_editmode_load(struct Object *obedit) {STUB_ASSERT(0); return false; } +void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object) {STUB_ASSERT(0);} int uiLayoutGetActive(struct uiLayout *layout) {STUB_ASSERT(0); return 0;} int uiLayoutGetOperatorContext(struct uiLayout *layout) {STUB_ASSERT(0); return 0;} int uiLayoutGetAlignment(struct uiLayout *layout) {STUB_ASSERT(0); return 0;} -- cgit v1.2.3 From 2d8d3f364ed4841c89497a7082ad96d6537512cb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Nov 2013 18:52:18 +0600 Subject: Buildbot: update configuration file Consider this configuration final-1 for the migration, Linux and OSX slaves seems to be fine, Windows slave would need some changes from the slave side. --- build_files/buildbot/master.cfg | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg index 529b4e483b4..220fa08b23a 100644 --- a/build_files/buildbot/master.cfg +++ b/build_files/buildbot/master.cfg @@ -26,9 +26,10 @@ c['slavePortnum'] = 9989 # CHANGE SOURCES from buildbot.changes.svnpoller import SVNPoller +from buildbot.changes.gitpoller import GitPoller -c['change_source'] = SVNPoller( - 'https://svn.blender.org/svnroot/bf-blender/trunk/', +c['change_source'] = GitPoller( + 'git://git.blender.org/blender.git', pollinterval=1200) # SCHEDULERS @@ -70,6 +71,7 @@ for i in range(0, schedule_cycle): from buildbot.process.factory import BuildFactory from buildbot.steps.source import SVN +from buildbot.steps.source import Git from buildbot.steps.shell import ShellCommand from buildbot.steps.shell import Compile from buildbot.steps.shell import Test @@ -100,12 +102,18 @@ def add_builder(c, name, libdir, factory, branch='', rsync=False, hour=3, minute # common steps +def git_submodule_step(submodule): + return Git(name=submodule+'.git', repourl='git://git.blender.org/' + submodule + '.git', mode='update', workdir=submodule + '.git') -def svn_step(branch=''): +def git_step(branch=''): if branch: - return SVN(baseURL='https://svn.blender.org/svnroot/bf-blender/branches/%%BRANCH%%', mode='update', defaultBranch=branch, workdir='blender') + return Git(name='blender.git', repourl='git://git.blender.org/blender.git', mode='update', branch=branch, workdir='blender.git', submodules=True) else: - return SVN(baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/blender', mode='update', defaultBranch='trunk', workdir='blender') + return Git(name='blender.git', repourl='git://git.blender.org/blender.git', mode='update', workdir='blender.git', submodules=True) + +def git_submodules_update(): + command = ['git', 'submodule', 'foreach', '--recursive', 'git', 'pull', 'origin', 'master'] + return ShellCommand(name='Submodules Update', command=command, description='updating', descriptionDone='up to date', workdir='blender.git') def lib_svn_step(dir): return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir, mode='update', defaultBranch='trunk', workdir='lib/' + dir) @@ -118,14 +126,17 @@ def rsync_step(id, branch, rsync_script): def generic_builder(id, libdir='', branch='', rsync=False): filename = 'uploaded/buildbot_upload_' + id + '.zip' - compile_script = '../blender/build_files/buildbot/slave_compile.py' - test_script = '../blender/build_files/buildbot/slave_test.py' - pack_script = '../blender/build_files/buildbot/slave_pack.py' - rsync_script = '../blender/build_files/buildbot/slave_rsync.py' + compile_script = '../blender.git/build_files/buildbot/slave_compile.py' + test_script = '../blender.git/build_files/buildbot/slave_test.py' + pack_script = '../blender.git/build_files/buildbot/slave_pack.py' + rsync_script = '../blender.git/build_files/buildbot/slave_rsync.py' unpack_script = 'master_unpack.py' f = BuildFactory() - f.addStep(svn_step(branch)) + for submodule in ('blender-translations', 'blender-addons', 'blender-addons-contrib', 'scons'): + f.addStep(git_submodule_step(submodule)) + f.addStep(git_step(branch)) + f.addStep(git_submodules_update()) if libdir != '': f.addStep(lib_svn_step(libdir)) @@ -149,6 +160,8 @@ add_builder(c, 'linux_glibc211_i386_scons', '', generic_builder, hour=1) add_builder(c, 'linux_glibc211_x86_64_scons', '', generic_builder, hour=2) add_builder(c, 'win32_scons', 'windows', generic_builder, hour=1) add_builder(c, 'win64_scons', 'win64', generic_builder, hour=2) +add_builder(c, 'win32_scons_vc2012', 'windows_vc11', generic_builder, hour=1) +add_builder(c, 'win64_scons_vc2012', 'win64_vc11', generic_builder, hour=2) #add_builder(c, 'mingw_win32_scons', 'mingw32', generic_builder, hour=4) add_builder(c, 'mingw_win64_scons', 'mingw64', generic_builder, hour=3) #add_builder(c, 'freebsd_i386_cmake', '', generic_builder, hour=1) -- cgit v1.2.3 From 0c0bed3b161ae005821cc68e56ea78223d5fe16c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Nov 2013 00:00:05 +1100 Subject: Fix: Game Engine regression drawing text from recent cleanup --- .../gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 2a8c3ac7929..5105e2c2b8d 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -726,7 +726,7 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms, if (m_attrib[unit] == RAS_TEXCO_UV) glattrib = unit; - GPU_render_text(polymat->GetMTFace(), polymat->GetDrawingMode(), mytext, mytext.Length(), polymat->GetMCol(), v[1], v[2], v[3], v[4], glattrib); + GPU_render_text(polymat->GetMTFace(), polymat->GetDrawingMode(), mytext, mytext.Length(), polymat->GetMCol(), v[0], v[1], v[2], v[3], glattrib); ClearCachingInfo(); } -- cgit v1.2.3 From 035d86402bbb8dab2bfb086a3027e5ec93e52748 Mon Sep 17 00:00:00 2001 From: Henrik Aarnio Date: Tue, 19 Nov 2013 16:31:48 +0100 Subject: Fix: tab completing a filepath name in file browsers asks to create a new directory if name was not fully matched When hitting tab to complete a directory name in the filepath field in the filebrowser Blender shows a "create new directory?" popup, if the beginning of directory name typed in the field matches many entries. For example if you have directories in the open directory called "test123" and "test456", typing "te", tab would complete up to "test", but ask to create a new folder with the name "test". This patch unsets the boolean storing the info about changing filepath if the folder with the completed name does not exist. Reviewed By: brecht Differential Revision: http://developer.blender.org/D10 --- release/scripts/addons | 2 +- source/blender/editors/include/UI_interface.h | 6 +++++- source/blender/editors/interface/interface.c | 16 ++++++++++++---- source/blender/editors/interface/interface_regions.c | 6 +++--- source/blender/editors/space_file/filesel.c | 16 ++++++++-------- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/release/scripts/addons b/release/scripts/addons index 3adbc8f30b2..2c7464fb951 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 3adbc8f30b229e7c9ff465183d5ab0acbbdf921a +Subproject commit 2c7464fb9510bedc6a19c43064ae83ed15f3f7c7 diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 38aad640ee1..50e2e53dbf0 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -641,9 +641,13 @@ void uiButSetFocusOnEnter(struct wmWindow *win, uiBut *but); typedef struct AutoComplete AutoComplete; +#define AUTOCOMPLETE_NO_MATCH 0 +#define AUTOCOMPLETE_FULL_MATCH 1 +#define AUTOCOMPLETE_PARTIAL_MATCH 2 + AutoComplete *autocomplete_begin(const char *startname, size_t maxlen); void autocomplete_do_name(AutoComplete *autocpl, const char *name); -bool autocomplete_end(AutoComplete *autocpl, char *autoname); +int autocomplete_end(AutoComplete *autocpl, char *autoname); /* Panels * diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 96638f77b10..6ee097b066f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3188,6 +3188,7 @@ static int findBitIndex(unsigned int x) /* autocomplete helper functions */ struct AutoComplete { size_t maxlen; + int matches; char *truncate; const char *startname; }; @@ -3198,6 +3199,7 @@ AutoComplete *autocomplete_begin(const char *startname, size_t maxlen) autocpl = MEM_callocN(sizeof(AutoComplete), "AutoComplete"); autocpl->maxlen = maxlen; + autocpl->matches = 0; autocpl->truncate = MEM_callocN(sizeof(char) * maxlen, "AutoCompleteTruncate"); autocpl->startname = startname; @@ -3216,6 +3218,7 @@ void autocomplete_do_name(AutoComplete *autocpl, const char *name) } /* found a match */ if (startname[a] == 0) { + autocpl->matches++; /* first match */ if (truncate[0] == 0) BLI_strncpy(truncate, name, autocpl->maxlen); @@ -3233,21 +3236,26 @@ void autocomplete_do_name(AutoComplete *autocpl, const char *name) } } -bool autocomplete_end(AutoComplete *autocpl, char *autoname) +int autocomplete_end(AutoComplete *autocpl, char *autoname) { - bool change = false; + int match = AUTOCOMPLETE_NO_MATCH; if (autocpl->truncate[0]) { + if (autocpl->matches == 1) { + match = AUTOCOMPLETE_FULL_MATCH; + } else { + match = AUTOCOMPLETE_PARTIAL_MATCH; + } BLI_strncpy(autoname, autocpl->truncate, autocpl->maxlen); - change = true; } else { if (autoname != autocpl->startname) { /* don't copy a string over its self */ BLI_strncpy(autoname, autocpl->startname, autocpl->maxlen); } } + MEM_freeN(autocpl->truncate); MEM_freeN(autocpl); - return change; + return match; } static void ui_check_but_and_iconize(uiBut *but, int icon) diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 3ef613f5867..1de0a278b56 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1054,17 +1054,17 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset) bool ui_searchbox_autocomplete(bContext *C, ARegion *ar, uiBut *but, char *str) { uiSearchboxData *data = ar->regiondata; - bool changed = false; + int match = AUTOCOMPLETE_NO_MATCH; if (str[0]) { data->items.autocpl = autocomplete_begin(str, ui_get_but_string_max_length(but)); but->search_func(C, but->search_arg, but->editstr, &data->items); - changed = autocomplete_end(data->items.autocpl, str); + match = autocomplete_end(data->items.autocpl, str); data->items.autocpl = NULL; } - return changed; + return match != AUTOCOMPLETE_NO_MATCH; } static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 9d762c80405..c6e1541352d 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -637,7 +637,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche bool autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) { SpaceFile *sfile = CTX_wm_space_file(C); - bool change = false; + int match = AUTOCOMPLETE_NO_MATCH; /* search if str matches the beginning of name */ if (str[0] && sfile->files) { @@ -672,9 +672,9 @@ bool autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) } closedir(dir); - change = autocomplete_end(autocpl, str); - if (change) { - if (BLI_exists(str)) { + match = autocomplete_end(autocpl, str); + if (match) { + if (match == AUTOCOMPLETE_FULL_MATCH) { BLI_add_slash(str); } else { @@ -684,13 +684,13 @@ bool autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) } } - return change; + return match == AUTOCOMPLETE_FULL_MATCH; } bool autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) { SpaceFile *sfile = CTX_wm_space_file(C); - bool change = false; + int match = AUTOCOMPLETE_NO_MATCH; /* search if str matches the beginning of name */ if (str[0] && sfile->files) { @@ -704,9 +704,9 @@ bool autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) autocomplete_do_name(autocpl, file->relname); } } - change = autocomplete_end(autocpl, str); + match = autocomplete_end(autocpl, str); } - return change; + return match != AUTOCOMPLETE_NO_MATCH; } void ED_fileselect_clear(struct wmWindowManager *wm, struct SpaceFile *sfile) -- cgit v1.2.3 From 5743a6e36458874be1fe992a361ce493edbee5a4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Nov 2013 02:40:29 +1100 Subject: Code Cleanup: move trans-verts out of snap code into their own file. Developer Note: * minmax & centroid was being calculated when creating trans-verts but never used. * static vars removed, replace with TransVertStore stack var. --- source/blender/editors/include/ED_transverts.h | 70 +++ source/blender/editors/space_view3d/view3d_snap.c | 560 ++-------------------- source/blender/editors/util/CMakeLists.txt | 2 + source/blender/editors/util/ed_transverts.c | 462 ++++++++++++++++++ 4 files changed, 578 insertions(+), 516 deletions(-) create mode 100644 source/blender/editors/include/ED_transverts.h create mode 100644 source/blender/editors/util/ed_transverts.c diff --git a/source/blender/editors/include/ED_transverts.h b/source/blender/editors/include/ED_transverts.h new file mode 100644 index 00000000000..a82e54e425b --- /dev/null +++ b/source/blender/editors/include/ED_transverts.h @@ -0,0 +1,70 @@ +/* + * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ED_transverts.h + * \ingroup editors + */ + +#ifndef __ED_TRANSVERTS_H__ +#define __ED_TRANSVERTS_H__ + +struct Object; + +typedef struct TransVert { + float *loc; + float oldloc[3], maploc[3]; + float *val, oldval; + int flag; +} TransVert; + +typedef struct TransVertStore { + struct TransVert *transverts; + int transverts_tot; +} TransVertStore; + +void ED_transverts_create_from_obedit(TransVertStore *tvs, struct Object *obedit, int mode); +void ED_transverts_update_obedit(TransVertStore *tvs, struct Object *obedit); +void ED_transverts_free(TransVertStore *tvs); +bool ED_transverts_check_obedit(Object *obedit); + +/* currently only used for bmesh index values */ +enum { + TM_INDEX_ON = 1, /* tag to make trans verts */ + TM_INDEX_OFF = 0, /* don't make verts */ + TM_INDEX_SKIP = -1 /* dont make verts (when the index values point to trans-verts) */ +}; + +/* mode flags: */ +enum { + TM_ALL_JOINTS = 1, /* all joints (for bones only) */ + TM_SKIP_HANDLES = 2 /* skip handles when control point is selected (for curves only) */ +}; + + + /* SELECT == (1 << 0) */ +#define TX_VERT_USE_MAPLOC (1 << 1) + +#endif /* __ED_TRANSVERTS_H__ */ diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 34896eb19aa..25458613842 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -30,35 +30,21 @@ */ -#include -#include - -#include "MEM_guardedalloc.h" - #include "DNA_armature_types.h" #include "DNA_curve_types.h" -#include "DNA_lattice_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meta_types.h" -#include "DNA_scene_types.h" #include "DNA_object_types.h" #include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_linklist.h" #include "BLI_utildefines.h" +#include "BLI_math.h" #include "BKE_armature.h" #include "BKE_context.h" -#include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_lattice.h" -#include "BKE_main.h" #include "BKE_mball.h" #include "BKE_object.h" #include "BKE_editmesh.h" -#include "BKE_DerivedMesh.h" -#include "BKE_scene.h" #include "BKE_tracking.h" #include "WM_api.h" @@ -67,468 +53,14 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "ED_armature.h" -#include "ED_mesh.h" +#include "ED_transverts.h" #include "ED_keyframing.h" #include "ED_screen.h" -#include "ED_curve.h" /* for curve_editnurbs */ #include "view3d_intern.h" -/* ************************************************** */ -/* ********************* old transform stuff ******** */ -/* *********** will get replaced with new transform * */ -/* ************************************************** */ - static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]); -typedef struct TransVert { - float *loc; - float oldloc[3], maploc[3]; - float *val, oldval; - int flag; -} TransVert; - - /* SELECT == (1 << 0) */ -#define TX_VERT_USE_MAPLOC (1 << 1) - -static TransVert *transvmain = NULL; -static int tottrans = 0; - -/* copied from editobject.c, now uses (almost) proper depgraph */ -static void special_transvert_update(Object *obedit) -{ - if (obedit) { - DAG_id_tag_update(obedit->data, 0); - - if (obedit->type == OB_MESH) { - BMEditMesh *em = BKE_editmesh_from_object(obedit); - BM_mesh_normals_update(em->bm); - } - else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - Curve *cu = obedit->data; - ListBase *nurbs = BKE_curve_editNurbs_get(cu); - Nurb *nu = nurbs->first; - - while (nu) { - /* keep handles' vectors unchanged */ - if (nu->bezt) { - int a = nu->pntsu; - TransVert *tv = transvmain; - BezTriple *bezt = nu->bezt; - - while (a--) { - if (bezt->f1 & SELECT) tv++; - - if (bezt->f2 & SELECT) { - float v[3]; - - if (bezt->f1 & SELECT) { - sub_v3_v3v3(v, (tv - 1)->oldloc, tv->oldloc); - add_v3_v3v3(bezt->vec[0], bezt->vec[1], v); - } - - if (bezt->f3 & SELECT) { - sub_v3_v3v3(v, (tv + 1)->oldloc, tv->oldloc); - add_v3_v3v3(bezt->vec[2], bezt->vec[1], v); - } - - tv++; - } - - if (bezt->f3 & SELECT) tv++; - - bezt++; - } - } - - BKE_nurb_test2D(nu); - BKE_nurb_handles_test(nu, true); /* test for bezier too */ - nu = nu->next; - } - } - else if (obedit->type == OB_ARMATURE) { - bArmature *arm = obedit->data; - EditBone *ebo; - TransVert *tv = transvmain; - int a = 0; - - /* Ensure all bone tails are correctly adjusted */ - for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { - /* adjust tip if both ends selected */ - if ((ebo->flag & BONE_ROOTSEL) && (ebo->flag & BONE_TIPSEL)) { - if (tv) { - float diffvec[3]; - - sub_v3_v3v3(diffvec, tv->loc, tv->oldloc); - add_v3_v3(ebo->tail, diffvec); - - a++; - if (a < tottrans) tv++; - } - } - } - - /* Ensure all bones are correctly adjusted */ - for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { - if ((ebo->flag & BONE_CONNECTED) && ebo->parent) { - /* If this bone has a parent tip that has been moved */ - if (ebo->parent->flag & BONE_TIPSEL) { - copy_v3_v3(ebo->head, ebo->parent->tail); - } - /* If this bone has a parent tip that has NOT been moved */ - else { - copy_v3_v3(ebo->parent->tail, ebo->head); - } - } - } - if (arm->flag & ARM_MIRROR_EDIT) - transform_armature_mirror_update(obedit); - } - else if (obedit->type == OB_LATTICE) { - Lattice *lt = obedit->data; - - if (lt->editlatt->latt->flag & LT_OUTSIDE) - outside_lattice(lt->editlatt->latt); - } - } -} - -/* currently only used for bmesh index values */ -enum { - TM_INDEX_ON = 1, /* tag to make trans verts */ - TM_INDEX_OFF = 0, /* don't make verts */ - TM_INDEX_SKIP = -1 /* dont make verts (when the index values point to trans-verts) */ -}; - -/* copied from editobject.c, needs to be replaced with new transform code still */ -/* mode flags: */ -enum { - TM_ALL_JOINTS = 1, /* all joints (for bones only) */ - TM_SKIP_HANDLES = 2 /* skip handles when control point is selected (for curves only) */ -}; - -static void set_mapped_co(void *vuserdata, int index, const float co[3], - const float UNUSED(no[3]), const short UNUSED(no_s[3])) -{ - void **userdata = vuserdata; - BMEditMesh *em = userdata[0]; - TransVert *tv = userdata[1]; - BMVert *eve = BM_vert_at_index(em->bm, index); - - if (BM_elem_index_get(eve) != TM_INDEX_SKIP) { - tv = &tv[BM_elem_index_get(eve)]; - - /* be clever, get the closest vertex to the original, - * behaves most logically when the mirror modifier is used for eg [#33051]*/ - if ((tv->flag & TX_VERT_USE_MAPLOC) == 0) { - /* first time */ - copy_v3_v3(tv->maploc, co); - tv->flag |= TX_VERT_USE_MAPLOC; - } - else { - /* find best location to use */ - if (len_squared_v3v3(eve->co, co) < len_squared_v3v3(eve->co, tv->maploc)) { - copy_v3_v3(tv->maploc, co); - } - } - } -} - -static void make_trans_verts(Object *obedit, float min[3], float max[3], int mode) -{ - Nurb *nu; - BezTriple *bezt; - BPoint *bp; - TransVert *tv = NULL; - MetaElem *ml; - BMVert *eve; - EditBone *ebo; - float total, center[3], centroid[3]; - int a; - - tottrans = 0; /* global! */ - - INIT_MINMAX(min, max); - zero_v3(centroid); - - if (obedit->type == OB_MESH) { - BMEditMesh *em = BKE_editmesh_from_object(obedit); - BMesh *bm = em->bm; - BMIter iter; - void *userdata[2] = {em, NULL}; - /*int proptrans = 0; */ /*UNUSED*/ - - /* abuses vertex index all over, set, just set dirty here, - * perhaps this could use its own array instead? - campbell */ - - /* transform now requires awareness for select mode, so we tag the f1 flags in verts */ - tottrans = 0; - if (em->selectmode & SCE_SELECT_VERTEX) { - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - BM_elem_index_set(eve, TM_INDEX_ON); /* set_dirty! */ - tottrans++; - } - else { - BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */ - } - } - } - else if (em->selectmode & SCE_SELECT_EDGE) { - BMEdge *eed; - - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */ - } - - BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { - if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SELECT)) { - BM_elem_index_set(eed->v1, TM_INDEX_ON); /* set_dirty! */ - BM_elem_index_set(eed->v2, TM_INDEX_ON); /* set_dirty! */ - } - } - - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_index_get(eve) == TM_INDEX_ON) tottrans++; - } - } - else { - BMFace *efa; - - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */ - } - - BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { - if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT)) { - BMIter liter; - BMLoop *l; - - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - BM_elem_index_set(l->v, TM_INDEX_ON); /* set_dirty! */ - } - } - } - - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_index_get(eve) == TM_INDEX_ON) tottrans++; - } - } - /* for any of the 3 loops above which all dirty the indices */ - bm->elem_index_dirty |= BM_VERT; - - /* and now make transverts */ - if (tottrans) { - tv = transvmain = MEM_callocN(tottrans * sizeof(TransVert), "maketransverts"); - - a = 0; - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_index_get(eve)) { - BM_elem_index_set(eve, a); /* set_dirty! */ - copy_v3_v3(tv->oldloc, eve->co); - tv->loc = eve->co; - tv->flag = (BM_elem_index_get(eve) == TM_INDEX_ON) ? SELECT : 0; - tv++; - a++; - } - else { - BM_elem_index_set(eve, TM_INDEX_SKIP); /* set_dirty! */ - } - } - /* set dirty already, above */ - - userdata[1] = transvmain; - } - - if (transvmain && em->derivedCage) { - BM_mesh_elem_table_ensure(bm, BM_VERT); - em->derivedCage->foreachMappedVert(em->derivedCage, set_mapped_co, userdata, DM_FOREACH_NOP); - } - } - else if (obedit->type == OB_ARMATURE) { - bArmature *arm = obedit->data; - int totmalloc = BLI_countlist(arm->edbo); - - totmalloc *= 2; /* probably overkill but bones can have 2 trans verts each */ - - tv = transvmain = MEM_callocN(totmalloc * sizeof(TransVert), "maketransverts armature"); - - for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { - if (ebo->layer & arm->layer) { - short tipsel = (ebo->flag & BONE_TIPSEL); - short rootsel = (ebo->flag & BONE_ROOTSEL); - short rootok = (!(ebo->parent && (ebo->flag & BONE_CONNECTED) && (ebo->parent->flag & BONE_TIPSEL))); - - if ((tipsel && rootsel) || (rootsel)) { - /* Don't add the tip (unless mode & TM_ALL_JOINTS, for getting all joints), - * otherwise we get zero-length bones as tips will snap to the same - * location as heads. - */ - if (rootok) { - copy_v3_v3(tv->oldloc, ebo->head); - tv->loc = ebo->head; - tv->flag = SELECT; - tv++; - tottrans++; - } - - if ((mode & TM_ALL_JOINTS) && (tipsel)) { - copy_v3_v3(tv->oldloc, ebo->tail); - tv->loc = ebo->tail; - tv->flag = SELECT; - tv++; - tottrans++; - } - } - else if (tipsel) { - copy_v3_v3(tv->oldloc, ebo->tail); - tv->loc = ebo->tail; - tv->flag = SELECT; - tv++; - tottrans++; - } - } - } - } - else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - Curve *cu = obedit->data; - int totmalloc = 0; - ListBase *nurbs = BKE_curve_editNurbs_get(cu); - - for (nu = nurbs->first; nu; nu = nu->next) { - if (nu->type == CU_BEZIER) - totmalloc += 3 * nu->pntsu; - else - totmalloc += nu->pntsu * nu->pntsv; - } - tv = transvmain = MEM_callocN(totmalloc * sizeof(TransVert), "maketransverts curve"); - - nu = nurbs->first; - while (nu) { - if (nu->type == CU_BEZIER) { - a = nu->pntsu; - bezt = nu->bezt; - while (a--) { - if (bezt->hide == 0) { - int skip_handle = 0; - if (bezt->f2 & SELECT) - skip_handle = mode & TM_SKIP_HANDLES; - - if ((bezt->f1 & SELECT) && !skip_handle) { - copy_v3_v3(tv->oldloc, bezt->vec[0]); - tv->loc = bezt->vec[0]; - tv->flag = bezt->f1 & SELECT; - tv++; - tottrans++; - } - if (bezt->f2 & SELECT) { - copy_v3_v3(tv->oldloc, bezt->vec[1]); - tv->loc = bezt->vec[1]; - tv->val = &(bezt->alfa); - tv->oldval = bezt->alfa; - tv->flag = bezt->f2 & SELECT; - tv++; - tottrans++; - } - if ((bezt->f3 & SELECT) && !skip_handle) { - copy_v3_v3(tv->oldloc, bezt->vec[2]); - tv->loc = bezt->vec[2]; - tv->flag = bezt->f3 & SELECT; - tv++; - tottrans++; - } - } - bezt++; - } - } - else { - a = nu->pntsu * nu->pntsv; - bp = nu->bp; - while (a--) { - if (bp->hide == 0) { - if (bp->f1 & SELECT) { - copy_v3_v3(tv->oldloc, bp->vec); - tv->loc = bp->vec; - tv->val = &(bp->alfa); - tv->oldval = bp->alfa; - tv->flag = bp->f1 & SELECT; - tv++; - tottrans++; - } - } - bp++; - } - } - nu = nu->next; - } - } - else if (obedit->type == OB_MBALL) { - MetaBall *mb = obedit->data; - int totmalloc = BLI_countlist(mb->editelems); - - tv = transvmain = MEM_callocN(totmalloc * sizeof(TransVert), "maketransverts mball"); - - ml = mb->editelems->first; - while (ml) { - if (ml->flag & SELECT) { - tv->loc = &ml->x; - copy_v3_v3(tv->oldloc, tv->loc); - tv->val = &(ml->rad); - tv->oldval = ml->rad; - tv->flag = SELECT; - tv++; - tottrans++; - } - ml = ml->next; - } - } - else if (obedit->type == OB_LATTICE) { - Lattice *lt = obedit->data; - - bp = lt->editlatt->latt->def; - - a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; - - tv = transvmain = MEM_callocN(a * sizeof(TransVert), "maketransverts latt"); - - while (a--) { - if (bp->f1 & SELECT) { - if (bp->hide == 0) { - copy_v3_v3(tv->oldloc, bp->vec); - tv->loc = bp->vec; - tv->flag = bp->f1 & SELECT; - tv++; - tottrans++; - } - } - bp++; - } - } - - if (!tottrans && transvmain) { - /* prevent memory leak. happens for curves/latticies due to */ - /* difficult condition of adding points to trans data */ - MEM_freeN(transvmain); - transvmain = NULL; - } - - /* cent etc */ - tv = transvmain; - total = 0.0; - for (a = 0; a < tottrans; a++, tv++) { - if (tv->flag & SELECT) { - add_v3_v3(centroid, tv->oldloc); - total += 1.0f; - minmax_v3v3_v3(min, max, tv->oldloc); - } - } - if (total != 0.0f) { - mul_v3_fl(centroid, 1.0f / total); - } - - mid_v3_v3v3(center, min, max); -} /* *********************** operators ******************** */ @@ -537,6 +69,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) Object *obedit = CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); RegionView3D *rv3d = CTX_wm_region_data(C); + TransVertStore tvs = {NULL}; TransVert *tv; float gridf, imat[3][3], bmat[3][3], vec[3]; int a; @@ -544,17 +77,16 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) gridf = rv3d->gridview; if (obedit) { - tottrans = 0; - - if (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)) - make_trans_verts(obedit, bmat[0], bmat[1], 0); - if (tottrans == 0) return OPERATOR_CANCELLED; - + if (ED_transverts_check_obedit(obedit)) + ED_transverts_create_from_obedit(&tvs, obedit, 0); + if (tvs.transverts_tot == 0) + return OPERATOR_CANCELLED; + copy_m3_m4(bmat, obedit->obmat); invert_m3_m3(imat, bmat); - tv = transvmain; - for (a = 0; a < tottrans; a++, tv++) { + tv = tvs.transverts; + for (a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(vec, tv->loc); mul_m3_v3(bmat, vec); add_v3_v3(vec, obedit->obmat[3]); @@ -567,10 +99,8 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) copy_v3_v3(tv->loc, vec); } - special_transvert_update(obedit); - - MEM_freeN(transvmain); - transvmain = NULL; + ED_transverts_update_obedit(&tvs, obedit); + ED_transverts_free(&tvs); } else { struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID); @@ -593,9 +123,9 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) copy_v3_v3(nLoc, pchan->pose_mat[3]); /* We must operate in world space! */ mul_m4_v3(ob->obmat, nLoc); - vec[0] = gridf * (float)(floor(0.5f + nLoc[0] / gridf)); - vec[1] = gridf * (float)(floor(0.5f + nLoc[1] / gridf)); - vec[2] = gridf * (float)(floor(0.5f + nLoc[2] / gridf)); + vec[0] = gridf * floorf(0.5f + nLoc[0] / gridf); + vec[1] = gridf * floorf(0.5f + nLoc[1] / gridf); + vec[2] = gridf * floorf(0.5f + nLoc[2] / gridf); /* Back in object space... */ mul_m4_v3(ob->imat, vec); @@ -678,6 +208,7 @@ static int snap_sel_to_curs_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); + TransVertStore tvs = {NULL}; TransVert *tv; float imat[3][3], bmat[3][3]; const float *cursor_global; @@ -696,13 +227,12 @@ static int snap_sel_to_curs_exec(bContext *C, wmOperator *op) if (obedit) { float cursor_local[3]; - - tottrans = 0; - - if (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)) - make_trans_verts(obedit, bmat[0], bmat[1], 0); - if (tottrans == 0) return OPERATOR_CANCELLED; + if (ED_transverts_check_obedit(obedit)) + ED_transverts_create_from_obedit(&tvs, obedit, 0); + if (tvs.transverts_tot == 0) + return OPERATOR_CANCELLED; + copy_m3_m4(bmat, obedit->obmat); invert_m3_m3(imat, bmat); @@ -715,22 +245,20 @@ static int snap_sel_to_curs_exec(bContext *C, wmOperator *op) mul_v3_m3v3(offset_local, imat, offset_global); - tv = transvmain; - for (a = 0; a < tottrans; a++, tv++) { + tv = tvs.transverts; + for (a = 0; a < tvs.transverts_tot; a++, tv++) { add_v3_v3(tv->loc, offset_local); } } else { - tv = transvmain; - for (a = 0; a < tottrans; a++, tv++) { + tv = tvs.transverts; + for (a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(tv->loc, cursor_local); } } - special_transvert_update(obedit); - - MEM_freeN(transvmain); - transvmain = NULL; + ED_transverts_update_obedit(&tvs, obedit); + ED_transverts_free(&tvs); } else { struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID); @@ -937,6 +465,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]) Object *obedit = CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); + TransVertStore tvs = {NULL}; TransVert *tv; float bmat[3][3], vec[3], min[3], max[3], centroid[3]; int count, a; @@ -946,19 +475,18 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]) zero_v3(centroid); if (obedit) { - tottrans = 0; - if (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)) - make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS | TM_SKIP_HANDLES); + if (ED_transverts_check_obedit(obedit)) + ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS | TM_SKIP_HANDLES); - if (tottrans == 0) { + if (tvs.transverts_tot == 0) { return false; } copy_m3_m4(bmat, obedit->obmat); - tv = transvmain; - for (a = 0; a < tottrans; a++, tv++) { + tv = tvs.transverts; + for (a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(vec, tv->loc); mul_m3_v3(bmat, vec); add_v3_v3(vec, obedit->obmat[3]); @@ -967,14 +495,14 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]) } if (v3d->around == V3D_CENTROID) { - mul_v3_fl(centroid, 1.0f / (float)tottrans); + mul_v3_fl(centroid, 1.0f / (float)tvs.transverts_tot); copy_v3_v3(cursor, centroid); } else { mid_v3_v3v3(cursor, min, max); } - MEM_freeN(transvmain); - transvmain = NULL; + + ED_transverts_free(&tvs); } else { Object *obact = CTX_data_active_object(C); @@ -1156,6 +684,7 @@ void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot) bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3]) { + TransVertStore tvs = {NULL}; TransVert *tv; float centroid[3], vec[3], bmat[3][3]; int a; @@ -1173,16 +702,16 @@ bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3]) return change; } - tottrans = 0; - if (ELEM5(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE)) - make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS); + if (ED_transverts_check_obedit(obedit)) + ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS); - if (tottrans == 0) return false; + if (tvs.transverts_tot == 0) + return false; copy_m3_m4(bmat, obedit->obmat); - tv = transvmain; - for (a = 0; a < tottrans; a++, tv++) { + tv = tvs.transverts; + for (a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(vec, (tv->flag & TX_VERT_USE_MAPLOC) ? tv->maploc : tv->loc); mul_m3_v3(bmat, vec); add_v3_v3(vec, obedit->obmat[3]); @@ -1190,8 +719,7 @@ bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3]) minmax_v3v3_v3(min, max, vec); } - MEM_freeN(transvmain); - transvmain = NULL; + ED_transverts_free(&tvs); return true; } diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index e72385b311d..6c0bf92a484 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -35,6 +35,7 @@ set(INC_SYS ) set(SRC + ed_transverts.c ed_util.c editmode_undo.c numinput.c @@ -79,6 +80,7 @@ set(SRC ../include/ED_space_api.h ../include/ED_text.h ../include/ED_transform.h + ../include/ED_transverts.h ../include/ED_types.h ../include/ED_util.h ../include/ED_uvedit.h diff --git a/source/blender/editors/util/ed_transverts.c b/source/blender/editors/util/ed_transverts.c new file mode 100644 index 00000000000..4123132ad03 --- /dev/null +++ b/source/blender/editors/util/ed_transverts.c @@ -0,0 +1,462 @@ +/* + * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_view3d/ed_transverts.c + * \ingroup edutil + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_armature_types.h" +#include "DNA_curve_types.h" +#include "DNA_lattice_types.h" +#include "DNA_meta_types.h" +#include "DNA_scene_types.h" +#include "DNA_object_types.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" +#include "BLI_math.h" + +#include "BKE_curve.h" +#include "BKE_depsgraph.h" +#include "BKE_lattice.h" +#include "BKE_editmesh.h" +#include "BKE_DerivedMesh.h" + +#include "ED_armature.h" + +#include "ED_transverts.h" /* own include */ + + +/* copied from editobject.c, now uses (almost) proper depgraph */ +void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit) +{ + BLI_assert(ED_transverts_check_obedit(obedit) == true); + + DAG_id_tag_update(obedit->data, 0); + + if (obedit->type == OB_MESH) { + BMEditMesh *em = BKE_editmesh_from_object(obedit); + BM_mesh_normals_update(em->bm); + } + else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { + Curve *cu = obedit->data; + ListBase *nurbs = BKE_curve_editNurbs_get(cu); + Nurb *nu = nurbs->first; + + while (nu) { + /* keep handles' vectors unchanged */ + if (nu->bezt) { + int a = nu->pntsu; + TransVert *tv = tvs->transverts; + BezTriple *bezt = nu->bezt; + + while (a--) { + if (bezt->f1 & SELECT) tv++; + + if (bezt->f2 & SELECT) { + float v[3]; + + if (bezt->f1 & SELECT) { + sub_v3_v3v3(v, (tv - 1)->oldloc, tv->oldloc); + add_v3_v3v3(bezt->vec[0], bezt->vec[1], v); + } + + if (bezt->f3 & SELECT) { + sub_v3_v3v3(v, (tv + 1)->oldloc, tv->oldloc); + add_v3_v3v3(bezt->vec[2], bezt->vec[1], v); + } + + tv++; + } + + if (bezt->f3 & SELECT) tv++; + + bezt++; + } + } + + BKE_nurb_test2D(nu); + BKE_nurb_handles_test(nu, true); /* test for bezier too */ + nu = nu->next; + } + } + else if (obedit->type == OB_ARMATURE) { + bArmature *arm = obedit->data; + EditBone *ebo; + TransVert *tv = tvs->transverts; + int a = 0; + + /* Ensure all bone tails are correctly adjusted */ + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { + /* adjust tip if both ends selected */ + if ((ebo->flag & BONE_ROOTSEL) && (ebo->flag & BONE_TIPSEL)) { + if (tv) { + float diffvec[3]; + + sub_v3_v3v3(diffvec, tv->loc, tv->oldloc); + add_v3_v3(ebo->tail, diffvec); + + a++; + if (a < tvs->transverts_tot) tv++; + } + } + } + + /* Ensure all bones are correctly adjusted */ + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { + if ((ebo->flag & BONE_CONNECTED) && ebo->parent) { + /* If this bone has a parent tip that has been moved */ + if (ebo->parent->flag & BONE_TIPSEL) { + copy_v3_v3(ebo->head, ebo->parent->tail); + } + /* If this bone has a parent tip that has NOT been moved */ + else { + copy_v3_v3(ebo->parent->tail, ebo->head); + } + } + } + if (arm->flag & ARM_MIRROR_EDIT) + transform_armature_mirror_update(obedit); + } + else if (obedit->type == OB_LATTICE) { + Lattice *lt = obedit->data; + + if (lt->editlatt->latt->flag & LT_OUTSIDE) + outside_lattice(lt->editlatt->latt); + } +} + +static void set_mapped_co(void *vuserdata, int index, const float co[3], + const float UNUSED(no[3]), const short UNUSED(no_s[3])) +{ + void **userdata = vuserdata; + BMEditMesh *em = userdata[0]; + TransVert *tv = userdata[1]; + BMVert *eve = BM_vert_at_index(em->bm, index); + + if (BM_elem_index_get(eve) != TM_INDEX_SKIP) { + tv = &tv[BM_elem_index_get(eve)]; + + /* be clever, get the closest vertex to the original, + * behaves most logically when the mirror modifier is used for eg [#33051]*/ + if ((tv->flag & TX_VERT_USE_MAPLOC) == 0) { + /* first time */ + copy_v3_v3(tv->maploc, co); + tv->flag |= TX_VERT_USE_MAPLOC; + } + else { + /* find best location to use */ + if (len_squared_v3v3(eve->co, co) < len_squared_v3v3(eve->co, tv->maploc)) { + copy_v3_v3(tv->maploc, co); + } + } + } +} + +bool ED_transverts_check_obedit(Object *obedit) +{ + return (ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)); +} + +void ED_transverts_create_from_obedit(TransVertStore *tvs, Object *obedit, const int mode) +{ + Nurb *nu; + BezTriple *bezt; + BPoint *bp; + TransVert *tv = NULL; + MetaElem *ml; + BMVert *eve; + EditBone *ebo; + int a; + + tvs->transverts_tot = 0; + + if (obedit->type == OB_MESH) { + BMEditMesh *em = BKE_editmesh_from_object(obedit); + BMesh *bm = em->bm; + BMIter iter; + void *userdata[2] = {em, NULL}; + /*int proptrans = 0; */ /*UNUSED*/ + + /* abuses vertex index all over, set, just set dirty here, + * perhaps this could use its own array instead? - campbell */ + + /* transform now requires awareness for select mode, so we tag the f1 flags in verts */ + tvs->transverts_tot = 0; + if (em->selectmode & SCE_SELECT_VERTEX) { + BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BM_elem_flag_test(eve, BM_ELEM_SELECT)) { + BM_elem_index_set(eve, TM_INDEX_ON); /* set_dirty! */ + tvs->transverts_tot++; + } + else { + BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */ + } + } + } + else if (em->selectmode & SCE_SELECT_EDGE) { + BMEdge *eed; + + BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { + BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */ + } + + BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SELECT)) { + BM_elem_index_set(eed->v1, TM_INDEX_ON); /* set_dirty! */ + BM_elem_index_set(eed->v2, TM_INDEX_ON); /* set_dirty! */ + } + } + + BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_index_get(eve) == TM_INDEX_ON) tvs->transverts_tot++; + } + } + else { + BMFace *efa; + + BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { + BM_elem_index_set(eve, TM_INDEX_OFF); /* set_dirty! */ + } + + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { + if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT)) { + BMIter liter; + BMLoop *l; + + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + BM_elem_index_set(l->v, TM_INDEX_ON); /* set_dirty! */ + } + } + } + + BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_index_get(eve) == TM_INDEX_ON) tvs->transverts_tot++; + } + } + /* for any of the 3 loops above which all dirty the indices */ + bm->elem_index_dirty |= BM_VERT; + + /* and now make transverts */ + if (tvs->transverts_tot) { + tv = tvs->transverts = MEM_callocN(tvs->transverts_tot * sizeof(TransVert), __func__); + + a = 0; + BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_index_get(eve)) { + BM_elem_index_set(eve, a); /* set_dirty! */ + copy_v3_v3(tv->oldloc, eve->co); + tv->loc = eve->co; + tv->flag = (BM_elem_index_get(eve) == TM_INDEX_ON) ? SELECT : 0; + tv++; + a++; + } + else { + BM_elem_index_set(eve, TM_INDEX_SKIP); /* set_dirty! */ + } + } + /* set dirty already, above */ + + userdata[1] = tvs->transverts; + } + + if (tvs->transverts && em->derivedCage) { + BM_mesh_elem_table_ensure(bm, BM_VERT); + em->derivedCage->foreachMappedVert(em->derivedCage, set_mapped_co, userdata, DM_FOREACH_NOP); + } + } + else if (obedit->type == OB_ARMATURE) { + bArmature *arm = obedit->data; + int totmalloc = BLI_countlist(arm->edbo); + + totmalloc *= 2; /* probably overkill but bones can have 2 trans verts each */ + + tv = tvs->transverts = MEM_callocN(totmalloc * sizeof(TransVert), __func__); + + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { + if (ebo->layer & arm->layer) { + short tipsel = (ebo->flag & BONE_TIPSEL); + short rootsel = (ebo->flag & BONE_ROOTSEL); + short rootok = (!(ebo->parent && (ebo->flag & BONE_CONNECTED) && (ebo->parent->flag & BONE_TIPSEL))); + + if ((tipsel && rootsel) || (rootsel)) { + /* Don't add the tip (unless mode & TM_ALL_JOINTS, for getting all joints), + * otherwise we get zero-length bones as tips will snap to the same + * location as heads. + */ + if (rootok) { + copy_v3_v3(tv->oldloc, ebo->head); + tv->loc = ebo->head; + tv->flag = SELECT; + tv++; + tvs->transverts_tot++; + } + + if ((mode & TM_ALL_JOINTS) && (tipsel)) { + copy_v3_v3(tv->oldloc, ebo->tail); + tv->loc = ebo->tail; + tv->flag = SELECT; + tv++; + tvs->transverts_tot++; + } + } + else if (tipsel) { + copy_v3_v3(tv->oldloc, ebo->tail); + tv->loc = ebo->tail; + tv->flag = SELECT; + tv++; + tvs->transverts_tot++; + } + } + } + } + else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { + Curve *cu = obedit->data; + int totmalloc = 0; + ListBase *nurbs = BKE_curve_editNurbs_get(cu); + + for (nu = nurbs->first; nu; nu = nu->next) { + if (nu->type == CU_BEZIER) + totmalloc += 3 * nu->pntsu; + else + totmalloc += nu->pntsu * nu->pntsv; + } + tv = tvs->transverts = MEM_callocN(totmalloc * sizeof(TransVert), __func__); + + nu = nurbs->first; + while (nu) { + if (nu->type == CU_BEZIER) { + a = nu->pntsu; + bezt = nu->bezt; + while (a--) { + if (bezt->hide == 0) { + int skip_handle = 0; + if (bezt->f2 & SELECT) + skip_handle = mode & TM_SKIP_HANDLES; + + if ((bezt->f1 & SELECT) && !skip_handle) { + copy_v3_v3(tv->oldloc, bezt->vec[0]); + tv->loc = bezt->vec[0]; + tv->flag = bezt->f1 & SELECT; + tv++; + tvs->transverts_tot++; + } + if (bezt->f2 & SELECT) { + copy_v3_v3(tv->oldloc, bezt->vec[1]); + tv->loc = bezt->vec[1]; + tv->val = &(bezt->alfa); + tv->oldval = bezt->alfa; + tv->flag = bezt->f2 & SELECT; + tv++; + tvs->transverts_tot++; + } + if ((bezt->f3 & SELECT) && !skip_handle) { + copy_v3_v3(tv->oldloc, bezt->vec[2]); + tv->loc = bezt->vec[2]; + tv->flag = bezt->f3 & SELECT; + tv++; + tvs->transverts_tot++; + } + } + bezt++; + } + } + else { + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + while (a--) { + if (bp->hide == 0) { + if (bp->f1 & SELECT) { + copy_v3_v3(tv->oldloc, bp->vec); + tv->loc = bp->vec; + tv->val = &(bp->alfa); + tv->oldval = bp->alfa; + tv->flag = bp->f1 & SELECT; + tv++; + tvs->transverts_tot++; + } + } + bp++; + } + } + nu = nu->next; + } + } + else if (obedit->type == OB_MBALL) { + MetaBall *mb = obedit->data; + int totmalloc = BLI_countlist(mb->editelems); + + tv = tvs->transverts = MEM_callocN(totmalloc * sizeof(TransVert), __func__); + + ml = mb->editelems->first; + while (ml) { + if (ml->flag & SELECT) { + tv->loc = &ml->x; + copy_v3_v3(tv->oldloc, tv->loc); + tv->val = &(ml->rad); + tv->oldval = ml->rad; + tv->flag = SELECT; + tv++; + tvs->transverts_tot++; + } + ml = ml->next; + } + } + else if (obedit->type == OB_LATTICE) { + Lattice *lt = obedit->data; + + bp = lt->editlatt->latt->def; + + a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; + + tv = tvs->transverts = MEM_callocN(a * sizeof(TransVert), __func__); + + while (a--) { + if (bp->f1 & SELECT) { + if (bp->hide == 0) { + copy_v3_v3(tv->oldloc, bp->vec); + tv->loc = bp->vec; + tv->flag = bp->f1 & SELECT; + tv++; + tvs->transverts_tot++; + } + } + bp++; + } + } + + if (!tvs->transverts_tot && tvs->transverts) { + /* prevent memory leak. happens for curves/latticies due to */ + /* difficult condition of adding points to trans data */ + MEM_freeN(tvs->transverts); + tvs->transverts = NULL; + } +} + +void ED_transverts_free(TransVertStore *tvs) +{ + MEM_SAFE_FREE(tvs->transverts); + tvs->transverts_tot = 0; +} -- cgit v1.2.3 From 50fbebe0a443d10b3b5525c9a7e152acc32b4527 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Nov 2013 22:01:43 +0600 Subject: Buildinfo fixes - Use -M suffix if working tree does have uncommitted modifications. - Local commits are considered local changes as well --- CMakeLists.txt | 1 + build_files/cmake/buildinfo.cmake | 19 +++++++++++-------- build_files/scons/tools/Blender.py | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3a4d65e0ce..d96c41bf79e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,4 @@ + # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake index 389386629db..2cc92df15e7 100644 --- a/build_files/cmake/buildinfo.cmake +++ b/build_files/cmake/buildinfo.cmake @@ -22,12 +22,6 @@ if(EXISTS ${SOURCE_DIR}/.git/) OUTPUT_VARIABLE MY_WC_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE) - # Get latest version tag - execute_process(COMMAND git describe --match "v[0-9]*" --abbrev=0 - WORKING_DIRECTORY ${SOURCE_DIR} - OUTPUT_VARIABLE _git_latest_version_tag - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND git log -1 --format=%ct WORKING_DIRECTORY ${SOURCE_DIR} OUTPUT_VARIABLE MY_WC_COMMIT_TIMESTAMP @@ -44,11 +38,20 @@ if(EXISTS ${SOURCE_DIR}/.git/) OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT _git_changed_files STREQUAL "") - set(MY_WC_CHANGE "${MY_WC_CHANGE}M") + set(MY_WC_BRANCH "${MY_WC_BRANCH} (modified)") + else() + # Unpushed commits are also considered local odifications + execute_process(COMMAND git log @{u}.. + WORKING_DIRECTORY ${SOURCE_DIR} + OUTPUT_VARIABLE _git_unpushed_log + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT _git_unpushed_log STREQUAL "") + set(MY_WC_BRANCH "${MY_WC_BRANCH} (modified)") + endif() + unset(_git_unpushed_log) endif() unset(_git_changed_files) - unset(_git_latest_version_tag) endif() endif() diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index e750ce09aff..894c8dbca25 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -421,6 +421,22 @@ def buildinfo(lenv, build_type): else: build_hash = os.popen('git rev-parse --short HEAD').read().strip() build_branch = os.popen('git rev-parse --abbrev-ref HEAD').read().strip() + + # ## Check for local modifications + has_local_changes = False + + # Update GIT index before getting dirty files + os.system('git update-index -q --refresh') + changed_files = os.popen('git diff-index --name-only HEAD --').read().strip() + + if changed_files: + has_local_changes = True + else: + unpushed_log = os.popen('git log @{u}..').read().strip() + has_local_changes = unpushed_log != '' + + if has_local_changes: + build_branch += ' (modified)' else: build_hash = 'unknown' build_commit_timestamp = '0' -- cgit v1.2.3 From 780459e40646e99b555fee7062ace7386dc845fd Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 19 Nov 2013 22:25:08 +0600 Subject: Extra unwanted change from the previous commit --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d96c41bf79e..d3a4d65e0ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,3 @@ - # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or -- cgit v1.2.3 From 1ea47c9af9bf707d7ddb36c88425636ac35e0fc8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Nov 2013 03:38:18 +1100 Subject: Code Cleanup: style, spelling and pep8 edits --- release/scripts/modules/addon_utils.py | 1 + release/scripts/modules/bpy/path.py | 2 +- release/scripts/modules/rna_info.py | 1 + release/scripts/startup/bl_operators/anim.py | 1 - release/scripts/startup/bl_operators/view3d.py | 1 - release/scripts/startup/bl_ui/properties_data_curve.py | 2 +- release/scripts/startup/bl_ui/properties_data_mesh.py | 4 ++-- release/scripts/startup/bl_ui/properties_particle.py | 12 ++++++------ release/scripts/startup/bl_ui/space_image.py | 2 +- release/scripts/startup/bl_ui/space_info.py | 1 - release/scripts/startup/bl_ui/space_node.py | 2 +- release/scripts/startup/bl_ui/space_time.py | 4 ++-- release/scripts/startup/bl_ui/space_view3d.py | 5 +++-- release/scripts/startup/bl_ui/space_view3d_toolbar.py | 8 ++++---- source/blender/blenkernel/BKE_customdata.h | 4 ++-- source/blender/blenkernel/intern/bmfont.c | 2 +- source/blender/editors/interface/interface.c | 3 ++- source/blender/editors/space_view3d/view3d_fly.c | 2 +- source/blender/modifiers/intern/MOD_mask.c | 2 +- 19 files changed, 30 insertions(+), 29 deletions(-) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 6f08f70458b..e76bcc02751 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -35,6 +35,7 @@ error_duplicates = False error_encoding = False addons_fake_modules = {} + def paths(): # RELEASE SCRIPTS: official scripts distributed in Blender releases addon_paths = _bpy.utils.script_paths("addons") diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index da1a52e560d..ccc9df93b0d 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -321,7 +321,7 @@ def reduce_dirs(dirs): """ dirs = list({_os.path.normpath(_os.path.abspath(d)) for d in dirs}) dirs.sort(key=lambda d: len(d)) - for i in range(len(dirs) -1, -1, -1): + for i in range(len(dirs) - 1, -1, -1): for j in range(i): print(i, j) if len(dirs[i]) == len(dirs[j]): diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py index 60b11884e30..3643ad89ea6 100644 --- a/release/scripts/modules/rna_info.py +++ b/release/scripts/modules/rna_info.py @@ -98,6 +98,7 @@ class InfoStructRNA: ) global_lookup = {} + def __init__(self, rna_type): self.bl_rna = rna_type diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index 3c4b66514de..41f39b90464 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -281,4 +281,3 @@ class ClearUselessActions(Operator): self.report({'INFO'}, "Removed %d empty and/or fake-user only Actions" % removed) return {'FINISHED'} - diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py index bf51dc5672a..2ec095d2e7b 100644 --- a/release/scripts/startup/bl_operators/view3d.py +++ b/release/scripts/startup/bl_operators/view3d.py @@ -111,7 +111,6 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator): return self.execute(context) - class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator): "Extrude and move along individual normals" bl_label = "Extrude and Move on Individual Normals" diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index 5269d151bdc..2171ce67fd3 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -306,7 +306,7 @@ class DATA_PT_font(CurveButtonsPanel, Panel): row.template_ID(text, "font_bold_italic", open="font.open", unlink="font.unlink") #layout.prop(text, "font") - + row = layout.split(percentage=0.25) row.label(text="Body Text:") row.prop(text, "body", text="") diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index e8d0bec6524..f59d479c509 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -339,7 +339,7 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel): col = row.column(align=True) col.operator("mesh.uv_texture_add", icon='ZOOMIN', text="") col.operator("mesh.uv_texture_remove", icon='ZOOMOUT', text="") - + if lay: layout.prop(lay, "name") @@ -362,7 +362,7 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel): col = row.column(align=True) col.operator("mesh.vertex_color_add", icon='ZOOMIN', text="") col.operator("mesh.vertex_color_remove", icon='ZOOMOUT', text="") - + if lay: layout.prop(lay, "name") diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 4d5d3e6936a..f8a37e2768f 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -1218,27 +1218,27 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel): row = col.row(align=True) row.prop_search(psys, "vertex_group_density", ob, "vertex_groups", text="Density") row.prop(psys, "invert_vertex_group_density", text="", toggle=True, icon='ARROW_LEFTRIGHT') - + row = col.row(align=True) row.prop_search(psys, "vertex_group_length", ob, "vertex_groups", text="Length") row.prop(psys, "invert_vertex_group_length", text="", toggle=True, icon='ARROW_LEFTRIGHT') - + row = col.row(align=True) row.prop_search(psys, "vertex_group_clump", ob, "vertex_groups", text="Clump") row.prop(psys, "invert_vertex_group_clump", text="", toggle=True, icon='ARROW_LEFTRIGHT') - + row = col.row(align=True) row.prop_search(psys, "vertex_group_kink", ob, "vertex_groups", text="Kink") row.prop(psys, "invert_vertex_group_kink", text="", toggle=True, icon='ARROW_LEFTRIGHT') - + row = col.row(align=True) row.prop_search(psys, "vertex_group_roughness_1", ob, "vertex_groups", text="Roughness 1") row.prop(psys, "invert_vertex_group_roughness_1", text="", toggle=True, icon='ARROW_LEFTRIGHT') - + row = col.row(align=True) row.prop_search(psys, "vertex_group_roughness_2", ob, "vertex_groups", text="Roughness 2") row.prop(psys, "invert_vertex_group_roughness_2", text="", toggle=True, icon='ARROW_LEFTRIGHT') - + row = col.row(align=True) row.prop_search(psys, "vertex_group_roughness_end", ob, "vertex_groups", text="Roughness End") row.prop(psys, "invert_vertex_group_roughness_end", text="", toggle=True, icon='ARROW_LEFTRIGHT') diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index cc2d1dc1e66..397b74116c2 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -727,7 +727,7 @@ class IMAGE_PT_tools_brush_overlay(BrushButtonsPanel, Panel): tex_slot_mask = brush.mask_texture_slot col = layout.column() - + col.label(text="Curve:") row = col.row(align=True) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 52592594748..a7a648e3c44 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -169,7 +169,6 @@ class INFO_MT_file_external_data(Menu): layout.operator("file.find_missing_files") - class INFO_MT_game(Menu): bl_label = "Game" diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 8d577bb22c5..46234b638eb 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -364,7 +364,7 @@ class NODE_PT_backdrop(Panel): col.prop(snode, "backdrop_x", text="X") col.prop(snode, "backdrop_y", text="Y") col.operator("node.backimage_move", text="Move") - + layout.operator("node.backimage_fit", text="Fit") diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py index 700d1004718..4cb67181fdb 100644 --- a/release/scripts/startup/bl_ui/space_time.py +++ b/release/scripts/startup/bl_ui/space_time.py @@ -228,9 +228,9 @@ def marker_menu_generic(layout): layout.operator("marker.rename", text="Rename Marker") layout.operator("marker.move", text="Grab/Move Marker") - + layout.separator() - + layout.operator("screen.marker_jump", text="Jump to Next Marker").next = True layout.operator("screen.marker_jump", text="Jump to Previous Marker").next = False diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index ec9c7ae9ffc..c49fa6768fe 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -833,6 +833,7 @@ class VIEW3D_MT_select_paint_mask_vertex(Menu): # XXX: INFO_MT_ names used to keep backwards compatibility (Addons etc that hook into the menu) + class INFO_MT_mesh_add(Menu): bl_idname = "INFO_MT_mesh_add" bl_label = "Mesh" @@ -1597,7 +1598,7 @@ class VIEW3D_MT_hide_mask(Menu): props = layout.operator("paint.mask_flood_fill", text="Clear Mask") props.mode = 'VALUE' props.value = 0 - + props = layout.operator("view3d.select_border", text="Box Mask") props = layout.operator("paint.mask_lasso_gesture", text="Lasso Mask") @@ -2799,7 +2800,7 @@ class VIEW3D_PT_view3d_shading(Panel): if not scene.render.use_shading_nodes: col.prop(gs, "material_mode", text="") col.prop(view, "show_textured_solid") - + if view.viewport_shade == 'SOLID': col.prop(view, "use_matcap") if view.use_matcap: diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 8c86cc6c8a5..cd3c238fe86 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -740,6 +740,7 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): col.prop(brush, "vertex_tool", text="Blend") + class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel): bl_label = "Overlay" bl_options = {'DEFAULT_CLOSED'} @@ -753,8 +754,7 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel): context.vertex_paint_object or context.weight_paint_object or context.image_paint_object)) - - + def draw(self, context): layout = self.layout @@ -764,7 +764,7 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel): tex_slot_mask = brush.mask_texture_slot col = layout.column() - + col.label(text="Curve:") row = col.row(align=True) @@ -778,7 +778,7 @@ class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel): sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA') col.active = brush.brush_capabilities.has_overlay - + if context.image_paint_object or context.sculpt_object or context.vertex_paint_object: col.label(text="Texture:") row = col.row(align=True) diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 5a283922707..f28d16427cf 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -147,14 +147,14 @@ void *CustomData_add_layer_named(struct CustomData *data, int type, int alloctyp void *layer, int totelem, const char *name); /* frees the active or first data layer with the give type. - * returns 1 on succes, 0 if no layer with the given type is found + * returns 1 on success, 0 if no layer with the given type is found * * in editmode, use EDBM_data_layer_free instead of this function */ bool CustomData_free_layer(struct CustomData *data, int type, int totelem, int index); /* frees the layer index with the give type. - * returns 1 on succes, 0 if no layer with the given type is found + * returns 1 on success, 0 if no layer with the given type is found * * in editmode, use EDBM_data_layer_free instead of this function */ diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index 2d7249b54f5..732c0c35feb 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -204,7 +204,7 @@ void detectBitmapFont(ImBuf *ibuf) printf("detectBitmapFont :Unsupported version %d\n", (int)version); } - /* on succes ibuf->userdata points to the bitmapfont */ + /* on success ibuf->userdata points to the bitmapfont */ if (ibuf->userdata) { break; } diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 6ee097b066f..83b100db1b2 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3242,7 +3242,8 @@ int autocomplete_end(AutoComplete *autocpl, char *autoname) if (autocpl->truncate[0]) { if (autocpl->matches == 1) { match = AUTOCOMPLETE_FULL_MATCH; - } else { + } + else { match = AUTOCOMPLETE_PARTIAL_MATCH; } BLI_strncpy(autoname, autocpl->truncate, autocpl->maxlen); diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 6d04b9b8826..373e57d5708 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -218,7 +218,7 @@ typedef struct FlyInfo { short persp_backup; /* remember if were ortho or not, only used for restoring the view if it was a ortho view */ /* are we flying an ortho camera in perspective view, - * which was originall in ortho view? + * which was originally in ortho view? * could probably figure it out but better be explicit */ bool is_ortho_cam; void *obtfm; /* backup the objects transform */ diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 2822cf6925b..839e30d9c1a 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -172,7 +172,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* if no dverts (i.e. no data for vertex groups exists), we've got an - * inconsistent situation, so free hashes and return oirginal mesh + * inconsistent situation, so free hashes and return original mesh */ dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); if (dvert == NULL) { -- cgit v1.2.3 From fb91a602c756f3ee5a122efa1862b8be7604186b Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 19 Nov 2013 20:30:49 +0100 Subject: Blender Internal: * Remove "Edge" post processing effect and the corresponding render layer. Since we have freestyle, this is not needed anymore and was a very simple effect anyway (Zbuffer filter effect, could be added to the compositor if really needed again). Reviewed By: brecht, ton Differential Revision: http://developer.blender.org/D14 --- release/scripts/startup/bl_ui/properties_render.py | 7 -- .../startup/bl_ui/properties_render_layer.py | 1 - source/blender/blenkernel/intern/scene.c | 1 - source/blender/makesdna/DNA_scene_types.h | 6 +- source/blender/makesrna/intern/rna_scene.c | 23 ---- source/blender/render/intern/source/initrender.c | 2 +- source/blender/render/intern/source/pipeline.c | 7 -- source/blender/render/intern/source/rendercore.c | 130 +-------------------- 8 files changed, 9 insertions(+), 168 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 5061e534c9b..5e54287ac33 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -319,13 +319,6 @@ class RENDER_PT_post_processing(RenderButtonsPanel, Panel): sub.row().prop(rd, "field_order", expand=True) sub.prop(rd, "use_fields_still", text="Still") - col = split.column() - col.prop(rd, "use_edge_enhance") - sub = col.column() - sub.active = rd.use_edge_enhance - sub.prop(rd, "edge_threshold", text="Threshold", slider=True) - sub.prop(rd, "edge_color", text="") - class RENDER_PT_stamp(RenderButtonsPanel, Panel): bl_label = "Stamp" diff --git a/release/scripts/startup/bl_ui/properties_render_layer.py b/release/scripts/startup/bl_ui/properties_render_layer.py index 66479b11a2b..dcc4508f086 100644 --- a/release/scripts/startup/bl_ui/properties_render_layer.py +++ b/release/scripts/startup/bl_ui/properties_render_layer.py @@ -113,7 +113,6 @@ class RENDERLAYER_PT_layer_options(RenderLayerButtonsPanel, Panel): col = split.column() col.prop(rl, "use_sky") - col.prop(rl, "use_edge_enhance") col.prop(rl, "use_strand") if bpy.app.build_options.freestyle: row = col.row() diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 05e1ec82392..985eae18570 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -444,7 +444,6 @@ Scene *BKE_scene_add(Main *bmain, const char *name) sce->r.blurfac = 0.5; sce->r.frs_sec = 24; sce->r.frs_sec_base = 1; - sce->r.edgeint = 10; sce->r.ocres = 128; /* OCIO_TODO: for forwards compatibility only, so if no tonecurve are used, diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index ca328423072..7aabad86809 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -196,7 +196,7 @@ typedef struct SceneRenderLayer { #define SCE_LAY_SOLID 1 #define SCE_LAY_ZTRA 2 #define SCE_LAY_HALO 4 -#define SCE_LAY_EDGE 8 +#define SCE_LAY_EDGE 8 /* deprecated */ #define SCE_LAY_SKY 16 #define SCE_LAY_STRAND 32 #define SCE_LAY_FRS 64 @@ -378,7 +378,7 @@ typedef struct RenderData { float framelen, blurfac; /** For UR edge rendering: give the edges this color */ - float edgeR, edgeG, edgeB; + float edgeR DNA_DEPRECATED, edgeG DNA_DEPRECATED, edgeB DNA_DEPRECATED; /* standalone player */ // XXX deprecated since 2.5 @@ -1220,7 +1220,7 @@ typedef struct Scene { #define R_GAMMA 0x0004 #define R_ORTHO 0x0008 #define R_ENVMAP 0x0010 -#define R_EDGE 0x0020 +#define R_EDGE 0x0020 /* deprecated */ #define R_FIELDS 0x0040 #define R_FIELDSTILL 0x0080 /*#define R_RADIO 0x0100 */ /* deprecated */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 4d8592e7d7a..686672e1629 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2323,12 +2323,6 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "use_edge_enhance", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_EDGE); - RNA_def_property_ui_text(prop, "Edge", "Render Edge-enhance in this Layer (only works for Solid faces)"); - if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - else RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "use_strand", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_STRAND); RNA_def_property_ui_text(prop, "Strand", "Render Strands in this Layer"); @@ -4372,23 +4366,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Textures", "Use textures to affect material properties"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_edge_enhance", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE); - RNA_def_property_ui_text(prop, "Edge", "Create a toon outline around the edges of geometry"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - prop = RNA_def_property(srna, "edge_threshold", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "edgeint"); - RNA_def_property_range(prop, 0, 255); - RNA_def_property_ui_text(prop, "Edge Threshold", "Threshold for drawing outlines on geometry edges"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - - prop = RNA_def_property(srna, "edge_color", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "edgeR"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Edge Color", "Edge color"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE_FRS); RNA_def_property_ui_text(prop, "Edge", "Draw stylized strokes using Freestyle"); diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 2fb723faa12..28932d0e93b 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -608,7 +608,7 @@ void RE_parts_init(Render *re, int do_crop) RenderPart *pa = MEM_callocN(sizeof(RenderPart), "new part"); /* Non-box filters need 2 pixels extra to work */ - if (do_crop && (re->r.filtertype || (re->r.mode & R_EDGE))) { + if (do_crop && re->r.filtertype) { pa->crop = 2; disprect.xmin -= pa->crop; disprect.ymin -= pa->crop; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 8128dd25fdc..d11f4615698 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2293,13 +2293,6 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r BKE_report(reports, RPT_ERROR, "Cannot save render buffers, check the temp default path"); return 0; } - - /* no fullsample and edge */ - if ((scemode & R_FULL_SAMPLE) && (scene->r.mode & R_EDGE)) { - BKE_report(reports, RPT_ERROR, "Full sample does not support edge enhance"); - return 0; - } - } if (scemode & R_DOCOMP) { diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 89d8345a0d7..8791af55792 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -967,25 +967,6 @@ static void addps(ListBase *lb, intptr_t *rd, int obi, int facenr, int z, int ma ps->shadfac= 0; } -static void edge_enhance_add(RenderPart *pa, float *rectf, float *arect) -{ - float addcol[4]; - int pix; - - if (arect==NULL) - return; - - for (pix= pa->rectx*pa->recty; pix>0; pix--, arect++, rectf+=4) { - if (*arect != 0.0f) { - addcol[0]= *arect * R.r.edgeR; - addcol[1]= *arect * R.r.edgeG; - addcol[2]= *arect * R.r.edgeB; - addcol[3]= *arect; - addAlphaOverFloat(rectf, addcol); - } - } -} - /* clamp alpha and RGB to 0..1 and 0..inf, can go outside due to filter */ static void clamp_alpha_rgb_range(RenderPart *pa, RenderLayer *rl) { @@ -1010,67 +991,6 @@ static void clamp_alpha_rgb_range(RenderPart *pa, RenderLayer *rl) } } -/* adds only alpha values */ -static void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz) -{ - /* use zbuffer to define edges, add it to the image */ - int y, x, col, *rz, *rz1, *rz2, *rz3; - int zval1, zval2, zval3; - float *rf; - - /* shift values in zbuffer 4 to the right (anti overflows), for filter we need multiplying with 12 max */ - rz= rectz; - if (rz==NULL) return; - - for (y=0; yrecty; y++) - for (x=0; xrectx; x++, rz++) (*rz)>>= 4; - - rz1= rectz; - rz2= rz1+pa->rectx; - rz3= rz2+pa->rectx; - - rf= rectf+pa->rectx+1; - - for (y=0; yrecty-2; y++) { - for (x=0; xrectx-2; x++, rz1++, rz2++, rz3++, rf++) { - - /* prevent overflow with sky z values */ - zval1= rz1[0] + 2*rz1[1] + rz1[2]; - zval2= 2*rz2[0] + 2*rz2[2]; - zval3= rz3[0] + 2*rz3[1] + rz3[2]; - - col= ( 4*rz2[1] - (zval1 + zval2 + zval3)/3 ); - if (col<0) col= -col; - - col >>= 5; - if (col > (1<<16)) col= (1<<16); - else col= (R.r.edgeint*col)>>8; - - if (col>0) { - float fcol; - - if (col>255) fcol= 1.0f; - else fcol= (float)col/255.0f; - - if (R.osa) - *rf+= fcol/(float)R.osa; - else - *rf= fcol; - } - } - rz1+= 2; - rz2+= 2; - rz3+= 2; - rf+= 2; - } - - /* shift back zbuf values, we might need it still */ - rz= rectz; - for (y=0; yrecty; y++) - for (x=0; xrectx; x++, rz++) (*rz)<<= 4; - -} - static void reset_sky_speed(RenderPart *pa, RenderLayer *rl) { /* for all pixels with max speed, set to zero */ @@ -1149,7 +1069,6 @@ static void addAlphaOverFloatMask(float *dest, float *source, unsigned short dma typedef struct ZbufSolidData { RenderLayer *rl; ListBase *psmlist; - float *edgerect; } ZbufSolidData; static void make_pixelstructs(RenderPart *pa, ZSpan *zspan, int sample, void *data) @@ -1171,10 +1090,6 @@ static void make_pixelstructs(RenderPart *pa, ZSpan *zspan, int sample, void *da } } } - - if (sdata->rl->layflag & SCE_LAY_EDGE) - if (R.r.mode & R_EDGE) - edge_enhance_tile(pa, sdata->edgerect, zspan->rectz); } /* main call for shading Delta Accum, for OSA */ @@ -1184,7 +1099,6 @@ void zbufshadeDA_tile(RenderPart *pa) RenderResult *rr= pa->result; RenderLayer *rl; ListBase psmlist= {NULL, NULL}; - float *edgerect= NULL; /* allocate the necessary buffers */ /* zbuffer inits these rects */ @@ -1195,21 +1109,16 @@ void zbufshadeDA_tile(RenderPart *pa) if ((rl->layflag & SCE_LAY_ZMASK) && (rl->layflag & SCE_LAY_NEG_ZMASK)) pa->rectmask= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectmask"); - /* initialize pixelstructs and edge buffer */ + /* initialize pixelstructs */ addpsmain(&psmlist); pa->rectdaps= MEM_callocN(sizeof(intptr_t)*pa->rectx*pa->recty+4, "zbufDArectd"); - if (rl->layflag & SCE_LAY_EDGE) - if (R.r.mode & R_EDGE) - edgerect= MEM_callocN(sizeof(float)*pa->rectx*pa->recty, "rectedge"); - /* always fill visibility */ for (pa->sample=0; pa->samplesample+=4) { ZbufSolidData sdata; sdata.rl= rl; sdata.psmlist= &psmlist; - sdata.edgerect= edgerect; zbuffer_solid(pa, rl, make_pixelstructs, &sdata); if (R.test_break(R.tbh)) break; } @@ -1276,18 +1185,12 @@ void zbufshadeDA_tile(RenderPart *pa) } /* sun/sky */ - if (rl->layflag & SCE_LAY_SKY) + if (rl->layflag & SCE_LAY_SKY) { atm_tile(pa, rl); - - /* sky before edge */ - if (rl->layflag & SCE_LAY_SKY) sky_tile(pa, rl); + } - /* extra layers */ - if (rl->layflag & SCE_LAY_EDGE) - if (R.r.mode & R_EDGE) - edge_enhance_add(pa, rl->rectf, edgerect); - + /* extra layers */ if (rl->passflag & SCE_PASS_VECTOR) reset_sky_speed(pa, rl); @@ -1297,9 +1200,6 @@ void zbufshadeDA_tile(RenderPart *pa) /* free stuff within loop! */ MEM_freeN(pa->rectdaps); pa->rectdaps= NULL; freeps(&psmlist); - - if (edgerect) MEM_freeN(edgerect); - edgerect= NULL; if (pa->rectmask) { MEM_freeN(pa->rectmask); @@ -1328,7 +1228,6 @@ void zbufshade_tile(RenderPart *pa) RenderResult *rr= pa->result; RenderLayer *rl; PixStr ps; - float *edgerect= NULL; /* fake pixel struct, to comply to osa render */ ps.next= NULL; @@ -1350,14 +1249,6 @@ void zbufshade_tile(RenderPart *pa) if (!R.test_break(R.tbh)) { /* NOTE: this if () is not consistent */ - /* edges only for solid part, ztransp doesn't support it yet anti-aliased */ - if (rl->layflag & SCE_LAY_EDGE) { - if (R.r.mode & R_EDGE) { - edgerect= MEM_callocN(sizeof(float)*pa->rectx*pa->recty, "rectedge"); - edge_enhance_tile(pa, edgerect, pa->rectz); - } - } - /* initialize scanline updates for main thread */ rr->renrect.ymin = 0; rr->renlay= rl; @@ -1438,24 +1329,13 @@ void zbufshade_tile(RenderPart *pa) } /* sun/sky */ - if (rl->layflag & SCE_LAY_SKY) + if (rl->layflag & SCE_LAY_SKY) { atm_tile(pa, rl); - - /* sky before edge */ - if (rl->layflag & SCE_LAY_SKY) sky_tile(pa, rl); - - if (!R.test_break(R.tbh)) { - if (rl->layflag & SCE_LAY_EDGE) - if (R.r.mode & R_EDGE) - edge_enhance_add(pa, rl->rectf, edgerect); } if (rl->passflag & SCE_PASS_VECTOR) reset_sky_speed(pa, rl); - - if (edgerect) MEM_freeN(edgerect); - edgerect= NULL; if (pa->rectmask) { MEM_freeN(pa->rectmask); -- cgit v1.2.3 From 5edf6fc19d3e288e8f0d7227be6da5897d6c8bda Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 20 Nov 2013 02:36:03 +0600 Subject: Fix for addons submodule which was pointing to a not existing revision Pretty much likely happened because of arc utility included this changes by accident and there were local commits in a local tree. Not sure about how to prevent this from happening yet, just be careful for now. --- release/scripts/addons | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/addons b/release/scripts/addons index 2c7464fb951..120612c8bd7 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 2c7464fb9510bedc6a19c43064ae83ed15f3f7c7 +Subproject commit 120612c8bd74040dd624f25e359f30a257d180e6 -- cgit v1.2.3 From 447d2774989cd2df249e1d48cf44ef7e1a109a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20M=C3=BCller?= Date: Wed, 20 Nov 2013 00:20:51 +0100 Subject: Fix IRC reported by elubie: windows crash with audio animation There was a bug in how the iterators of STL list was used when erasing during iteration of a list, which was triggered by the STL implementation of MSVC, but hid well with gcc. --- intern/audaspace/intern/AUD_AnimateableProperty.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/intern/audaspace/intern/AUD_AnimateableProperty.cpp b/intern/audaspace/intern/AUD_AnimateableProperty.cpp index 6d1a307d868..61adae4b34b 100644 --- a/intern/audaspace/intern/AUD_AnimateableProperty.cpp +++ b/intern/audaspace/intern/AUD_AnimateableProperty.cpp @@ -112,8 +112,12 @@ void AUD_AnimateableProperty::write(const float* data, int position, int count) // otherwise it's not at the end, let's check if some unknown part got filled else { - for(std::list::iterator it = m_unknown.begin(); it != m_unknown.end(); it++) + bool erased = false; + + for(std::list::iterator it = m_unknown.begin(); it != m_unknown.end(); erased ? it : it++) { + erased = false; + // unknown area before position if(it->end < position) continue; @@ -130,9 +134,8 @@ void AUD_AnimateableProperty::write(const float* data, int position, int count) if(position + count > it->end) { // simply delete - std::list::iterator it2 = it; - it++; - m_unknown.erase(it2); + it = m_unknown.erase(it); + erased = true; } // the end is excluded, a second part remains else -- cgit v1.2.3 From 02114a673787257dc93d151b8ea61844df9098e6 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Wed, 20 Nov 2013 00:38:51 +0100 Subject: OSX/Cmake: workaround for missing OpenGL headers, make sure sdk lookup --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3a4d65e0ce..5781558a61b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -378,7 +378,11 @@ if(APPLE) set(CMAKE_XCODE_ATTRIBUTE_SDKROOT macosx${OSX_SYSTEM}) # to silence sdk not found warning, just overrides CMAKE_OSX_SYSROOT endif() endif() - + + if(OSX_SYSTEM MATCHES 10.9) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT}) # make sure syslibs and headers are looked up in sdk ( expecially for 10.9 openGL atm. ) + endif() + if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING "" FORCE) # 10.6 is our min. target, if you use higher sdk, weak linking happens endif() -- cgit v1.2.3 From 4c017090185f90f62eccd12c9f892964a4ffe93a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Nov 2013 11:46:22 +1100 Subject: Math Library: add dot_m4_v3_row_x/y/z --- source/blender/blenlib/BLI_math_vector.h | 3 +++ source/blender/blenlib/intern/math_vector_inline.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 5a23e879b1a..3ff81e478c9 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -120,6 +120,9 @@ MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3]) ATTR_WA MINLINE float dot_m3_v3_row_x(float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT; MINLINE float dot_m3_v3_row_y(float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT; MINLINE float dot_m3_v3_row_z(float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT; +MINLINE float dot_m4_v3_row_x(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT; +MINLINE float dot_m4_v3_row_y(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT; +MINLINE float dot_m4_v3_row_z(float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT; MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f); MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]); diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 0ce5855b16a..ace8e6b48c1 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -450,6 +450,22 @@ MINLINE float dot_m3_v3_row_z(float M[3][3], const float a[3]) return M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2]; } +/** + * Almost like mul_m4_v3(), misses adding translation. + */ +MINLINE float dot_m4_v3_row_x(float M[4][4], const float a[3]) +{ + return M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2]; +} +MINLINE float dot_m4_v3_row_y(float M[4][4], const float a[3]) +{ + return M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2]; +} +MINLINE float dot_m4_v3_row_z(float M[4][4], const float a[3]) +{ + return M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2]; +} + MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f) { r[0] += a[0] * f; -- cgit v1.2.3 From 067d52cd48b879936d12938b1c7edcd0ae7d81ff Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Nov 2013 12:14:10 +1100 Subject: Transform: rename Warp to Bend --- release/scripts/addons | 2 +- release/scripts/presets/keyconfig/3dsmax.py | 2 +- release/scripts/startup/bl_ui/space_view3d.py | 2 +- source/blender/editors/include/ED_transform.h | 2 +- source/blender/editors/transform/transform.c | 38 +++++++++++----------- .../blender/editors/transform/transform_generics.c | 4 +-- source/blender/editors/transform/transform_ops.c | 19 +++++------ 7 files changed, 34 insertions(+), 35 deletions(-) diff --git a/release/scripts/addons b/release/scripts/addons index 120612c8bd7..48bdb7b52fe 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 120612c8bd74040dd624f25e359f30a257d180e6 +Subproject commit 48bdb7b52fe827cbc21d50cce3079223243414bd diff --git a/release/scripts/presets/keyconfig/3dsmax.py b/release/scripts/presets/keyconfig/3dsmax.py index e18624461a2..f484ecd44b5 100644 --- a/release/scripts/presets/keyconfig/3dsmax.py +++ b/release/scripts/presets/keyconfig/3dsmax.py @@ -687,7 +687,7 @@ kmi = km.keymap_items.new('transform.translate', 'W', 'PRESS', shift=True) kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') kmi = km.keymap_items.new('transform.rotate', 'E', 'PRESS', shift=True) kmi = km.keymap_items.new('transform.resize', 'R', 'PRESS', shift=True) -kmi = km.keymap_items.new('transform.warp', 'Q', 'PRESS', shift=True) +kmi = km.keymap_items.new('transform.bend', 'Q', 'PRESS', shift=True) kmi = km.keymap_items.new('transform.tosphere', 'S', 'PRESS', shift=True, alt=True) kmi = km.keymap_items.new('transform.shear', 'S', 'PRESS', shift=True, ctrl=True, alt=True) kmi = km.keymap_items.new('transform.select_orientation', 'SPACE', 'PRESS', alt=True) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index c49fa6768fe..4c316c94269 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -179,7 +179,7 @@ class VIEW3D_MT_transform_base(Menu): layout.operator("transform.tosphere", text="To Sphere") layout.operator("transform.shear", text="Shear") - layout.operator("transform.warp", text="Warp") + layout.operator("transform.bend", text="Bend") layout.operator("transform.push_pull", text="Push/Pull") diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 8ad78630dc7..dde1aa30a26 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -62,7 +62,7 @@ enum TfmMode { TFM_SKIN_RESIZE, TFM_TOSPHERE, TFM_SHEAR, - TFM_WARP, + TFM_BEND, TFM_SHRINKFATTEN, TFM_TILT, TFM_TRACKBALL, diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ea5c86b5966..2756685e9f6 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -111,9 +111,9 @@ static void postInputRotation(TransInfo *t, float values[3]); /* Transform Callbacks */ -static void initWarp(TransInfo *t); -static eRedrawFlag handleEventWarp(TransInfo *t, const struct wmEvent *event); -static void Warp(TransInfo *t, const int mval[2]); +static void initBend(TransInfo *t); +static eRedrawFlag handleEventBend(TransInfo *t, const struct wmEvent *event); +static void Bend(TransInfo *t, const int mval[2]); static void initShear(TransInfo *t); static eRedrawFlag handleEventShear(TransInfo *t, const struct wmEvent *event); @@ -2069,8 +2069,8 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even case TFM_SHEAR: initShear(t); break; - case TFM_WARP: - initWarp(t); + case TFM_BEND: + initBend(t); break; case TFM_SHRINKFATTEN: initShrinkFatten(t); @@ -2672,12 +2672,12 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* -------------------------------------------------------------------- */ -/* Transform (Warp) */ +/* Transform (Bend) */ -/** \name Transform Warp +/** \name Transform Bend * \{ */ -struct WarpCustomData { +struct BendCustomData { float warp_sta[3]; float warp_end[3]; @@ -2688,16 +2688,16 @@ struct WarpCustomData { float warp_init_dist; }; -static void initWarp(TransInfo *t) +static void initBend(TransInfo *t) { const float mval_fl[2] = {UNPACK2(t->mval)}; const float *curs; float tvec[3]; - struct WarpCustomData *data; + struct BendCustomData *data; - t->mode = TFM_WARP; - t->transform = Warp; - t->handleEvent = handleEventWarp; + t->mode = TFM_BEND; + t->transform = Bend; + t->handleEvent = handleEventBend; setInputPostFct(&t->mouse, postInputRotation); initMouseInputMode(t, &t->mouse, INPUT_ANGLE_SPRING); @@ -2740,7 +2740,7 @@ static void initWarp(TransInfo *t) t->customData = data; } -static eRedrawFlag handleEventWarp(TransInfo *UNUSED(t), const wmEvent *event) +static eRedrawFlag handleEventBend(TransInfo *UNUSED(t), const wmEvent *event) { eRedrawFlag status = TREDRAW_NOTHING; @@ -2751,7 +2751,7 @@ static eRedrawFlag handleEventWarp(TransInfo *UNUSED(t), const wmEvent *event) return status; } -static void Warp(TransInfo *t, const int UNUSED(mval[2])) +static void Bend(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float vec[3]; @@ -2759,7 +2759,7 @@ static void Warp(TransInfo *t, const int UNUSED(mval[2])) float warp_end_radius[3]; int i; char str[MAX_INFO_LEN]; - const struct WarpCustomData *data = t->customData; + const struct BendCustomData *data = t->customData; const bool is_clamp = (t->flag & T_ALT_TRANSFORM) == 0; union { @@ -2767,7 +2767,7 @@ static void Warp(TransInfo *t, const int UNUSED(mval[2])) float vector[2]; } values; - /* amount of radians for warp */ + /* amount of radians for bend */ copy_v2_v2(values.vector, t->values); #if 0 @@ -2792,7 +2792,7 @@ static void Warp(TransInfo *t, const int UNUSED(mval[2])) outputNumInput(&(t->num), c); - BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Warp Angle: %s Radius: %s Alt, Clamp %s"), + BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Bend Angle: %s Radius: %s Alt, Clamp %s"), &c[0], &c[NUM_STR_REP_LEN], WM_bool_as_string(is_clamp)); @@ -2801,7 +2801,7 @@ static void Warp(TransInfo *t, const int UNUSED(mval[2])) } else { /* default header print */ - BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Warp Angle: %.3f Radius: %.4f, Alt, Clamp %s"), + BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Bend Angle: %.3f Radius: %.4f, Alt, Clamp %s"), RAD2DEGF(values.angle), values.scale * data->warp_init_dist, WM_bool_as_string(is_clamp)); } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 422060c48e6..95b6067f2c4 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1137,8 +1137,8 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even if (v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN; t->around = v3d->around; - /* warp always uses the cursor */ - if (t->mode == TFM_WARP) { + /* bend always uses the cursor */ + if (t->mode == TFM_BEND) { t->around = V3D_CURSOR; } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 8f31e49bfe9..106024cd3e2 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -68,7 +68,7 @@ static char OP_TOSPHERE[] = "TRANSFORM_OT_tosphere"; static char OP_RESIZE[] = "TRANSFORM_OT_resize"; static char OP_SKIN_RESIZE[] = "TRANSFORM_OT_skin_resize"; static char OP_SHEAR[] = "TRANSFORM_OT_shear"; -static char OP_WARP[] = "TRANSFORM_OT_warp"; +static char OP_BEND[] = "TRANSFORM_OT_bend"; static char OP_SHRINK_FATTEN[] = "TRANSFORM_OT_shrink_fatten"; static char OP_PUSH_PULL[] = "TRANSFORM_OT_push_pull"; static char OP_TILT[] = "TRANSFORM_OT_tilt"; @@ -86,7 +86,7 @@ static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot); static void TRANSFORM_OT_resize(struct wmOperatorType *ot); static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot); static void TRANSFORM_OT_shear(struct wmOperatorType *ot); -static void TRANSFORM_OT_warp(struct wmOperatorType *ot); +static void TRANSFORM_OT_bend(struct wmOperatorType *ot); static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot); static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot); static void TRANSFORM_OT_tilt(struct wmOperatorType *ot); @@ -106,7 +106,7 @@ static TransformModeItem transform_modes[] = {OP_RESIZE, TFM_RESIZE, TRANSFORM_OT_resize}, {OP_SKIN_RESIZE, TFM_SKIN_RESIZE, TRANSFORM_OT_skin_resize}, {OP_SHEAR, TFM_SHEAR, TRANSFORM_OT_shear}, - {OP_WARP, TFM_WARP, TRANSFORM_OT_warp}, + {OP_BEND, TFM_BEND, TRANSFORM_OT_bend}, {OP_SHRINK_FATTEN, TFM_SHRINKFATTEN, TRANSFORM_OT_shrink_fatten}, {OP_PUSH_PULL, TFM_PUSHPULL, TRANSFORM_OT_push_pull}, {OP_TILT, TFM_TILT, TRANSFORM_OT_tilt}, @@ -130,7 +130,7 @@ EnumPropertyItem transform_mode_types[] = {TFM_SKIN_RESIZE, "SKIN_RESIZE", 0, "Skin Resize", ""}, {TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""}, {TFM_SHEAR, "SHEAR", 0, "Shear", ""}, - {TFM_WARP, "WARP", 0, "Warp", ""}, + {TFM_BEND, "BEND", 0, "Bend", ""}, {TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""}, {TFM_TILT, "TILT", 0, "Tilt", ""}, {TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""}, @@ -693,12 +693,12 @@ static void TRANSFORM_OT_tilt(struct wmOperatorType *ot) Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP); } -static void TRANSFORM_OT_warp(struct wmOperatorType *ot) +static void TRANSFORM_OT_bend(struct wmOperatorType *ot) { /* identifiers */ - ot->name = "Warp"; - ot->description = "Warp selected items around the cursor"; - ot->idname = OP_WARP; + ot->name = "Bend"; + ot->description = "Bend selected items between the 3D cursor and the mouse"; + ot->idname = OP_BEND; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* api callbacks */ @@ -711,7 +711,6 @@ static void TRANSFORM_OT_warp(struct wmOperatorType *ot) RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP); - // XXX Warp axis? } static void TRANSFORM_OT_shear(struct wmOperatorType *ot) @@ -982,7 +981,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, OP_WARP, WKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, OP_BEND, WKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, OP_TOSPHERE, SKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); -- cgit v1.2.3 From 1de23f6c0d52a09227a0dc8d5a01f3acd9973d63 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 20 Nov 2013 15:19:43 +0600 Subject: Tweaks and improvements to fundamental/homography estimation - A bit more reasonable name for the estimation option structure and estimation functions. - Get rid of unclear function and parameter tolerance, it wasn't clear at all in which units they are. Now we've got expected_average_symmetric_distance as an early output check and as soon as average symmetric error goes below this threshold refining finishes. This distance is measured in the same units as input points are. It is arguable whether we need callback for this or not, but seems Ceres doesn't have some kind of absolute threshold for function value and function_tolerance behaves different from logic behind expected symmetric error. - Added option to normalize correspondences before estimating the homography in order to increase estimation stability. See R. Hartley and A. Zisserman. Multiple View Geometry in Computer Vision. Cambridge University Press, second edition, 2003. https://www.cs.ubc.ca/grads/resources/thesis/May09/Dubrofsky_Elan.pdf --- extern/libmv/libmv-capi.cc | 4 +- extern/libmv/libmv/multiview/fundamental.cc | 75 +++++++++++--- extern/libmv/libmv/multiview/fundamental.h | 25 ++--- extern/libmv/libmv/multiview/homography.cc | 109 +++++++++++++++++---- extern/libmv/libmv/multiview/homography.h | 50 ++++++---- .../libmv/simple_pipeline/keyframe_selection.cc | 16 +-- 6 files changed, 206 insertions(+), 73 deletions(-) diff --git a/extern/libmv/libmv-capi.cc b/extern/libmv/libmv-capi.cc index f02ca0e98e0..95ac2ff703a 100644 --- a/extern/libmv/libmv-capi.cc +++ b/extern/libmv/libmv-capi.cc @@ -1089,8 +1089,8 @@ void libmv_homography2DFromCorrespondencesEuc(double (*x1)[2], double (*x2)[2], LG << "x1: " << x1_mat; LG << "x2: " << x2_mat; - libmv::HomographyEstimationOptions options; - libmv::Homography2DFromCorrespondencesEuc(x1_mat, x2_mat, options, &H_mat); + libmv::EstimateHomographyOptions options; + libmv::EstimateHomography2DFromCorrespondences(x1_mat, x2_mat, options, &H_mat); LG << "H: " << H_mat; diff --git a/extern/libmv/libmv/multiview/fundamental.cc b/extern/libmv/libmv/multiview/fundamental.cc index ec6c70d81cf..7a1433c3419 100644 --- a/extern/libmv/libmv/multiview/fundamental.cc +++ b/extern/libmv/libmv/multiview/fundamental.cc @@ -408,13 +408,16 @@ void FundamentalToEssential(const Mat3 &F, Mat3 *E) { *E = svd.matrixU() * diag.asDiagonal() * svd.matrixV().transpose(); } -FundamentalEstimationOptions::FundamentalEstimationOptions(void) : - use_refine_if_algebraic_fails(true), +// Default settings for fundamental estimation which should be suitable +// for a wide range of use cases. +EstimateFundamentalOptions::EstimateFundamentalOptions(void) : max_num_iterations(50), - parameter_tolerance(1e-16), - function_tolerance(1e-16) { + expected_average_symmetric_distance(1e-16) { } +namespace { +// Cost functor which computes symmetric epipolar distance +// used for fundamental matrix refinement. class FundamentalSymmetricEpipolarCostFunctor { public: FundamentalSymmetricEpipolarCostFunctor(const Vec2 &x, @@ -445,21 +448,60 @@ class FundamentalSymmetricEpipolarCostFunctor { const Mat y_; }; +// Termination checking callback used for fundamental estimation. +// It finished the minimization as soon as actual average of +// symmetric epipolar distance is less or equal to the expected +// average value. +class TerminationCheckingCallback : public ceres::IterationCallback { + public: + TerminationCheckingCallback(const Mat &x1, const Mat &x2, + const EstimateFundamentalOptions &options, + Mat3 *F) + : options_(options), x1_(x1), x2_(x2), F_(F) {} + + virtual ceres::CallbackReturnType operator()( + const ceres::IterationSummary& summary) { + // If the step wasn't successful, there's nothing to do. + if (!summary.step_is_successful) { + return ceres::SOLVER_CONTINUE; + } + + // Calculate average of symmetric epipolar distance. + double average_distance = 0.0; + for (int i = 0; i < x1_.cols(); i++) { + average_distance = SymmetricEpipolarDistance(*F_, + x1_.col(i), + x2_.col(i)); + } + average_distance /= x1_.cols(); + + if (average_distance <= options_.expected_average_symmetric_distance) { + return ceres::SOLVER_TERMINATE_SUCCESSFULLY; + } + + return ceres::SOLVER_CONTINUE; + } + + private: + const EstimateFundamentalOptions &options_; + const Mat &x1_; + const Mat &x2_; + Mat3 *F_; +}; +} // namespace + /* Fundamental transformation estimation. */ -bool FundamentalFromCorrespondencesEuc( +bool EstimateFundamentalFromCorrespondences( const Mat &x1, const Mat &x2, - const FundamentalEstimationOptions &options, + const EstimateFundamentalOptions &options, Mat3 *F) { // Step 1: Algebraic fundamental estimation. - bool algebraic_success = NormalizedEightPointSolver(x1, x2, F); - LG << "Algebraic result " << algebraic_success - << ", estimated matrix:\n" << *F; + // Assume algebraic estiation always succeeds, + NormalizedEightPointSolver(x1, x2, F); - if (!algebraic_success && !options.use_refine_if_algebraic_fails) { - return false; - } + LG << "Estimated matrix after algebraic estimation:\n" << *F; // Step 2: Refine matrix using Ceres minimizer. ceres::Problem problem; @@ -483,8 +525,10 @@ bool FundamentalFromCorrespondencesEuc( solver_options.linear_solver_type = ceres::DENSE_QR; solver_options.max_num_iterations = options.max_num_iterations; solver_options.update_state_every_iteration = true; - solver_options.parameter_tolerance = options.parameter_tolerance; - solver_options.function_tolerance = options.function_tolerance; + + // Terminate if the average symmetric distance is good enough. + TerminationCheckingCallback callback(x1, x2, options, F); + solver_options.callbacks.push_back(&callback); // Run the solve. ceres::Solver::Summary summary; @@ -495,7 +539,8 @@ bool FundamentalFromCorrespondencesEuc( LG << "Final refined matrix:\n" << *F; return !(summary.termination_type == ceres::DID_NOT_RUN || - summary.termination_type == ceres::NUMERICAL_FAILURE); + summary.termination_type == ceres::NUMERICAL_FAILURE || + summary.termination_type == ceres::USER_ABORT); } } // namespace libmv diff --git a/extern/libmv/libmv/multiview/fundamental.h b/extern/libmv/libmv/multiview/fundamental.h index 2961a46cdc4..51067aefc2b 100644 --- a/extern/libmv/libmv/multiview/fundamental.h +++ b/extern/libmv/libmv/multiview/fundamental.h @@ -151,21 +151,22 @@ void FundamentalToEssential(const Mat3 &F, Mat3 *E); * Defaults should be suitable for a wide range of use cases, but * better performance and accuracy might require tweaking/ */ -struct FundamentalEstimationOptions { +struct EstimateFundamentalOptions { // Default constructor which sets up a options for generic usage. - FundamentalEstimationOptions(void); - - // Refine fundamental matrix even if algebraic estimation reported failure. - bool use_refine_if_algebraic_fails; + EstimateFundamentalOptions(void); // Maximal number of iterations for refinement step. int max_num_iterations; - // Paramaneter tolerance used by minimizer termination criteria. - float parameter_tolerance; - - // Function tolerance used by minimizer termination criteria. - float function_tolerance; + // Expected average of symmetric epipolar distance between + // actual destination points and original ones transformed by + // estimated fundamental matrix. + // + // Refinement will finish as soon as average of symmetric + // epipolar distance is less or equal to this value. + // + // This distance is measured in the same units as input points are. + double expected_average_symmetric_distance; }; /** @@ -175,10 +176,10 @@ struct FundamentalEstimationOptions { * correspondences by doing algebraic estimation first followed with result * refinement. */ -bool FundamentalFromCorrespondencesEuc( +bool EstimateFundamentalFromCorrespondences( const Mat &x1, const Mat &x2, - const FundamentalEstimationOptions &options, + const EstimateFundamentalOptions &options, Mat3 *F); } // namespace libmv diff --git a/extern/libmv/libmv/multiview/homography.cc b/extern/libmv/libmv/multiview/homography.cc index 6041849d9fe..cbd3ec78a57 100644 --- a/extern/libmv/libmv/multiview/homography.cc +++ b/extern/libmv/libmv/multiview/homography.cc @@ -22,6 +22,7 @@ #include "ceres/ceres.h" #include "libmv/logging/logging.h" +#include "libmv/multiview/conditioning.h" #include "libmv/multiview/homography_parameterization.h" namespace libmv { @@ -155,14 +156,26 @@ bool Homography2DFromCorrespondencesLinear(const Mat &x1, } } -HomographyEstimationOptions::HomographyEstimationOptions(void) : - expected_algebraic_precision(EigenDouble::dummy_precision()), - use_refine_if_algebraic_fails(true), +// Default settings for homography estimation which should be suitable +// for a wide range of use cases. +EstimateHomographyOptions::EstimateHomographyOptions(void) : + use_normalization(true), max_num_iterations(50), - parameter_tolerance(1e-16), - function_tolerance(1e-16) { + expected_average_symmetric_distance(1e-16) { } +namespace { +void GetNormalizedPoints(const Mat &original_points, + Mat *normalized_points, + Mat3 *normalization_matrix) { + IsotropicPreconditionerFromPoints(original_points, normalization_matrix); + ApplyTransformationToPoints(original_points, + *normalization_matrix, + normalized_points); +} + +// Cost functor which computes symmetric geometric distance +// used for homography matrix refinement. class HomographySymmetricGeometricCostFunctor { public: HomographySymmetricGeometricCostFunctor(const Vec2 &x, @@ -200,13 +213,55 @@ class HomographySymmetricGeometricCostFunctor { const Vec2 y_; }; +// Termination checking callback used for homography estimation. +// It finished the minimization as soon as actual average of +// symmetric geometric distance is less or equal to the expected +// average value. +class TerminationCheckingCallback : public ceres::IterationCallback { + public: + TerminationCheckingCallback(const Mat &x1, const Mat &x2, + const EstimateHomographyOptions &options, + Mat3 *H) + : options_(options), x1_(x1), x2_(x2), H_(H) {} + + virtual ceres::CallbackReturnType operator()( + const ceres::IterationSummary& summary) { + // If the step wasn't successful, there's nothing to do. + if (!summary.step_is_successful) { + return ceres::SOLVER_CONTINUE; + } + + // Calculate average of symmetric geometric distance. + double average_distance = 0.0; + for (int i = 0; i < x1_.cols(); i++) { + average_distance = SymmetricGeometricDistance(*H_, + x1_.col(i), + x2_.col(i)); + } + average_distance /= x1_.cols(); + + if (average_distance <= options_.expected_average_symmetric_distance) { + return ceres::SOLVER_TERMINATE_SUCCESSFULLY; + } + + return ceres::SOLVER_CONTINUE; + } + + private: + const EstimateHomographyOptions &options_; + const Mat &x1_; + const Mat &x2_; + Mat3 *H_; +}; +} // namespace + /** 2D Homography transformation estimation in the case that points are in * euclidean coordinates. */ -bool Homography2DFromCorrespondencesEuc( +bool EstimateHomography2DFromCorrespondences( const Mat &x1, const Mat &x2, - const HomographyEstimationOptions &options, + const EstimateHomographyOptions &options, Mat3 *H) { // TODO(sergey): Support homogenous coordinates, not just euclidean. @@ -215,18 +270,31 @@ bool Homography2DFromCorrespondencesEuc( assert(x1.rows() == x2.rows()); assert(x1.cols() == x2.cols()); + Mat3 T1 = Mat3::Identity(), + T2 = Mat3::Identity(); + // Step 1: Algebraic homography estimation. - bool algebraic_success = - Homography2DFromCorrespondencesLinear(x1, x2, H, - options.expected_algebraic_precision); + Mat x1_normalized, x2_normalized; - LG << "Algebraic result " << algebraic_success - << ", estimated matrix:\n" << *H; + if (options.use_normalization) { + LG << "Estimating homography using normalization."; + GetNormalizedPoints(x1, &x1_normalized, &T1); + GetNormalizedPoints(x2, &x2_normalized, &T2); + } else { + x1_normalized = x1; + x2_normalized = x2; + } - if (!algebraic_success && !options.use_refine_if_algebraic_fails) { - return false; + // Assume algebraic estiation always suceeds, + Homography2DFromCorrespondencesLinear(x1_normalized, x2_normalized, H); + + // Denormalize the homography matrix. + if (options.use_normalization) { + *H = T2.inverse() * (*H) * T1; } + LG << "Estimated matrix after algebraic estimation:\n" << *H; + // Step 2: Refine matrix using Ceres minimizer. ceres::Problem problem; for (int i = 0; i < x1.cols(); i++) { @@ -249,8 +317,10 @@ bool Homography2DFromCorrespondencesEuc( solver_options.linear_solver_type = ceres::DENSE_QR; solver_options.max_num_iterations = options.max_num_iterations; solver_options.update_state_every_iteration = true; - solver_options.parameter_tolerance = options.parameter_tolerance; - solver_options.function_tolerance = options.function_tolerance; + + // Terminate if the average symmetric distance is good enough. + TerminationCheckingCallback callback(x1, x2, options, H); + solver_options.callbacks.push_back(&callback); // Run the solve. ceres::Solver::Summary summary; @@ -261,7 +331,8 @@ bool Homography2DFromCorrespondencesEuc( LG << "Final refined matrix:\n" << *H; return !(summary.termination_type == ceres::DID_NOT_RUN || - summary.termination_type == ceres::NUMERICAL_FAILURE); + summary.termination_type == ceres::NUMERICAL_FAILURE || + summary.termination_type == ceres::USER_ABORT); } /** @@ -377,7 +448,9 @@ bool Homography3DFromCorrespondencesLinear(const Mat &x1, } } -double SymmetricGeometricDistance(Mat3 &H, Vec2 &x1, Vec2 &x2) { +double SymmetricGeometricDistance(const Mat3 &H, + const Vec2 &x1, + const Vec2 &x2) { Vec3 x(x1(0), x1(1), 1.0); Vec3 y(x2(0), x2(1), 1.0); diff --git a/extern/libmv/libmv/multiview/homography.h b/extern/libmv/libmv/multiview/homography.h index 1928e39dffb..6d810c845ed 100644 --- a/extern/libmv/libmv/multiview/homography.h +++ b/extern/libmv/libmv/multiview/homography.h @@ -60,24 +60,35 @@ bool Homography2DFromCorrespondencesLinear(const Mat &x1, * Defaults should be suitable for a wide range of use cases, but * better performance and accuracy might require tweaking/ */ -struct HomographyEstimationOptions { +struct EstimateHomographyOptions { // Default constructor which sets up a options for generic usage. - HomographyEstimationOptions(void); + EstimateHomographyOptions(void); - // Expected precision of algebraic estimation. - double expected_algebraic_precision; + // Normalize correspondencies before estimating the homography + // in order to increase estimation stability. + // + // Normaliztion will make it so centroid od correspondences + // is the coordinate origin and their average distance from + // the origin is sqrt(2). + // + // See: + // - R. Hartley and A. Zisserman. Multiple View Geometry in Computer + // Vision. Cambridge University Press, second edition, 2003. + // - https://www.cs.ubc.ca/grads/resources/thesis/May09/Dubrofsky_Elan.pdf + bool use_normalization; - // Refine homography even if algebraic estimation reported failure. - bool use_refine_if_algebraic_fails; - - // Maximal number of iterations for refinement step. + // Maximal number of iterations for the refinement step. int max_num_iterations; - // Paramaneter tolerance used by minimizer termination criteria. - float parameter_tolerance; - - // Function tolerance used by minimizer termination criteria. - float function_tolerance; + // Expected average of symmetric geometric distance between + // actual destination points and original ones transformed by + // estimated homography matrix. + // + // Refinement will finish as soon as average of symmetric + // geometric distance is less or equal to this value. + // + // This distance is measured in the same units as input points are. + double expected_average_symmetric_distance; }; /** @@ -87,10 +98,11 @@ struct HomographyEstimationOptions { * correspondences by doing algebraic estimation first followed with result * refinement. */ -bool Homography2DFromCorrespondencesEuc(const Mat &x1, - const Mat &x2, - const HomographyEstimationOptions &options, - Mat3 *H); +bool EstimateHomography2DFromCorrespondences( + const Mat &x1, + const Mat &x2, + const EstimateHomographyOptions &options, + Mat3 *H); /** * 3D Homography transformation estimation. @@ -124,7 +136,9 @@ bool Homography3DFromCorrespondencesLinear(const Mat &x1, * * D(H * x1, x2)^2 + D(H^-1 * x2, x1) */ -double SymmetricGeometricDistance(Mat3 &H, Vec2 &x1, Vec2 &x2); +double SymmetricGeometricDistance(const Mat3 &H, + const Vec2 &x1, + const Vec2 &x2); } // namespace libmv diff --git a/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc b/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc index d4ddee56fda..6ab9e7eefb6 100644 --- a/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc +++ b/extern/libmv/libmv/simple_pipeline/keyframe_selection.cc @@ -207,19 +207,19 @@ void SelectKeyframesBasedOnGRICAndVariance(const Tracks &tracks, Mat3 H, F; // Estimate homography using default options. - HomographyEstimationOptions homography_estimation_options; - Homography2DFromCorrespondencesEuc(x1, - x2, - homography_estimation_options, - &H); + EstimateHomographyOptions estimate_homography_options; + EstimateHomography2DFromCorrespondences(x1, + x2, + estimate_homography_options, + &H); // Convert homography to original pixel space. H = N_inverse * H * N; - FundamentalEstimationOptions fundamental_estimation_options; - FundamentalFromCorrespondencesEuc(x1, + EstimateFundamentalOptions estimate_fundamental_options; + EstimateFundamentalFromCorrespondences(x1, x2, - fundamental_estimation_options, + estimate_fundamental_options, &F); // Convert fundamental to original pixel space. -- cgit v1.2.3 From 06c86e7722b7d88c9e0a0746c234a028a711e3fa Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 20 Nov 2013 15:32:31 +0600 Subject: Fix T37172: Plane Tracker Deform - No perspective Previous wrap implementation was based on inverse bilinear mapping, which doesn't give perspective. Now plane track wrap estimates perspective transform matrix as a homography estimation between frame coordinates and plane corners. Uses Libmv's implementation for this, which means plane track wouldn't work properly with Libmv disabled. Not a deal for official builds at all, just folks who keeps things disabled need to be aware of this. --- .../COM_PlaneTrackWarpImageOperation.cpp | 86 +++++++++++----------- .../operations/COM_PlaneTrackWarpImageOperation.h | 1 + 2 files changed, 42 insertions(+), 45 deletions(-) diff --git a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp index e3788f89b2d..dba3a6f3505 100644 --- a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp +++ b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.cpp @@ -47,23 +47,17 @@ BLI_INLINE bool isPointInsideQuad(const float x, const float y, const float corn isect_point_tri_v2(point, corners[0], corners[2], corners[3]); } -BLI_INLINE bool resolveUV(const float x, const float y, const float corners[4][2], float uv[2]) +BLI_INLINE void warpCoord(float x, float y, float matrix[3][3], float uv[2]) { - float point[2]; - bool inside; - - inside = isPointInsideQuad(x, y, corners); - - point[0] = x; - point[1] = y; - - /* Use reverse bilinear to get UV coordinates within original frame */ - resolve_quad_uv(uv, point, corners[0], corners[1], corners[2], corners[3]); + float vec[3] = {x, y, 1.0f}; + mul_m3_v3(matrix, vec); + vec[0] /= vec[2]; + vec[1] /= vec[2]; - return inside; + copy_v2_v2(uv, vec); } -BLI_INLINE void resolveUVAndDxDy(const float x, const float y, const float corners[4][2], +BLI_INLINE void resolveUVAndDxDy(const float x, const float y, float matrix[3][3], float *u_r, float *v_r, float *dx_r, float *dy_r) { float inputUV[2]; @@ -73,23 +67,21 @@ BLI_INLINE void resolveUVAndDxDy(const float x, const float y, const float corne float uv_l, uv_r; float uv_u, uv_d; - bool ok1, ok2; - - resolveUV(x, y, corners, inputUV); + warpCoord(x, y, matrix, inputUV); /* adaptive sampling, red (U) channel */ - ok1 = resolveUV(x - 1, y, corners, uv_a); - ok2 = resolveUV(x + 1, y, corners, uv_b); - uv_l = ok1 ? fabsf(inputUV[0] - uv_a[0]) : 0.0f; - uv_r = ok2 ? fabsf(inputUV[0] - uv_b[0]) : 0.0f; + warpCoord(x - 1, y, matrix, uv_a); + warpCoord(x + 1, y, matrix, uv_b); + uv_l = fabsf(inputUV[0] - uv_a[0]); + uv_r = fabsf(inputUV[0] - uv_b[0]); dx = 0.5f * (uv_l + uv_r); /* adaptive sampling, green (V) channel */ - ok1 = resolveUV(x, y - 1, corners, uv_a); - ok2 = resolveUV(x, y + 1, corners, uv_b); - uv_u = ok1 ? fabsf(inputUV[1] - uv_a[1]) : 0.f; - uv_d = ok2 ? fabsf(inputUV[1] - uv_b[1]) : 0.f; + warpCoord(x, y - 1, matrix, uv_a); + warpCoord(x, y + 1, matrix, uv_b); + uv_u = fabsf(inputUV[1] - uv_a[1]); + uv_d = fabsf(inputUV[1] - uv_b[1]); dy = 0.5f * (uv_u + uv_d); @@ -118,6 +110,16 @@ void PlaneTrackWarpImageOperation::initExecution() this->m_pixelReader = this->getInputSocketReader(0); BLI_jitter_init(this->m_jitter[0], this->m_osa); + + const int width = this->m_pixelReader->getWidth(); + const int height = this->m_pixelReader->getHeight(); + float frame_corners[4][2] = {{0.0f, 0.0f}, + {(float) width, 0.0f}, + {(float) width, (float) height}, + {0.0f, (float) height}}; + BKE_tracking_homography_between_two_quads(this->m_frameSpaceCorners, + frame_corners, + this->m_perspectiveMatrix); } void PlaneTrackWarpImageOperation::deinitExecution() @@ -125,22 +127,23 @@ void PlaneTrackWarpImageOperation::deinitExecution() this->m_pixelReader = NULL; } -void PlaneTrackWarpImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) +void PlaneTrackWarpImageOperation::executePixelSampled(float output[4], float x_, float y_, PixelSampler sampler) { float color_accum[4]; zero_v4(color_accum); for (int sample = 0; sample < this->m_osa; sample++) { - float current_x = x + this->m_jitter[sample][0], - current_y = y + this->m_jitter[sample][1]; + float current_x = x_ + this->m_jitter[sample][0], + current_y = y_ + this->m_jitter[sample][1]; if (isPointInsideQuad(current_x, current_y, this->m_frameSpaceCorners)) { float current_color[4]; float u, v, dx, dy; - resolveUVAndDxDy(current_x, current_y, this->m_frameSpaceCorners, &u, &v, &dx, &dy); + resolveUVAndDxDy(current_x, current_y, m_perspectiveMatrix, &u, &v, &dx, &dy); - u *= this->m_pixelReader->getWidth(); - v *= this->m_pixelReader->getHeight(); + /* derivatives are to be in normalized space.. */ + dx /= this->m_pixelReader->getWidth(); + dy /= this->m_pixelReader->getHeight(); this->m_pixelReader->readFiltered(current_color, u, v, dx, dy, COM_PS_NEAREST); add_v4_v4(color_accum, current_color); @@ -152,20 +155,13 @@ void PlaneTrackWarpImageOperation::executePixelSampled(float output[4], float x, bool PlaneTrackWarpImageOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { - float frame_space_corners[4][2]; - - for (int i = 0; i < 4; i++) { - frame_space_corners[i][0] = this->m_corners[i][0] * this->getWidth(); - frame_space_corners[i][1] = this->m_corners[i][1] * this->getHeight(); - } - float UVs[4][2]; /* TODO(sergey): figure out proper way to do this. */ - resolveUV(input->xmin - 2, input->ymin - 2, frame_space_corners, UVs[0]); - resolveUV(input->xmax + 2, input->ymin - 2, frame_space_corners, UVs[1]); - resolveUV(input->xmax + 2, input->ymax + 2, frame_space_corners, UVs[2]); - resolveUV(input->xmin - 2, input->ymax + 2, frame_space_corners, UVs[3]); + warpCoord(input->xmin - 2, input->ymin - 2, this->m_perspectiveMatrix, UVs[0]); + warpCoord(input->xmax + 2, input->ymin - 2, this->m_perspectiveMatrix, UVs[1]); + warpCoord(input->xmax + 2, input->ymax + 2, this->m_perspectiveMatrix, UVs[2]); + warpCoord(input->xmin - 2, input->ymax + 2, this->m_perspectiveMatrix, UVs[3]); float min[2], max[2]; INIT_MINMAX2(min, max); @@ -175,10 +171,10 @@ bool PlaneTrackWarpImageOperation::determineDependingAreaOfInterest(rcti *input, rcti newInput; - newInput.xmin = min[0] * readOperation->getWidth() - 1; - newInput.ymin = min[1] * readOperation->getHeight() - 1; - newInput.xmax = max[0] * readOperation->getWidth() + 1; - newInput.ymax = max[1] * readOperation->getHeight() + 1; + newInput.xmin = min[0] - 1; + newInput.ymin = min[1] - 1; + newInput.xmax = max[0] + 1; + newInput.ymax = max[1] + 1; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } diff --git a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h index 4d73a01cad0..ed9cc2fe5aa 100644 --- a/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h +++ b/source/blender/compositor/operations/COM_PlaneTrackWarpImageOperation.h @@ -38,6 +38,7 @@ protected: SocketReader *m_pixelReader; int m_osa; float m_jitter[32][2]; + float m_perspectiveMatrix[3][3]; public: PlaneTrackWarpImageOperation(); -- cgit v1.2.3 From d7eac00d12a13876786c9c8b7b409f104dc6ae1d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 20 Nov 2013 15:55:23 +0600 Subject: Expose track's offset to the RNA --- source/blender/makesrna/intern/rna_tracking.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 92d12a3a92c..a0aed94f3c6 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1354,6 +1354,14 @@ static void rna_def_trackingTrack(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "weight"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Weight", "Influence of this track on a final solution"); + + /* offset */ + prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_float_sdna(prop, NULL, "offset"); + RNA_def_property_ui_text(prop, "Offset", "Offset of track from the parenting point"); + RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, NULL); } static void rna_def_trackingPlaneMarker(BlenderRNA *brna) -- cgit v1.2.3 From 25560a3734a18657518652366fe24ce4574d54ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Wed, 20 Nov 2013 11:34:18 +0100 Subject: Fix T37545: SV+H color cube display changes H slider position when modifying S or V. The widget for the SV gradient was disabling display colorspace transform, but this was not happening for the H slider below, leading to varying H values used to calculate the slider position. --- .../blender/editors/interface/interface_handlers.c | 27 +++++++--------------- .../blender/editors/interface/interface_intern.h | 1 + .../blender/editors/interface/interface_widgets.c | 20 ++++++++++++---- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 05d7700f634..2b8b7643f39 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3879,8 +3879,8 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, float x, y; float mx_fl, my_fl; bool changed = true; - int color_profile = but->block->color_profile; - + bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but); + ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); #ifdef USE_CONT_MOUSE_CORRECT @@ -3892,14 +3892,9 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, } #endif - if (but->rnaprop) { - if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = FALSE; - } - ui_get_but_vectorf(but, rgb); - if (color_profile && (int)but->a1 != UI_GRAD_SV) + if (use_display_colorspace) ui_block_to_display_space_v3(but->block, rgb); rgb_to_hsv_compat_v(rgb, hsv); @@ -3913,7 +3908,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, /* calculate original hsv again */ copy_v3_v3(rgb, data->origvec); - if (color_profile && (int)but->a1 != UI_GRAD_SV) + if (use_display_colorspace) ui_block_to_display_space_v3(but->block, rgb); copy_v3_v3(hsvo, ui_block_hsv_get(but->block)); @@ -3974,7 +3969,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, hsv_to_rgb_v(hsv, rgb); - if (color_profile && ((int)but->a1 != UI_GRAD_SV)) + if (use_display_colorspace) ui_block_to_scene_linear_v3(but->block, rgb); /* clamp because with color conversion we can exceed range [#34295] */ @@ -3997,17 +3992,11 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, float *hsv = ui_block_hsv_get(but->block); float rgb[3]; float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt; - - int color_profile = but->block->color_profile; - - if (but->rnaprop) { - if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = FALSE; - } + bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but); ui_get_but_vectorf(but, rgb); - if (color_profile && (int)but->a1 != UI_GRAD_SV) + if (use_display_colorspace) ui_block_to_display_space_v3(but->block, rgb); rgb_to_hsv_compat_v(rgb, hsv); @@ -4055,7 +4044,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, hsv_to_rgb_v(hsv, rgb); - if (color_profile && (int)but->a1 != UI_GRAD_SV) + if (use_display_colorspace) ui_block_to_scene_linear_v3(but->block, rgb); copy_v3_v3(data->vec, rgb); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index be0a2810d2e..5ecd1e55086 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -385,6 +385,7 @@ extern void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rc const float mx, const float my); extern void ui_hsvcircle_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xpos, float *ypos); extern void ui_hsvcube_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp); +bool ui_hsvcube_use_display_colorspace(struct uiBut *but); extern void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision); extern void ui_get_but_string(uiBut *but, char *str, const size_t maxlen); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index c26998a7541..97dd4f59ff6 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2146,6 +2146,19 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons } +bool ui_hsvcube_use_display_colorspace(uiBut *but) +{ + bool color_profile = but->block->color_profile; + + if (but->rnaprop) { + if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) + color_profile = FALSE; + } + + /* SV+H gradient does not use display colorspace */ + return color_profile && !ELEM((int)but->a1, UI_GRAD_SV, UI_GRAD_H); +} + void ui_hsvcube_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp) { float x, y; @@ -2182,16 +2195,13 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) float x = 0.0f, y = 0.0f; float *hsv = ui_block_hsv_get(but->block); float hsv_n[3]; - int color_profile = but->block->color_profile; - - if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = FALSE; + bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but); copy_v3_v3(hsv_n, hsv); ui_get_but_vectorf(but, rgb); - if (color_profile && (int)but->a1 != UI_GRAD_SV) + if (use_display_colorspace) ui_block_to_display_space_v3(but->block, rgb); rgb_to_hsv_compat_v(rgb, hsv_n); -- cgit v1.2.3 From 1158c1f7c0ec3f5d31989cb85207a08888d2c0d3 Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Wed, 20 Nov 2013 07:10:35 -0500 Subject: Bevel Fix for nonplanar faces / reflex angles When beveling two adjacent edges, code used face normal instead of the face-corner normal (these can be different for nonplanar faces); the bevel may look uneven in such cases. Switched to using corner normal, and needed to fix the case where the edges meet at a reflex angle. Fixed a similar case when beveling two edges with one non-beveled in between. Also removed unnecessary argument from offset_meet. --- source/blender/bmesh/tools/bmesh_bevel.c | 33 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index af3160b004d..5e68e468fb8 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -468,14 +468,12 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3]) * Calculate the meeting point between the offset edges for e1 and e2, putting answer in meetco. * e1 and e2 share vertex v and face f (may be NULL) and viewed from the normal side of * the bevel vertex, e1 precedes e2 in CCW order. - * If on_right is true, offset edge is on right of both edges, where e1 enters v and - * e2 leave it. If on_right is false, then the offset edge is on the left. + * Offset edge is on right of both edges, where e1 enters v and e2 leave it. * When offsets are equal, the new point is on the edge bisector, with length offset/sin(angle/2), * but if the offsets are not equal (allowing for this, as bevel modifier has edge weights that may * lead to different offsets) then meeting point can be found be intersecting offset lines. */ -static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, - int on_right, float meetco[3]) +static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, float meetco[3]) { float dir1[3], dir2[3], norm_v[3], norm_perp1[3], norm_perp2[3], off1a[3], off1b[3], off2a[3], off2b[3], isect2[3], ang; @@ -506,16 +504,15 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, slide_dist(e2, v, e2->offset_l, meetco); } else { - /* get normal to plane where meet point should be */ + /* Get normal to plane where meet point should be, + * using cross product instead of f->no in case f is non-planar. + * If e1-v-e2 is a reflex angle (viewed from vertex normal side), need to flip*/ cross_v3_v3v3(norm_v, dir2, dir1); normalize_v3(norm_v); - if (!on_right) + if (dot_v3v3(norm_v, v->no) < 0.0f) negate_v3(norm_v); /* get vectors perp to each edge, perp to norm_v, and pointing into face */ - if (f) { - copy_v3_v3(norm_v, f->no); - } cross_v3_v3v3(norm_perp1, dir1, norm_v); cross_v3_v3v3(norm_perp2, dir2, norm_v); normalize_v3(norm_perp1); @@ -551,12 +548,12 @@ static void offset_on_edge_between(BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, * Prefer the one whose other end hasn't been constructed yet. * Following will choose to change e2 if both have already been constructed. */ if (find_other_end_edge_half(bp, e1)) { - offset_meet(e1, emid, v, e1->fnext, TRUE, meetco); + offset_meet(e1, emid, v, e1->fnext, meetco); /* now e2's left offset is probably different */ e2->offset_l = dist_to_line_v3(meetco, v->co, BM_edge_other_vert(e2->e, v)->co); } else { - offset_meet(emid, e2, v, emid->fnext, TRUE, meetco); + offset_meet(emid, e2, v, emid->fnext, meetco); /* now e1's right offset is probably different */ e1->offset_r = dist_to_line_v3(meetco, v->co, BM_edge_other_vert(e1->e, v)->co); } @@ -585,6 +582,14 @@ static void offset_in_two_planes(BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, Ed /* calculate face normals at corner in case faces are nonplanar */ cross_v3_v3v3(f1no, dirmid, dir1); cross_v3_v3v3(f2no, dirmid, dir2); + + /* if e1-v-emid or emid-v-e2 are reflex angles, need to flip corner normals */ + if (dot_v3v3(f1no, v->no) < 0.0f) + negate_v3(f1no); + if (dot_v3v3(f2no, v->no) < 0.0f) + negate_v3(f2no); + + /* get vectors perpendicular to e1 and e2, pointing into the proper faces */ cross_v3_v3v3(norm_perp1, dir1, f1no); normalize_v3(norm_perp1); cross_v3_v3v3(norm_perp2, dir2, f2no); @@ -874,7 +879,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv) /* handle only left side of beveled edge e here: next iteration should do right side */ if (e->prev->is_bev) { BLI_assert(e->prev != e); /* see: wire edge special case */ - offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co); + offset_meet(e->prev, e, bv->v, e->fprev, co); v = add_new_bound_vert(mem_arena, vm, co); v->efirst = e->prev; v->elast = v->ebev = e; @@ -899,7 +904,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv) } else { /* neither e->prev nor e->prev->prev are beveled: make on-edge on e->prev */ - offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co); + offset_meet(e->prev, e, bv->v, e->fprev, co); v = add_new_bound_vert(mem_arena, vm, co); v->efirst = e->prev; v->elast = v->ebev = e; @@ -917,7 +922,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv) } else if (e->prev->is_bev) { /* on-edge meet between e->prev and e */ - offset_meet(e->prev, e, bv->v, e->fprev, TRUE, co); + offset_meet(e->prev, e, bv->v, e->fprev, co); v = add_new_bound_vert(mem_arena, vm, co); v->efirst = e->prev; v->elast = e; -- cgit v1.2.3 From 33ae2b6c70b0f140502dc593e7882c687de2d1f4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Nov 2013 12:25:07 +1100 Subject: Transform: Warp tool (rewritten) * Can optionally warp a segment (sets min/max default so it acts as old warp did). * Can rotate the warp axis (old warp tool was limited to horizontal). --- release/scripts/startup/bl_ui/space_view3d.py | 1 + source/blender/editors/object/CMakeLists.txt | 1 + source/blender/editors/object/object_intern.h | 3 + source/blender/editors/object/object_ops.c | 2 + source/blender/editors/object/object_warp.c | 325 ++++++++++++++++++++++++++ 5 files changed, 332 insertions(+) create mode 100644 source/blender/editors/object/object_warp.c diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 4c316c94269..74d274a8896 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -181,6 +181,7 @@ class VIEW3D_MT_transform_base(Menu): layout.operator("transform.shear", text="Shear") layout.operator("transform.bend", text="Bend") layout.operator("transform.push_pull", text="Push/Pull") + layout.operator("object.vertex_warp", text="Warp") # Generic transform menu - geometry types diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 3e7aeba63c3..143a33c3fdd 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -53,6 +53,7 @@ set(SRC object_select.c object_shapekey.c object_transform.c + object_warp.c object_vgroup.c object_intern.h diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 313ac1d29f0..bfed1f2f982 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -234,6 +234,9 @@ void OBJECT_OT_vertex_weight_set_active(struct wmOperatorType *ot); void OBJECT_OT_vertex_weight_normalize_active_vertex(struct wmOperatorType *ot); void OBJECT_OT_vertex_weight_copy(struct wmOperatorType *ot); +/* object_warp.c */ +void OBJECT_OT_vertex_warp(struct wmOperatorType *ot); + /* object_shapekey.c */ void OBJECT_OT_shape_key_add(struct wmOperatorType *ot); void OBJECT_OT_shape_key_remove(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index f5c2bcbef70..6d760acb698 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -203,6 +203,8 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_vertex_weight_normalize_active_vertex); WM_operatortype_append(OBJECT_OT_vertex_weight_copy); + WM_operatortype_append(OBJECT_OT_vertex_warp); + WM_operatortype_append(OBJECT_OT_game_property_new); WM_operatortype_append(OBJECT_OT_game_property_remove); WM_operatortype_append(OBJECT_OT_game_property_copy); diff --git a/source/blender/editors/object/object_warp.c b/source/blender/editors/object/object_warp.c new file mode 100644 index 00000000000..06b59a8e954 --- /dev/null +++ b/source/blender/editors/object/object_warp.c @@ -0,0 +1,325 @@ +/* + * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2013 by Blender Foundation + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/object/object_warp.c + * \ingroup edobj + */ + +#include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_view3d_types.h" + +#include "BLI_math.h" + +#include "BKE_utildefines.h" +#include "BKE_context.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_view3d.h" +#include "ED_transverts.h" + +#include "object_intern.h" + + +static void object_warp_calc_view_matrix(float r_mat_view[4][4], float r_center_view[3], + Object *obedit, float viewmat[4][4], const float center[3], + const float offset_angle) +{ + float mat_offset[4][4]; + float viewmat_roll[4][4]; + + /* apply the rotation offset by rolling the view */ + unit_m4(mat_offset); + rotate_m4(mat_offset, 'Z', offset_angle); + mul_m4_m4m4(viewmat_roll, mat_offset, viewmat); + + /* apply the view and the object matrix */ + mul_m4_m4m4(r_mat_view, viewmat_roll, obedit->obmat); + + /* get the view-space cursor */ + mul_v3_m4v3(r_center_view, viewmat_roll, center); +} + + +static void object_warp_transverts_minmax_x(TransVertStore *tvs, + float mat_view[4][4], const float center_view[3], + float *r_min, float *r_max) +{ + /* no need to apply translation and cursor offset for every vertex, delay this */ + const float x_ofs = (mat_view[3][0] - center_view[0]); + float min = FLT_MAX, max = -FLT_MAX; + + TransVert *tv; + int i; + + + tv = tvs->transverts; + for (i = 0; i < tvs->transverts_tot; i++, tv++) { + float val; + + /* convert objectspace->viewspace */ + val = dot_m4_v3_row_x(mat_view, tv->loc); + + min = min_ff(min, val); + max = max_ff(max, val); + } + + *r_min = min + x_ofs; + *r_max = max + x_ofs; +} + + +static void object_warp_transverts(TransVertStore *tvs, + float mat_view[4][4], const float center_view[3], + const float angle_, const float min, const float max) +{ + TransVert *tv; + int i; + const float angle = -angle_; + /* cache vars for tiny speedup */ +#if 1 + const float range = max - min; + const float range_inv = 1.0f / range; + const float min_ofs = min + (0.5f * range); +#endif + + float dir_min[2], dir_max[2]; + float imat_view[4][4]; + + + invert_m4_m4(imat_view, mat_view); + + /* calculate the direction vectors outside min/max range */ + { + const float phi = angle * 0.5f; + + dir_max[0] = cosf(phi); + dir_max[1] = sinf(phi); + + dir_min[0] = -dir_max[0]; + dir_min[1] = dir_max[1]; + } + + + tv = tvs->transverts; + for (i = 0; i < tvs->transverts_tot; i++, tv++) { + float co[3], co_add[2]; + float val, phi; + + /* convert objectspace->viewspace */ + mul_v3_m4v3(co, mat_view, tv->loc); + sub_v2_v2(co, center_view); + + val = co[0]; + /* is overwritten later anyway */ + // co[0] = 0.0f; + + if (val < min) { + mul_v2_v2fl(co_add, dir_min, min - val); + val = min; + } + else if (val > max) { + mul_v2_v2fl(co_add, dir_max, val - max); + val = max; + } + else { + zero_v2(co_add); + } + + /* map from x axis to (-0.5 - 0.5) */ +#if 0 + val = ((val - min) / (max - min)) - 0.5f; +#else + val = (val - min_ofs) * range_inv; +#endif + + /* convert the x axis into a rotation */ + phi = val * angle; + + co[0] = -sinf(phi) * co[1]; + co[1] = cosf(phi) * co[1]; + + add_v2_v2(co, co_add); + + /* convert viewspace->objectspace */ + add_v2_v2(co, center_view); + mul_v3_m4v3(tv->loc, imat_view, co); + } +} + +static int object_warp_verts_exec(bContext *C, wmOperator *op) +{ + const float warp_angle = RNA_float_get(op->ptr, "warp_angle"); + const float offset_angle = RNA_float_get(op->ptr, "offset_angle"); + + TransVertStore tvs = {NULL}; + Object *obedit = CTX_data_edit_object(C); + + /* typically from 'rv3d' and 3d cursor */ + float viewmat[4][4]; + float center[3]; + + /* 'viewmat' relative vars */ + float mat_view[4][4]; + float center_view[3]; + + float min, max; + + + ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS | TM_SKIP_HANDLES); + if (tvs.transverts == 0) { + return OPERATOR_CANCELLED; + } + + + /* get viewmatrix */ + { + PropertyRNA *prop_viewmat = RNA_struct_find_property(op->ptr, "viewmat"); + if (RNA_property_is_set(op->ptr, prop_viewmat)) { + RNA_property_float_get_array(op->ptr, prop_viewmat, (float *)viewmat); + } + else { + RegionView3D *rv3d = CTX_wm_region_view3d(C); + + if (rv3d) { + copy_m4_m4(viewmat, rv3d->viewmat); + } + else { + unit_m4(viewmat); + } + + RNA_property_float_set_array(op->ptr, prop_viewmat, (float *)viewmat); + } + } + + + /* get center */ + { + PropertyRNA *prop_center = RNA_struct_find_property(op->ptr, "center"); + if (RNA_property_is_set(op->ptr, prop_center)) { + RNA_property_float_get_array(op->ptr, prop_center, center); + } + else { + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + const float *cursor; + + cursor = ED_view3d_cursor3d_get(scene, v3d); + copy_v3_v3(center, cursor); + + RNA_property_float_set_array(op->ptr, prop_center, center); + } + } + + + object_warp_calc_view_matrix(mat_view, center_view, obedit, viewmat, center, offset_angle); + + + /* get minmax */ + { + PropertyRNA *prop_min = RNA_struct_find_property(op->ptr, "min"); + PropertyRNA *prop_max = RNA_struct_find_property(op->ptr, "max"); + + if (RNA_property_is_set(op->ptr, prop_min) || + RNA_property_is_set(op->ptr, prop_max)) + { + min = RNA_property_float_get(op->ptr, prop_min); + max = RNA_property_float_get(op->ptr, prop_max); + } + else { + /* handy to set the bounds of the mesh */ + object_warp_transverts_minmax_x(&tvs, mat_view, center_view, &min, &max); + + RNA_property_float_set(op->ptr, prop_min, min); + RNA_property_float_set(op->ptr, prop_max, max); + } + + if (min > max) { + SWAP(float, min, max); + } + } + + if (min != max) { + object_warp_transverts(&tvs, mat_view, center_view, warp_angle, min, max); + } + + ED_transverts_update_obedit(&tvs, obedit); + ED_transverts_free(&tvs); + + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); + + return OPERATOR_FINISHED; +} + +static int object_warp_verts_poll(bContext *C) +{ + Object *obedit = CTX_data_edit_object(C); + if (obedit) { + if (ED_transverts_check_obedit(obedit)) { + return true; + } + } + return false; +} + + +void OBJECT_OT_vertex_warp(struct wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Warp"; + ot->description = "Warp vertices around the cursor"; + ot->idname = "OBJECT_OT_vertex_warp"; + + /* api callbacks */ + ot->exec = object_warp_verts_exec; + ot->poll = object_warp_verts_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* props */ + prop = RNA_def_float(ot->srna, "warp_angle", DEG2RADF(360.0f), -FLT_MAX, FLT_MAX, "Warp Angle", + "Amount to warp about the cursor", DEG2RADF(-360.0f), DEG2RADF(360.0f)); + RNA_def_property_subtype(prop, PROP_ANGLE); + + prop = RNA_def_float(ot->srna, "offset_angle", DEG2RADF(0.0f), -FLT_MAX, FLT_MAX, "Offset Angle", + "Angle to use as the basis for warping", DEG2RADF(-360.0f), DEG2RADF(360.0f)); + RNA_def_property_subtype(prop, PROP_ANGLE); + + prop = RNA_def_float(ot->srna, "min", -1.0f, -FLT_MAX, FLT_MAX, "Min", "", -100.0, 100.0); + prop = RNA_def_float(ot->srna, "max", 1.0f, -FLT_MAX, FLT_MAX, "Max", "", -100.0, 100.0); + + /* hidden props */ + prop = RNA_def_float_matrix(ot->srna, "viewmat", 4, 4, NULL, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + + prop = RNA_def_float_vector_xyz(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "", -FLT_MAX, FLT_MAX); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); +} -- cgit v1.2.3 From c4bb2e9774243a13a5c5abbab570ff48ffc8f421 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 20 Nov 2013 15:21:13 +1300 Subject: Updating icons for NLA Track "solo" button (as used in standard widgets) --- source/blender/editors/animation/anim_channels_defines.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 142342997be..4f298d8a235 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3355,8 +3355,8 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann break; case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */ - //icon = ((enabled) ? ICON_LAYER_ACTIVE : ICON_LAYER_USED); - icon = ICON_LAYER_USED; + //icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON); + icon = ICON_SOLO_OFF; tooltip = TIP_("NLA Track is the only one evaluated for the AnimData block it belongs to"); break; -- cgit v1.2.3 From 2f88fc35de4c0714acc3f56683bd13c89107ed8c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 20 Nov 2013 17:06:37 +1300 Subject: Skeleton of type defines for NlaTrack animchannel --- .../editors/animation/anim_channels_defines.c | 95 +++++++++++++++++++++- 1 file changed, 91 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 4f298d8a235..977e0194c1f 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -2764,6 +2764,94 @@ static bAnimChannelType ACF_MASKLAYER = acf_masklay_setting_ptr /* pointer for setting */ }; +/* NLA Track ----------------------------------------------- */ + +/* name for nla track entries */ +static void acf_nlatrack_name(bAnimListElem *ale, char *name) +{ + NlaTrack *nlt = (NlaTrack *)ale->data; + + if (nlt && name) + BLI_strncpy(name, nlt->name, ANIM_CHAN_NAME_SIZE); +} + +/* name property for nla track entries */ +static short acf_nlatrack_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +{ + if (ale->data) { + RNA_pointer_create(ale->id, &RNA_NlaTrack, ale->data, ptr); + *prop = RNA_struct_name_property(ptr->type); + + return (*prop != NULL); + } + + return 0; +} + +/* check if some setting exists for this channel */ +static short acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *ale, int setting) +{ + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; + + /* visibility of settings depends on various states... */ + + // XXX: + return 0; +} + +/* get the appropriate flag(s) for the setting when it is valid */ +static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +{ + /* clear extra return data first */ + *neg = 0; + + switch (setting) { + case ACHANNEL_SETTING_SELECT: /* selected */ + return NLATRACK_SELECTED; + + case ACHANNEL_SETTING_MUTE: /* muted */ + return NLATRACK_MUTED; + + case ACHANNEL_SETTING_PROTECT: /* protected */ + return NLATRACK_PROTECTED; + + case ACHANNEL_SETTING_SOLO: /* solo */ + return NLATRACK_SOLO; + + default: /* unsupported */ + return 0; + } +} + +/* get pointer to the setting */ +static void *acf_nlatrack_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type) +{ + NlaTrack *nlt = (NlaTrack *)ale->data; + return GET_ACF_FLAG_PTR(nlt->flag, type); +} + +/* nla track type define */ +static bAnimChannelType ACF_NLATRACK = +{ + "NLA Track", /* type name */ + + acf_generic_channel_color, /* backdrop color */ // XXX: color depends on whether track is solo or not! + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_flexible, /* indent level */ + acf_generic_group_offset, /* offset */ // XXX? + + acf_nlatrack_name, /* name */ + acf_nlatrack_name_prop, /* name prop */ + NULL, /* icon */ + + acf_nlatrack_setting_valid, /* has setting */ + acf_nlatrack_setting_flag, /* flag for setting */ + acf_nlatrack_setting_ptr /* pointer for setting */ +}; + + + /* *********************************************** */ /* Type Registration and General Access */ @@ -2822,10 +2910,8 @@ static void ANIM_init_channel_typeinfo_data(void) animchannelTypeInfo[type++] = &ACF_MASKDATA; /* Mask Datablock */ animchannelTypeInfo[type++] = &ACF_MASKLAYER; /* Mask Layer */ - // TODO: these types still need to be implemented!!! - // probably need a few extra flags for these special cases... - animchannelTypeInfo[type++] = NULL; /* NLA Track */ - animchannelTypeInfo[type++] = NULL; /* NLA Action */ + animchannelTypeInfo[type++] = &ACF_NLATRACK; /* NLA Track */ + animchannelTypeInfo[type++] = &ACF_NLAACTION; /* NLA Action */ } } @@ -3422,6 +3508,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann /* no flushing */ case ACHANNEL_SETTING_EXPAND: /* expanding - cannot flush, otherwise all would open/close at once */ + case ACHANNEL_SETTING_SOLO: /* NLA Tracks - solo flag */ default: uiButSetFunc(but, achannel_setting_widget_cb, NULL, NULL); break; -- cgit v1.2.3 From eb727124852083be13f9fff5ce1def4ffe2a0959 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 20 Nov 2013 19:03:55 +1300 Subject: Ported over logic for which animchannel settings are supported by NLA Tracks --- .../editors/animation/anim_channels_defines.c | 39 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 977e0194c1f..02e3c6a7aa2 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -2795,9 +2795,42 @@ static short acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem AnimData *adt = ale->adt; /* visibility of settings depends on various states... */ - - // XXX: - return 0; + switch (setting) { + /* always supported */ + case ACHANNEL_SETTING_SELECT: + case ACHANNEL_SETTING_SOLO: + return 1; + + /* conditionally supported... */ + case ACHANNEL_SETTING_PROTECT: + case ACHANNEL_SETTING_MUTE: + /* if this track is active and we're tweaking it, don't draw these toggles */ + if (((nlt->flag & NLATRACK_ACTIVE) && (nlt->flag & NLATRACK_DISABLED)) == 0) { + /* is track enabled for solo drawing? */ + if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) { + if (nlt->flag & NLATRACK_SOLO) { + /* ok - we've got a solo track, and this is it */ + return 1; + } + else { + /* not ok - we've got a solo track, but this isn't it, so make it more obvious */ + return 0; + } + } + + + /* ok - no tracks are solo'd, and this isn't being tweaked */ + return 1; + } + else { + /* unsupported - this track is being tweaked */ + return 0; + } + + /* unsupported */ + default: + return 0; + } } /* get the appropriate flag(s) for the setting when it is valid */ -- cgit v1.2.3 From 5efad6f6c616124b4db6210cb3bf527bb7c2a696 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 20 Nov 2013 19:24:17 +1300 Subject: Ported code for setting colour of NLA Track anim channel --- .../editors/animation/anim_channels_defines.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 02e3c6a7aa2..3848eb3ef6b 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -2766,6 +2766,25 @@ static bAnimChannelType ACF_MASKLAYER = /* NLA Track ----------------------------------------------- */ +/* get backdrop color for nla track channels */ +static void acf_nlatrack_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float r_color[3]) +{ + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; + bool nonSolo = false; + + /* is track enabled for solo drawing? */ + if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) { + if ((nlt->flag & NLATRACK_SOLO) == 0) { + /* tag for special non-solo handling */ + nonSolo = true; + } + } + + /* set color for nla track */ + UI_GetThemeColorShade3fv(TH_HEADER, ((nonSolo == false) ? 20 : -20), r_color); +} + /* name for nla track entries */ static void acf_nlatrack_name(bAnimListElem *ale, char *name) { @@ -2869,7 +2888,7 @@ static bAnimChannelType ACF_NLATRACK = { "NLA Track", /* type name */ - acf_generic_channel_color, /* backdrop color */ // XXX: color depends on whether track is solo or not! + acf_nlatrack_color, /* backdrop color */ acf_generic_channel_backdrop, /* backdrop */ acf_generic_indention_flexible, /* indent level */ acf_generic_group_offset, /* offset */ // XXX? -- cgit v1.2.3 From be971959bc8db20c69cd0b894978fec8985d0abf Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 21 Nov 2013 00:28:12 +1300 Subject: Added button callback so that toggling solo mode on NLA Tracks now works correctly --- .../editors/animation/anim_channels_defines.c | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 3848eb3ef6b..a67e69e1665 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -63,6 +63,7 @@ #include "BKE_curve.h" #include "BKE_key.h" +#include "BKE_nla.h" #include "BKE_context.h" #include "UI_interface.h" @@ -3363,6 +3364,26 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void BLI_freelistN(&anim_data); } +/* callback for wrapping NLA Track "solo" toggle logic */ +static void achannel_nlatrack_solo_widget_cb(bContext *C, void *adt_poin, void *nlt_poin) +{ + AnimData *adt = adt_poin; + NlaTrack *nlt = nlt_poin; + + /* Toggle 'solo' mode. There are several complications here which need explaining: + * - The method call is needed to perform a few additional validation operations + * to ensure that the mode is applied properly + * - BUT, since the button already toggles the value, we need to un-toggle it + * before the API call gets to it, otherwise it will end up clearing the result + * again! + */ + nlt->flag ^= NLATRACK_SOLO; + BKE_nlatrack_solo_toggle(adt, nlt); + + /* send notifiers */ + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL); +} + /* callback for rename widgets - clear rename-in-progress */ static void achannel_setting_rename_done_cb(bContext *C, void *ads_poin, void *UNUSED(arg2)) { @@ -3558,9 +3579,13 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann uiButSetNFunc(but, achannel_setting_flush_widget_cb, MEM_dupallocN(ale), SET_INT_IN_POINTER(setting)); break; + /* settings needing special attention */ + case ACHANNEL_SETTING_SOLO: /* NLA Tracks - Solo toggle */ + uiButSetFunc(but, achannel_nlatrack_solo_widget_cb, ale->adt, ale->data); + break; + /* no flushing */ case ACHANNEL_SETTING_EXPAND: /* expanding - cannot flush, otherwise all would open/close at once */ - case ACHANNEL_SETTING_SOLO: /* NLA Tracks - solo flag */ default: uiButSetFunc(but, achannel_setting_widget_cb, NULL, NULL); break; -- cgit v1.2.3 From 2213b93521de4fc2221e448d4eef4bba8399b617 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 21 Nov 2013 00:29:29 +1300 Subject: Remove old drawing code for NLA Tracks --- source/blender/editors/space_nla/nla_draw.c | 40 ----------------------------- 1 file changed, 40 deletions(-) diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index b4c52a5b1ca..c30862fb156 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -645,46 +645,6 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View /* determine what needs to be drawn */ switch (ale->type) { - case ANIMTYPE_NLATRACK: /* NLA Track */ - { - NlaTrack *nlt = (NlaTrack *)ale->data; - - /* 'solo' as the 'special' button? */ - if (nlt->flag & NLATRACK_SOLO) - special = ICON_SOLO_ON; - else - special = ICON_SOLO_OFF; - - /* if this track is active and we're tweaking it, don't draw these toggles */ - // TODO: need a special macro for this... - if (((nlt->flag & NLATRACK_ACTIVE) && (nlt->flag & NLATRACK_DISABLED)) == 0) { - if (nlt->flag & NLATRACK_MUTED) - mute = ICON_MUTE_IPO_ON; - else - mute = ICON_MUTE_IPO_OFF; - - if (EDITABLE_NLT(nlt)) - protect = ICON_UNLOCKED; - else - protect = ICON_LOCKED; - } - - /* is track enabled for solo drawing? */ - if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) { - if ((nlt->flag & NLATRACK_SOLO) == 0) { - /* tag for special non-solo handling; also hide the mute toggles */ - nonSolo = 1; - mute = 0; - } - } - - sel = SEL_NLT(nlt); - BLI_strncpy(name, nlt->name, sizeof(name)); - - /* draw manually still */ - do_draw = TRUE; - break; - } case ANIMTYPE_NLAACTION: /* NLA Action-Line */ { bAction *act = (bAction *)ale->data; -- cgit v1.2.3 From 96a4ee725e7685b4b3846d3d23ad8fb7429a9be9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 21 Nov 2013 01:01:10 +1300 Subject: Anim Editors: Improve some tooltips to be more accurate for the type of editor/data they're shown for This commit fixes some problems where some tooltips were not adapting as intended when used for different channel types in different places. --- source/blender/editors/animation/anim_channels_defines.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index a67e69e1665..d02626f9274 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3502,7 +3502,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann icon = ICON_VISIBLE_IPO_OFF; if (ale->type == ANIMTYPE_FCURVE) - tooltip = TIP_("Channel is visible in Graph Editor for editing"); + tooltip = TIP_("F-Curve is visible in Graph Editor for editing"); else tooltip = TIP_("Channels are visible in Graph Editor for editing"); break; @@ -3516,7 +3516,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */ //icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON); icon = ICON_SOLO_OFF; - tooltip = TIP_("NLA Track is the only one evaluated for the AnimData block it belongs to"); + tooltip = TIP_("NLA Track is the only one evaluated in this Animation Data block, with all others muted"); break; /* --- */ @@ -3525,14 +3525,18 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann // TODO: what about when there's no protect needed? //icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED); icon = ICON_UNLOCKED; - tooltip = TIP_("Editability of keyframes for this channel"); + + if (ale->datatype != ALE_NLASTRIP) + tooltip = TIP_("Editability of keyframes for this channel"); + else + tooltip = TIP_("Editability of NLA Strips in this track"); break; case ACHANNEL_SETTING_MUTE: /* muted speaker */ //icon = ((enabled) ? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF); icon = ICON_MUTE_IPO_OFF; - if (ale->type == ALE_FCURVE) + if (ale->type == ANIMTYPE_FCURVE) tooltip = TIP_("Does F-Curve contribute to result"); else tooltip = TIP_("Do channels contribute to result"); -- cgit v1.2.3 From 905085228f475b4ca82ba21a6414b5e0a02f49a8 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 21 Nov 2013 01:01:52 +1300 Subject: Anim Editors: Ensure that "solo" flag doesn't get accidentally handled on channels which don't support it --- source/blender/editors/animation/anim_channels_defines.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index d02626f9274..7b656da3de3 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -816,6 +816,11 @@ static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale { /* for now, all settings are supported, though some are only conditionally */ switch (setting) { + /* unsupported */ + case ACHANNEL_SETTING_SOLO: /* Only available in NLA Editor for tracks */ + return 0; + + /* conditionally supported */ case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ return (ac->spacetype == SPACE_IPO); @@ -925,6 +930,7 @@ static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int switch (setting) { /* unsupported */ + case ACHANNEL_SETTING_SOLO: /* Solo Flag is only for NLA */ case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */ return 0; @@ -2542,6 +2548,7 @@ static short acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUS /* unsupported */ case ACHANNEL_SETTING_EXPAND: /* gpencil layers are more like F-Curves than groups */ case ACHANNEL_SETTING_VISIBLE: /* graph editor only */ + case ACHANNEL_SETTING_SOLO: /* nla editor only */ return 0; /* always available */ @@ -2707,6 +2714,7 @@ static short acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem * /* unsupported */ case ACHANNEL_SETTING_EXPAND: /* mask layers are more like F-Curves than groups */ case ACHANNEL_SETTING_VISIBLE: /* graph editor only */ + case ACHANNEL_SETTING_SOLO: /* nla editor only */ return 0; /* always available */ -- cgit v1.2.3 From efdd4894e93748e7305d03ca6f32deb869cc2862 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 21 Nov 2013 01:13:30 +1300 Subject: NLA Channel Drawing Refactor: Remove rest of old drawing code for NLA Track channels NLA Track drawing has now been ported over to use the UI widgets like the rest of the anim channels do in the DopeSheet and Graph Editors. The main benefit of this for users is that these buttons will now show tooltips when you hover over them. Hopefully this will help make the "solo" buttons more discoverable. I've decided to postpone porting the "Action Line" channels to the widget system for now, since there are quite a few more issues there which need quite a bit more time to work through. --- .../editors/animation/anim_channels_defines.c | 4 ++- source/blender/editors/space_nla/nla_draw.c | 35 ++-------------------- 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 7b656da3de3..1d9022e463b 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -2972,7 +2972,9 @@ static void ANIM_init_channel_typeinfo_data(void) animchannelTypeInfo[type++] = &ACF_MASKLAYER; /* Mask Layer */ animchannelTypeInfo[type++] = &ACF_NLATRACK; /* NLA Track */ - animchannelTypeInfo[type++] = &ACF_NLAACTION; /* NLA Action */ + + // TODO: this channel type still hasn't been ported over yet, since it requires special attention + animchannelTypeInfo[type++] = NULL; /* NLA Action */ } } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index c30862fb156..c9a86547984 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -638,8 +638,8 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View { AnimData *adt = ale->adt; - short indent = 0, offset = 0, sel = 0, group = 0, nonSolo = 0; - int expand = -1, protect = -1, special = -1, mute = -1; + short indent = 0, offset = 0, sel = 0, group = 0; + int special = -1; char name[128]; short do_draw = FALSE; @@ -660,7 +660,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View break; } default: /* handled by standard channel-drawing API */ - // draw backdrops only... + /* (draw backdrops only...) */ ANIM_channel_draw(ac, ale, yminc, ymaxc); break; } @@ -743,25 +743,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View /* clear group value, otherwise we cause errors... */ group = 0; } - else { - /* NLA tracks - darker color if not solo track when we're showing solo */ - UI_ThemeColorShade(TH_HEADER, ((nonSolo == 0) ? 20 : -20)); - - indent += group; - offset += 0.35f * U.widget_unit * indent; - glBegin(GL_QUADS); - glVertex2f(x + offset, yminc); - glVertex2f(x + offset, ymaxc); - glVertex2f((float)v2d->cur.xmax, ymaxc); - glVertex2f((float)v2d->cur.xmax, yminc); - glEnd(); - } - /* draw expand/collapse triangle */ - if (expand > 0) { - UI_icon_draw(x + offset, ydatac, expand); - offset += 0.85f * U.widget_unit; - } /* draw special icon indicating certain data-types */ if (special > -1) { @@ -786,17 +768,6 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - /* draw protect 'lock' */ - if (protect > -1) { - offset = 0.8f * U.widget_unit; - UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, protect); - } - - /* draw mute 'eye' */ - if (mute > -1) { - offset += 0.8f * U.widget_unit; - UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, mute); - } /* draw NLA-action line 'status-icons' - only when there's an action */ if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { -- cgit v1.2.3 From 82238c3e3679d11e38f0e127698afc9dee8521b4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Nov 2013 00:21:31 +1100 Subject: Fix T37550: Crash while snaping to curve made from Susane (bug in recent addition) --- source/blender/editors/transform/transform_snap.c | 36 ++++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 8283197c70b..4cda56028ca 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1446,23 +1446,37 @@ static bool snapCurve(short snap_mode, ARegion *ar, Object *ob, Curve *cu, float case SCE_SNAP_MODE_VERTEX: { if (ob->mode == OB_MODE_EDIT) { - /* don't snap to selected (moving) or hidden */ - if (nu->bezt[u].f2 & SELECT || nu->bezt[u].hide != 0) { - break; - } - retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); - /* don't snap if handle is selected (moving), or if it is aligning to a moving handle */ - if (!(nu->bezt[u].f1 & SELECT) && !(nu->bezt[u].h1 & HD_ALIGN && nu->bezt[u].f3 & SELECT)) { - retval |= snapVertex(ar, nu->bezt[u].vec[0], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + if (nu->bezt) { + /* don't snap to selected (moving) or hidden */ + if (nu->bezt[u].f2 & SELECT || nu->bezt[u].hide != 0) { + break; + } + retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + /* don't snap if handle is selected (moving), or if it is aligning to a moving handle */ + if (!(nu->bezt[u].f1 & SELECT) && !(nu->bezt[u].h1 & HD_ALIGN && nu->bezt[u].f3 & SELECT)) { + retval |= snapVertex(ar, nu->bezt[u].vec[0], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + } + if (!(nu->bezt[u].f3 & SELECT) && !(nu->bezt[u].h2 & HD_ALIGN && nu->bezt[u].f1 & SELECT)) { + retval |= snapVertex(ar, nu->bezt[u].vec[2], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + } } - if (!(nu->bezt[u].f3 & SELECT) && !(nu->bezt[u].h2 & HD_ALIGN && nu->bezt[u].f1 & SELECT)) { - retval |= snapVertex(ar, nu->bezt[u].vec[2], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + else { + /* don't snap to selected (moving) or hidden */ + if (nu->bp[u].f1 & SELECT || nu->bp[u].hide != 0) { + break; + } + retval |= snapVertex(ar, nu->bp[u].vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); } } else { /* curve is not visible outside editmode if nurb length less than two */ if (nu->pntsu > 1) { - retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + if (nu->bezt) { + retval |= snapVertex(ar, nu->bezt[u].vec[1], NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + } + else { + retval |= snapVertex(ar, nu->bp[u].vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist_px, r_depth); + } } } break; -- cgit v1.2.3 From 31a1bcfcd7041c3d346ce8b4eb16786c353153c1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Nov 2013 02:15:38 +1100 Subject: fix T37411: Transform mouse constraint could fail in some situations. Was caused by int rounding when an axis was < 1.0. --- source/blender/editors/transform/transform_constraints.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 8df289ff917..4ba87eb8c39 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -930,9 +930,9 @@ static void setNearestAxis2d(TransInfo *t) static void setNearestAxis3d(TransInfo *t) { float zfac; - float mvec[3], axis[3], proj[3]; + float mvec[3], proj[3]; float len[3]; - int i, icoord[2]; + int i; /* calculate mouse movement */ mvec[0] = (float)(t->mval[0] - t->con.imval[0]); @@ -950,15 +950,16 @@ static void setNearestAxis3d(TransInfo *t) zfac = len_v3(t->persinv[0]) * 2.0f / t->ar->winx * zfac * 30.0f; for (i = 0; i < 3; i++) { + float axis[3], axis_2d[2]; + copy_v3_v3(axis, t->con.mtx[i]); mul_v3_fl(axis, zfac); /* now we can project to get window coordinate */ add_v3_v3(axis, t->con.center); - projectIntView(t, axis, icoord); + projectFloatView(t, axis, axis_2d); - axis[0] = (float)(icoord[0] - t->center2d[0]); - axis[1] = (float)(icoord[1] - t->center2d[1]); + sub_v2_v2v2(axis, axis_2d, t->center2d); axis[2] = 0.0f; if (normalize_v3(axis) != 0.0f) { -- cgit v1.2.3 From 0af52adac044d4851b95dd238ba209593f106996 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Nov 2013 04:16:41 +1100 Subject: Code Cleanup: remove unused members for editfont (3D text) --- source/blender/blenkernel/BKE_font.h | 2 -- source/blender/blenkernel/intern/curve.c | 4 ---- source/blender/editors/curve/editfont.c | 9 --------- 3 files changed, 15 deletions(-) diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h index 028ff0f93d6..8f5ccf1087e 100644 --- a/source/blender/blenkernel/BKE_font.h +++ b/source/blender/blenkernel/BKE_font.h @@ -63,8 +63,6 @@ typedef struct EditFont { wchar_t *textbuf; struct CharInfo *textbufinfo; - wchar_t *oldstr; - struct CharInfo *oldstrinfo; float textcurs[4][2]; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 4524b3ac7ac..b31be3f0067 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -104,10 +104,6 @@ void BKE_curve_editfont_free(Curve *cu) if (cu->editfont) { EditFont *ef = cu->editfont; - if (ef->oldstr) - MEM_freeN(ef->oldstr); - if (ef->oldstrinfo) - MEM_freeN(ef->oldstrinfo); if (ef->textbuf) MEM_freeN(ef->textbuf); if (ef->textbufinfo) diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index dc58e84415c..6ba54145c25 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1442,18 +1442,14 @@ void make_editText(Object *obedit) ef->textbufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo"); ef->copybuf = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "texteditcopybuf"); ef->copybufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditcopybufinfo"); - ef->oldstr = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "oldstrbuf"); - ef->oldstrinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "oldstrbuf"); } /* Convert the original text to wchar_t */ BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT + 4); /* length is bogus */ - wcscpy(ef->oldstr, ef->textbuf); cu->len = wcslen(ef->textbuf); memcpy(ef->textbufinfo, cu->strinfo, (cu->len) * sizeof(CharInfo)); - memcpy(ef->oldstrinfo, cu->strinfo, (cu->len) * sizeof(CharInfo)); if (cu->pos > cu->len) cu->pos = cu->len; @@ -1471,11 +1467,6 @@ void load_editText(Object *obedit) Curve *cu = obedit->data; EditFont *ef = cu->editfont; - MEM_freeN(ef->oldstr); - ef->oldstr = NULL; - MEM_freeN(ef->oldstrinfo); - ef->oldstrinfo = NULL; - update_string(cu); if (cu->strinfo) -- cgit v1.2.3 From d232486b4093fbc306dadbc21bd3fde81284364d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Nov 2013 04:32:28 +1100 Subject: Fix T37543: Multiline 3D Text saved in edit mode breaks on load --- source/blender/blenkernel/intern/curve.c | 2 ++ source/blender/blenloader/intern/readfile.c | 2 ++ source/blender/editors/curve/editfont.c | 7 ------- source/blender/editors/object/object_edit.c | 2 +- source/blender/makesdna/DNA_curve_types.h | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index b31be3f0067..bcf0eafaa65 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -116,6 +116,8 @@ void BKE_curve_editfont_free(Curve *cu) MEM_freeN(ef); cu->editfont = NULL; } + + MEM_SAFE_FREE(cu->selboxes); } void BKE_curve_editNurb_keyIndex_free(EditNurb *editnurb) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 01a71cfd63d..de055b22d74 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3360,6 +3360,8 @@ static void lib_link_curve(FileData *fd, Main *main) cu->ipo = newlibadr_us(fd, cu->id.lib, cu->ipo); // XXX deprecated - old animation system cu->key = newlibadr_us(fd, cu->id.lib, cu->key); + + cu->selboxes = NULL; /* runtime, clear */ cu->id.flag -= LIB_NEED_LINK; } diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 6ba54145c25..8f536575a28 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1475,13 +1475,6 @@ void load_editText(Object *obedit) memcpy(cu->strinfo, ef->textbufinfo, (cu->len) * sizeof(CharInfo)); cu->len = strlen(cu->str); - - /* this memory system is weak... */ - - if (cu->selboxes) { - MEM_freeN(cu->selboxes); - cu->selboxes = NULL; - } } void free_editText(Object *obedit) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 02cbc1060df..2e011493fce 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -351,7 +351,7 @@ static bool ED_object_editmode_load_ex(Object *obedit, const bool freedata) load_editNurb(obedit); if (freedata) free_editNurb(obedit); } - else if (obedit->type == OB_FONT && freedata) { + else if (obedit->type == OB_FONT) { load_editText(obedit); if (freedata) free_editText(obedit); } diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index f1a2cd68f28..0141c4b61db 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -223,7 +223,7 @@ typedef struct Curve { float linewidth; char *str; - struct SelBox *selboxes; + struct SelBox *selboxes; /* runtime variable for drawing selections (editmode data) */ struct EditFont *editfont; char family[24]; -- cgit v1.2.3 From 30512d7c5586189d02e2b2e71d0d5257b0713a16 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 20 Nov 2013 19:09:24 +0100 Subject: Blender Internal: * Remove Stars feature. This was a quite minimalistic feature and there are better alternatives with more control (particles for example). Removal discussed during BCon13 developer meeting and already years before, time to do it.. Reviewed By: brecht Differential Revision: http://developer.blender.org/D17 --- release/scripts/startup/bl_ui/properties_world.py | 28 ---- source/blender/blenkernel/intern/ipo.c | 11 -- source/blender/blenkernel/intern/world.c | 2 - source/blender/editors/space_view3d/view3d_draw.c | 9 -- source/blender/makesdna/DNA_ipo_types.h | 1 + source/blender/makesdna/DNA_world_types.h | 7 +- source/blender/makesrna/intern/rna_world.c | 59 ------- source/blender/render/extern/include/RE_pipeline.h | 4 - .../blender/render/intern/source/convertblender.c | 176 --------------------- 9 files changed, 5 insertions(+), 292 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py index 0b8d8a45a08..0b6ce41eb5d 100644 --- a/release/scripts/startup/bl_ui/properties_world.py +++ b/release/scripts/startup/bl_ui/properties_world.py @@ -244,34 +244,6 @@ class WORLD_PT_mist(WorldButtonsPanel, Panel): layout.prop(world.mist_settings, "falloff") -class WORLD_PT_stars(WorldButtonsPanel, Panel): - bl_label = "Stars" - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER'} - - def draw_header(self, context): - world = context.world - - self.layout.prop(world.star_settings, "use_stars", text="") - - def draw(self, context): - layout = self.layout - - world = context.world - - layout.active = world.star_settings.use_stars - - split = layout.split() - - col = split.column() - col.prop(world.star_settings, "size") - col.prop(world.star_settings, "color_random", text="Colors") - - col = split.column() - col.prop(world.star_settings, "distance_min", text="Min. Dist") - col.prop(world.star_settings, "average_separation", text="Separation") - - class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, Panel): COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'} _context_path = "world" diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index ecc4a03d255..8ef3b7ef23d 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -712,17 +712,6 @@ static const char *world_adrcodes_to_paths(int adrcode, int *array_index) return "mist.start"; case WO_MISTHI: return "mist.height"; - - case WO_STAR_R: - case WO_STAR_G: - case WO_STAR_B: - printf("WARNING: WO_STAR_R/G/B deprecated\n"); - return NULL; - - case WO_STARDIST: - return "stars.min_distance"; - case WO_STARSIZE: - return "stars.size"; default: /* for now, we assume that the others were MTex channels */ return mtex_adrcodes_to_paths(adrcode, array_index); diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 206f829eaa8..c5a932e4173 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -92,8 +92,6 @@ World *add_world(Main *bmain, const char *name) wrld->zeng = 0.01f; wrld->zenb = 0.01f; wrld->skytype = 0; - wrld->stardist = 15.0f; - wrld->starsize = 2.0f; wrld->exp = 0.0f; wrld->exposure = wrld->range = 1.0f; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 1bf137e5787..abdf017c6ee 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -64,7 +64,6 @@ #include "BKE_movieclip.h" #include "RE_engine.h" -#include "RE_pipeline.h" /* make_stars */ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -3279,14 +3278,6 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { drawfloor(scene, v3d, grid_unit); } - if (rv3d->persp == RV3D_CAMOB) { - if (scene->world) { - if (scene->world->mode & WO_STARS) { - RE_make_stars(NULL, scene, star_stuff_init_func, star_stuff_vertex_func, - star_stuff_term_func); - } - } - } } else { if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h index 2699c6e576e..b4088cc5a5d 100644 --- a/source/blender/makesdna/DNA_ipo_types.h +++ b/source/blender/makesdna/DNA_ipo_types.h @@ -308,6 +308,7 @@ typedef struct Ipo { #define WO_MISTSTA 10 #define WO_MISTHI 11 +/* Stars are deprecated */ #define WO_STAR_R 12 #define WO_STAR_G 13 #define WO_STAR_B 14 diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h index a0863b18cca..44f7813bda0 100644 --- a/source/blender/makesdna/DNA_world_types.h +++ b/source/blender/makesdna/DNA_world_types.h @@ -96,8 +96,9 @@ typedef struct World { float misi, miststa, mistdist, misthi; float starr DNA_DEPRECATED, starg DNA_DEPRECATED, starb DNA_DEPRECATED, stark DNA_DEPRECATED; /* Deprecated */ - float starsize, starmindist; - float stardist, starcolnoise; + + float starsize DNA_DEPRECATED, starmindist DNA_DEPRECATED; + float stardist DNA_DEPRECATED, starcolnoise DNA_DEPRECATED; /* unused now: DOF */ short dofsta, dofend, dofmin, dofmax; @@ -142,7 +143,7 @@ typedef struct World { /* mode */ #define WO_MIST 1 -#define WO_STARS 2 +#define WO_STARS 2 /* deprecated */ /*#define WO_DOF 4*/ #define WO_ACTIVITY_CULLING 8 #define WO_ENV_LIGHT 16 diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index b689a82c231..c7997bebedb 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -56,10 +56,6 @@ static PointerRNA rna_World_lighting_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_WorldLighting, ptr->id.data); } -static PointerRNA rna_World_stars_get(PointerRNA *ptr) -{ - return rna_pointer_inherit_refine(ptr, &RNA_WorldStarsSettings, ptr->id.data); -} static PointerRNA rna_World_mist_get(PointerRNA *ptr) { @@ -114,14 +110,6 @@ static void rna_World_draw_mist_update(Main *UNUSED(bmain), Scene *UNUSED(scene) WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } -static void rna_World_stars_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - World *wo = ptr->id.data; - - DAG_id_tag_update(&wo->id, 0); - WM_main_add_notifier(NC_WORLD | ND_WORLD_STARS, wo); -} - static void rna_World_use_nodes_update(bContext *C, PointerRNA *ptr) { World *wrld = (World *)ptr->data; @@ -450,46 +438,6 @@ static void rna_def_world_mist(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_World_update"); } -static void rna_def_world_stars(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "WorldStarsSettings", NULL); - RNA_def_struct_sdna(srna, "World"); - RNA_def_struct_nested(brna, srna, "World"); - RNA_def_struct_ui_text(srna, "World Stars", "Stars settings for a World data-block"); - - prop = RNA_def_property(srna, "use_stars", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_STARS); - RNA_def_property_ui_text(prop, "Use Stars", "Enable starfield generation"); - RNA_def_property_update(prop, 0, "rna_World_stars_update"); - - prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "starsize"); - RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Size", "Average screen dimension of stars"); - RNA_def_property_update(prop, 0, "rna_World_draw_update"); /* use normal update since this isn't visualized */ - - prop = RNA_def_property(srna, "distance_min", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, NULL, "starmindist"); - RNA_def_property_range(prop, 0, 1000); - RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance to the camera for stars"); - RNA_def_property_update(prop, 0, "rna_World_stars_update"); - - prop = RNA_def_property(srna, "average_separation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "stardist"); - RNA_def_property_range(prop, 2, 1000); - RNA_def_property_ui_text(prop, "Average Separation", "Average distance between any two stars"); - RNA_def_property_update(prop, 0, "rna_World_stars_update"); - - prop = RNA_def_property(srna, "color_random", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "starcolnoise"); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Color Randomization", "Randomize star colors"); - RNA_def_property_update(prop, 0, "rna_World_stars_update"); -} - void RNA_def_world(BlenderRNA *brna) { StructRNA *srna; @@ -568,12 +516,6 @@ void RNA_def_world(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_World_mist_get", NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Mist", "World mist settings"); - prop = RNA_def_property(srna, "star_settings", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "WorldStarsSettings"); - RNA_def_property_pointer_funcs(prop, "rna_World_stars_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Stars", "World stars settings"); - /* nodes */ prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); @@ -588,7 +530,6 @@ void RNA_def_world(BlenderRNA *brna) rna_def_lighting(brna); rna_def_world_mist(brna); - rna_def_world_stars(brna); rna_def_world_mtex(brna); } diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 79826a63690..109524c9814 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -247,10 +247,6 @@ int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct /* do a full sample buffer compo */ void RE_MergeFullSample(struct Render *re, struct Main *bmain, struct Scene *sce, struct bNodeTree *ntree); -/* ancient stars function... go away! */ -void RE_make_stars(struct Render *re, struct Scene *scenev3d, void (*initfunc)(void), - void (*vertexfunc)(const float *), void (*termfunc)(void)); - /* display and event callbacks */ void RE_display_init_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)); void RE_display_clear_cb(struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index b4873e7d310..c5c804e9700 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -160,175 +160,6 @@ static HaloRen *initstar(Render *re, ObjectRen *obr, const float vec[3], float h return har; } -/* there must be a 'fixed' amount of stars generated between - * near and far - * all stars must by preference lie on the far and solely - * differ in clarity/color - */ - -void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), - void (*vertexfunc)(const float *), void (*termfunc)(void)) -{ - extern unsigned char hash[512]; - ObjectRen *obr= NULL; - World *wrld= NULL; - HaloRen *har; - Scene *scene; - Object *camera; - Camera *cam; - RNG *rng; - double dblrand, hlfrand; - float vec[4], fx, fy, fz; - float fac, starmindist, clipend; - float mat[4][4], stargrid, maxrand, maxjit, force, alpha; - int x, y, z, sx, sy, sz, ex, ey, ez, done = FALSE; - unsigned int totstar= 0; - - if (initfunc) { - scene= scenev3d; - wrld= scene->world; - } - else { - scene= re->scene; - wrld= &(re->wrld); - } - - stargrid = wrld->stardist; /* distance between stars */ - maxrand = 2.0; /* amount a star can be shifted (in grid units) */ - maxjit = (wrld->starcolnoise); /* amount a color is being shifted */ - - /* size of stars */ - force = ( wrld->starsize ); - - /* minimal free space (starting at camera) */ - starmindist= wrld->starmindist; - - if (stargrid <= 0.10f) return; - - if (re) re->flag |= R_HALO; - else stargrid *= 1.0f; /* then it draws fewer */ - - if (re) invert_m4_m4(mat, re->viewmat); - else unit_m4(mat); - - /* BOUNDING BOX CALCULATION - * bbox goes from z = loc_near_var | loc_far_var, - * x = -z | +z, - * y = -z | +z - */ - - camera= re ? RE_GetCamera(re) : scene->camera; - - if (camera==NULL || camera->type != OB_CAMERA) - return; - - cam = camera->data; - clipend = cam->clipend; - - /* convert to grid coordinates */ - - sx = ((mat[3][0] - clipend) / stargrid) - maxrand; - sy = ((mat[3][1] - clipend) / stargrid) - maxrand; - sz = ((mat[3][2] - clipend) / stargrid) - maxrand; - - ex = ((mat[3][0] + clipend) / stargrid) + maxrand; - ey = ((mat[3][1] + clipend) / stargrid) + maxrand; - ez = ((mat[3][2] + clipend) / stargrid) + maxrand; - - dblrand = maxrand * stargrid; - hlfrand = 2.0 * dblrand; - - if (initfunc) { - initfunc(); - } - - if (re) /* add render object for stars */ - obr= RE_addRenderObject(re, NULL, NULL, 0, 0, 0); - - rng = BLI_rng_new(0); - - for (x = sx, fx = sx * stargrid; x <= ex; x++, fx += stargrid) { - for (y = sy, fy = sy * stargrid; y <= ey; y++, fy += stargrid) { - for (z = sz, fz = sz * stargrid; z <= ez; z++, fz += stargrid) { - - BLI_rng_seed(rng, (hash[z & 0xff] << 24) + (hash[y & 0xff] << 16) + (hash[x & 0xff] << 8)); - vec[0] = fx + (hlfrand * BLI_rng_get_double(rng)) - dblrand; - vec[1] = fy + (hlfrand * BLI_rng_get_double(rng)) - dblrand; - vec[2] = fz + (hlfrand * BLI_rng_get_double(rng)) - dblrand; - vec[3] = 1.0; - - if (vertexfunc) { - if (done & 1) vertexfunc(vec); - done++; - } - else { - if (re) - mul_m4_v3(re->viewmat, vec); - - /* in vec are global coordinates - * calculate distance to camera - * and using that, define the alpha - */ - alpha = len_v3(vec); - - if (alpha >= clipend) alpha = 0.0; - else if (alpha <= starmindist) alpha = 0.0; - else if (alpha <= 2.0f * starmindist) { - alpha = (alpha - starmindist) / starmindist; - } - else { - alpha -= 2.0f * starmindist; - alpha /= (clipend - 2.0f * starmindist); - alpha = 1.0f - alpha; - } - - - if (alpha != 0.0f) { - fac = force * BLI_rng_get_double(rng); - - har = initstar(re, obr, vec, fac); - - if (har) { - har->alfa = sqrt(sqrt(alpha)); - har->add= 255; - har->r = har->g = har->b = 1.0; - if (maxjit) { - har->r += ((maxjit * BLI_rng_get_double(rng)) ) - maxjit; - har->g += ((maxjit * BLI_rng_get_double(rng)) ) - maxjit; - har->b += ((maxjit * BLI_rng_get_double(rng)) ) - maxjit; - } - har->hard = 32; - har->lay= -1; - har->type |= HA_ONLYSKY; - done++; - } - } - } - - /* break out of the loop if generating stars takes too long */ - if (re && !(totstar % 1000000)) { - if (re->test_break(re->tbh)) { - x= ex + 1; - y= ey + 1; - z= ez + 1; - } - } - - totstar++; - } - /* do not call blender_test_break() here, since it is used in UI as well, confusing the callback system */ - /* main cause is G.is_break of course, a global again... (ton) */ - } - } - if (termfunc) termfunc(); - - if (obr) - re->tothalo += obr->tothalo; - - BLI_rng_free(rng); -} - - /* ------------------------------------------------------------------------- */ /* tool functions/defines for ad hoc simplification and possible future * cleanup */ @@ -5370,13 +5201,6 @@ void RE_Database_Preprocess(Render *re) /* don't sort stars */ tothalo= re->tothalo; - if (!re->test_break(re->tbh)) { - if (re->wrld.mode & WO_STARS) { - re->i.infostr = IFACE_("Creating Starfield"); - re->stats_draw(re->sdh, &re->i); - RE_make_stars(re, NULL, NULL, NULL, NULL); - } - } sort_halos(re, tothalo); init_camera_inside_volumes(re); -- cgit v1.2.3 From b0ea93aa9d74d09833fa19fcff4b1f04365906ac Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 20 Nov 2013 19:37:23 +0100 Subject: * Remove more code for stars, missed those. Sorry! --- source/blender/editors/space_view3d/space_view3d.c | 8 ------- source/blender/editors/space_view3d/view3d_draw.c | 15 ------------ source/blender/makesdna/DNA_world_types.h | 3 +-- source/blender/makesrna/RNA_access.h | 1 - .../blender/render/intern/source/convertblender.c | 27 ---------------------- source/blender/render/intern/source/pixelshading.c | 1 - source/blender/windowmanager/WM_types.h | 1 - 7 files changed, 1 insertion(+), 55 deletions(-) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 3fbb78ac016..b803a4a8473 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -843,14 +843,6 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN case ND_WORLD_DRAW: /* handled by space_view3d_listener() for v3d access */ break; - case ND_WORLD_STARS: - { - RegionView3D *rv3d = ar->regiondata; - if (rv3d->persp == RV3D_CAMOB) { - ED_region_tag_redraw(ar); - } - break; - } } break; case NC_LAMP: diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index abdf017c6ee..dc00e55e0f4 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -106,21 +106,6 @@ extern void bl_debug_draw_quad_add(const float v0[3], const float v1[3], const f extern void bl_debug_draw_edge_add(const float v0[3], const float v1[3]); #endif -static void star_stuff_init_func(void) -{ - cpack(0xFFFFFF); - glPointSize(1.0); - glBegin(GL_POINTS); -} -static void star_stuff_vertex_func(const float vec[3]) -{ - glVertex3fv(vec); -} -static void star_stuff_term_func(void) -{ - glEnd(); -} - void circf(float x, float y, float rad) { GLUquadricObj *qobj = gluNewQuadric(); diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h index 44f7813bda0..3e01e159d6c 100644 --- a/source/blender/makesdna/DNA_world_types.h +++ b/source/blender/makesdna/DNA_world_types.h @@ -47,7 +47,7 @@ struct MTex; /** * World defines general modeling data such as a background fill, - * gravity, color model, stars, etc. It mixes game-data, rendering + * gravity, color model etc. It mixes game-data, rendering * data and modeling data. */ typedef struct World { ID id; @@ -96,7 +96,6 @@ typedef struct World { float misi, miststa, mistdist, misthi; float starr DNA_DEPRECATED, starg DNA_DEPRECATED, starb DNA_DEPRECATED, stark DNA_DEPRECATED; /* Deprecated */ - float starsize DNA_DEPRECATED, starmindist DNA_DEPRECATED; float stardist DNA_DEPRECATED, starcolnoise DNA_DEPRECATED; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index f5afff56545..d82bae1ce57 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -660,7 +660,6 @@ extern StructRNA RNA_World; extern StructRNA RNA_WorldAmbientOcclusion; extern StructRNA RNA_WorldLighting; extern StructRNA RNA_WorldMistSettings; -extern StructRNA RNA_WorldStarsSettings; extern StructRNA RNA_WorldTextureSlot; extern StructRNA RNA_XnorController; extern StructRNA RNA_XorController; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index c5c804e9700..fb9f96b0ef7 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -134,32 +134,6 @@ # pragma GCC diagnostic ignored "-Wdouble-promotion" #endif -/* ------------------------------------------------------------------------- */ - -/* Stuff for stars. This sits here because it uses gl-things. Part of - * this code may move down to the converter. */ -/* ------------------------------------------------------------------------- */ -/* this is a bad beast, since it is misused by the 3d view drawing as well. */ - -static HaloRen *initstar(Render *re, ObjectRen *obr, const float vec[3], float hasize) -{ - HaloRen *har; - float hoco[4]; - - projectverto(vec, re->winmat, hoco); - - har= RE_findOrAddHalo(obr, obr->tothalo++); - - /* projectvert is done in function zbufvlaggen again, because of parts */ - copy_v3_v3(har->co, vec); - har->hasize= hasize; - - har->zd= 0.0; - har->pool = re->pool; - - return har; -} - /* ------------------------------------------------------------------------- */ /* tool functions/defines for ad hoc simplification and possible future * cleanup */ @@ -5199,7 +5173,6 @@ void RE_Database_Preprocess(Render *re) if (!re->test_break(re->tbh)) { int tothalo; - /* don't sort stars */ tothalo= re->tothalo; sort_halos(re, tothalo); diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 43e052a6efc..feaf68a8c4a 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -289,7 +289,6 @@ int shadeHaloFloat(HaloRen *har, float col[4], int zz, if (R.wrld.mode & WO_MIST) { if (har->type & HA_ONLYSKY) { - /* stars but no mist */ alpha= har->alfa; } else { diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 6538272a43c..dabb90b2ba0 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -311,7 +311,6 @@ typedef struct wmNotifier { /* NC_WORLD World */ #define ND_WORLD_DRAW (45<<16) -#define ND_WORLD_STARS (46<<16) /* NC_TEXT Text */ #define ND_CURSOR (50<<16) -- cgit v1.2.3 From 7cdfe18385b8ab1036a2208860d73af920533ae3 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 20 Nov 2013 23:47:05 +0200 Subject: Fix compile error on MinGW64, time.h is required for gmtime. --- source/blender/blenloader/intern/readfile.c | 1 + source/creator/creator.c | 1 + 2 files changed, 2 insertions(+) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index de055b22d74..ddb045de290 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -40,6 +40,7 @@ #include // for strrchr strncmp strstr #include // for fabs #include /* for va_start/end */ +#include /* for gmtime */ #include "BLI_utildefines.h" #ifndef WIN32 diff --git a/source/creator/creator.c b/source/creator/creator.c index adedab80338..420dceb812b 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -63,6 +63,7 @@ #include #include #include +#include /* This little block needed for linking to Blender... */ -- cgit v1.2.3 From ac021a42addfde0ea3ea8437936142718f4a786c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Nov 2013 10:35:48 +1100 Subject: Code Cleanup: use strict flags for screw modifier, reduce sign conversion --- source/blender/makesdna/DNA_modifier_types.h | 9 ++- source/blender/modifiers/intern/MOD_screw.c | 113 ++++++++++++++------------- 2 files changed, 64 insertions(+), 58 deletions(-) diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 43de7166c4f..11bdf707c45 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -822,12 +822,13 @@ typedef struct ScrewModifierData { ModifierData modifier; struct Object *ob_axis; - int steps; - int render_steps; - int iter; + unsigned int steps; + unsigned int render_steps; + unsigned int iter; float screw_ofs; float angle; - short axis; + char axis; + char pad; short flag; } ScrewModifierData; diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index f3d5157a6ef..7955e02cdb6 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -34,6 +34,7 @@ /* Screw modifier: revolves the edges about an axis */ +#include #include "DNA_meshdata_types.h" #include "DNA_object_types.h" @@ -41,19 +42,20 @@ #include "BLI_math.h" #include "BLI_utildefines.h" - #include "BKE_cdderivedmesh.h" #include "depsgraph_private.h" #include "MOD_modifiertypes.h" #include "MEM_guardedalloc.h" +#include "BLI_strict_flags.h" + /* used for gathering edge connectivity */ typedef struct ScrewVertConnect { float dist; /* distance from the center axis */ float co[3]; /* loaction relative to the transformed axis */ float no[3]; /* calc normal of the vertex */ - int v[2]; /* 2 verts on either side of this one */ + unsigned int v[2]; /* 2 verts on either side of this one */ MEdge *e[2]; /* edges on either side, a bit of a waste since each edge ref's 2 edges */ char flag; } ScrewVertConnect; @@ -61,18 +63,20 @@ typedef struct ScrewVertConnect { typedef struct ScrewVertIter { ScrewVertConnect *v_array; ScrewVertConnect *v_poin; - int v; - int v_other; + unsigned int v, v_other; MEdge *e; } ScrewVertIter; +#define SV_UNUSED (UINT_MAX) +#define SV_INVALID ((UINT_MAX) - 1) +#define SV_IS_VALID(v) (v < SV_INVALID) -static void screwvert_iter_init(ScrewVertIter *iter, ScrewVertConnect *array, int v_init, int dir) +static void screwvert_iter_init(ScrewVertIter *iter, ScrewVertConnect *array, unsigned int v_init, unsigned int dir) { iter->v_array = array; iter->v = v_init; - if (v_init >= 0) { + if (SV_IS_VALID(v_init)) { iter->v_poin = &array[v_init]; iter->v_other = iter->v_poin->v[dir]; iter->e = iter->v_poin->e[!dir]; @@ -94,7 +98,7 @@ static void screwvert_iter_step(ScrewVertIter *iter) iter->v_other = iter->v; iter->v = iter->v_poin->v[0]; } - if (iter->v >= 0) { + if (SV_IS_VALID(iter->v)) { iter->v_poin = &iter->v_array[iter->v]; iter->e = iter->v_poin->e[(iter->v_poin->e[0] == iter->e)]; } @@ -109,7 +113,7 @@ static void initData(ModifierData *md) { ScrewModifierData *ltmd = (ScrewModifierData *) md; ltmd->ob_axis = NULL; - ltmd->angle = M_PI * 2.0; + ltmd->angle = (float)(M_PI * 2.0); ltmd->axis = 2; ltmd->flag = MOD_SCREW_SMOOTH_SHADING; ltmd->steps = 16; @@ -143,18 +147,19 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, int *origindex; int mpoly_index = 0; - int step; - int i, j; + unsigned int step; + unsigned int i, j; unsigned int i1, i2; - int step_tot = useRenderParams ? ltmd->render_steps : ltmd->steps; - const int do_flip = ltmd->flag & MOD_SCREW_NORMAL_FLIP ? 1 : 0; - int maxVerts = 0, maxEdges = 0, maxPolys = 0; - const unsigned int totvert = dm->getNumVerts(dm); - const unsigned int totedge = dm->getNumEdges(dm); - const unsigned int totpoly = dm->getNumPolys(dm); - int *edge_poly_map = NULL; - - char axis_char = 'X', close; + unsigned int step_tot = useRenderParams ? ltmd->render_steps : ltmd->steps; + const bool do_flip = ltmd->flag & MOD_SCREW_NORMAL_FLIP ? 1 : 0; + unsigned int maxVerts = 0, maxEdges = 0, maxPolys = 0; + const unsigned int totvert = (unsigned int)dm->getNumVerts(dm); + const unsigned int totedge = (unsigned int)dm->getNumEdges(dm); + const unsigned int totpoly = (unsigned int)dm->getNumPolys(dm); + unsigned int *edge_poly_map = NULL; + + char axis_char = 'X'; + bool close; float angle = ltmd->angle; float screw_ofs = ltmd->screw_ofs; float axis_vec[3] = {0.0f, 0.0f, 0.0f}; @@ -164,11 +169,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, float mtx_tx_inv[4][4]; /* inverted */ float mtx_tmp_a[4][4]; - int vc_tot_linked = 0; + unsigned int vc_tot_linked = 0; short other_axis_1, other_axis_2; float *tmpf1, *tmpf2; - int edge_offset; + unsigned int edge_offset; MPoly *mpoly_orig, *mpoly_new, *mp_new; MLoop *mloop_orig, *mloop_new, *ml_new; @@ -261,7 +266,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } else { /* exis char is used by i_rotate*/ - axis_char += ltmd->axis; /* 'X' + axis */ + axis_char = (char)(axis_char + ltmd->axis); /* 'X' + axis */ /* useful to be able to use the axis vec in some cases still */ zero_v3(axis_vec); @@ -269,8 +274,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* apply the multiplier */ - angle *= ltmd->iter; - screw_ofs *= ltmd->iter; + angle *= (float)ltmd->iter; + screw_ofs *= (float)ltmd->iter; /* multiplying the steps is a bit tricky, this works best */ step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1); @@ -301,7 +306,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, maxPolys = totedge * (step_tot - 1); } - result = CDDM_from_template(dm, maxVerts, maxEdges, 0, maxPolys * 4, maxPolys); + result = CDDM_from_template(dm, (int)maxVerts, (int)maxEdges, 0, (int)maxPolys * 4, (int)maxPolys); /* copy verts from mesh */ mvert_orig = dm->getVertArray(dm); @@ -313,12 +318,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, medge_new = result->getEdgeArray(result); if (!CustomData_has_layer(&result->polyData, CD_ORIGINDEX)) { - CustomData_add_layer(&result->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, maxPolys); + CustomData_add_layer(&result->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, (int)maxPolys); } origindex = CustomData_get_layer(&result->polyData, CD_ORIGINDEX); - DM_copy_vert_data(dm, result, 0, 0, totvert); /* copy first otherwise this overwrites our own vertex normals */ + DM_copy_vert_data(dm, result, 0, 0, (int)totvert); /* copy first otherwise this overwrites our own vertex normals */ /* Set the locations of the first set of verts */ @@ -342,12 +347,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mpoly_orig = dm->getPolyArray(dm); mloop_orig = dm->getLoopArray(dm); edge_poly_map = MEM_mallocN(sizeof(*edge_poly_map) * totedge, __func__); - fill_vn_i(edge_poly_map, totedge, -1); + memset(edge_poly_map, 0xff, sizeof(*edge_poly_map) * totedge); for (i = 0, mp_orig = mpoly_orig; i < totpoly; i++, mp_orig++) { MLoop *ml_orig = &mloop_orig[mp_orig->loopstart]; - int j; - for (j = 0; j < mp_orig->totloop; j++, ml_orig++) { + int k; + for (k = 0; k < mp_orig->totloop; k++, ml_orig++) { edge_poly_map[ml_orig->e] = i; /* also order edges based on faces */ @@ -410,7 +415,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, vc->flag = 0; vc->e[0] = vc->e[1] = NULL; - vc->v[0] = vc->v[1] = -1; + vc->v[0] = vc->v[1] = SV_UNUSED; mul_m4_v3(mtx_tx, vc->co); /* length in 2d, don't sqrt because this is only for comparison */ @@ -428,7 +433,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, vc->flag = 0; vc->e[0] = vc->e[1] = NULL; - vc->v[0] = vc->v[1] = -1; + vc->v[0] = vc->v[1] = SV_UNUSED; /* length in 2d, don't sqrt because this is only for comparison */ vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + @@ -442,31 +447,31 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, for (i = 0; i < totedge; i++, med_new++) { vc = &vert_connect[med_new->v1]; - if (vc->v[0] == -1) { /* unused */ + if (vc->v[0] == SV_UNUSED) { /* unused */ vc->v[0] = med_new->v2; vc->e[0] = med_new; } - else if (vc->v[1] == -1) { + else if (vc->v[1] == SV_UNUSED) { vc->v[1] = med_new->v2; vc->e[1] = med_new; } else { - vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */ + vc->v[0] = vc->v[1] = SV_INVALID; /* error value - don't use, 3 edges on vert */ } vc = &vert_connect[med_new->v2]; /* same as above but swap v1/2 */ - if (vc->v[0] == -1) { /* unused */ + if (vc->v[0] == SV_UNUSED) { /* unused */ vc->v[0] = med_new->v1; vc->e[0] = med_new; } - else if (vc->v[1] == -1) { + else if (vc->v[1] == SV_UNUSED) { vc->v[1] = med_new->v1; vc->e[1] = med_new; } else { - vc->v[0] = vc->v[1] = -2; /* error value - don't use, 3 edges on vert */ + vc->v[0] = vc->v[1] = SV_INVALID; /* error value - don't use, 3 edges on vert */ } } @@ -477,12 +482,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, * so resulting faces are flipped the right way */ vc_tot_linked = 0; /* count the number of linked verts for this loop */ if (vc->flag == 0) { - int v_best = -1, ed_loop_closed = 0; /* vert and vert new */ + unsigned int v_best = SV_UNUSED, ed_loop_closed = 0; /* vert and vert new */ ScrewVertIter lt_iter; float fl = -1.0f; /* compiler complains if not initialized, but it should be initialized below */ - int ed_loop_flip = 0; + bool ed_loop_flip = false; /*printf("Loop on connected vert: %i\n", i);*/ @@ -496,7 +501,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /*printf("\t\tVERT: %i\n", lt_iter.v);*/ if (lt_iter.v_poin->flag) { /*printf("\t\t\tBreaking Found end\n");*/ - //endpoints[0] = endpoints[1] = -1; + //endpoints[0] = endpoints[1] = SV_UNUSED; ed_loop_closed = 1; /* circle */ break; } @@ -518,7 +523,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* now we have a collection of used edges. flip their edges the right way*/ - /*if (v_best != -1) - */ + /*if (v_best != SV_UNUSED) - */ /*printf("Done Looking - vc_tot_linked: %i\n", vc_tot_linked);*/ @@ -532,7 +537,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* edge connects on each side! */ - if ((vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) { + if (SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1])) { /*printf("Verts on each side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ /* find out which is higher */ @@ -561,7 +566,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } } } - else if (vc_tmp->v[0] >= 0) { /*vertex only connected on 1 side */ + else if (SV_IS_VALID(vc_tmp->v[0])) { /*vertex only connected on 1 side */ /*printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */ ed_loop_flip = 1; @@ -602,7 +607,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* If this is the vert off the best vert and * the best vert has 2 edges connected too it * then swap the flip direction */ - if (j == 1 && (vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) + if (j == 1 && SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1])) ed_loop_flip = !ed_loop_flip; while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) { @@ -647,8 +652,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, * * calculate vertex normals that can be propagated on lathing * use edge connectivity work this out */ - if (vc->v[0] >= 0) { - if (vc->v[1] >= 0) { + if (SV_IS_VALID(vc->v[0])) { + if (SV_IS_VALID(vc->v[1])) { /* 2 edges connedted */ /* make 2 connecting vert locations relative to the middle vert */ sub_v3_v3v3(tmp_vec1, mvert_new[vc->v[0]].co, mvert_new[i].co); @@ -714,12 +719,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* Add Faces */ for (step = 1; step < step_tot; step++) { - const int varray_stride = totvert * step; + const unsigned int varray_stride = totvert * step; float step_angle; float nor_tx[3]; float mat[4][4]; /* Rotation Matrix */ - step_angle = (angle / (step_tot - (!close))) * step; + step_angle = (angle / (float)(step_tot - (!close))) * (float)step; if (ltmd->ob_axis) { axis_angle_normalized_to_mat3(mat3, axis_vec, step_angle); @@ -735,7 +740,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)step / (float)(step_tot - 1))); /* copy a slice */ - DM_copy_vert_data(dm, result, 0, varray_stride, totvert); + DM_copy_vert_data(dm, result, 0, (int)varray_stride, (int)totvert); mv_new_base = mvert_new; mv_new = &mvert_new[varray_stride]; /* advance to the next slice */ @@ -782,7 +787,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (close) { /* last loop of edges, previous loop dosnt account for the last set of edges */ - const int varray_stride = (step_tot - 1) * totvert; + const unsigned int varray_stride = (step_tot - 1) * totvert; for (i = 0; i < totvert; i++) { med_new->v1 = i; @@ -806,7 +811,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, i1 = med_new_firstloop->v1; i2 = med_new_firstloop->v2; - if (totpoly && (edge_poly_map[i] != -1)) { + if (totpoly && (edge_poly_map[i] != UINT_MAX)) { mat_nr = mpoly_orig[edge_poly_map[i]].mat_nr; } else { @@ -907,10 +912,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* validate loop edges */ #if 0 { - i = 0; + unsigned i = 0; printf("\n"); for (; i < maxPolys * 4; i += 4) { - int ii; + unsigned int ii; ml_new = mloop_new + i; ii = findEd(medge_new, maxEdges, ml_new[0].v, ml_new[1].v); printf("%d %d -- ", ii, ml_new[0].e); -- cgit v1.2.3 From 98bf859efc1835c9df28d7727854438de81825a7 Mon Sep 17 00:00:00 2001 From: IRIE Shinsuke Date: Thu, 21 Nov 2013 04:02:00 +0900 Subject: Blender Internal: Add shader nodes "Separate HSV" and "Combine HSV", same as Cycles' ones. --- release/scripts/startup/nodeitems_builtins.py | 2 ++ .../blender/gpu/shaders/gpu_shader_material.glsl | 15 +++++++++++ .../nodes/shader/nodes/node_shader_sepcombHSV.c | 30 ++++++++++++++++++++-- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 71ff547f6da..fdda753372f 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -141,6 +141,8 @@ shader_node_categories = [ NodeItem("ShaderNodeSqueeze"), NodeItem("ShaderNodeSeparateRGB"), NodeItem("ShaderNodeCombineRGB"), + NodeItem("ShaderNodeSeparateHSV"), + NodeItem("ShaderNodeCombineHSV"), ]), ShaderOldNodeCategory("SH_GROUP", "Group", items=node_group_items), ShaderOldNodeCategory("SH_LAYOUT", "Layout", items=[ diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 5e5fac3049c..b2c7c2e3cef 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -735,6 +735,21 @@ void combine_rgb(float r, float g, float b, out vec4 col) col = vec4(r, g, b, 1.0); } +void separate_hsv(vec4 col, out float h, out float s, out float v) +{ + vec4 hsv; + + rgb_to_hsv(col, hsv); + h = hsv[0]; + s = hsv[1]; + v = hsv[2]; +} + +void combine_hsv(float h, float s, float v, out vec4 col) +{ + hsv_to_rgb(vec4(h, s, v, 1.0), col); +} + void output_node(vec4 rgb, float alpha, out vec4 outrgb) { outrgb = vec4(rgb.rgb, alpha); diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c index 707e295241a..2c515d587c0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c @@ -44,13 +44,26 @@ static bNodeSocketTemplate sh_node_sephsv_out[] = { { -1, 0, "" } }; +static void node_shader_exec_sephsv(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) +{ + rgb_to_hsv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], + &out[0]->vec[0], &out[1]->vec[0], &out[2]->vec[0]); +} + +static int gpu_shader_sephsv(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) +{ + return GPU_stack_link(mat, "separate_hsv", in, out); +} + void register_node_type_sh_sephsv(void) { static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out); + node_type_exec(&ntype, NULL, NULL, node_shader_exec_sephsv); + node_type_gpu(&ntype, gpu_shader_sephsv); nodeRegisterType(&ntype); } @@ -68,13 +81,26 @@ static bNodeSocketTemplate sh_node_combhsv_out[] = { { -1, 0, "" } }; +static void node_shader_exec_combhsv(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) +{ + hsv_to_rgb(in[0]->vec[0], in[1]->vec[0], in[2]->vec[0], + &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2]); +} + +static int gpu_shader_combhsv(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) +{ + return GPU_stack_link(mat, "combine_hsv", in, out); +} + void register_node_type_sh_combhsv(void) { static bNodeType ntype; sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out); + node_type_exec(&ntype, NULL, NULL, node_shader_exec_combhsv); + node_type_gpu(&ntype, gpu_shader_combhsv); nodeRegisterType(&ntype); } -- cgit v1.2.3 From 91f0a38ad69149fb3e6c57e8a8c4ddff34c03f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Thu, 21 Nov 2013 10:45:52 +0100 Subject: Fix T37558: Cosmetic label change to indicate that the path for individual inputs in the File Output node is actually a sub-path based on the overall node file path. --- source/blender/editors/space_node/drawnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 50a4b515490..b33c3d6c228 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1635,7 +1635,7 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi else { col = uiLayoutColumn(layout, TRUE); - uiItemL(col, IFACE_("File Path:"), ICON_NONE); + uiItemL(col, IFACE_("File Subpath:"), ICON_NONE); row = uiLayoutRow(col, FALSE); uiItemR(row, &active_input_ptr, "path", 0, "", ICON_NONE); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", -- cgit v1.2.3 From 044a342ecb6ec1377c91c0b3ab37aca5335fbc9d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 21 Nov 2013 19:11:24 +0600 Subject: Fix a wrong check ls == NULL || lb->first == NULL --- source/blender/editors/space_view3d/drawobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 2083da2d64f..ee9ed96cd33 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -4058,7 +4058,7 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3 if (BKE_mball_is_basis(ob)) { lb = ob->curve_cache ? &ob->curve_cache->disp : NULL; - if (ELEM(lb, lb->first, NULL)) { + if (ELEM(NULL, lb, lb->first)) { BKE_displist_make_mball(scene, ob); lb = &ob->curve_cache->disp; } -- cgit v1.2.3 From 254aa8f3a0fbffcbcb886cfaa81b630ae3e9bb78 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 21 Nov 2013 14:43:08 +0100 Subject: Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 6f97e194e58aab38d351c796bf7bb6abca33f5f9 Author: Bastien Montagne Date: Wed Nov 20 21:18:20 2013 +0100 Code cleanup: Move some uiBut->flag to uiBut->drawflag, make those flags anonymous enums. Summary: Make some room in but->flag (I did not add another flag, we already have drawflag, which was nearly not used up till now). Note: I’m not sure whether REDALERT (and perhaps even DISABLED?) should not go to but->drawflag as well... Related to D8 Reviewers: brecht Differential Revision: http://developer.blender.org/D22 --- source/blender/editors/include/UI_interface.h | 82 ++++++++++++---------- source/blender/editors/interface/interface.c | 30 ++++---- .../blender/editors/interface/interface_handlers.c | 2 +- .../blender/editors/interface/interface_intern.h | 16 +++-- .../blender/editors/interface/interface_layout.c | 16 ++--- .../blender/editors/interface/interface_regions.c | 12 ++-- .../editors/interface/interface_templates.c | 7 +- .../blender/editors/interface/interface_widgets.c | 30 ++++---- .../editors/space_buttons/buttons_texture.c | 4 +- source/blender/editors/space_file/file_panels.c | 2 +- source/blender/editors/space_node/node_templates.c | 11 +-- .../blender/editors/space_view3d/view3d_buttons.c | 4 +- 12 files changed, 112 insertions(+), 104 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 50e2e53dbf0..53bfc94dfdd 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -93,7 +93,7 @@ typedef struct uiLayout uiLayout; /* use for clamping popups within the screen */ #define UI_SCREEN_MARGIN 10 -/* uiBlock->dt */ +/* uiBlock->dt and uiBut->dt */ #define UI_EMBOSS 0 /* use widget style for drawing */ #define UI_EMBOSSN 1 /* Nothing, only icon and/or text */ #define UI_EMBOSSP 2 /* Pulldown menu style */ @@ -130,8 +130,7 @@ typedef struct uiLayout uiLayout; #define UI_BLOCK_POPUP_MEMORY (1 << 12) #define UI_BLOCK_CLIP_EVENTS (1 << 13) /* stop handling mouse events */ -/* XXX This comment is no more valid! Maybe it is now bits 14-17? */ -/* block->flag bits 12-15 are identical to but->flag bits */ +/* block->flag bits 14-17 are identical to but->drawflag bits */ #define UI_BLOCK_LIST_ITEM (1 << 19) @@ -148,46 +147,51 @@ typedef struct uiLayout uiLayout; #define UI_PNL_CLOSE (1 << 5) #define UI_PNL_SCALE (1 << 9) -/* warning the first 6 flags are internal */ -/* but->flag */ -#define UI_TEXT_LEFT (1 << 6) -#define UI_ICON_LEFT (1 << 7) -#define UI_ICON_SUBMENU (1 << 8) -#define UI_ICON_PREVIEW (1 << 9) - -#define UI_TEXT_RIGHT (1 << 10) -#define UI_BUT_NODE_LINK (1 << 11) -#define UI_BUT_NODE_ACTIVE (1 << 12) -#define UI_BUT_DRAG_LOCK (1 << 13) - -/* button align flag, for drawing groups together */ -#define UI_BUT_ALIGN (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN) -#define UI_BUT_ALIGN_TOP (1 << 14) -#define UI_BUT_ALIGN_LEFT (1 << 15) -#define UI_BUT_ALIGN_RIGHT (1 << 16) -#define UI_BUT_ALIGN_DOWN (1 << 17) - -#define UI_BUT_DISABLED (1 << 18) -#define UI_BUT_COLOR_LOCK (1 << 19) -#define UI_BUT_ANIMATED (1 << 20) -#define UI_BUT_ANIMATED_KEY (1 << 21) -#define UI_BUT_DRIVEN (1 << 22) -#define UI_BUT_REDALERT (1 << 23) -#define UI_BUT_INACTIVE (1 << 24) -#define UI_BUT_LAST_ACTIVE (1 << 25) -#define UI_BUT_UNDO (1 << 26) -#define UI_BUT_IMMEDIATE (1 << 27) -#define UI_BUT_NO_TOOLTIP (1 << 28) -#define UI_BUT_NO_UTF8 (1 << 29) - -#define UI_BUT_VEC_SIZE_LOCK (1 << 30) /* used to flag if color hsv-circle should keep luminance */ -#define UI_BUT_COLOR_CUBIC (1 << 31) /* cubic saturation for the color wheel */ +/* but->flag - general state flags. */ +enum { + /* warning, the first 6 flags are internal */ + UI_ICON_SUBMENU = (1 << 6), + UI_ICON_PREVIEW = (1 << 7), + + UI_BUT_NODE_LINK = (1 << 8), + UI_BUT_NODE_ACTIVE = (1 << 9), + UI_BUT_DRAG_LOCK = (1 << 10), + UI_BUT_DISABLED = (1 << 11), + UI_BUT_COLOR_LOCK = (1 << 12), + UI_BUT_ANIMATED = (1 << 13), + UI_BUT_ANIMATED_KEY = (1 << 14), + UI_BUT_DRIVEN = (1 << 15), + UI_BUT_REDALERT = (1 << 16), + UI_BUT_INACTIVE = (1 << 17), + UI_BUT_LAST_ACTIVE = (1 << 18), + UI_BUT_UNDO = (1 << 19), + UI_BUT_IMMEDIATE = (1 << 20), + UI_BUT_NO_UTF8 = (1 << 21), + + UI_BUT_VEC_SIZE_LOCK = (1 << 22), /* used to flag if color hsv-circle should keep luminance */ + UI_BUT_COLOR_CUBIC = (1 << 23), /* cubic saturation for the color wheel */ +}; #define UI_PANEL_WIDTH 340 #define UI_COMPACT_PANEL_WIDTH 160 -/* uiBut->drawflag */ -#define UI_BUT_DRAW_ENUM_ARROWS (1 << 0) /* draw enum-like up/down arrows for button */ +/* but->drawflag - these flags should only affect how the button is drawn. */ +enum { + /* draw enum-like up/down arrows for button */ + UI_BUT_DRAW_ENUM_ARROWS = (1 << 0), + /* Text and icon alignment (by default, they are centered). */ + UI_BUT_TEXT_LEFT = (1 << 1), + UI_BUT_ICON_LEFT = (1 << 2), + UI_BUT_TEXT_RIGHT = (1 << 3), + /* Prevent the button to show any tooltip. */ + UI_BUT_NO_TOOLTIP = (1 << 4), + /* button align flag, for drawing groups together (also used in uiBlock->flag!) */ + UI_BUT_ALIGN_TOP = (1 << 14), + UI_BUT_ALIGN_LEFT = (1 << 15), + UI_BUT_ALIGN_RIGHT = (1 << 16), + UI_BUT_ALIGN_DOWN = (1 << 17), + UI_BUT_ALIGN = (UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT | UI_BUT_ALIGN_DOWN), +}; /* scale fixed button widths by this to account for DPI */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 83b100db1b2..800fee648e7 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2604,7 +2604,7 @@ static void ui_block_do_align_but(uiBut *first, short nr) next = NULL; /* clear old flag */ - but->flag &= ~UI_BUT_ALIGN; + but->drawflag &= ~UI_BUT_ALIGN; if (flag == 0) { /* first case */ if (next) { @@ -2683,7 +2683,7 @@ static void ui_block_do_align_but(uiBut *first, short nr) } } - but->flag |= flag; + but->drawflag |= flag; /* merge coordinates */ if (prev) { @@ -2863,10 +2863,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, if ((block->flag & UI_BLOCK_LOOP) || ELEM8(but->type, MENU, TEX, LABEL, BLOCK, BUTM, SEARCH_MENU, PROGRESSBAR, SEARCH_MENU_UNLINK)) { - but->flag |= (UI_TEXT_LEFT | UI_ICON_LEFT); + but->drawflag |= (UI_BUT_TEXT_LEFT | UI_BUT_ICON_LEFT); } - but->flag |= (block->flag & UI_BUT_ALIGN); + but->drawflag |= (block->flag & UI_BUT_ALIGN); if (but->lock == TRUE) { if (but->lockstr) { @@ -3041,7 +3041,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s if (icon) { but->icon = (BIFIconID)icon; but->flag |= UI_HAS_ICON; - but->flag |= UI_ICON_LEFT; + but->drawflag |= UI_BUT_ICON_LEFT; } if (!RNA_property_editable(&but->rnapoin, prop)) { @@ -3430,7 +3430,7 @@ uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const ch { uiBut *but = ui_def_but(block, type, retval, str, x, y, width, height, poin, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); - but->flag |= UI_ICON_LEFT; + but->drawflag |= UI_BUT_ICON_LEFT; return but; } static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip) @@ -3481,7 +3481,7 @@ uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const c uiBut *but; but = ui_def_but_rna_propname(block, type, retval, str, x, y, width, height, ptr, propname, index, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); - but->flag |= UI_ICON_LEFT; + but->drawflag |= UI_BUT_ICON_LEFT; return but; } uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) @@ -3489,7 +3489,7 @@ uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, co uiBut *but; but = ui_def_but_rna(block, type, retval, str, x, y, width, height, ptr, prop, index, min, max, a1, a2, tip); ui_check_but_and_iconize(but, icon); - but->flag |= UI_ICON_LEFT; + but->drawflag |= UI_BUT_ICON_LEFT; return but; } uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip) @@ -3497,7 +3497,7 @@ uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int o uiBut *but; but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x, y, width, height, tip); ui_check_but_and_iconize(but, icon); - but->flag |= UI_ICON_LEFT; + but->drawflag |= UI_BUT_ICON_LEFT; return but; } uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip) @@ -3553,7 +3553,7 @@ void uiBlockFlipOrder(uiBlock *block) return; for (but = block->buttons.first; but; but = but->next) { - if (but->flag & UI_BUT_ALIGN) return; + if (but->drawflag & UI_BUT_ALIGN) return; if (but->rect.ymin < miny) miny = but->rect.ymin; if (but->rect.ymax > maxy) maxy = but->rect.ymax; } @@ -3794,7 +3794,7 @@ uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, in but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; - but->flag |= UI_ICON_LEFT; + but->drawflag |= UI_BUT_ICON_LEFT; but->flag |= UI_ICON_SUBMENU; but->menu_create_func = func; @@ -3809,7 +3809,7 @@ uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int ic but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; - but->flag &= ~UI_ICON_LEFT; + but->drawflag &= ~UI_BUT_ICON_LEFT; but->menu_create_func = func; ui_check_but(but); @@ -3825,7 +3825,7 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, /* XXX temp, old menu calls pass on icon arrow, which is now UI_ICON_SUBMENU flag */ if (icon != ICON_RIGHTARROW_THIN) { but->icon = (BIFIconID) icon; - but->flag |= UI_ICON_LEFT; + but->drawflag |= UI_BUT_ICON_LEFT; } but->flag |= UI_HAS_ICON; but->flag |= UI_ICON_SUBMENU; @@ -3844,7 +3844,7 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; - but->flag |= UI_ICON_LEFT; + but->drawflag |= UI_BUT_ICON_LEFT; but->block_create_func = func; ui_check_but(but); @@ -3879,7 +3879,7 @@ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxle but->icon = (BIFIconID) icon; but->flag |= UI_HAS_ICON; - but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT; + but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT; ui_check_but(but); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 2b8b7643f39..33a054318b6 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -881,7 +881,7 @@ static bool ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, const wmEvent *eve if (but->imb) { /* use button size itself */ } - else if (but->flag & UI_ICON_LEFT) { + else if (but->drawflag & UI_BUT_ICON_LEFT) { rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect)); } else { diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 5ecd1e55086..30a0eb424e0 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -108,13 +108,15 @@ typedef enum { #define UI_PANEL_MINY 70 /* uiBut->flag */ -#define UI_SELECT 1 /* use when the button is pressed */ -#define UI_SCROLLED 2 /* temp hidden, scrolled away */ -#define UI_ACTIVE 4 -#define UI_HAS_ICON 8 -#define UI_TEXTINPUT 16 -#define UI_HIDDEN 32 -/* warn: rest of uiBut->flag in UI_interface.h */ +enum { + UI_SELECT = (1 << 0), /* use when the button is pressed */ + UI_SCROLLED = (1 << 1), /* temp hidden, scrolled away */ + UI_ACTIVE = (1 << 2), + UI_HAS_ICON = (1 << 3), + UI_TEXTINPUT = (1 << 4), + UI_HIDDEN = (1 << 5), + /* warn: rest of uiBut->flag in UI_interface.h */ +}; /* internal panel drawing defines */ #define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 0f6034ba1cd..4517c098202 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -580,7 +580,7 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt } if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL) - but->flag |= UI_TEXT_LEFT; + but->drawflag |= UI_BUT_TEXT_LEFT; } uiBlockSetCurLayout(block, layout); @@ -762,7 +762,7 @@ PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *nam /* text alignment for toolbar buttons */ if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon) - but->flag |= UI_TEXT_LEFT; + but->drawflag |= UI_BUT_TEXT_LEFT; if (flag & UI_ITEM_R_NO_BG) uiBlockSetEmboss(block, UI_EMBOSS); @@ -912,7 +912,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname uiItemL(column, item->name, ICON_NONE); but = block->buttons.last; - but->flag = UI_TEXT_LEFT; + but->drawflag = UI_BUT_TEXT_LEFT; ui_but_tip_from_enum_item(but, item); } else { /* XXX bug here, colums draw bottom item badly */ @@ -1336,7 +1336,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname uiItemL(column, item[i].name, ICON_NONE); bt = block->buttons.last; - bt->flag = UI_TEXT_LEFT; + bt->drawflag = UI_BUT_TEXT_LEFT; ui_but_tip_from_enum_item(bt, &item[i]); } @@ -1486,7 +1486,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN but->hardmax = MAX2(but->hardmax, 256.0f); but->rnasearchpoin = *searchptr; but->rnasearchprop = searchprop; - but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT; + but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT; if (RNA_property_type(prop) == PROP_ENUM) { /* XXX, this will have a menu string, @@ -1629,7 +1629,7 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre (force_menu && layout->root->type != UI_LAYOUT_MENU)) /* We never want a dropdown in menu! */ { but->type = MENU; - but->flag |= UI_TEXT_LEFT; + but->drawflag |= UI_BUT_TEXT_LEFT; } } @@ -1681,8 +1681,8 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) * make text aligned right if the layout is aligned right. */ if (uiLayoutGetAlignment(layout) == UI_LAYOUT_ALIGN_RIGHT) { - but->flag &= ~UI_TEXT_LEFT; /* default, needs to be unset */ - but->flag |= UI_TEXT_RIGHT; + but->drawflag &= ~UI_BUT_TEXT_LEFT; /* default, needs to be unset */ + but->drawflag |= UI_BUT_TEXT_RIGHT; } /* Mark as a label inside a listbox. */ diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 1de0a278b56..f869c5de8e6 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -443,7 +443,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL}; uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL}; - if (but->flag & UI_BUT_NO_TOOLTIP) + if (but->drawflag & UI_BUT_NO_TOOLTIP) return NULL; /* create tooltip data */ @@ -1389,9 +1389,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* widget_roundbox_set has this correction too, keep in sync */ if (but->type != PULLDOWN) { - if (but->flag & UI_BUT_ALIGN_TOP) + if (but->drawflag & UI_BUT_ALIGN_TOP) butrct.ymax += U.pixelsize; - if (but->flag & UI_BUT_ALIGN_LEFT) + if (but->drawflag & UI_BUT_ALIGN_LEFT) butrct.xmin -= U.pixelsize; } @@ -1840,7 +1840,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a else { uiItemL(layout, md->title, ICON_NONE); bt = block->buttons.last; - bt->flag = UI_TEXT_LEFT; + bt->drawflag = UI_BUT_TEXT_LEFT; } } @@ -1876,7 +1876,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a if (entry->str[0]) { uiItemL(column, entry->str, entry->icon); bt = block->buttons.last; - bt->flag = UI_TEXT_LEFT; + bt->drawflag = UI_BUT_TEXT_LEFT; } else { uiItemS(column); @@ -2560,7 +2560,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) } else { but = uiDefBut(pup->block, LABEL, 0, title, 0, 0, 200, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); - but->flag = UI_TEXT_LEFT; + but->drawflag = UI_BUT_TEXT_LEFT; } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ef9b16f5445..1d1b7dbb835 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -443,7 +443,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str but->icon = RNA_struct_ui_icon(type); /* default dragging of icon for id browse buttons */ uiButSetDragID(but, id); - uiButSetFlag(but, UI_HAS_ICON | UI_ICON_LEFT); + uiButSetFlag(but, UI_HAS_ICON); + uiButSetDrawFlag(but, UI_BUT_ICON_LEFT); } if ((idfrom && idfrom->lib) || !editable) @@ -2939,7 +2940,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL); - uiButSetFlag(but, UI_BUT_NO_TOOLTIP); + uiButSetDrawFlag(but, UI_BUT_NO_TOOLTIP); sub = uiLayoutRow(overlap, FALSE); @@ -3026,7 +3027,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL); - uiButSetFlag(but, UI_BUT_NO_TOOLTIP); + uiButSetDrawFlag(but, UI_BUT_NO_TOOLTIP); sub = uiLayoutRow(overlap, FALSE); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 97dd4f59ff6..76be6ff1c84 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -890,7 +890,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, const rcti if (icon && icon != ICON_BLANK1) { float ofs = 1.0f / aspect; - if (but->flag & UI_ICON_LEFT) { + if (but->drawflag & UI_BUT_ICON_LEFT) { if (but->block->flag & UI_BLOCK_LOOP) { if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) xs = rect->xmin + 4.0f * ofs; @@ -956,7 +956,7 @@ static void ui_text_clip_give_next_off(uiBut *but) */ static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect) { - int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; + int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; int okwidth = BLI_rcti_size_x(rect) - border; if (but->flag & UI_HAS_ICON) @@ -991,7 +991,7 @@ static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect) */ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rect) { - int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; + int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0); if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE; @@ -1055,7 +1055,7 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rec */ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti *rect) { - int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; + int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0); char *cpoin = NULL; int drawstr_len = strlen(but->drawstr); @@ -1140,9 +1140,9 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b uiStyleFontSet(fstyle); - if (but->editstr || (but->flag & UI_TEXT_LEFT)) + if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) fstyle->align = UI_STYLE_TEXT_LEFT; - else if (but->flag & UI_TEXT_RIGHT) + else if (but->drawflag & UI_BUT_TEXT_RIGHT) fstyle->align = UI_STYLE_TEXT_RIGHT; else fstyle->align = UI_STYLE_TEXT_CENTER; @@ -1310,17 +1310,17 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB /* icons default draw 0.8f x height */ rect->xmin += (int)(0.8f * BLI_rcti_size_y(rect)); - if (but->editstr || (but->flag & UI_TEXT_LEFT)) { + if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) { rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; } - else if ((but->flag & UI_TEXT_RIGHT)) { + else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) { rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; } } - else if ((but->flag & UI_TEXT_LEFT)) { + else if ((but->drawflag & UI_BUT_TEXT_LEFT)) { rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; } - else if ((but->flag & UI_TEXT_RIGHT)) { + else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) { rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; } @@ -3139,15 +3139,15 @@ static int widget_roundbox_set(uiBut *but, rcti *rect) int roundbox = UI_CNR_ALL; /* alignment */ - if ((but->flag & UI_BUT_ALIGN) && but->type != PULLDOWN) { + if ((but->drawflag & UI_BUT_ALIGN) && but->type != PULLDOWN) { /* ui_block_position has this correction too, keep in sync */ - if (but->flag & UI_BUT_ALIGN_TOP) + if (but->drawflag & UI_BUT_ALIGN_TOP) rect->ymax += U.pixelsize; - if (but->flag & UI_BUT_ALIGN_LEFT) + if (but->drawflag & UI_BUT_ALIGN_LEFT) rect->xmin -= U.pixelsize; - switch (but->flag & UI_BUT_ALIGN) { + switch (but->drawflag & UI_BUT_ALIGN) { case UI_BUT_ALIGN_TOP: roundbox = UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT; break; @@ -3295,7 +3295,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct case OPTIONN: if (!(but->flag & UI_HAS_ICON)) { wt = widget_type(UI_WTYPE_OPTION); - but->flag |= UI_TEXT_LEFT; + but->drawflag |= UI_BUT_TEXT_LEFT; } else wt = widget_type(UI_WTYPE_TOGGLE); diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 8508123f942..975123f244c 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -516,7 +516,7 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS if (!last_category || strcmp(last_category, user->category) != 0) { uiItemL(layout, user->category, ICON_NONE); but = block->buttons.last; - but->flag = UI_TEXT_LEFT; + but->drawflag = UI_BUT_TEXT_LEFT; } /* create button */ @@ -577,7 +577,7 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) /* some cosmetic tweaks */ but->type = MENU; - but->flag |= UI_TEXT_LEFT; + but->drawflag |= UI_BUT_TEXT_LEFT; but->flag &= ~UI_ICON_SUBMENU; } diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index f4161c7da1c..1809c6cb835 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -116,7 +116,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat but = uiDefIconTextButS(block, LISTROW, 0, icon, dir, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, nr, 0, i, 0, 0, entry); uiButSetFunc(but, file_panel_cb, entry, NULL); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ - uiButSetFlag(but, UI_ICON_LEFT | UI_TEXT_LEFT); + uiButSetDrawFlag(but, UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT); /* create delete button */ if (allow_delete && fsmenu_can_save(fsmenu, category, i)) { diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index a67a8791a64..f8eb0ede262 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -461,7 +461,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) uiItemL(column, IFACE_(cname), ICON_NODE); but = block->buttons.last; - but->flag = UI_TEXT_LEFT; + but->drawflag = UI_BUT_TEXT_LEFT; first = 0; } @@ -471,7 +471,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) cur_node_name = items[i].node_name; uiItemL(column, IFACE_(cur_node_name), ICON_NODE); but = block->buttons.last; - but->flag = UI_TEXT_LEFT; + but->drawflag = UI_BUT_TEXT_LEFT; } BLI_snprintf(name, UI_MAX_NAME_STR, " %s", IFACE_(items[i].socket_name)); @@ -528,7 +528,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_ if (sock->link) { uiItemL(column, IFACE_("Link"), ICON_NONE); but = block->buttons.last; - but->flag = UI_TEXT_LEFT; + but->drawflag = UI_BUT_TEXT_LEFT; but = uiDefBut(block, BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input")); @@ -564,7 +564,8 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo but = uiDefIconMenuBut(block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); but->type = MENU; - but->flag |= UI_TEXT_LEFT | UI_BUT_NODE_LINK; + but->drawflag |= UI_BUT_TEXT_LEFT; + but->flag |= UI_BUT_NODE_LINK; but->poin = (char *)but; but->func_argN = arg; @@ -654,7 +655,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, uiItemL(row, label, ICON_NONE); bt = block->buttons.last; - bt->flag = UI_TEXT_LEFT; + bt->drawflag = UI_BUT_TEXT_LEFT; if (dependency_loop) { row = uiLayoutRow(split, FALSE); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index c4fdacaa915..dc6f3a0274c 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -859,7 +859,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) xco, yco, (x = UI_UNIT_X * 5), UI_UNIT_Y, ""); but_ptr = uiButGetOperatorPtrRNA(but); RNA_int_set(but_ptr, "weight_group", i); - uiButSetFlag(but, UI_TEXT_RIGHT); + uiButSetDrawFlag(but, UI_BUT_TEXT_RIGHT); if (ob->actdef != i + 1) { uiButSetFlag(but, UI_BUT_INACTIVE); } @@ -873,7 +873,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) but = uiDefButF(block, NUM, B_VGRP_PNL_EDIT_SINGLE + i, "", xco, yco, (x = UI_UNIT_X * 4), UI_UNIT_Y, &dw->weight, 0.0, 1.0, 1, 3, ""); - uiButSetFlag(but, UI_TEXT_LEFT); + uiButSetDrawFlag(but, UI_BUT_TEXT_LEFT); if (locked) { lock_count++; } -- cgit v1.2.3 From 904129fd9b11988c5915d940773552d2110f23ab Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 21 Nov 2013 16:51:29 +0100 Subject: Squashed commit of the following: commit b8b7180760b7c57f15b9930c29207febcf5fefb3 Author: Bastien Montagne Date: Thu Nov 21 16:31:16 2013 +0100 Code cleanup: replace "LISTLABEL" button type by an "UI_BUT_LIST_ITEM" button flag. Summary: Rationals: I) I was never that happy to have a full button type just to set custom colors to labels inside listitems! II) If we use (as planned) TEX buttons instead of labels to allow listitems click-rename, I'd like to be able to use listitems' theme color here as well, much easier witha flag than adding yet another button type! Note: related to D8 Reviewers: brecht Differential Revision: http://developer.blender.org/D25 --- release/datafiles/locale | 2 +- release/scripts/addons | 2 +- release/scripts/addons_contrib | 2 +- scons | 2 +- source/blender/editors/include/UI_interface.h | 5 +++- .../blender/editors/interface/interface_handlers.c | 11 ++++---- .../blender/editors/interface/interface_intern.h | 1 - .../blender/editors/interface/interface_layout.c | 4 +-- .../blender/editors/interface/interface_widgets.c | 33 +++++++++++----------- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/release/datafiles/locale b/release/datafiles/locale index cb1967cc63a..d3e0405103f 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit cb1967cc63a6d2d75d2b59cdf91c5f5645285aea +Subproject commit d3e0405103f9ccabb8e567a8c69e9d4015aaa3bb diff --git a/release/scripts/addons b/release/scripts/addons index 48bdb7b52fe..4d8cb6c2947 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 48bdb7b52fe827cbc21d50cce3079223243414bd +Subproject commit 4d8cb6c294727ff10afeb548759f629b0c2169d6 diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index 31545d25c9c..4fe6a9e046f 160000 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit 31545d25c9cb41d271a3f3ef84d327708572290e +Subproject commit 4fe6a9e046f9578a0dadb1186269ac5e406a8c15 diff --git a/scons b/scons index ccea0f01de1..2d6ebcb2390 160000 --- a/scons +++ b/scons @@ -1 +1 @@ -Subproject commit ccea0f01de1c3e9210086bd447df71bae353fa07 +Subproject commit 2d6ebcb23909058b846aa232ecb2fee497924cf8 diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 53bfc94dfdd..0c37d35a93b 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -170,12 +170,16 @@ enum { UI_BUT_VEC_SIZE_LOCK = (1 << 22), /* used to flag if color hsv-circle should keep luminance */ UI_BUT_COLOR_CUBIC = (1 << 23), /* cubic saturation for the color wheel */ + UI_BUT_LIST_ITEM = (1 << 24), /* This but is "inside" a list item (currently used to change theme colors). */ }; #define UI_PANEL_WIDTH 340 #define UI_COMPACT_PANEL_WIDTH 160 /* but->drawflag - these flags should only affect how the button is drawn. */ +/* Note: currently, these flags _are not passed_ to the widget's state() or draw() functions + * (except for the 'align' ones)! + */ enum { /* draw enum-like up/down arrows for button */ UI_BUT_DRAW_ENUM_ARROWS = (1 << 0), @@ -263,7 +267,6 @@ typedef enum { PROGRESSBAR = (51 << 9), SEARCH_MENU_UNLINK = (52 << 9), NODESOCKET = (53 << 9), - LISTLABEL = (54 << 9), } eButType; #define BUTTYPE (63 << 9) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 33a054318b6..db53809c7c4 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -301,7 +301,7 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) static bool ui_but_editable(uiBut *but) { - return ELEM6(but->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR); + return ELEM5(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR); } static uiBut *ui_but_prev(uiBut *but) @@ -2097,7 +2097,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa uiBut *but; /* label and roundbox can overlap real buttons (backdrops...) */ - if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX)) + if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return; for (but = actbut->next; but; but = but->next) { @@ -2125,7 +2125,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa uiBut *but; /* label and roundbox can overlap real buttons (backdrops...) */ - if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX)) + if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return; for (but = actbut->prev; but; but = but->prev) { @@ -5675,7 +5675,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * break; case ROUNDBOX: case LABEL: - case LISTLABEL: case ROW: case LISTROW: case BUT_IMAGE: @@ -5888,7 +5887,7 @@ static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y) bool ui_is_but_interactive(uiBut *but) { /* note, LABEL is included for highlights, this allows drags */ - if (ELEM(but->type, LABEL, LISTLABEL) && but->dragpoin == NULL) + if ((but->type == LABEL) && but->dragpoin == NULL) return false; if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX)) return false; @@ -7444,7 +7443,7 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH for (but = block->buttons.first; but; but = but->next) { int doit = FALSE; - if (but->type != LABEL && but->type != LISTLABEL && but->type != SEPR) + if (!ELEM(but->type, LABEL, SEPR)) count++; /* exception for rna layer buts */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 30a0eb424e0..30d8535e471 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -95,7 +95,6 @@ typedef enum { UI_WTYPE_SCROLL, UI_WTYPE_LISTITEM, UI_WTYPE_PROGRESSBAR, - UI_WTYPE_LISTLABEL, } uiWidgetTypeEnum; /* menu scrolling */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 4517c098202..e3686b7560c 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1687,7 +1687,7 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) /* Mark as a label inside a listbox. */ if (block->flag & UI_BLOCK_LIST_ITEM) { - but->type = LISTLABEL; + but->flag |= UI_BUT_LIST_ITEM; } return but; @@ -2457,7 +2457,7 @@ void ui_layout_list_set_labels_active(uiLayout *layout) if (bitem->item.type != ITEM_BUTTON) { ui_layout_list_set_labels_active((uiLayout *)(&bitem->item)); } - else if (bitem->but->type == LISTLABEL) { + else if (bitem->but->flag & UI_BUT_LIST_ITEM) { uiButSetFlag(bitem->but, UI_SELECT); } } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 76be6ff1c84..3058888c012 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -882,7 +882,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, const rcti } /* extra feature allows more alpha blending */ - if (ELEM(but->type, LABEL, LISTLABEL) && but->a1 == 1.0f) + if ((but->type == LABEL) && but->a1 == 1.0f) alpha *= but->a2; glEnable(GL_BLEND); @@ -2866,12 +2866,21 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN /* labels use Editor theme colors for text */ static void widget_state_label(uiWidgetType *wt, int state) { - /* call this for option button */ - widget_state(wt, state); - if (state & UI_SELECT) - UI_GetThemeColor3ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text); - else - UI_GetThemeColor3ubv(TH_TEXT, (unsigned char *)wt->wcol.text); + if (state & UI_BUT_LIST_ITEM) { + /* Override default label theme's colors. */ + bTheme *btheme = UI_GetTheme(); + wt->wcol_theme = &btheme->tui.wcol_list_item; + /* call this for option button */ + widget_state(wt, state); + } + else { + /* call this for option button */ + widget_state(wt, state); + if (state & UI_SELECT) + UI_GetThemeColor3ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text); + else + UI_GetThemeColor3ubv(TH_TEXT, (unsigned char *)wt->wcol.text); + } } static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) @@ -2991,11 +3000,6 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type) case UI_WTYPE_REGULAR: break; - case UI_WTYPE_LISTLABEL: - wt.wcol_theme = &btheme->tui.wcol_list_item; - wt.draw = NULL; - /* Can't use usual label code. */ - break; case UI_WTYPE_LABEL: wt.draw = NULL; wt.state = widget_state_label; @@ -3245,11 +3249,6 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct fstyle = &style->widgetlabel; } break; - - case LISTLABEL: - wt = widget_type(UI_WTYPE_LISTLABEL); - fstyle = &style->widgetlabel; - break; case SEPR: break; -- cgit v1.2.3 From 24795943511c85d4a8aeea6aba05c5b648df8e04 Mon Sep 17 00:00:00 2001 From: Emanuel Claesson Date: Thu, 21 Nov 2013 17:38:52 +0100 Subject: CMake: minor spelling fix for WITH_BOOST Reviewed By: brecht Differential Revision: http://developer.blender.org/D26 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5781558a61b..fc6c83eed10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,7 +297,7 @@ mark_as_advanced(WITH_CXX_GUARDEDALLOC) option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF) mark_as_advanced(WITH_ASSERT_ABORT) -option(WITH_BOOST "Enable features depending no boost" ON) +option(WITH_BOOST "Enable features depending on boost" ON) if(CMAKE_COMPILER_IS_GNUCC) option(WITH_GCC_MUDFLAP "Enable mudflap" OFF) -- cgit v1.2.3 From 811ce5a696ae4b7043744a081980c3e77e4bd927 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 21 Nov 2013 20:25:31 +0100 Subject: Code cleanup: Minor addition to rB254aa8f3a0fbffcbcb886cfaa81b630ae3e9bb78: handle copying of drawflag in ui_but_update_from_old_block() Note that this is not really needed currently, as the only flag being copied here (UI_BUT_REDALERT) remained in but->flag. However, since we'll have more flags in drawflag now, it's better to explicitly handle this situation... This func could use some cleanup anyway (a bunch of commented code here)... Thanks to Campbell for noting this! --- source/blender/editors/interface/interface.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 800fee648e7..3f48446f029 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -613,6 +613,7 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut { /* flags from the buttons we want to refresh, may want to add more here... */ const int flag_copy = UI_BUT_REDALERT; + const int drawflag_copy = 0; /* None currently. */ uiBlock *oldblock; uiBut *oldbut, *but = *butpp; @@ -670,8 +671,9 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut SWAP(char *, oldbut->poin, but->poin); SWAP(void *, oldbut->func_argN, but->func_argN); } - + oldbut->flag = (oldbut->flag & ~flag_copy) | (but->flag & flag_copy); + oldbut->drawflag = (oldbut->drawflag & ~drawflag_copy) | (but->drawflag & drawflag_copy); /* copy hardmin for list rows to prevent 'sticking' highlight to mouse position * when scrolling without moving mouse (see [#28432]) */ -- cgit v1.2.3 From 41e563594db6410381742b3803cf140099db88e2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Nov 2013 12:24:43 +1100 Subject: Code Cleanup: int pointer comparison --- source/blender/freestyle/intern/application/Controller.cpp | 1 - .../freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp | 2 +- .../intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp | 2 +- .../freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp | 2 +- .../freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp | 2 +- source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp | 6 +++--- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp index c61f72295d2..81034c1502c 100644 --- a/source/blender/freestyle/intern/application/Controller.cpp +++ b/source/blender/freestyle/intern/application/Controller.cpp @@ -204,7 +204,6 @@ void Controller::setPassZ(float *buf, int width, int height) void Controller::setContext(bContext *C) { PythonInterpreter *py_inter = dynamic_cast(_inter); - assert(py_inter != 0); py_inter->setContext(C); } diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp index 2b8b4eec4dd..99ac72db028 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainPredicateIterator.cpp @@ -104,7 +104,7 @@ PyDoc_STRVAR(ChainPredicateIterator_doc, static int check_begin(PyObject *obj, void *v) { - if (obj != 0 && obj != Py_None && !BPy_ViewEdge_Check(obj)) + if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) return 0; *((PyObject **)v) = obj; return 1; diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp index b723631f365..1a082ac93bb 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainSilhouetteIterator.cpp @@ -74,7 +74,7 @@ PyDoc_STRVAR(ChainSilhouetteIterator_doc, static int check_begin(PyObject *obj, void *v) { - if (obj != 0 && obj != Py_None && !BPy_ViewEdge_Check(obj)) + if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) return 0; *((PyObject **)v) = obj; return 1; diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp index 9a4eb2b7f61..1dadfbced03 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp @@ -75,7 +75,7 @@ PyDoc_STRVAR(ChainingIterator_doc, static int check_begin(PyObject *obj, void *v) { - if (obj != 0 && obj != Py_None && !BPy_ViewEdge_Check(obj)) + if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) return 0; *((PyObject **)v) = obj; return 1; diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp index 87e05a790b4..4a45be8caa5 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp @@ -65,7 +65,7 @@ PyDoc_STRVAR(ViewEdgeIterator_doc, static int check_begin(PyObject *obj, void *v) { - if (obj != 0 && obj != Py_None && !BPy_ViewEdge_Check(obj)) + if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) return 0; *((PyObject **)v) = obj; return 1; diff --git a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp index 91d077278fb..b5d73640c11 100644 --- a/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewEdgeXBuilder.cpp @@ -39,7 +39,7 @@ namespace Freestyle { void ViewEdgeXBuilder::Init(ViewShape *oVShape) { - if (0 == oVShape) + if (NULL == oVShape) return; // for design conveniance, we store the current SShape. @@ -527,7 +527,7 @@ FEdge *ViewEdgeXBuilder::BuildSmoothFEdge(FEdge *feprevious, const OWXFaceLayer& bool ViewEdgeXBuilder::stopSmoothViewEdge(WXFaceLayer *iFaceLayer) { - if (0 == iFaceLayer) + if (NULL == iFaceLayer) return true; if (iFaceLayer->userdata == 0) return false; @@ -698,7 +698,7 @@ FEdge *ViewEdgeXBuilder::BuildSharpFEdge(FEdge *feprevious, const OWXEdge& iwe) bool ViewEdgeXBuilder::stopSharpViewEdge(WXEdge *iEdge) { - if (0 == iEdge) + if (NULL == iEdge) return true; if (iEdge->userdata == 0) return false; -- cgit v1.2.3 From a08750addf764c8d02552b03f09b732b1cf76507 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Nov 2013 08:36:48 +1100 Subject: Armature Editing: select shortest path (Ctrl+RMB matching mesh operator) Patch originally from Terry Struven, modified to use more generic functions. --- source/blender/editors/armature/armature_intern.h | 1 + source/blender/editors/armature/armature_ops.c | 3 + source/blender/editors/armature/armature_select.c | 120 ++++++++++++++++++++++ source/blender/editors/armature/armature_utils.c | 41 ++++++++ source/blender/editors/include/ED_armature.h | 1 + 5 files changed, 166 insertions(+) diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index bc7d69d1558..f3db9042879 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -68,6 +68,7 @@ void ARMATURE_OT_select_less(struct wmOperatorType *ot); void ARMATURE_OT_select_hierarchy(struct wmOperatorType *ot); void ARMATURE_OT_select_linked(struct wmOperatorType *ot); void ARMATURE_OT_select_similar(struct wmOperatorType *ot); +void ARMATURE_OT_shortest_path_pick(struct wmOperatorType *ot); void ARMATURE_OT_delete(struct wmOperatorType *ot); void ARMATURE_OT_duplicate(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 4c7eb847054..feb9b0f939a 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -64,6 +64,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(ARMATURE_OT_select_hierarchy); WM_operatortype_append(ARMATURE_OT_select_linked); WM_operatortype_append(ARMATURE_OT_select_similar); + WM_operatortype_append(ARMATURE_OT_shortest_path_pick); WM_operatortype_append(ARMATURE_OT_delete); WM_operatortype_append(ARMATURE_OT_duplicate); @@ -264,6 +265,8 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_select_linked", LKEY, KM_PRESS, 0, 0); + + WM_keymap_add_item(keymap, "ARMATURE_OT_shortest_path_pick", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_delete", DELKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 003f6bf36f3..0bc6f1e037c 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -1120,3 +1120,123 @@ void ARMATURE_OT_select_mirror(wmOperatorType *ot) RNA_def_boolean(ot->srna, "only_active", false, "Active Only", "Only operate on the active bone"); RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); } + + +/****************** Select Path ****************/ + +static bool armature_shortest_path_select(bArmature *arm, EditBone *ebone_parent, EditBone *ebone_child, + bool use_parent, bool is_test) +{ + do { + + if (!use_parent && (ebone_child == ebone_parent)) + break; + + if (is_test) { + if (!EBONE_SELECTABLE(arm, ebone_child)) { + return false; + } + } + else { + ED_armature_ebone_selectflag_set(ebone_child, (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)); + } + + if (ebone_child == ebone_parent) + break; + + ebone_child = ebone_child->parent; + } while (true); + + return true; +} + +static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = obedit->data; + EditBone *ebone_src, *ebone_dst; + EditBone *ebone_isect_parent = NULL; + EditBone *ebone_isect_child[2]; + bool change; + + view3d_operator_needs_opengl(C); + + ebone_src = arm->act_edbone; + ebone_dst = get_nearest_bone(C, 0, event->mval[0], event->mval[1]); + + /* fallback to object selection */ + if (ELEM(NULL, ebone_src, ebone_dst) || (ebone_src == ebone_dst)) { + return OPERATOR_PASS_THROUGH; + } + + ebone_isect_child[0] = ebone_src; + ebone_isect_child[1] = ebone_dst; + + + /* ensure 'ebone_src' is the parent of 'ebone_dst', or set 'ebone_isect_parent' */ + if (ED_armature_ebone_is_child_recursive(ebone_src, ebone_dst)) { + /* pass */ + } + else if (ED_armature_ebone_is_child_recursive(ebone_dst, ebone_src)) { + SWAP(EditBone *, ebone_src, ebone_dst); + } + else if ((ebone_isect_parent = ED_armature_bone_find_shared_parent(ebone_isect_child, 2))) { + /* pass */ + } + else { + /* disconnected bones */ + return OPERATOR_CANCELLED; + } + + + if (ebone_isect_parent) { + if (armature_shortest_path_select(arm, ebone_isect_parent, ebone_src, false, true) && + armature_shortest_path_select(arm, ebone_isect_parent, ebone_dst, false, true)) + { + armature_shortest_path_select(arm, ebone_isect_parent, ebone_src, false, false); + armature_shortest_path_select(arm, ebone_isect_parent, ebone_dst, false, false); + change = true; + } + else { + /* unselectable */ + change = false; + } + } + else { + if (armature_shortest_path_select(arm, ebone_src, ebone_dst, true, true)) { + armature_shortest_path_select(arm, ebone_src, ebone_dst, true, false); + change = true; + } + else { + /* unselectable */ + change = false; + } + } + + if (change) { + arm->act_edbone = ebone_dst; + ED_armature_sync_selection(arm->edbo); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); + + return OPERATOR_FINISHED; + } + else { + BKE_report(op->reports, RPT_WARNING, "Unselectable bone in chain"); + return OPERATOR_CANCELLED; + } +} + +void ARMATURE_OT_shortest_path_pick(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Pick Shortest Path"; + ot->idname = "ARMATURE_OT_shortest_path_pick"; + ot->description = "Select shortest path between two bones"; + + /* api callbacks */ + ot->invoke = armature_shortest_path_pick_invoke; + ot->poll = ED_operator_editarmature; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 2cbfb52db91..be26ad537fc 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -156,6 +156,47 @@ bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebon return false; } +/** + * Finds the first parent shared by \a ebone_child + * + * \param ebone_child Children bones to search + * \param ebone_child_tot Size of the ebone_child array + * \return The shared parent or NULL. + */ +EditBone *ED_armature_bone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot) +{ + unsigned int i; + EditBone *ebone_iter; + +#define EBONE_TEMP_UINT(ebone) (*((unsigned int *)(&((ebone)->temp)))) + + /* clear all */ + for (i = 0; i < ebone_child_tot; i++) { + for (ebone_iter = ebone_child[i]; ebone_iter; ebone_iter = ebone_iter->parent) { + EBONE_TEMP_UINT(ebone_iter) = 0; + } + } + + /* accumulate */ + for (i = 0; i < ebone_child_tot; i++) { + ebone_iter = ebone_child[i]; + for (ebone_iter = ebone_child[i]->parent; ebone_iter; ebone_iter = ebone_iter->parent) { + EBONE_TEMP_UINT(ebone_iter) += 1; + } + } + + /* only need search the first chain */ + for (ebone_iter = ebone_child[0]->parent; ebone_iter; ebone_iter = ebone_iter->parent) { + if (EBONE_TEMP_UINT(ebone_iter) == ebone_child_tot) { + return ebone_iter; + } + } + +#undef EBONE_TEMP_UINT + + return NULL; +} + void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]) { float delta[3]; diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 455378fc2ce..e9caf89d9da 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -138,6 +138,7 @@ struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *na void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone); bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child); +EditBone *ED_armature_bone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot); void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]); void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]); -- cgit v1.2.3 From bd5da19d86e5c490e4945bb4befc50b6eac48a86 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 22 Nov 2013 00:33:28 +0100 Subject: Cycles: Add a "Normal" input socket to the Layer Weight node + GLSL drawing code. Patch by lichtwerk (Philipp Oeser). Differential Revision: http://developer.blender.org/D28 --- intern/cycles/kernel/svm/svm_fresnel.h | 12 +++++++----- intern/cycles/render/nodes.cpp | 8 ++++++-- source/blender/gpu/shaders/gpu_shader_material.glsl | 18 ++++++++++++++++++ .../nodes/shader/nodes/node_shader_layer_weight.c | 8 ++++++-- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/intern/cycles/kernel/svm/svm_fresnel.h b/intern/cycles/kernel/svm/svm_fresnel.h index bb70a3faa2a..0a3d576cfe1 100644 --- a/intern/cycles/kernel/svm/svm_fresnel.h +++ b/intern/cycles/kernel/svm/svm_fresnel.h @@ -39,10 +39,12 @@ ccl_device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node) { uint blend_offset = node.y; uint blend_value = node.z; - float blend = (stack_valid(blend_offset))? stack_load_float(stack, blend_offset): __uint_as_float(blend_value); - uint type, out_offset; - decode_node_uchar4(node.w, &type, &out_offset, NULL, NULL); + uint type, normal_offset, out_offset; + decode_node_uchar4(node.w, &type, &normal_offset, &out_offset, NULL); + + float blend = (stack_valid(blend_offset))? stack_load_float(stack, blend_offset): __uint_as_float(blend_value); + float3 normal_in = (stack_valid(normal_offset))? stack_load_float3(stack, normal_offset): sd->N; float f; @@ -50,10 +52,10 @@ ccl_device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node) float eta = fmaxf(1.0f - blend, 1e-5f); eta = (sd->flag & SD_BACKFACING)? eta: 1.0f/eta; - f = fresnel_dielectric_cos(dot(sd->I, sd->N), eta); + f = fresnel_dielectric_cos(dot(sd->I, normal_in), eta); } else { - f = fabsf(dot(sd->I, sd->N)); + f = fabsf(dot(sd->I, normal_in)); if(blend != 0.5f) { blend = clamp(blend, 0.0f, 1.0f-1e-5f); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 4919222e81c..daf75c81396 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -3198,8 +3198,12 @@ LayerWeightNode::LayerWeightNode() void LayerWeightNode::compile(SVMCompiler& compiler) { + ShaderInput *normal_in = input("Normal"); ShaderInput *blend_in = input("Blend"); + if(normal_in->link) + compiler.stack_assign(normal_in); + if(blend_in->link) compiler.stack_assign(blend_in); @@ -3207,14 +3211,14 @@ void LayerWeightNode::compile(SVMCompiler& compiler) if(!fresnel_out->links.empty()) { compiler.stack_assign(fresnel_out); compiler.add_node(NODE_LAYER_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x), - compiler.encode_uchar4(NODE_LAYER_WEIGHT_FRESNEL, fresnel_out->stack_offset)); + compiler.encode_uchar4(NODE_LAYER_WEIGHT_FRESNEL, normal_in->stack_offset, fresnel_out->stack_offset)); } ShaderOutput *facing_out = output("Facing"); if(!facing_out->links.empty()) { compiler.stack_assign(facing_out); compiler.add_node(NODE_LAYER_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x), - compiler.encode_uchar4(NODE_LAYER_WEIGHT_FACING, facing_out->stack_offset)); + compiler.encode_uchar4(NODE_LAYER_WEIGHT_FACING, normal_in->stack_offset, facing_out->stack_offset)); } } diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index b2c7c2e3cef..f5881cdc923 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2159,6 +2159,24 @@ void node_fresnel(float ior, vec3 N, vec3 I, out float result) result = fresnel_dielectric(normalize(I), N, (gl_FrontFacing)? eta: 1.0/eta); } +/* layer_weight */ + +void node_layer_weight(float blend, vec3 N, vec3 I, out float fresnel, out float facing) +{ + /* fresnel */ + float eta = max(1.0 - blend, 0.00001); + fresnel = fresnel_dielectric(normalize(I), N, (gl_FrontFacing)? 1.0/eta : eta ); + + /* facing */ + facing = abs(dot(normalize(I), N)); + if(blend != 0.5) { + blend = clamp(blend, 0.0, 0.99999); + blend = (blend < 0.5)? 2.0*blend: 0.5/(1.0 - blend); + facing = pow(facing, blend); + } + facing = 1.0 - facing; +} + /* gamma */ void node_gamma(vec4 col, float gamma, out vec4 outcol) diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c index 9b9c3cf705b..832ce582b4b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c +++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c @@ -31,6 +31,7 @@ static bNodeSocketTemplate sh_node_layer_weight_in[] = { { SOCK_FLOAT, 1, N_("Blend"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; @@ -40,9 +41,12 @@ static bNodeSocketTemplate sh_node_layer_weight_out[] = { { -1, 0, "" } }; -static int node_shader_gpu_layer_weight(GPUMaterial *UNUSED(mat), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *UNUSED(in), GPUNodeStack *UNUSED(out)) +static int node_shader_gpu_layer_weight(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) { - return 0; + if (!in[1].link) + in[1].link = GPU_builtin(GPU_VIEW_NORMAL); + + return GPU_stack_link(mat, "node_layer_weight", in, out, GPU_builtin(GPU_VIEW_POSITION)); } /* node type definition */ -- cgit v1.2.3 From f801f8057da824a2306963ea1b10bb5917a267c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Nov 2013 10:36:35 +1100 Subject: fix for active bone not saving in editmode. --- source/blender/editors/armature/armature_utils.c | 2 +- source/blender/editors/interface/interface_layout.c | 12 ++++++++---- source/blender/makesdna/DNA_armature_types.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index be26ad537fc..7d6b3710a38 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -501,6 +501,7 @@ void ED_armature_from_edit(Object *obedit) /* armature bones */ BKE_armature_bonelist_free(&arm->bonebase); + arm->act_bone = NULL; /* remove zero sized bones, this gives unstable restposes */ for (eBone = arm->edbo->first; eBone; eBone = neBone) { @@ -634,7 +635,6 @@ void ED_armature_to_edit(Object *ob) ED_armature_edit_free(ob); arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature"); arm->act_edbone = make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone); - arm->act_bone = NULL; // BIF_freeTemplates(); /* force template update when entering editmode */ } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index e3686b7560c..b85c30b8710 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -390,11 +390,15 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in layer_used = arm->layer_used; - if (arm->edbo && arm->act_edbone) { - layer_active |= arm->act_edbone->layer; + if (arm->edbo) { + if (arm->act_edbone) { + layer_active |= arm->act_edbone->layer; + } } - else if (arm->act_bone) { - layer_active |= arm->act_bone->layer; + else { + if (arm->act_bone) { + layer_active |= arm->act_bone->layer; + } } } diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h index 4780b2e85de..e751966c34d 100644 --- a/source/blender/makesdna/DNA_armature_types.h +++ b/source/blender/makesdna/DNA_armature_types.h @@ -88,7 +88,7 @@ typedef struct bArmature { * - from the user perspective active == last selected * - active should be ignored when not visible (hidden layer) */ - Bone *act_bone; /* active bone (when not in editmode) */ + Bone *act_bone; /* active bone */ struct EditBone *act_edbone; /* active editbone (in editmode) */ void *sketch; /* sketch struct for etch-a-ton */ -- cgit v1.2.3 From a5183d7a87b3b7cad50b47d7bda24efbeddcade7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Nov 2013 10:43:42 +1100 Subject: Code Cleanup: use NULL for pointer checks and remove joke. --- intern/guardedalloc/intern/mmap_win.c | 14 +++++++------- source/blender/imbuf/intern/anim_movie.c | 4 ++-- source/blender/windowmanager/intern/wm_jobs.c | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/intern/guardedalloc/intern/mmap_win.c b/intern/guardedalloc/intern/mmap_win.c index 6f03188a579..3096c589101 100644 --- a/intern/guardedalloc/intern/mmap_win.c +++ b/intern/guardedalloc/intern/mmap_win.c @@ -182,14 +182,14 @@ static void mmap_addtail(volatile mmapListBase *listbase, void *vlink) { struct mmapLink *link = vlink; - if (link == 0) return; - if (listbase == 0) return; + if (link == NULL) return; + if (listbase == NULL) return; link->next = 0; link->prev = listbase->last; if (listbase->last) ((struct mmapLink *)listbase->last)->next = link; - if (listbase->first == 0) listbase->first = link; + if (listbase->first == NULL) listbase->first = link; listbase->last = link; } @@ -197,8 +197,8 @@ static void mmap_remlink(volatile mmapListBase *listbase, void *vlink) { struct mmapLink *link = vlink; - if (link == 0) return; - if (listbase == 0) return; + if (link == NULL) return; + if (listbase == NULL) return; if (link->next) link->next->prev = link->prev; if (link->prev) link->prev->next = link->next; @@ -211,8 +211,8 @@ static void *mmap_findlink(volatile mmapListBase *listbase, void *ptr) { MemMap *mm; - if (ptr == 0) return NULL; - if (listbase == 0) return NULL; + if (ptr == NULL) return NULL; + if (listbase == NULL) return NULL; mm = (MemMap *)listbase->first; while (mm) { diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 63790cf7d25..271e52da1d4 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -477,7 +477,7 @@ static int startffmpeg(struct anim *anim) const int *inv_table; #endif - if (anim == 0) return(-1); + if (anim == NULL) return(-1); streamcount = anim->streamindex; @@ -960,7 +960,7 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, int new_frame_index = 0; /* To quiet gcc barking... */ int old_frame_index = 0; /* To quiet gcc barking... */ - if (anim == 0) return (0); + if (anim == NULL) return (0); av_log(anim->pFormatCtx, AV_LOG_DEBUG, "FETCH: pos=%d\n", position); diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 6908588ebd7..b3856a2aa9c 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -523,9 +523,9 @@ void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, sho wm_job = wm->jobs.first; while (wm_job) { if (wm_job->owner == owner || wm_job->startjob == startjob) { - wmJob *bill = wm_job; + wmJob *wm_job_kill = wm_job; wm_job = wm_job->next; - wm_jobs_kill_job(wm, bill); + wm_jobs_kill_job(wm, wm_job_kill); } else { wm_job = wm_job->next; -- cgit v1.2.3 From d4a11388bf988b9377b19269abf2f0632ddd1fd5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Nov 2013 11:30:40 +1100 Subject: Code Cleanup: warnings --- CMakeLists.txt | 1 + source/blender/bmesh/tools/bmesh_beautify.c | 5 ----- source/blender/compositor/intern/COM_SocketReader.h | 8 ++++---- source/blender/compositor/intern/COM_WorkScheduler.cpp | 6 +++--- .../compositor/operations/COM_MovieDistortionOperation.cpp | 2 +- .../Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 2 +- .../Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 4 ++-- 7 files changed, 12 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc6c83eed10..a7f6b879555 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2058,6 +2058,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS -Wno-unused-macros) ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations) + ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers) ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function) ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast) ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes) diff --git a/source/blender/bmesh/tools/bmesh_beautify.c b/source/blender/bmesh/tools/bmesh_beautify.c index 1a1201c015e..cad5e1beeff 100644 --- a/source/blender/bmesh/tools/bmesh_beautify.c +++ b/source/blender/bmesh/tools/bmesh_beautify.c @@ -309,8 +309,6 @@ static void bm_edge_update_beauty_cost_single(BMEdge *e, Heap *eheap, HeapNode * /* check if we can add it back */ BLI_assert(BM_edge_is_manifold(e) == true); - //BLI_assert(BMO_elem_flag_test(bm, e->l->f, FACE_MARK) && - // BMO_elem_flag_test(bm, e->l->radial_next->f, FACE_MARK)); /* check we're not moving back into a state we have been in before */ if (e_state_set != NULL) { @@ -354,9 +352,6 @@ static void bm_edge_update_beauty_cost(BMEdge *e, Heap *eheap, HeapNode **eheap_ /* -------------------------------------------------------------------- */ /* Beautify Fill */ -#define ELE_NEW 1 -#define FACE_MARK 2 - /** * \note All edges in \a edge_array must be tagged and * have their index values set according to their position in the array. diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h index 2eaeb664c67..2168611d0c0 100644 --- a/source/blender/compositor/intern/COM_SocketReader.h +++ b/source/blender/compositor/intern/COM_SocketReader.h @@ -102,11 +102,11 @@ public: } virtual void *initializeTileData(rcti *rect) { return 0; } - virtual void deinitializeTileData(rcti *rect, void *data) { - } - - virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return 0; } + virtual void deinitializeTileData(rcti *rect, void *data) {} + virtual ~SocketReader() {} + + virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return 0; } inline const unsigned int getWidth() const { return this->m_width; } inline const unsigned int getHeight() const { return this->m_height; } diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index 330e61e7fea..57e996fe3b2 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -77,9 +77,9 @@ static bool g_openclInitialized = false; #define MAX_HIGHLIGHT 8 static bool g_highlightInitialized = false; extern "C" { -int g_highlightIndex; -void **g_highlightedNodes; -void **g_highlightedNodesRead; +static int g_highlightIndex; +static void **g_highlightedNodes; +static void **g_highlightedNodesRead; #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE #define HIGHLIGHT(wp) \ diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp index a8c7728160d..bc792244dcb 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp @@ -29,7 +29,7 @@ extern "C" { } -vector s_cache; +static vector s_cache; void deintializeDistortionCache(void) { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 5105e2c2b8d..2884983a17e 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -1229,7 +1229,7 @@ void RAS_OpenGLRasterizer::RemoveLight(struct RAS_LightObject* lightobject) m_lights.erase(lit); } -bool RAS_OpenGLRasterizer::RayHit(class KX_ClientObjectInfo *client, KX_RayCast *result, void * const data) +bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, void * const data) { double* const oglmatrix = (double* const) data; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index e1159ab3d2d..01c42050b36 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -380,8 +380,8 @@ public: void PushMatrix(); void PopMatrix(); - bool RayHit(class KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data); - bool NeedRayCast(class KX_ClientObjectInfo*) { return true; } + bool RayHit(struct KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data); + bool NeedRayCast(struct KX_ClientObjectInfo*) { return true; } void AddLight(struct RAS_LightObject* lightobject); -- cgit v1.2.3 From 283f43d31a602c88e4dd7123973689cca84b3f7f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Nov 2013 19:42:14 +1100 Subject: Fix T37559: Crash dissolving vertices in some situations --- source/blender/bmesh/operators/bmo_dissolve.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index cf36e88ea98..ae645b97874 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -440,13 +440,18 @@ void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op) BMO_error_raise(bm, op, BMERR_DISSOLVEVERTS_FAILED, msg); } - /* clean up any remainin */ - BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) { + /* clean up any remaining */ + /* note: don't use BM_ITER_MESH_MUTABLE here, even though vertices are removed (T37559) */ + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BMO_elem_flag_test(bm, v, VERT_MARK)) { if (!BM_vert_dissolve(bm, v)) { BMO_error_raise(bm, op, BMERR_DISSOLVEVERTS_FAILED, NULL); return; } +#ifdef DEBUG + /* workaround debug assert */ + iter.count = bm->totvert; +#endif } } -- cgit v1.2.3 From d44c79b7c93fb8c6525b79fa4b57548334185bbf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Nov 2013 20:10:26 +1100 Subject: Fix T37281: View3D could have invalid transform orientation using undo --- source/blender/blenloader/intern/readfile.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ddb045de290..3428e52ca4e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5936,6 +5936,14 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc /* not very nice, but could help */ if ((v3d->layact & v3d->lay) == 0) v3d->layact = v3d->lay; + /* its possible the current transform orientation has been removed */ + if (v3d->twmode >= V3D_MANIP_CUSTOM) { + const int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM); + if (!BLI_findlink(&sc->scene->transform_spaces, selected_index)) { + v3d->twmode = V3D_MANIP_GLOBAL; + } + } + /* free render engines for now */ for (ar = sa->regionbase.first; ar; ar = ar->next) { RegionView3D *rv3d= ar->regiondata; -- cgit v1.2.3 From 0469971b05ea94b9bf9ea3c8e935049c5c5b7120 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Nov 2013 20:38:48 +1100 Subject: Fix T37465: UV Coords we're incorrect when converting from a curve --- source/blender/blenkernel/intern/mesh.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 844252c583c..e6fca21f2af 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1351,6 +1351,8 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase, mloopuv->uv[1] = (v % dl->nr) / (float)orco_sizeu; /* cyclic correction */ + if ((i == 1 || i == 2) && mloopuv->uv[0] == 0.0f) + mloopuv->uv[0] = 1.0f; if ((i == 0 || i == 1) && mloopuv->uv[1] == 0.0f) mloopuv->uv[1] = 1.0f; } -- cgit v1.2.3 From 885354daec2fa8181aeb27b637c80e4ee4c247df Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 22 Nov 2013 16:48:08 +0600 Subject: Optimization for render result save Skip byte->float conversion if output file format supports high bit depths but configured to only output 8 bits per channel. Gives around 30% speedup when re-exporting movie file to PNG image sequence here on laptop. Possible further optimization: - Skip color space conversion in imbuf_for_write function if we've got already have buffer in that space. This doesn't seem to happen often after tweak to render result to imbuf. - Skip black alpha-under if original image is opaque, This is a bit tricky to detect. --- source/blender/render/intern/source/render_result.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 37587d89ce0..487de42515d 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -1124,7 +1124,13 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd) */ if (ibuf->rect) { if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) { - IMB_float_from_rect(ibuf); + if (rd->im_format.depth == R_IMF_CHAN_DEPTH_8) { + /* Higher depth bits are supported but not needed for current file output. */ + ibuf->rect_float = NULL; + } + else { + IMB_float_from_rect(ibuf); + } } else { /* ensure no float buffer remained from previous frame */ -- cgit v1.2.3 From 5feb0d2bfe8f6723bf48073b1760b732bc6a5ceb Mon Sep 17 00:00:00 2001 From: Miika Hamalainen Date: Fri, 22 Nov 2013 15:25:19 +0200 Subject: Fix T37359: Dynamic Paint deletes inactive texture from smoke domain when using a material as brush color --- source/blender/render/intern/source/render_texture.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index e8127b0e6b9..049d7e5a732 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -3558,12 +3558,15 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) /* strip material copy from unsupported flags */ for (tex_nr=0; tex_nrseptex & (1<mtex[tex_nr]) { MTex *mtex = mat->mtex[tex_nr]; - if (!mtex->tex) continue; + /* just in case make all non-used mtexes empty*/ + Tex *cur_tex = mtex->tex; + mtex->tex = NULL; + + if (mat->septex & (1<texflag = mtex->texflag & (MTEX_RGBTOINT | MTEX_STENCIL | MTEX_NEGATIVE | MTEX_ALPHAMIX); @@ -3598,7 +3601,7 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) } /* copy texture */ - tex= mtex->tex = localize_texture(mtex->tex); + tex= mtex->tex = localize_texture(cur_tex); /* update texture anims */ BKE_animsys_evaluate_animdata(scene, &tex->id, tex->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM); @@ -3646,7 +3649,8 @@ void RE_free_sample_material(Material *mat) } } - BKE_material_free(mat); + /* don't update user counts as we are freeing a duplicate */ + BKE_material_free_ex(mat, false); MEM_freeN(mat); } -- cgit v1.2.3 From e3a79258d17e6cdca26120eab7a2c48c7c4d4a0f Mon Sep 17 00:00:00 2001 From: Martijn Berger Date: Fri, 22 Nov 2013 14:16:47 +0100 Subject: Cycles: test code for sse 4.1 kernel and alignment for some vector types. This is mostly work towards enabling the __KERNEL_SSE__ option to start using SIMD operations for vector math operations. This 4.1 kernel performes about 8% faster with that option but overall is still slower than without the option. WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 is the cmake flag for testing this kernel. Alignment of int3, int4, float3, float4 to 16 bytes seems to give a slight 1-2% speedup on tested systems with the current kernel already, so is enabled now. --- intern/cycles/CMakeLists.txt | 4 ++ intern/cycles/SConscript | 10 +++++ intern/cycles/device/CMakeLists.txt | 4 ++ intern/cycles/device/device_cpu.cpp | 50 +++++++++++++++++++++++ intern/cycles/kernel/CMakeLists.txt | 9 ++++- intern/cycles/kernel/kernel.h | 9 +++++ intern/cycles/kernel/kernel_sse41.cpp | 76 +++++++++++++++++++++++++++++++++++ intern/cycles/util/util_math.h | 13 ++++++ intern/cycles/util/util_system.cpp | 5 +++ intern/cycles/util/util_system.h | 1 + intern/cycles/util/util_types.h | 12 ++++-- 11 files changed, 187 insertions(+), 6 deletions(-) create mode 100644 intern/cycles/kernel/kernel_sse41.cpp diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 6821e93ad87..9b84f882046 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -17,9 +17,11 @@ if(WIN32 AND MSVC) if(CMAKE_CL_64) set(CYCLES_SSE2_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") set(CYCLES_SSE3_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") + set(CYCLES_SSE41_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") else() set(CYCLES_SSE2_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") set(CYCLES_SSE3_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") + set(CYCLES_SSE41_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") @@ -29,10 +31,12 @@ if(WIN32 AND MSVC) elseif(CMAKE_COMPILER_IS_GNUCC) set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2 -mfpmath=sse") set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse") + set(CYCLES_SSE41_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mfpmath=sse") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math") elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CYCLES_SSE2_KERNEL_FLAGS "-ffast-math -msse -msse2") set(CYCLES_SSE3_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3") + set(CYCLES_SSE41_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math") endif() diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript index e61018bc3dd..eeb60f37f92 100644 --- a/intern/cycles/SConscript +++ b/intern/cycles/SConscript @@ -37,6 +37,7 @@ sources = cycles.Glob('bvh/*.cpp') + cycles.Glob('device/*.cpp') + cycles.Glob(' sources.remove(path.join('util', 'util_view.cpp')) sources.remove(path.join('kernel', 'kernel_sse2.cpp')) sources.remove(path.join('kernel', 'kernel_sse3.cpp')) +sources.remove(path.join('kernel', 'kernel_sse41.cpp')) incs = [] defs = [] @@ -77,21 +78,30 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', ' if env['WITH_BF_RAYOPTIMIZATION']: sse2_cxxflags = Split(env['CXXFLAGS']) sse3_cxxflags = Split(env['CXXFLAGS']) + sse41_cxxflags = Split(env['CXXFLAGS']) if env['OURPLATFORM'] == 'win32-vc': # there is no /arch:SSE3, but intrinsics are available anyway sse2_cxxflags.append('/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split()) sse3_cxxflags.append('/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split()) + sse41_cxxflags.append('/arch:SSE /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split()) elif env['OURPLATFORM'] == 'win64-vc': sse2_cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split()) sse3_cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split()) + sse41_cxxflags.append('-D_CRT_SECURE_NO_WARNINGS /fp:fast /Ox /Gs-'.split()) else: sse2_cxxflags.append('-ffast-math -msse -msse2 -mfpmath=sse'.split()) sse3_cxxflags.append('-ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse'.split()) + sse41_cxxflags.append('-ffast-math -msse -msse2 -msse3 -mssse3 -msse4.1 -mfpmath=sse'.split()) defs.append('WITH_OPTIMIZED_KERNEL') optim_defs = defs[:] + # Disabled sse4+ patchs for now + #cycles_sse41 = cycles.Clone() + #sse41_sources = [path.join('kernel', 'kernel_sse41.cpp')] + #cycles_sse41.BlenderLib('bf_intern_cycles_sse41', sse41_sources, incs, optim_defs, libtype=['intern'], priority=[10], cxx_compileflags=sse41_cxxflags) + cycles_sse3 = cycles.Clone() sse3_sources = [path.join('kernel', 'kernel_sse3.cpp')] cycles_sse3.BlenderLib('bf_intern_cycles_sse3', sse3_sources, incs, optim_defs, libtype=['intern'], priority=[10], cxx_compileflags=sse3_cxxflags) diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt index fe2368b7ea8..920223dd8a4 100644 --- a/intern/cycles/device/CMakeLists.txt +++ b/intern/cycles/device/CMakeLists.txt @@ -13,6 +13,10 @@ set(INC_SYS ${GLEW_INCLUDE_PATH} ) +if(WITH_CYCLES_OPTIMIZED_KERNEL_SSE41) + add_definitions(-DWITH_CYCLES_OPTIMIZED_KERNEL_SSE41=1) +endif() + set(SRC device.cpp device_cpu.cpp diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index d04c5df82fb..85a7b9c186d 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -58,6 +58,7 @@ public: /* do now to avoid thread issues */ system_cpu_support_sse2(); system_cpu_support_sse3(); + system_cpu_support_sse41(); } ~CPUDevice() @@ -164,6 +165,28 @@ public: int end_sample = tile.start_sample + tile.num_samples; #ifdef WITH_OPTIMIZED_KERNEL +#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 + if(system_cpu_support_sse41()) { + for(int sample = start_sample; sample < end_sample; sample++) { + if (task.get_cancel() || task_pool.canceled()) { + if(task.need_finish_queue == false) + break; + } + + for(int y = tile.y; y < tile.y + tile.h; y++) { + for(int x = tile.x; x < tile.x + tile.w; x++) { + kernel_cpu_sse41_path_trace(&kg, render_buffer, rng_state, + sample, x, y, tile.offset, tile.stride); + } + } + + tile.sample = sample + 1; + + task.update_progress(tile); + } + } + else +#endif if(system_cpu_support_sse3()) { for(int sample = start_sample; sample < end_sample; sample++) { if (task.get_cancel() || task_pool.canceled()) { @@ -243,6 +266,15 @@ public: if(task.rgba_half) { #ifdef WITH_OPTIMIZED_KERNEL +#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 + if(system_cpu_support_sse41()) { + for(int y = task.y; y < task.y + task.h; y++) + for(int x = task.x; x < task.x + task.w; x++) + kernel_cpu_sse41_convert_to_half_float(&kernel_globals, (uchar4*)task.rgba_half, (float*)task.buffer, + sample_scale, x, y, task.offset, task.stride); + } + else +#endif if(system_cpu_support_sse3()) { for(int y = task.y; y < task.y + task.h; y++) for(int x = task.x; x < task.x + task.w; x++) @@ -266,6 +298,14 @@ public: } else { #ifdef WITH_OPTIMIZED_KERNEL +#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 + if(system_cpu_support_sse41()) { + for(int y = task.y; y < task.y + task.h; y++) + for(int x = task.x; x < task.x + task.w; x++) + kernel_cpu_sse41_convert_to_byte(&kernel_globals, (uchar4*)task.rgba_byte, (float*)task.buffer, + sample_scale, x, y, task.offset, task.stride); + } +#endif if(system_cpu_support_sse3()) { for(int y = task.y; y < task.y + task.h; y++) for(int x = task.x; x < task.x + task.w; x++) @@ -298,6 +338,16 @@ public: #endif #ifdef WITH_OPTIMIZED_KERNEL +#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 + if(system_cpu_support_sse41()) { + for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) { + kernel_cpu_sse41_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x); + + if(task_pool.canceled()) + break; + } + } +#endif if(system_cpu_support_sse3()) { for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) { kernel_cpu_sse3_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x); diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 56ba0e08743..39444b91131 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -190,13 +190,18 @@ endif() include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) -add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS}) - if(WITH_CYCLES_OPTIMIZED_KERNEL) set_source_files_properties(kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}") set_source_files_properties(kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}") endif() +if(WITH_CYCLES_OPTIMIZED_KERNEL_SSE41) + set_source_files_properties(kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}") + list(APPEND SRC kernel_sse41.cpp) +endif() + +add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS}) + if(WITH_CYCLES_CUDA) add_dependencies(cycles_kernel cycles_kernel_cuda) endif() diff --git a/intern/cycles/kernel/kernel.h b/intern/cycles/kernel/kernel.h index 361f5b0856d..105a3887da0 100644 --- a/intern/cycles/kernel/kernel.h +++ b/intern/cycles/kernel/kernel.h @@ -61,6 +61,15 @@ void kernel_cpu_sse3_convert_to_half_float(KernelGlobals *kg, uchar4 *rgba, floa float sample_scale, int x, int y, int offset, int stride); void kernel_cpu_sse3_shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int i); + +void kernel_cpu_sse41_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state, + int sample, int x, int y, int offset, int stride); +void kernel_cpu_sse41_convert_to_byte(KernelGlobals *kg, uchar4 *rgba, float *buffer, + float sample_scale, int x, int y, int offset, int stride); +void kernel_cpu_sse41_convert_to_half_float(KernelGlobals *kg, uchar4 *rgba, float *buffer, + float sample_scale, int x, int y, int offset, int stride); +void kernel_cpu_sse41_shader(KernelGlobals *kg, uint4 *input, float4 *output, + int type, int i); #endif CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_sse41.cpp b/intern/cycles/kernel/kernel_sse41.cpp new file mode 100644 index 00000000000..0c68fd3651b --- /dev/null +++ b/intern/cycles/kernel/kernel_sse41.cpp @@ -0,0 +1,76 @@ +/* + * Copyright 2011-2013 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +/* Optimized CPU kernel entry points. This file is compiled with SSE3/SSSE3 + * optimization flags and nearly all functions inlined, while kernel.cpp + * is compiled without for other CPU's. */ + +#ifdef WITH_OPTIMIZED_KERNEL + +/* SSE optimization disabled for now on 32 bit, see bug #36316 */ +#if !(defined(__GNUC__) && (defined(i386) || defined(_M_IX86))) +#define __KERNEL_SSE2__ +#define __KERNEL_SSE3__ +#define __KERNEL_SSSE3__ +#define __KERNEL_SSE41__ +#endif + +#include "kernel.h" +#include "kernel_compat_cpu.h" +#include "kernel_math.h" +#include "kernel_types.h" +#include "kernel_globals.h" +#include "kernel_film.h" +#include "kernel_path.h" +#include "kernel_displace.h" + +CCL_NAMESPACE_BEGIN + +/* Path Tracing */ + +void kernel_cpu_sse41_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride) +{ +#ifdef __BRANCHED_PATH__ + if(kernel_data.integrator.branched) + kernel_branched_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride); + else +#endif + kernel_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride); +} + +/* Film */ + +void kernel_cpu_sse41_convert_to_byte(KernelGlobals *kg, uchar4 *rgba, float *buffer, float sample_scale, int x, int y, int offset, int stride) +{ + kernel_film_convert_to_byte(kg, rgba, buffer, sample_scale, x, y, offset, stride); +} + +void kernel_cpu_sse41_convert_to_half_float(KernelGlobals *kg, uchar4 *rgba, float *buffer, float sample_scale, int x, int y, int offset, int stride) +{ + kernel_film_convert_to_half_float(kg, rgba, buffer, sample_scale, x, y, offset, stride); +} + +/* Shader Evaluate */ + +void kernel_cpu_sse41_shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int i) +{ + kernel_shader_evaluate(kg, input, output, (ShaderEvalType)type, i); +} + +CCL_NAMESPACE_END + +#endif + diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 6db532faf74..851c67b1189 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -462,7 +462,11 @@ ccl_device_inline float3 operator/=(float3& a, float f) ccl_device_inline float dot(const float3 a, const float3 b) { +#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__) + return _mm_cvtss_f32(_mm_dp_ps(a, b, 0x7F)); +#else return a.x*b.x + a.y*b.y + a.z*b.z; +#endif } ccl_device_inline float3 cross(const float3 a, const float3 b) @@ -475,7 +479,11 @@ ccl_device_inline float3 cross(const float3 a, const float3 b) ccl_device_inline float len(const float3 a) { +#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__) + return _mm_cvtss_f32(_mm_sqrt_ss(_mm_dp_ps(a.m128, a.m128, 0x7F))); +#else return sqrtf(dot(a, a)); +#endif } ccl_device_inline float len_squared(const float3 a) @@ -487,7 +495,12 @@ ccl_device_inline float len_squared(const float3 a) ccl_device_inline float3 normalize(const float3 a) { +#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__) + __m128 norm = _mm_sqrt_ps(_mm_dp_ps(a.m128, a.m128, 0x7F)); + return _mm_div_ps(a.m128, norm); +#else return a/len(a); +#endif } #endif diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp index 345c76bdfab..8b249106913 100644 --- a/intern/cycles/util/util_system.cpp +++ b/intern/cycles/util/util_system.cpp @@ -195,6 +195,11 @@ bool system_cpu_support_sse3() return caps.sse && caps.sse2 && caps.sse3 && caps.ssse3; } +bool system_cpu_support_sse41() +{ + CPUCapabilities& caps = system_cpu_capabilities(); + return caps.sse && caps.sse2 && caps.sse3 && caps.ssse3 && caps.sse41; +} #else bool system_cpu_support_sse2() diff --git a/intern/cycles/util/util_system.h b/intern/cycles/util/util_system.h index 333782c2d01..64cfa4906b3 100644 --- a/intern/cycles/util/util_system.h +++ b/intern/cycles/util/util_system.h @@ -26,6 +26,7 @@ string system_cpu_brand_string(); int system_cpu_bits(); bool system_cpu_support_sse2(); bool system_cpu_support_sse3(); +bool system_cpu_support_sse41(); CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index c53d67235f6..fe743221f32 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -95,6 +95,10 @@ #include /* SSSE 3 */ #endif +#ifdef __KERNEL_SSE41__ +#include /* SSE 4.1 */ +#endif + #else /* MinGW64 has conflicting declarations for these SSE headers in . @@ -199,7 +203,7 @@ struct ccl_align(16) int3 { __forceinline operator const __m128i&(void) const { return m128; } __forceinline operator __m128i&(void) { return m128; } #else -struct int3 { +struct ccl_align(16) int3 { int x, y, z, w; #endif @@ -219,7 +223,7 @@ struct ccl_align(16) int4 { __forceinline operator const __m128i&(void) const { return m128; } __forceinline operator __m128i&(void) { return m128; } #else -struct int4 { +struct ccl_align(16) int4 { int x, y, z, w; #endif @@ -267,7 +271,7 @@ struct ccl_align(16) float3 { __forceinline operator const __m128&(void) const { return m128; } __forceinline operator __m128&(void) { return m128; } #else -struct float3 { +struct ccl_align(16) float3 { float x, y, z, w; #endif @@ -287,7 +291,7 @@ struct ccl_align(16) float4 { __forceinline operator const __m128&(void) const { return m128; } __forceinline operator __m128&(void) { return m128; } #else -struct float4 { +struct ccl_align(16) float4 { float x, y, z, w; #endif -- cgit v1.2.3 From 9c5fb7b2e7ecb0271371cd729808da44c3bc1bc3 Mon Sep 17 00:00:00 2001 From: Henrik Aarnio Date: Fri, 22 Nov 2013 14:35:34 +0100 Subject: Fix T37485: autocomplete while appending and autocomplete folder behaviour. This adds functionality to tab-autocomplete folders in the file browser file field, and the ability to autocomplete .blend files and their sub folders while linking. If only one match of a blend or a folder is found, it is opened, which applies to wildcards in the file field now. Reviewed By: elubie, brecht Differential Revision: http://developer.blender.org/D20 --- source/blender/editors/space_file/file_draw.c | 2 +- source/blender/editors/space_file/file_intern.h | 1 + source/blender/editors/space_file/file_ops.c | 59 ++++++++++++++++++++++++- source/blender/editors/space_file/filesel.c | 6 +-- source/blender/editors/space_file/space_file.c | 1 + 5 files changed, 64 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index c4e6ca97418..1ec2e3c804b 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -188,7 +188,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiButSetFlag(but, UI_BUT_NO_UTF8); if ((params->flag & FILE_DIRSEL_ONLY) == 0) { - but = uiDefBut(block, TEX, B_FS_FILENAME, "", + but = uiDefButTextO(block, TEX, "FILE_OT_filename", 0, "", min_x, line2_y, line2_w - chan_offs, btn_h, params->file, 0.0, (float)FILE_MAXFILE, 0, 0, TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name"))); diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index d01286442be..134fe0ac6bc 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -73,6 +73,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot); void FILE_OT_parent(struct wmOperatorType *ot); void FILE_OT_directory_new(struct wmOperatorType *ot); void FILE_OT_directory(struct wmOperatorType *ot); +void FILE_OT_filename(struct wmOperatorType *ot); void FILE_OT_previous(struct wmOperatorType *ot); void FILE_OT_next(struct wmOperatorType *ot); void FILE_OT_refresh(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index a97b3b1d719..ebc232e3ef1 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -32,6 +32,8 @@ #include "BLI_utildefines.h" #include "BLI_fileops_types.h" +#include "BLO_readfile.h" + #include "BKE_context.h" #include "BKE_screen.h" #include "BKE_global.h" @@ -1240,13 +1242,31 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) return OPERATOR_FINISHED; } +static int file_filename_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + SpaceFile *sfile = CTX_wm_space_file(C); + + if (sfile->params) { + file_expand_directory(C); + + return file_filename_exec(C, op); + } + + return OPERATOR_CANCELLED; +} + int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile = CTX_wm_space_file(C); char matched_file[FILE_MAX]; + char filepath[sizeof(sfile->params->dir)]; + if (sfile->params) { + int matches = 0; matched_file[0] = '\0'; - if (file_select_match(sfile, sfile->params->file, matched_file)) { + filepath[0] = '\0'; + + if (matches = file_select_match(sfile, sfile->params->file, matched_file)) { /* int i, numfiles = filelist_numfiles(sfile->files); */ /* XXX UNUSED */ sfile->params->file[0] = '\0'; /* replace the pattern (or filename that the user typed in, with the first selected file of the match */ @@ -1254,6 +1274,31 @@ int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } + + if (matches == 1) { + + BLI_join_dirfile(filepath, sizeof(sfile->params->dir), sfile->params->dir, sfile->params->file); + + /* if directory, open it and empty filename field */ + if (BLI_is_dir(filepath)) { + BLI_cleanup_dir(G.main->name, filepath); + BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir)); + sfile->params->file[0] = '\0'; + file_change_dir(C, 1); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + } + else if (sfile->params->type == FILE_LOADLIB){ + char tdir[FILE_MAX], tgroup[FILE_MAX]; + BLI_add_slash(filepath); + if (BLO_is_a_library(filepath, tdir, tgroup)) { + BLI_cleanup_dir(G.main->name, filepath); + BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir)); + sfile->params->file[0] = '\0'; + file_change_dir(C, 0); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); + } + } + } } return OPERATOR_FINISHED; @@ -1281,6 +1326,18 @@ void FILE_OT_directory(struct wmOperatorType *ot) ot->poll = file_directory_poll; /* <- important, handler is on window level */ } +void FILE_OT_filename(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Enter File Name"; + ot->description = "Enter a file name"; + ot->idname = "FILE_OT_filename"; + + /* api callbacks */ + ot->invoke = file_filename_invoke; + ot->exec = file_filename_exec; +} + void FILE_OT_refresh(struct wmOperatorType *ot) { /* identifiers */ diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index c6e1541352d..3cda5dd5e80 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -627,7 +627,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche if (!match) { BLI_strncpy(matched_file, file->relname, FILE_MAX); } - match = 1; + match++; } } @@ -700,13 +700,13 @@ bool autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) for (i = 0; i < nentries; ++i) { struct direntry *file = filelist_file(sfile->files, i); - if (file && S_ISREG(file->type)) { + if (file && (S_ISREG(file->type) || S_ISDIR(file->type))) { autocomplete_do_name(autocpl, file->relname); } } match = autocomplete_end(autocpl, str); } - return match != AUTOCOMPLETE_NO_MATCH; + return match == AUTOCOMPLETE_FULL_MATCH; } void ED_fileselect_clear(struct wmWindowManager *wm, struct SpaceFile *sfile) diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 1a8565a58b1..0bc2d073e0a 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -396,6 +396,7 @@ static void file_operatortypes(void) WM_operatortype_append(FILE_OT_rename); WM_operatortype_append(FILE_OT_smoothscroll); WM_operatortype_append(FILE_OT_directory); + WM_operatortype_append(FILE_OT_filename); } /* NOTE: do not add .blend file reading on this level */ -- cgit v1.2.3 From 70218ad14d156d47d729cd05e6ad993b4e7048a0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 23 Nov 2013 02:06:06 +1100 Subject: Style Cleanup: whitespace --- source/blender/editors/space_file/file_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index ebc232e3ef1..ca2f7b41334 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -1266,7 +1266,7 @@ int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) matched_file[0] = '\0'; filepath[0] = '\0'; - if (matches = file_select_match(sfile, sfile->params->file, matched_file)) { + if ((matches = file_select_match(sfile, sfile->params->file, matched_file))) { /* int i, numfiles = filelist_numfiles(sfile->files); */ /* XXX UNUSED */ sfile->params->file[0] = '\0'; /* replace the pattern (or filename that the user typed in, with the first selected file of the match */ @@ -1287,7 +1287,7 @@ int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) file_change_dir(C, 1); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } - else if (sfile->params->type == FILE_LOADLIB){ + else if (sfile->params->type == FILE_LOADLIB) { char tdir[FILE_MAX], tgroup[FILE_MAX]; BLI_add_slash(filepath); if (BLO_is_a_library(filepath, tdir, tgroup)) { -- cgit v1.2.3 From 5a4f7f46a569f7251b51a8b2199603af75782c83 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 22 Nov 2013 23:28:35 +0600 Subject: Ignore *.patch and *.diff files which are in the working tree root --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d4e04b64dca..e0228f27ced 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ Desktop.ini /blender.bin /user-config.py +# local patches +/*.patch +/*.diff -- cgit v1.2.3 From 58ec292fd82a168ac4901163c525325b6e28ae70 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 23 Nov 2013 05:24:26 +0100 Subject: Fix cycles build error with visual studio, apparently the windows ABI does not like 16 bit alignment on 32 bit. --- intern/cycles/util/util_types.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index fe743221f32..3fa1df6ab44 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -23,6 +23,12 @@ #endif +/* Bitness */ + +#if defined(__ppc64__) || defined(__PPC64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_X64) +#define __KERNEL_64_BIT__ +#endif + /* Qualifiers for kernel code shared by CPU and GPU */ #ifndef __KERNEL_GPU__ @@ -34,7 +40,11 @@ #if defined(_WIN32) && !defined(FREE_WINDOWS) #define ccl_device_inline static __forceinline +#ifdef __KERNEL_64_BIT__ #define ccl_align(...) __declspec(align(__VA_ARGS__)) +#else +#define ccl_align(...) /* not support for function arguments (error C2719) */ +#endif #define ccl_may_alias #else #define ccl_device_inline static inline __attribute__((always_inline)) @@ -47,12 +57,6 @@ #endif -/* Bitness */ - -#if defined(__ppc64__) || defined(__PPC64__) || defined(__x86_64__) || defined(__ia64__) || defined(_M_X64) -#define __KERNEL_64_BIT__ -#endif - /* SIMD Types */ #ifndef __KERNEL_GPU__ -- cgit v1.2.3 From ff66f3d3adc1022d732fba4f4d120067fa87f3f8 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 23 Nov 2013 18:44:39 +1300 Subject: Anim Editors: Refactored animchannel type definition callbacks to use bools Changes: - acf.name_prop() and acf.has_setting() now return bools instead of shorts - Renamed a few name_prop() callbacks whose names ended in "_nameprop" instead of "_name_prop", which made it difficult to safely find all such instances --- .../editors/animation/anim_channels_defines.c | 164 ++++++++++----------- source/blender/editors/include/ED_anim_api.h | 4 +- 2 files changed, 84 insertions(+), 84 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 1d9022e463b..958f721a241 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -342,7 +342,7 @@ static void acf_generic_idblock_name(bAnimListElem *ale, char *name) } /* name property for ID block entries */ -static short acf_generic_idblock_nameprop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +static bool acf_generic_idblock_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { RNA_id_pointer_create(ale->id, ptr); *prop = RNA_struct_name_property(ptr->type); @@ -352,7 +352,7 @@ static short acf_generic_idblock_nameprop(bAnimListElem *ale, PointerRNA *ptr, P /* name property for ID block entries which are just subheading "fillers" */ -static short acf_generic_idfill_nameprop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +static bool acf_generic_idfill_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { /* actual ID we're representing is stored in ale->data not ale->id, as id gives the owner */ RNA_id_pointer_create(ale->data, ptr); @@ -365,19 +365,19 @@ static short acf_generic_idfill_nameprop(bAnimListElem *ale, PointerRNA *ptr, Pr #if 0 /* channel type has no settings */ -static short acf_generic_none_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +static bool acf_generic_none_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) { - return 0; + return false; } #endif /* check if some setting exists for this object-based data-expander (datablock only) */ -static short acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting) +static bool acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting) { switch (setting) { /* expand is always supported */ case ACHANNEL_SETTING_EXPAND: - return 1; + return true; /* mute is only supported for NLA */ case ACHANNEL_SETTING_MUTE: @@ -385,11 +385,11 @@ static short acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListEle /* select is ok for most "ds*" channels (e.g. dsmat) */ case ACHANNEL_SETTING_SELECT: - return 1; + return true; /* other flags are never supported */ default: - return 0; + return false; } } @@ -438,7 +438,7 @@ static int acf_summary_icon(bAnimListElem *UNUSED(ale)) } /* check if some setting exists for this channel */ -static short acf_summary_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) +static bool acf_summary_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) { /* only expanded is supported, as it is used for hiding all stuff which the summary covers */ return (setting == ACHANNEL_SETTING_EXPAND); @@ -509,7 +509,7 @@ static int acf_scene_icon(bAnimListElem *UNUSED(ale)) } /* check if some setting exists for this channel */ -static short acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting) +static bool acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting) { switch (setting) { /* muted only in NLA */ @@ -523,10 +523,10 @@ static short acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale /* only select and expand supported otherwise */ case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: - return 1; + return true; default: - return 0; + return false; } } @@ -593,7 +593,7 @@ static bAnimChannelType ACF_SCENE = NULL, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_scene_icon, /* icon */ acf_scene_setting_valid, /* has setting */ @@ -649,7 +649,7 @@ static void acf_object_name(bAnimListElem *ale, char *name) } /* check if some setting exists for this channel */ -static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +static bool acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) { Base *base = (Base *)ale->data; Object *ob = base->object; @@ -666,10 +666,10 @@ static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int /* only select and expand supported otherwise */ case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: - return 1; + return true; default: - return 0; + return false; } } @@ -737,7 +737,7 @@ static bAnimChannelType ACF_OBJECT = NULL, /* offset */ acf_object_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_object_icon, /* icon */ acf_object_setting_valid, /* has setting */ @@ -803,7 +803,7 @@ static void acf_group_name(bAnimListElem *ale, char *name) } /* name property for group entries */ -static short acf_group_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +static bool acf_group_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { RNA_pointer_create(ale->id, &RNA_ActionGroup, ale->data, ptr); *prop = RNA_struct_name_property(ptr->type); @@ -812,20 +812,20 @@ static short acf_group_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRN } /* check if some setting exists for this channel */ -static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting) +static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting) { /* for now, all settings are supported, though some are only conditionally */ switch (setting) { /* unsupported */ case ACHANNEL_SETTING_SOLO: /* Only available in NLA Editor for tracks */ - return 0; + return false; /* conditionally supported */ case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ return (ac->spacetype == SPACE_IPO); default: /* always supported */ - return 1; + return true; } } @@ -903,7 +903,7 @@ static void acf_fcurve_name(bAnimListElem *ale, char *name) } /* "name" property for fcurve entries */ -static short acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { FCurve *fcu = (FCurve *)ale->data; @@ -924,7 +924,7 @@ static short acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyR } /* check if some setting exists for this channel */ -static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) +static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) { FCurve *fcu = (FCurve *)ale->data; @@ -932,21 +932,21 @@ static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int /* unsupported */ case ACHANNEL_SETTING_SOLO: /* Solo Flag is only for NLA */ case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */ - return 0; + return false; /* conditionally available */ case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */ if (fcu->bezt) - return 1; + return true; else - return 0; // NOTE: in this special case, we need to draw ICON_ZOOMOUT + return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ return (ac->spacetype == SPACE_IPO); /* always available */ default: - return 1; + return true; } } @@ -1012,16 +1012,16 @@ static int acf_fillactd_icon(bAnimListElem *UNUSED(ale)) } /* check if some setting exists for this channel */ -static short acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) +static bool acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) { switch (setting) { /* only select and expand supported */ case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: - return 1; + return true; default: - return 0; + return false; } } @@ -1079,7 +1079,7 @@ static bAnimChannelType ACF_FILLACTD = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ + acf_generic_idfill_name_prop, /* name prop */ acf_fillactd_icon, /* icon */ acf_fillactd_setting_valid, /* has setting */ @@ -1102,15 +1102,15 @@ static void acf_filldrivers_name(bAnimListElem *UNUSED(ale), char *name) /* check if some setting exists for this channel */ // TODO: this could be made more generic -static short acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) +static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) { switch (setting) { /* only expand supported */ case ACHANNEL_SETTING_EXPAND: - return 1; + return true; default: - return 0; + return false; } } @@ -1235,7 +1235,7 @@ static bAnimChannelType ACF_DSMAT = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dsmat_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -1311,7 +1311,7 @@ static bAnimChannelType ACF_DSLAM = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dslam_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -1394,7 +1394,7 @@ static bAnimChannelType ACF_DSTEX = acf_dstex_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ + acf_generic_idfill_name_prop, /* name prop */ acf_dstex_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -1470,7 +1470,7 @@ static bAnimChannelType ACF_DSCAM = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ + acf_generic_idfill_name_prop, /* name prop */ acf_dscam_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -1556,7 +1556,7 @@ static bAnimChannelType ACF_DSCUR = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dscur_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -1632,7 +1632,7 @@ static bAnimChannelType ACF_DSSKEY = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dsskey_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -1708,7 +1708,7 @@ static bAnimChannelType ACF_DSWOR = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ + acf_generic_idfill_name_prop, /* name prop */ acf_dswor_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -1784,7 +1784,7 @@ static bAnimChannelType ACF_DSPART = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dspart_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -1860,7 +1860,7 @@ static bAnimChannelType ACF_DSMBALL = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dsmball_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -1936,7 +1936,7 @@ static bAnimChannelType ACF_DSARM = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dsarm_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -2023,7 +2023,7 @@ static bAnimChannelType ACF_DSNTREE = acf_dsntree_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dsntree_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -2099,7 +2099,7 @@ static bAnimChannelType ACF_DSLINESTYLE = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dslinestyle_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -2175,7 +2175,7 @@ static bAnimChannelType ACF_DSMESH = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dsmesh_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -2251,7 +2251,7 @@ static bAnimChannelType ACF_DSLAT = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dslat_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -2327,7 +2327,7 @@ static bAnimChannelType ACF_DSSPK = acf_generic_basic_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ + acf_generic_idblock_name_prop, /* name prop */ acf_dsspk_icon, /* icon */ acf_generic_dataexpand_setting_valid, /* has setting */ @@ -2353,7 +2353,7 @@ static void acf_shapekey_name(bAnimListElem *ale, char *name) } /* name property for ShapeKey entries */ -static short acf_shapekey_nameprop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +static bool acf_shapekey_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { KeyBlock *kb = (KeyBlock *)ale->data; @@ -2365,21 +2365,21 @@ static short acf_shapekey_nameprop(bAnimListElem *ale, PointerRNA *ptr, Property return (*prop != NULL); } - return 0; + return false; } /* check if some setting exists for this channel */ -static short acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) +static bool acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) { switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted */ case ACHANNEL_SETTING_PROTECT: /* protected */ - return 1; + return true; /* nothing else is supported */ default: - return 0; + return false; } } @@ -2434,7 +2434,7 @@ static bAnimChannelType ACF_SHAPEKEY = acf_generic_basic_offset, /* offset */ acf_shapekey_name, /* name */ - acf_shapekey_nameprop, /* name prop */ + acf_shapekey_name_prop, /* name prop */ NULL, /* icon */ acf_shapekey_setting_valid, /* has setting */ @@ -2458,16 +2458,16 @@ static int acf_gpd_icon(bAnimListElem *UNUSED(ale)) } /* check if some setting exists for this channel */ -static short acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) +static bool acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) { switch (setting) { /* only select and expand supported */ case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: - return 1; + return true; default: - return 0; + return false; } } @@ -2509,7 +2509,7 @@ static bAnimChannelType ACF_GPD = acf_generic_group_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ + acf_generic_idfill_name_prop, /* name prop */ acf_gpd_icon, /* icon */ acf_gpd_setting_valid, /* has setting */ @@ -2529,7 +2529,7 @@ static void acf_gpl_name(bAnimListElem *ale, char *name) } /* name property for grease pencil layer entries */ -static short acf_gpl_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +static bool acf_gpl_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { if (ale->data) { RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, ptr); @@ -2538,22 +2538,22 @@ static short acf_gpl_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA return (*prop != NULL); } - return 0; + return false; } /* check if some setting exists for this channel */ -static short acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) +static bool acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) { switch (setting) { /* unsupported */ case ACHANNEL_SETTING_EXPAND: /* gpencil layers are more like F-Curves than groups */ case ACHANNEL_SETTING_VISIBLE: /* graph editor only */ case ACHANNEL_SETTING_SOLO: /* nla editor only */ - return 0; + return false; /* always available */ default: - return 1; + return true; } } @@ -2624,16 +2624,16 @@ static int acf_mask_icon(bAnimListElem *UNUSED(ale)) } /* check if some setting exists for this channel */ -static short acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) +static bool acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) { switch (setting) { /* only select and expand supported */ case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: - return 1; + return true; default: - return 0; + return false; } } @@ -2675,7 +2675,7 @@ static bAnimChannelType ACF_MASKDATA = acf_generic_group_offset, /* offset */ acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ + acf_generic_idfill_name_prop, /* name prop */ acf_mask_icon, /* icon */ acf_mask_setting_valid, /* has setting */ @@ -2695,7 +2695,7 @@ static void acf_masklay_name(bAnimListElem *ale, char *name) } /* name property for grease pencil layer entries */ -static short acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +static bool acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { if (ale->data) { RNA_pointer_create(ale->id, &RNA_MaskLayer, ale->data, ptr); @@ -2704,22 +2704,22 @@ static short acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, Property return (*prop != NULL); } - return 0; + return false; } /* check if some setting exists for this channel */ -static short acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) +static bool acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), int setting) { switch (setting) { /* unsupported */ case ACHANNEL_SETTING_EXPAND: /* mask layers are more like F-Curves than groups */ case ACHANNEL_SETTING_VISIBLE: /* graph editor only */ case ACHANNEL_SETTING_SOLO: /* nla editor only */ - return 0; + return false; /* always available */ default: - return 1; + return true; } } @@ -2804,7 +2804,7 @@ static void acf_nlatrack_name(bAnimListElem *ale, char *name) } /* name property for nla track entries */ -static short acf_nlatrack_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) +static bool acf_nlatrack_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { if (ale->data) { RNA_pointer_create(ale->id, &RNA_NlaTrack, ale->data, ptr); @@ -2813,11 +2813,11 @@ static short acf_nlatrack_name_prop(bAnimListElem *ale, PointerRNA *ptr, Propert return (*prop != NULL); } - return 0; + return false; } /* check if some setting exists for this channel */ -static short acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *ale, int setting) +static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *ale, int setting) { NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; @@ -2827,7 +2827,7 @@ static short acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem /* always supported */ case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_SOLO: - return 1; + return true; /* conditionally supported... */ case ACHANNEL_SETTING_PROTECT: @@ -2838,26 +2838,26 @@ static short acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) { if (nlt->flag & NLATRACK_SOLO) { /* ok - we've got a solo track, and this is it */ - return 1; + return true; } else { /* not ok - we've got a solo track, but this isn't it, so make it more obvious */ - return 0; + return false; } } /* ok - no tracks are solo'd, and this isn't being tweaked */ - return 1; + return true; } else { /* unsupported - this track is being tweaked */ - return 0; + return false; } /* unsupported */ default: - return 0; + return false; } } diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index d98fa1fc32f..a0dc5f48fdb 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -396,13 +396,13 @@ typedef struct bAnimChannelType { /* get name (for channel lists) */ void (*name)(bAnimListElem *ale, char *name); /* get RNA property+pointer for editing the name */ - short (*name_prop)(bAnimListElem *ale, struct PointerRNA *ptr, struct PropertyRNA **prop); + bool (*name_prop)(bAnimListElem *ale, struct PointerRNA *ptr, struct PropertyRNA **prop); /* get icon (for channel lists) */ int (*icon)(bAnimListElem *ale); /* settings */ /* check if the given setting is valid in the current context */ - short (*has_setting)(bAnimContext *ac, bAnimListElem *ale, int setting); + bool (*has_setting)(bAnimContext *ac, bAnimListElem *ale, int setting); /* get the flag used for this setting */ int (*setting_flag)(bAnimContext *ac, int setting, short *neg); /* get the pointer to int/short where data is stored, -- cgit v1.2.3 From 1d3309831404d0e0a6dca0bafb8260dbe77f2afa Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 23 Nov 2013 18:58:45 +1300 Subject: More short->bool refactoring work for anim channel type define callbacks Changed the "neg" flag for acf.setting_flag() to be a bool --- .../editors/animation/anim_channels_defines.c | 170 ++++++++++----------- source/blender/editors/include/ED_anim_api.h | 2 +- 2 files changed, 84 insertions(+), 88 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 958f721a241..75363f4f567 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -445,16 +445,16 @@ static bool acf_summary_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *U } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { if (setting == ACHANNEL_SETTING_EXPAND) { /* expanded */ - *neg = 1; + *neg = true; return ADS_FLAG_SUMMARY_COLLAPSED; } else { /* unsupported */ - *neg = 0; + *neg = false; return 0; } } @@ -531,24 +531,24 @@ static bool acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return SCE_DS_SELECTED; case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg = 1; + *neg = true; return SCE_DS_COLLAPSED; case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; default: /* unsupported */ @@ -674,10 +674,10 @@ static bool acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int s } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -691,7 +691,7 @@ static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; default: /* unsupported */ @@ -830,10 +830,10 @@ static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg) +static int acf_group_setting_flag(bAnimContext *ac, int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -854,7 +854,6 @@ static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg) return AGRP_MUTED; case ACHANNEL_SETTING_PROTECT: /* protected */ - // *neg = 1; - if we change this to edtiability return AGRP_PROTECTED; case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */ @@ -951,10 +950,10 @@ static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int s } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -964,7 +963,6 @@ static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, short return FCURVE_MUTED; case ACHANNEL_SETTING_PROTECT: /* protected */ - // *neg = 1; - if we change this to edtiability return FCURVE_PROTECTED; case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */ @@ -1026,17 +1024,17 @@ static bool acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem * } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg = 1; + *neg = true; return ACT_COLLAPSED; default: /* unsupported */ @@ -1115,14 +1113,14 @@ static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListEle } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg = 1; + *neg = true; return ADT_DRIVERS_COLLAPSED; default: /* unsupported */ @@ -1176,10 +1174,10 @@ static int acf_dsmat_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1189,7 +1187,7 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1252,10 +1250,10 @@ static int acf_dslam_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1265,7 +1263,7 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1335,10 +1333,10 @@ static short acf_dstex_offset(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(al } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1348,7 +1346,7 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1411,10 +1409,10 @@ static int acf_dscam_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1424,7 +1422,7 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1497,10 +1495,10 @@ static int acf_dscur_icon(bAnimListElem *ale) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1510,7 +1508,7 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1573,10 +1571,10 @@ static int acf_dsskey_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1586,7 +1584,7 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1649,10 +1647,10 @@ static int acf_dswor_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1662,7 +1660,7 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1725,10 +1723,10 @@ static int acf_dspart_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1738,7 +1736,7 @@ static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1801,10 +1799,10 @@ static int acf_dsmball_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1814,7 +1812,7 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1877,10 +1875,10 @@ static int acf_dsarm_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1890,7 +1888,7 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1964,10 +1962,10 @@ static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1977,7 +1975,7 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2040,10 +2038,10 @@ static int acf_dslinestyle_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2053,7 +2051,7 @@ static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), int setting, s return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2116,10 +2114,10 @@ static int acf_dsmesh_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2129,7 +2127,7 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2192,10 +2190,10 @@ static int acf_dslat_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2205,7 +2203,7 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2268,10 +2266,10 @@ static int acf_dsspk_icon(bAnimListElem *UNUSED(ale)) } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2281,7 +2279,7 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg = 1; + *neg = true; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2384,10 +2382,10 @@ static bool acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem * } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_MUTE: /* mute */ @@ -2472,10 +2470,10 @@ static bool acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSE } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2558,10 +2556,10 @@ static bool acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSE } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2571,7 +2569,6 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *ne return GP_LAYER_HIDE; case ACHANNEL_SETTING_PROTECT: /* protected */ - // *neg = 1; - if we change this to editability return GP_LAYER_LOCKED; default: /* unsupported */ @@ -2638,10 +2635,10 @@ static bool acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUS } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2724,20 +2721,16 @@ static bool acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *U } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return MASK_LAYERFLAG_SELECT; -// case ACHANNEL_SETTING_MUTE: /* muted */ -// return GP_LAYER_HIDE; - case ACHANNEL_SETTING_PROTECT: /* protected */ - // *neg = 1; - if we change this to editability return MASK_LAYERFLAG_LOCKED; default: /* unsupported */ @@ -2862,10 +2855,10 @@ static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem * } /* get the appropriate flag(s) for the setting when it is valid */ -static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) +static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac), int setting, bool *neg) { /* clear extra return data first */ - *neg = 0; + *neg = false; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -3037,7 +3030,8 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting /* 1) check that the setting exists for the current context */ if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) { /* 2) get pointer to check for flag in, and the flag to check for */ - short negflag, ptrsize; + short ptrsize; + bool negflag; int flag; void *ptr; @@ -3112,7 +3106,8 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, /* 1) check that the setting exists for the current context */ if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) { /* 2) get pointer to check for flag in, and the flag to check for */ - short negflag, ptrsize; + short ptrsize; + bool negflag; int flag; void *ptr; @@ -3494,7 +3489,8 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChannelType *acf, uiBlock *block, int xpos, int ypos, int setting) { - short negflag, ptrsize /* , enabled */ /* UNUSED */, butType; + short ptrsize, butType; + bool negflag; int flag, icon; void *ptr; const char *tooltip; diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index a0dc5f48fdb..8b9bb0a4ab0 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -404,7 +404,7 @@ typedef struct bAnimChannelType { /* check if the given setting is valid in the current context */ bool (*has_setting)(bAnimContext *ac, bAnimListElem *ale, int setting); /* get the flag used for this setting */ - int (*setting_flag)(bAnimContext *ac, int setting, short *neg); + int (*setting_flag)(bAnimContext *ac, int setting, bool *neg); /* get the pointer to int/short where data is stored, * with type being sizeof(ptr_data) which should be fine for runtime use... * - assume that setting has been checked to be valid for current context -- cgit v1.2.3 From 2cb63486a9cedf79aa4e10a26338acf8d7d7e94c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 23 Nov 2013 06:50:19 +0100 Subject: Fix scons build error compiling 32 bit OS X built on 64 bit. --- intern/locale/SConscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/locale/SConscript b/intern/locale/SConscript index 42941e2105f..4136ac8237d 100644 --- a/intern/locale/SConscript +++ b/intern/locale/SConscript @@ -58,9 +58,9 @@ if env['WITH_BF_INTERNATIONAL']: os.makedirs(build_dir) msgfmt_tool = env.Clone() + msgfmt_tool.Append(LINKFLAGS = env['PLATFORM_LINKFLAGS']) + targetpath = root_build_dir + '/msgfmt' - if env['OURPLATFORM'] == 'darwin': - msgfmt_tool.Replace( LINKFLAGS = '/usr/lib/libgcc_s.1.dylib /usr/lib/libstdc++.6.dylib /usr/lib/libSystem.B.dylib') # only need these dependencies msgfmt_target = msgfmt_tool.Program(target = targetpath, source = ['msgfmt.cc']) -- cgit v1.2.3 From d846c9a3b75c3d6f20bc7ab7d2da6cdd18bbbef2 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sat, 23 Nov 2013 16:39:07 +0100 Subject: OSX: fix T37065 cmd+c not working in Info - console --- source/blender/editors/space_info/space_info.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index aaa52597357..96e0de17918 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -220,6 +220,9 @@ static void info_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "INFO_OT_report_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "INFO_OT_report_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "INFO_OT_report_copy", CKEY, KM_PRESS, KM_CTRL, 0); +#ifdef __APPLE__ + WM_keymap_add_item(keymap, "INFO_OT_report_copy", CKEY, KM_PRESS, KM_OSKEY, 0); +#endif } /* add handlers, stuff you only do once or on area/region changes */ -- cgit v1.2.3