Merged from trunk 38474-38568
authorJason Hays <jason_hays22@mymail.eku.edu>
Thu, 21 Jul 2011 16:51:36 +0000 (16:51 +0000)
committerJason Hays <jason_hays22@mymail.eku.edu>
Thu, 21 Jul 2011 16:51:36 +0000 (16:51 +0000)
29 files changed:
GNUmakefile
build_files/scons/tools/Blender.py
intern/ghost/intern/GHOST_SystemX11.cpp
release/scripts/modules/bpy/path.py
release/scripts/modules/bpy/utils.py
release/scripts/modules/bpy_extras/image_utils.py
release/scripts/startup/bl_operators/image.py
release/scripts/startup/bl_operators/object_align.py
release/scripts/startup/bl_ui/properties_material.py
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenlib/intern/path_util.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/object/object_bake.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_intern.h
source/blender/makesdna/DNA_image_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_image.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_api.c
source/blender/modifiers/intern/MOD_util.h
source/blender/nodes/intern/SHD_util.c
source/blender/python/mathutils/mathutils_Matrix.c
source/blender/windowmanager/intern/wm_operators.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index d1a60ce..b6741d7 100644 (file)
@@ -73,7 +73,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"
@@ -112,6 +112,6 @@ test_deprecated:
        python3 source/tests/check_deprecated.py
 
 clean:
-       make -C $(BUILD_DIR) clean
+       $(MAKE) -C $(BUILD_DIR) clean
 
 .PHONY: all
index d8f5ba9..75af7e4 100644 (file)
@@ -320,11 +320,7 @@ def creator(env):
         defs.append('WITH_PYTHON')
         if env['BF_DEBUG']:
             defs.append('_DEBUG')
-        
-    if env['BF_BUILDINFO']:
-        defs.append('BUILD_DATE')
-        defs.append('NAN_BUILDINFO')
-        
+
     if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
         incs.append(env['BF_PTHREADS_INC'])
 
index 3ebd24c..dd296fa 100644 (file)
@@ -150,8 +150,9 @@ GHOST_SystemX11(
        if (gettimeofday(&tv,NULL) == -1) {
                GHOST_ASSERT(false,"Could not instantiate timer!");
        }
-
-       m_start_time = GHOST_TUns64(tv.tv_sec*1000 + tv.tv_usec/1000);
+       
+       // Taking care not to overflow the tv.tv_sec*1000
+       m_start_time = GHOST_TUns64(tv.tv_sec)*1000 + tv.tv_usec/1000;
        
        
        /* use detectable autorepeate, mac and windows also do this */
@@ -199,7 +200,8 @@ getMilliSeconds(
                GHOST_ASSERT(false,"Could not compute time!");
        }
 
-       return  GHOST_TUns64(tv.tv_sec*1000 + tv.tv_usec/1000) - m_start_time;
+       // Taking care not to overflow the tv.tv_sec*1000
+       return  GHOST_TUns64(tv.tv_sec)*1000 + tv.tv_usec/1000 - m_start_time;
 }
        
        GHOST_TUns8 
index 5e95428..f6254ef 100644 (file)
@@ -35,7 +35,7 @@ def abspath(path, start=None):
     :type start: string
     """
     if path.startswith("//"):
-        return _os.path.join(_os.path.dirname(_bpy.data.filepath if start is None else start), path[2:])
+        return _os.path.join(_os.path.dirname(_bpy.data.filepath) if start is None else start, path[2:])
 
     return path
 
@@ -117,7 +117,7 @@ def display_name_from_filepath(name):
     """
     Returns the path stripped of directort and extension, ensured to be utf8 compatible.
     """
-    return _os.path.splitext(_os.path.basename(name))[0].encode("utf8", "replace").decode("utf8")
+    return _os.path.splitext(basename(name))[0].encode("utf8", "replace").decode("utf8")
 
 
 def resolve_ncase(path):
@@ -231,3 +231,12 @@ def module_names(path, recursive=False):
                         modules.append(("%s.%s" % (filename, mod_name), mod_path))
 
     return modules
+
+
+def basename(path):
+    """
+    Equivalent to os.path.basename, but skips a "//" suffix.
+
+    Use for Windows compatibility.
+    """
+    return _os.path.basename(path[2:] if path.startswith("//") else path)
index 7c0d3d2..57d3e6d 100644 (file)
@@ -298,11 +298,18 @@ _presets = _os.path.join(_scripts[0], "presets")  # FIXME - multiple paths
 def preset_paths(subdir):
     """
     Returns a list of paths for a specific preset.
+
+    :arg subdir: preset subdirectory (must not be an absolute path).
+    :type subdir: string
+    :return: script paths.
+    :rtype: list
     """
     dirs = []
     for path in script_paths("presets", all=True):
         directory = _os.path.join(path, subdir)
-        if _os.path.isdir(directory):
+        if not directory.startswith(path):
+            raise Exception("invalid subdir given %r" % subdir)
+        elif _os.path.isdir(directory):
             dirs.append(directory)
     return dirs
 
index f91535a..e56c1c6 100644 (file)
@@ -86,7 +86,9 @@ def load_image(imagepath,
     variants = [imagepath]
 
     if dirname:
-        variants += [os.path.join(dirname, imagepath), os.path.join(dirname, os.path.basename(imagepath))]
+        variants += [os.path.join(dirname, imagepath),
+                     os.path.join(dirname, bpy.path.basename(imagepath)),
+                     ]
 
     for filepath_test in variants:
         if ncase_cmp:
@@ -99,7 +101,7 @@ def load_image(imagepath,
                 return _image_load(nfilepath)
 
     if place_holder:
-        image = bpy.data.images.new(os.path.basename(imagepath), 128, 128)
+        image = bpy.data.images.new(bpy.path.basename(imagepath), 128, 128)
         # allow the path to be resolved later
         image.filepath = imagepath
         return image
index 34c5b0d..4bb53f7 100644 (file)
@@ -163,7 +163,7 @@ class ProjectEdit(bpy.types.Operator):
             filepath_final = filepath + ("%.3d.%s" % (i, EXT))
             i += 1
 
-        image_new.name = os.path.basename(filepath_final)
+        image_new.name = bpy.path.basename(filepath_final)
         ProjectEdit._proj_hack[0] = image_new.name
 
         image_new.filepath_raw = filepath_final  # TODO, filepath raw is crummy
index 3202a71..d215f34 100644 (file)
 import bpy
 from mathutils import Vector
 
-
-def align_objects(align_x, align_y, align_z, align_mode, relative_to):
+def GlobalBB_LQ(bb_world):
+    
+    # Initialize the variables with the 8th vertex
+    left, right, front, back, down, up =\
+    bb_world[7][0],\
+    bb_world[7][0],\
+    bb_world[7][1],\
+    bb_world[7][1],\
+    bb_world[7][2],\
+    bb_world[7][2]
+    
+    # Test against the other 7 verts
+    for i in range (7):
+        
+        # X Range
+        val = bb_world[i][0]
+        if val < left:
+            left = val
+            
+        if val > right:
+            right = val
+            
+        # Y Range
+        val = bb_world[i][1]
+        if val < front:
+            front = val
+            
+        if val > back:
+            back = val
+            
+        # Z Range
+        val = bb_world[i][2]
+        if val < down:
+            down = val
+            
+        if val > up:
+            up = val
+        
+    return (Vector((left, front, up)), Vector((right, back, down)))
+
+def GlobalBB_HQ(obj):
+    
+    matrix_world = obj.matrix_world.copy()
+    
+    # Initialize the variables with the last vertex
+    
+    verts = obj.data.vertices
+    
+    val = verts[-1].co * matrix_world
+    
+    left, right, front, back, down, up =\
+    val[0],\
+    val[0],\
+    val[1],\
+    val[1],\
+    val[2],\
+    val[2]
+    
+    # Test against all other verts
+    for i in range (len(verts)-1):
+        
+        vco = verts[i].co * matrix_world
+        
+        # X Range
+        val = vco[0]
+        if val < left:
+            left = val
+            
+        if val > right:
+            right = val
+            
+        # Y Range
+        val = vco[1]
+        if val < front:
+            front = val
+            
+        if val > back:
+            back = val
+            
+        # Z Range
+        val = vco[2]
+        if val < down:
+            down = val
+            
+        if val > up:
+            up = val
+        
+    return (Vector((left, front, up)), Vector((right, back, down)))
+
+
+def align_objects(align_x, align_y, align_z, align_mode, relative_to, bb_quality):
 
     cursor = bpy.context.scene.cursor_location
 
-    Left_Up_Front_SEL = [0.0, 0.0, 0.0]
-    Right_Down_Back_SEL = [0.0, 0.0, 0.0]
+    Left_Front_Up_SEL = [0.0, 0.0, 0.0]
+    Right_Back_Down_SEL = [0.0, 0.0, 0.0]
 
     flag_first = True
 
@@ -42,78 +131,89 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
         return False
 
     for obj, bb_world in objs:
-        Left_Up_Front = bb_world[1]
-        Right_Down_Back = bb_world[7]
+        
+        if bb_quality:
+            GBB = GlobalBB_HQ(obj)
+        else:
+            GBB = GlobalBB_LQ(bb_world)
+            
+        Left_Front_Up = GBB[0]
+        Right_Back_Down = GBB[1]
 
         # Active Center
 
         if obj == bpy.context.active_object:
 
-            center_active_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2.0
-            center_active_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2.0
-            center_active_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2.0
+            center_active_x = (Left_Front_Up[0] + Right_Back_Down[0]) / 2.0
+            center_active_y = (Left_Front_Up[1] + Right_Back_Down[1]) / 2.0
+            center_active_z = (Left_Front_Up[2] + Right_Back_Down[2]) / 2.0
 
-            size_active_x = (Right_Down_Back[0] - Left_Up_Front[0]) / 2.0
-            size_active_y = (Right_Down_Back[1] - Left_Up_Front[1]) / 2.0
-            size_active_z = (Left_Up_Front[2] - Right_Down_Back[2]) / 2.0
+            size_active_x = (Right_Back_Down[0] - Left_Front_Up[0]) / 2.0
+            size_active_y = (Right_Back_Down[1] - Left_Front_Up[1]) / 2.0
+            size_active_z = (Left_Front_Up[2] - Right_Back_Down[2]) / 2.0
 
         # Selection Center
 
         if flag_first:
             flag_first = False
 
-            Left_Up_Front_SEL[0] = Left_Up_Front[0]
-            Left_Up_Front_SEL[1] = Left_Up_Front[1]
-            Left_Up_Front_SEL[2] = Left_Up_Front[2]
+            Left_Front_Up_SEL[0] = Left_Front_Up[0]
+            Left_Front_Up_SEL[1] = Left_Front_Up[1]
+            Left_Front_Up_SEL[2] = Left_Front_Up[2]
 
-            Right_Down_Back_SEL[0] = Right_Down_Back[0]
-            Right_Down_Back_SEL[1] = Right_Down_Back[1]
-            Right_Down_Back_SEL[2] = Right_Down_Back[2]
+            Right_Back_Down_SEL[0] = Right_Back_Down[0]
+            Right_Back_Down_SEL[1] = Right_Back_Down[1]
+            Right_Back_Down_SEL[2] = Right_Back_Down[2]
 
         else:
             # X axis
-            if Left_Up_Front[0] < Left_Up_Front_SEL[0]:
-                Left_Up_Front_SEL[0] = Left_Up_Front[0]
+            if Left_Front_Up[0] < Left_Front_Up_SEL[0]:
+                Left_Front_Up_SEL[0] = Left_Front_Up[0]
             # Y axis
-            if Left_Up_Front[1] < Left_Up_Front_SEL[1]:
-                Left_Up_Front_SEL[1] = Left_Up_Front[1]
+            if Left_Front_Up[1] < Left_Front_Up_SEL[1]:
+                Left_Front_Up_SEL[1] = Left_Front_Up[1]
             # Z axis
-            if Left_Up_Front[2] > Left_Up_Front_SEL[2]:
-                Left_Up_Front_SEL[2] = Left_Up_Front[2]
+            if Left_Front_Up[2] > Left_Front_Up_SEL[2]:
+                Left_Front_Up_SEL[2] = Left_Front_Up[2]
 
             # X axis
-            if Right_Down_Back[0] > Right_Down_Back_SEL[0]:
-                Right_Down_Back_SEL[0] = Right_Down_Back[0]
+            if Right_Back_Down[0] > Right_Back_Down_SEL[0]:
+                Right_Back_Down_SEL[0] = Right_Back_Down[0]
             # Y axis
-            if Right_Down_Back[1] > Right_Down_Back_SEL[1]:
-                Right_Down_Back_SEL[1] = Right_Down_Back[1]
+            if Right_Back_Down[1] > Right_Back_Down_SEL[1]:
+                Right_Back_Down_SEL[1] = Right_Back_Down[1]
             # Z axis
-            if Right_Down_Back[2] < Right_Down_Back_SEL[2]:
-                Right_Down_Back_SEL[2] = Right_Down_Back[2]
+            if Right_Back_Down[2] < Right_Back_Down_SEL[2]:
+                Right_Back_Down_SEL[2] = Right_Back_Down[2]
 
-    center_sel_x = (Left_Up_Front_SEL[0] + Right_Down_Back_SEL[0]) / 2.0
-    center_sel_y = (Left_Up_Front_SEL[1] + Right_Down_Back_SEL[1]) / 2.0
-    center_sel_z = (Left_Up_Front_SEL[2] + Right_Down_Back_SEL[2]) / 2.0
+    center_sel_x = (Left_Front_Up_SEL[0] + Right_Back_Down_SEL[0]) / 2.0
+    center_sel_y = (Left_Front_Up_SEL[1] + Right_Back_Down_SEL[1]) / 2.0
+    center_sel_z = (Left_Front_Up_SEL[2] + Right_Back_Down_SEL[2]) / 2.0
 
     # Main Loop
 
     for obj, bb_world in objs:
         bb_world = [Vector(v[:]) * obj.matrix_world for v in obj.bound_box]
+        
+        if bb_quality:
+            GBB = GlobalBB_HQ(obj)
+        else:
+            GBB = GlobalBB_LQ(bb_world)
+            
+        Left_Front_Up = GBB[0]
+        Right_Back_Down = GBB[1]
 
-        Left_Up_Front = bb_world[1]
-        Right_Down_Back = bb_world[7]
-
-        center_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2.0
-        center_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2.0
-        center_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2.0
+        center_x = (Left_Front_Up[0] + Right_Back_Down[0]) / 2.0
+        center_y = (Left_Front_Up[1] + Right_Back_Down[1]) / 2.0
+        center_z = (Left_Front_Up[2] + Right_Back_Down[2]) / 2.0
 
-        positive_x = Right_Down_Back[0]
-        positive_y = Right_Down_Back[1]
-        positive_z = Left_Up_Front[2]
+        positive_x = Right_Back_Down[0]
+        positive_y = Right_Back_Down[1]
+        positive_z = Left_Front_Up[2]
 
-        negative_x = Left_Up_Front[0]
-        negative_y = Left_Up_Front[1]
-        negative_z = Right_Down_Back[2]
+        negative_x = Left_Front_Up[0]
+        negative_y = Left_Front_Up[1]
+        negative_z = Right_Back_Down[2]
 
         obj_loc = obj.location
 
@@ -228,7 +328,7 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
     return True
 
 
-from bpy.props import EnumProperty
+from bpy.props import EnumProperty, BoolProperty
 
 
 class AlignObjects(bpy.types.Operator):
@@ -237,6 +337,11 @@ class AlignObjects(bpy.types.Operator):
     bl_label = "Align Objects"
     bl_options = {'REGISTER', 'UNDO'}
 
+    bb_quality = BoolProperty(
+            name="High Quality",
+            description="Enables high quality calculation of the bounding box for perfect results on complex shape meshes with rotation/scale (Slow)",
+            default=False)
+
     align_mode = EnumProperty(items=(
             ('OPT_1', "Negative Sides", ""),
             ('OPT_2', "Centers", ""),
@@ -269,10 +374,10 @@ class AlignObjects(bpy.types.Operator):
 
     def execute(self, context):
         align_axis = self.align_axis
-        ret = align_objects('X' in align_axis, 'Y' in align_axis, 'Z' in align_axis, self.align_mode, self.relative_to)
+        ret = align_objects('X' in align_axis, 'Y' in align_axis, 'Z' in align_axis, self.align_mode, self.relative_to, self.bb_quality)
 
         if not ret:
             self.report({'WARNING'}, "No objects with bound-box selected")
             return {'CANCELLED'}
         else:
-            return {'FINISHED'}
+            return {'FINISHED'}
\ No newline at end of file
index 45c15bd..2a52ae2 100644 (file)
@@ -174,6 +174,7 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, bpy.types.Panel):
         row.prop(mat, "use_transparency")
         sub = row.column()
         sub.prop(mat, "offset_z")
+
         sub.active = mat_type and mat.use_transparency and mat.transparency_method == 'Z_TRANSPARENCY'
 
         row = layout.row()
@@ -199,6 +200,7 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, bpy.types.Panel):
         col.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
         col.prop(mat, "use_cast_buffer_shadows")
         col.prop(mat, "use_cast_approximate")
+        col.prop(mat, "pass_index")
 
 
 class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel):
@@ -729,7 +731,8 @@ class MATERIAL_PT_options(MaterialButtonsPanel, bpy.types.Panel):
         col.prop(mat, "use_vertex_color_paint")
         col.prop(mat, "use_vertex_color_light")
         col.prop(mat, "use_object_color")
-        col.prop(mat, "pass_index")
+        if simple_material(base_mat):
+            col.prop(mat, "pass_index")
 
 
 class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel):
index c48497c..ab67d7e 100644 (file)
@@ -432,6 +432,7 @@ Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *n
                ima->gen_x= width;
                ima->gen_y= height;
                ima->gen_type= uvtestgrid;
+               ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
                
                ibuf= add_ibuf_size(width, height, name, depth, floatbuf, uvtestgrid, color);
                image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
@@ -2172,7 +2173,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
                                /* UV testgrid or black or solid etc */
                                if(ima->gen_x==0) ima->gen_x= 1024;
                                if(ima->gen_y==0) ima->gen_y= 1024;
-                               ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, 0, ima->gen_type, color);
+                               ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color);
                                image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
                                ima->ok= IMA_OK_LOADED;
                        }
index 265cc3e..d6a152a 100644 (file)
@@ -3232,9 +3232,10 @@ int seq_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
 {
        char name[sizeof(seq_a->name)];
 
-       if(seq_a->len != seq_b->len)
+       if(seq_a->len != seq_b->len) {
                *error_str= "Strips must be the same length";
                return 0;
+       }
 
        /* type checking, could be more advanced but disalow sound vs non-sound copy */
        if(seq_a->type != seq_b->type) {
index 80b8566..f892831 100644 (file)
@@ -1680,7 +1680,7 @@ void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name)
        if(GetModuleFileName(0, fullname, maxlen)) {
                if(!BLI_exists(fullname)) {
                        printf("path can't be found: \"%.*s\"\n", maxlen, fullname);
-                       MessageBox(NULL, "path constains invalid characters or is too long (see console)", "Error", MB_OK);
+                       MessageBox(NULL, "path contains invalid characters or is too long (see console)", "Error", MB_OK);
                }
                return;
        }
index ab30d92..4ad99c0 100644 (file)
@@ -10281,8 +10281,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        sce->gm.attrib = sce->r.attrib;
 
                        //Stereo
-                       sce->gm.xsch = sce->r.xsch;
-                       sce->gm.ysch = sce->r.ysch;
                        sce->gm.stereomode = sce->r.stereomode;
                        /* reassigning stereomode NO_STEREO and DOME to a separeted flag*/
                        if (sce->gm.stereomode == 1){ //1 = STEREO_NOSTEREO
index bdd911d..679e4e5 100644 (file)
@@ -860,6 +860,10 @@ static void finish_images(MultiresBakeRender *bkr)
                RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, bkr->bake_filter);
 
                ibuf->userflags|= IB_BITMAPDIRTY;
+
+               if(ibuf->rect_float)
+                       ibuf->userflags|= IB_RECT_INVALID;
+
                if(ibuf->mipmap[0]) {
                        ibuf->userflags|= IB_MIPMAP_INVALID;
                        imb_freemipmapImBuf(ibuf);
index e9ebe78..66e844e 100644 (file)
@@ -804,6 +804,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
                                col= uiLayoutColumn(split, 1);
                                uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE);
                                uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE);
+                               uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);
 
                                uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
                        }
index 10b8cb2..d5515bd 100644 (file)
@@ -500,7 +500,7 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op))
        Scene *scene;
        Object *obedit;
        Image *ima;
-       float size, min[2], max[2], d[2];
+       float size, min[2], max[2], d[2], aspx, aspy;
        int width, height;
 
        /* retrieve state */
@@ -511,6 +511,10 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op))
 
        ima= ED_space_image(sima);
        ED_space_image_size(sima, &width, &height);
+       ED_image_aspect(ima, &aspx, &aspy);
+
+       width= width*aspx;
+       height= height*aspy;
 
        /* get bounds */
        if(!ED_uvedit_minmax(scene, ima, obedit, min, max))
index 457d882..4a00538 100644 (file)
@@ -1335,6 +1335,11 @@ static void draw_focus_cross(float dist, float size)
        glEnd();
 }
 
+#ifdef VIEW3D_CAMERA_BORDER_HACK
+float view3d_camera_border_hack_col[4];
+short view3d_camera_border_hack_test= FALSE;
+#endif
+
 /* flag similar to draw_object() */
 static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, int flag)
 {
@@ -1348,7 +1353,15 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob
        const float scax= 1.0f / len_v3(ob->obmat[0]);
        const float scay= 1.0f / len_v3(ob->obmat[1]);
        const float scaz= 1.0f / len_v3(ob->obmat[2]);
-       
+
+#ifdef VIEW3D_CAMERA_BORDER_HACK
+       if(is_view && !(G.f & G_PICKSEL)) {
+               glGetFloatv(GL_CURRENT_COLOR, view3d_camera_border_hack_col);
+               view3d_camera_border_hack_test= TRUE;
+               return;
+       }
+#endif
+
        cam= ob->data;
        aspx= (float) scene->r.xsch*scene->r.xasp;
        aspy= (float) scene->r.ysch*scene->r.yasp;
index 0ed62f3..d2ff6ee 100644 (file)
@@ -1007,6 +1007,8 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
        /* note: quite un-scientific but without this bit extra
         * 0.0001 on the lower left the 2D border sometimes
         * obscures the 3D camera border */
+       /* note: with VIEW3D_CAMERA_BORDER_HACK defined this error isn't noticable
+        * but keep it here incase we need to remove the workaround */
        x1i= (int)(x1 - 1.0001f);
        y1i= (int)(y1 - 1.0001f);
        x2i= (int)(x2 + (1.0f-0.0001f));
@@ -1039,7 +1041,17 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
        setlinestyle(0);
        UI_ThemeColor(TH_BACK);
        glRectf(x1i, y1i, x2i, y2i);
-       
+
+#ifdef VIEW3D_CAMERA_BORDER_HACK
+       {
+               if(view3d_camera_border_hack_test == TRUE) {
+                       glColor4fv(view3d_camera_border_hack_col);
+                       glRectf(x1i+1, y1i+1, x2i-1, y2i-1);
+                       view3d_camera_border_hack_test= FALSE;
+               }
+       }
+#endif
+
        setlinestyle(3);
        UI_ThemeColor(TH_WIRE);
        glRectf(x1i, y1i, x2i, y2i);
index aa92f0d..d3886d4 100644 (file)
@@ -194,6 +194,16 @@ extern const char *view3d_context_dir[]; /* doc access */
 /* draw_volume.c */
 void draw_volume(struct ARegion *ar, struct GPUTexture *tex, float *min, float *max, int res[3], float dx, struct GPUTexture *tex_shadow);
 
+/* workaround for trivial but noticable camera bug caused by imprecision
+ * between view border calculation in 2D/3D space, workaround for bug [#28037].
+ * without this deifne we get the old behavior which is to try and align them
+ * both which _mostly_ works fine, but when the camera moves beyond ~1000 in
+ * any direction it starts to fail */
+#define VIEW3D_CAMERA_BORDER_HACK
+#ifdef VIEW3D_CAMERA_BORDER_HACK
+extern float view3d_camera_border_hack_col[4];
+extern short view3d_camera_border_hack_test;
+#endif
 
 #endif /* ED_VIEW3D_INTERN_H */
 
index 99ed231..dd03333 100644 (file)
@@ -102,7 +102,8 @@ typedef struct Image {
        short animspeed;
        
        /* for generated images */
-       short gen_x, gen_y, gen_type;
+       short gen_x, gen_y;
+       char gen_type, gen_flag;
        
        /* display aspect - for UV editing images resized for faster openGL display */
        float aspx, aspy;
@@ -136,5 +137,8 @@ typedef struct Image {
 #define IMA_MAX_RENDER_TEXT            512
 #define IMA_MAX_RENDER_SLOT            8
 
+/* gen_flag */
+#define IMA_GEN_FLOAT          1
+
 #endif
 
index 251329a..e9d7257 100644 (file)
@@ -430,7 +430,8 @@ typedef struct GameData {
        /*
         * Radius of the activity bubble, in Manhattan length. Objects
         * outside the box are activity-culled. */
-       float activityBoxRadius; //it's not being used ANYWHERE !!!!!!!!!!!!!!
+       float activityBoxRadius;
+
        /*
         * bit 3: (gameengine): Activity culling is enabled.
         * bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling
@@ -447,7 +448,8 @@ typedef struct GameData {
 
        /* stereo/dome mode */
        struct GameDome dome;
-       short stereoflag, stereomode, xsch, ysch; //xsch and ysch used for backwards compat.
+       short stereoflag, stereomode;
+       short pad2, pad3;
        float eyeseparation, pad1;
 } GameData;
 
index a52849b..eac4932 100644 (file)
@@ -502,6 +502,11 @@ static void rna_def_image(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Generated Height", "Generated image height");
        RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update");
 
+       prop= RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT);
+       RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating point buffer");
+       RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update");
+
        /* realtime properties */
        prop= RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
index 5341c4b..1bbe644 100644 (file)
@@ -2289,12 +2289,12 @@ static void rna_def_object(BlenderRNA *brna)
        
        prop= RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP);
-       RNA_def_property_ui_text(prop, "Draw Transparent", "Displays material transparency in the object");
+       RNA_def_property_ui_text(prop, "Draw Transparent", "Displays material transparency in the object (unsupported for duplicator drawing)");
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
        
        prop= RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWXRAY);
-       RNA_def_property_ui_text(prop, "X-Ray", "Makes the object draw in front of others");
+       RNA_def_property_ui_text(prop, "X-Ray", "Makes the object draw in front of others (unsupported for duplicator drawing)");
        RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
        
        /* Grease Pencil */
index b33935b..9018fd8 100644 (file)
@@ -45,6 +45,8 @@
 
 // #include "ED_mesh.h"
 
+#include "BLI_math.h"
+
 #ifdef RNA_RUNTIME
 
 #include "BKE_main.h"
@@ -64,8 +66,6 @@
 #include "BKE_mball.h"
 #include "BKE_modifier.h"
 
-#include "BLI_math.h"
-
 #include "DNA_mesh_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_meshdata_types.h"
@@ -415,7 +415,7 @@ void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], fl
        *index= -1;
 }
 
-void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float n_location[3], float n_normal[3], int *index)
+void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float max_dist, float n_location[3], float n_normal[3], int *index)
 {
        BVHTreeFromMesh treeData= {NULL};
        
@@ -435,7 +435,7 @@ void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float poi
                BVHTreeNearest nearest;
 
                nearest.index = -1;
-               nearest.dist = FLT_MAX;
+               nearest.dist = max_dist * max_dist;
 
                if(BLI_bvhtree_find_nearest(treeData.tree, point_co, &nearest, treeData.nearest_callback, &treeData) != -1) {
                        copy_v3_v3(n_location, nearest.co);
@@ -541,9 +541,10 @@ void RNA_api_object(StructRNA *srna)
        RNA_def_function_ui_description(func, "Find the nearest point on the object.");
        RNA_def_function_flag(func, FUNC_USE_REPORTS);
 
-       /* ray start and end */
+       /* location of point for test and max distance */
        parm= RNA_def_float_vector(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
        RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_float(func, "max_dist", sqrt(FLT_MAX), 0.0, FLT_MAX, "", "", 0.0, FLT_MAX);
 
        /* return location and normal */
        parm= RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The location on the object closest to the point", -1e4, 1e4);
@@ -553,7 +554,7 @@ void RNA_api_object(StructRNA *srna)
        RNA_def_property_flag(parm, PROP_THICK_WRAP);
        RNA_def_function_output(func, parm);
 
-       parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no intersection is found.", 0, 0);
+       parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no closest point is found.", 0, 0);
        RNA_def_function_output(func, parm);
 
        /* View */
index b9b5c8a..5e6f377 100644 (file)
@@ -52,6 +52,6 @@ void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]);
 void validate_layer_name(const struct CustomData *data, int type, char *name, char *outname);
 struct DerivedMesh *get_cddm(struct Object *ob, struct EditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3]);
 struct DerivedMesh *get_dm(struct Object *ob, struct EditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3], int orco);
-void modifier_get_vgroup(struct Object *ob, DerivedMesh *dm, const char *name, struct MDeformVert **dvert, int *defgrp_index);
+void modifier_get_vgroup(struct Object *ob, struct DerivedMesh *dm, const char *name, struct MDeformVert **dvert, int *defgrp_index);
 
 #endif /* MOD_UTIL_H */
index cf7c64c..190f68c 100644 (file)
@@ -83,7 +83,11 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
 void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
 {
        ShaderCallData scd;
-       
+       /*
+        @note: preserve material from ShadeInput for material id, nodetree execs change it
+        fix for bug "[#28012] Mat ID messy with shader nodes"
+        */
+       Material *mat = shi->mat;
        /* convert caller data to struct */
        scd.shi= shi;
        scd.shr= shr;
@@ -92,7 +96,8 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
        memset(shr, 0, sizeof(ShadeResult));
                   
        ntreeExecTree(ntree, &scd, shi->thread);        /* threads */
-       
+       // @note: set material back to preserved material
+       shi->mat = mat;
        /* better not allow negative for now */
        if(shr->combined[0]<0.0f) shr->combined[0]= 0.0f;
        if(shr->combined[1]<0.0f) shr->combined[1]= 0.0f;
index b0187c1..76a0994 100644 (file)
@@ -1318,21 +1318,20 @@ static PyObject *Matrix_repr(MatrixObject *self)
                }
        }
        switch(self->row_size) {
-       case 2: return PyUnicode_FromFormat("Matrix(%R,\n"
-                                                                               "       %R)", rows[0], rows[1]);
+       case 2: return PyUnicode_FromFormat("Matrix((%R,\n"
+                                                                               "        %R))", rows[0], rows[1]);
 
-       case 3: return PyUnicode_FromFormat("Matrix(%R,\n"
-                                                                               "       %R,\n"
-                                                                               "       %R)", rows[0], rows[1], rows[2]);
+       case 3: return PyUnicode_FromFormat("Matrix((%R,\n"
+                                                                               "        %R,\n"
+                                                                               "        %R))", rows[0], rows[1], rows[2]);
 
-       case 4: return PyUnicode_FromFormat("Matrix(%R,\n"
-                                                                               "       %R,\n"
-                                                                               "       %R,\n"
-                                                                               "       %R)", rows[0], rows[1], rows[2], rows[3]);
+       case 4: return PyUnicode_FromFormat("Matrix((%R,\n"
+                                                                               "        %R,\n"
+                                                                               "        %R,\n"
+                                                                               "        %R))", rows[0], rows[1], rows[2], rows[3]);
        }
 
-       PyErr_SetString(PyExc_RuntimeError,
-                       "internal error!");
+       Py_FatalError("Matrix(): invalid row size!");
        return NULL;
 }
 
@@ -1587,32 +1586,24 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2)
 
        if(mat1 && mat2) {
                /*MATRIX * MATRIX*/
-               if(mat1->row_size != mat2->col_size){
-                       PyErr_SetString(PyExc_ValueError,
-                                       "Matrix multiplication: "
-                                       "matrix A rowsize must equal matrix B colsize");
-                       return NULL;
-               }
-               else {
-                       float mat[16]= {0.0f, 0.0f, 0.0f, 0.0f,
-                                                       0.0f, 0.0f, 0.0f, 0.0f,
-                                                       0.0f, 0.0f, 0.0f, 0.0f,
-                                                       0.0f, 0.0f, 0.0f, 1.0f};
-                       double dot = 0.0f;
-                       int x, y, z;
-
-                       for(x = 0; x < mat2->row_size; x++) {
-                               for(y = 0; y < mat1->col_size; y++) {
-                                       for(z = 0; z < mat1->row_size; z++) {
-                                               dot += (mat1->matrix[z][y] * mat2->matrix[x][z]);
-                                       }
-                                       mat[((x * mat1->col_size) + y)] = (float)dot;
-                                       dot = 0.0f;
+               float mat[16]= {0.0f, 0.0f, 0.0f, 0.0f,
+                                               0.0f, 0.0f, 0.0f, 0.0f,
+                                               0.0f, 0.0f, 0.0f, 0.0f,
+                                               0.0f, 0.0f, 0.0f, 1.0f};
+               double dot = 0.0f;
+               int x, y, z;
+
+               for(x = 0; x < mat2->row_size; x++) {
+                       for(y = 0; y < mat1->col_size; y++) {
+                               for(z = 0; z < mat1->row_size; z++) {
+                                       dot += (mat1->matrix[z][y] * mat2->matrix[x][z]);
                                }
+                               mat[((x * mat1->col_size) + y)] = (float)dot;
+                               dot = 0.0f;
                        }
-
-                       return newMatrixObject(mat, mat2->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1));
                }
+
+               return newMatrixObject(mat, mat2->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1));
        }
        else if(mat2) {
                /*FLOAT/INT * MATRIX */
index 35afdf2..29afdb5 100644 (file)
@@ -3567,10 +3567,12 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
 
        /* items for modal map */
        WM_modalkeymap_add_item(keymap, ESCKEY,    KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL);
-       WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, GESTURE_MODAL_CANCEL);
+                       /* Note: cancel only on press otherwise you cannot map this to RMB-gesture */
+       WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL);
 
        WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN);
        WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT);
+       WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT);
 
 #if 0 // Durian guys like this
        WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_SHIFT, 0, GESTURE_MODAL_BEGIN);
index af11445..7b9c5d4 100644 (file)
@@ -1976,8 +1976,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                        frame_type = RAS_FrameSettings::e_frame_scale;
                }
                
-               aspect_width = blenderscene->gm.xsch;
-               aspect_height = blenderscene->gm.ysch;
+               aspect_width = blenderscene->r.xsch*blenderscene->r.xasp;
+               aspect_height = blenderscene->r.ysch*blenderscene->r.yasp;
        }
        
        RAS_FrameSettings frame_settings(