From 9af390ab67dff7113fef5bae6bde4133b922e3e1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 06:34:31 +0000 Subject: fix [#27485] Create new shapekey on lattice --- source/blender/blenkernel/intern/object.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3523d1812a0..e2a07427ce2 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3037,9 +3037,14 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int if(newkey || from_mix==FALSE) { kb= add_keyblock(key, name); - - /* create from lattice */ - latt_to_key(lt, kb); + if (!newkey) { + KeyBlock *basekb= (KeyBlock *)key->block.first; + kb->data= MEM_dupallocN(basekb->data); + kb->totelem= basekb->totelem; + } + else { + latt_to_key(lt, kb); + } } else { /* copy from current values */ @@ -3075,7 +3080,10 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int KeyBlock *basekb= (KeyBlock *)key->block.first; kb->data= MEM_dupallocN(basekb->data); kb->totelem= basekb->totelem; - } else curve_to_key(cu, kb, lb); + } + else { + curve_to_key(cu, kb, lb); + } } else { /* copy from current values */ -- cgit v1.2.3 From 6466673a62083cf13bcb1290f1e3fbcb9231199f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 07:16:56 +0000 Subject: move less common mesh operations out of bpy_types into bpy_extras.mesh_utils --- release/scripts/modules/bpy_extras/mesh_utils.py | 338 +++++++++++++++++++++ release/scripts/modules/bpy_types.py | 157 ---------- release/scripts/startup/bl_operators/mesh.py | 3 +- .../startup/bl_operators/uvcalc_follow_active.py | 4 +- 4 files changed, 343 insertions(+), 159 deletions(-) diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py index 5bacff7b0cc..ee7bceedb6e 100644 --- a/release/scripts/modules/bpy_extras/mesh_utils.py +++ b/release/scripts/modules/bpy_extras/mesh_utils.py @@ -67,3 +67,341 @@ def mesh_linked_faces(mesh): # return all face groups that are not null # this is all the faces that are connected in their own lists. return [fg for fg in face_groups if fg] + + +def edge_face_count_dict(mesh): + face_edge_keys = [face.edge_keys for face in mesh.faces] + face_edge_count = {} + for face_keys in face_edge_keys: + for key in face_keys: + try: + face_edge_count[key] += 1 + except: + face_edge_count[key] = 1 + + return face_edge_count + + +def edge_face_count(mesh): + edge_face_count_dict = edge_face_count_dict(mesh) + return [edge_face_count_dict.get(ed.key, 0) for ed in mesh.edges] + + +def edge_loops_from_faces(mesh, faces=None, seams=()): + """ + Edge loops defined by faces + + Takes me.faces or a list of faces and returns the edge loops + These edge loops are the edges that sit between quads, so they dont touch + 1 quad, note: not connected will make 2 edge loops, both only containing 2 edges. + + return a list of edge key lists + [ [(0,1), (4, 8), (3,8)], ...] + + return a list of edge vertex index lists + """ + + OTHER_INDEX = 2, 3, 0, 1 # opposite face index + + if faces is None: + faces = mesh.faces + + edges = {} + + for f in faces: +# if len(f) == 4: + if f.vertices_raw[3] != 0: + edge_keys = f.edge_keys + for i, edkey in enumerate(f.edge_keys): + edges.setdefault(edkey, []).append(edge_keys[OTHER_INDEX[i]]) + + for edkey in seams: + edges[edkey] = [] + + # Collect edge loops here + edge_loops = [] + + for edkey, ed_adj in edges.items(): + if 0 < len(ed_adj) < 3: # 1 or 2 + # Seek the first edge + context_loop = [edkey, ed_adj[0]] + edge_loops.append(context_loop) + if len(ed_adj) == 2: + other_dir = ed_adj[1] + else: + other_dir = None + + ed_adj[:] = [] + + flipped = False + + while 1: + # from knowing the last 2, look for th next. + ed_adj = edges[context_loop[-1]] + if len(ed_adj) != 2: + + if other_dir and flipped == False: # the original edge had 2 other edges + flipped = True # only flip the list once + context_loop.reverse() + ed_adj[:] = [] + context_loop.append(other_dir) # save 1 lookiup + + ed_adj = edges[context_loop[-1]] + if len(ed_adj) != 2: + ed_adj[:] = [] + break + else: + ed_adj[:] = [] + break + + i = ed_adj.index(context_loop[-2]) + context_loop.append(ed_adj[not i]) + + # Dont look at this again + ed_adj[:] = [] + + return edge_loops + +def edge_loops_from_edges(mesh, edges=None): + """ + Edge loops defined by edges + + Takes me.edges or a list of edges and returns the edge loops + + return a list of vertex indices. + [ [1, 6, 7, 2], ...] + + closed loops have matching start and end values. + """ + line_polys = [] + + # Get edges not used by a face + if edges is None: + edges = mesh.edges + + if not hasattr(edges, "pop"): + edges = edges[:] + + edge_dict = {ed.key: ed for ed in mesh.edges if ed.select} + + while edges: + current_edge = edges.pop() + vert_end, vert_start = current_edge.vertices[:] + line_poly = [vert_start, vert_end] + + ok = True + while ok: + ok = False + #for i, ed in enumerate(edges): + i = len(edges) + while i: + i -= 1 + ed = edges[i] + v1, v2 = ed.vertices + if v1 == vert_end: + line_poly.append(v2) + vert_end = line_poly[-1] + ok = 1 + del edges[i] + # break + elif v2 == vert_end: + line_poly.append(v1) + vert_end = line_poly[-1] + ok = 1 + del edges[i] + #break + elif v1 == vert_start: + line_poly.insert(0, v2) + vert_start = line_poly[0] + ok = 1 + del edges[i] + # break + elif v2 == vert_start: + line_poly.insert(0, v1) + vert_start = line_poly[0] + ok = 1 + del edges[i] + #break + line_polys.append(line_poly) + + return line_polys + + + +def ngon_tessellate(from_data, indices, fix_loops=True): + ''' + Takes a polyline of indices (fgon) + and returns a list of face indicie lists. + Designed to be used for importers that need indices for an fgon to create from existing verts. + + from_data: either a mesh, or a list/tuple of vectors. + indices: a list of indices to use this list is the ordered closed polyline to fill, and can be a subset of the data given. + fix_loops: If this is enabled polylines that use loops to make multiple polylines are delt with correctly. + ''' + + from mathutils import Vector + vector_to_tuple = Vector.to_tuple + + if not indices: + return [] + + def mlen(co): + return abs(co[0]) + abs(co[1]) + abs(co[2]) # manhatten length of a vector, faster then length + + def vert_treplet(v, i): + return v, vector_to_tuple(v, 6), i, mlen(v) + + def ed_key_mlen(v1, v2): + if v1[3] > v2[3]: + return v2[1], v1[1] + else: + return v1[1], v2[1] + + if not PREF_FIX_LOOPS: + ''' + Normal single concave loop filling + ''' + if type(from_data) in (tuple, list): + verts = [Vector(from_data[i]) for ii, i in enumerate(indices)] + else: + verts = [from_data.vertices[i].co for ii, i in enumerate(indices)] + + for i in range(len(verts) - 1, 0, -1): # same as reversed(xrange(1, len(verts))): + if verts[i][1] == verts[i - 1][0]: + verts.pop(i - 1) + + fill = fill_polygon([verts]) + + else: + ''' + Seperate this loop into multiple loops be finding edges that are used twice + This is used by lightwave LWO files a lot + ''' + + if type(from_data) in (tuple, list): + verts = [vert_treplet(Vector(from_data[i]), ii) for ii, i in enumerate(indices)] + else: + verts = [vert_treplet(from_data.vertices[i].co, ii) for ii, i in enumerate(indices)] + + edges = [(i, i - 1) for i in range(len(verts))] + if edges: + edges[0] = (0, len(verts) - 1) + + if not verts: + return [] + + edges_used = set() + edges_doubles = set() + # We need to check if any edges are used twice location based. + for ed in edges: + edkey = ed_key_mlen(verts[ed[0]], verts[ed[1]]) + if edkey in edges_used: + edges_doubles.add(edkey) + else: + edges_used.add(edkey) + + # Store a list of unconnected loop segments split by double edges. + # will join later + loop_segments = [] + + v_prev = verts[0] + context_loop = [v_prev] + loop_segments = [context_loop] + + for v in verts: + if v != v_prev: + # Are we crossing an edge we removed? + if ed_key_mlen(v, v_prev) in edges_doubles: + context_loop = [v] + loop_segments.append(context_loop) + else: + if context_loop and context_loop[-1][1] == v[1]: + #raise "as" + pass + else: + context_loop.append(v) + + v_prev = v + # Now join loop segments + + def join_seg(s1, s2): + if s2[-1][1] == s1[0][1]: + s1, s2 = s2, s1 + elif s1[-1][1] == s2[0][1]: + pass + else: + return False + + # If were stuill here s1 and s2 are 2 segments in the same polyline + s1.pop() # remove the last vert from s1 + s1.extend(s2) # add segment 2 to segment 1 + + if s1[0][1] == s1[-1][1]: # remove endpoints double + s1.pop() + + s2[:] = [] # Empty this segment s2 so we dont use it again. + return True + + joining_segments = True + while joining_segments: + joining_segments = False + segcount = len(loop_segments) + + for j in range(segcount - 1, -1, -1): # reversed(range(segcount)): + seg_j = loop_segments[j] + if seg_j: + for k in range(j - 1, -1, -1): # reversed(range(j)): + if not seg_j: + break + seg_k = loop_segments[k] + + if seg_k and join_seg(seg_j, seg_k): + joining_segments = True + + loop_list = loop_segments + + for verts in loop_list: + while verts and verts[0][1] == verts[-1][1]: + verts.pop() + + loop_list = [verts for verts in loop_list if len(verts) > 2] + # DONE DEALING WITH LOOP FIXING + + # vert mapping + vert_map = [None] * len(indices) + ii = 0 + for verts in loop_list: + if len(verts) > 2: + for i, vert in enumerate(verts): + vert_map[i + ii] = vert[2] + ii += len(verts) + + fill = tesselate_polygon([[v[0] for v in loop] for loop in loop_list]) + #draw_loops(loop_list) + #raise 'done loop' + # map to original indices + fill = [[vert_map[i] for i in reversed(f)] for f in fill] + + if not fill: + print('Warning Cannot scanfill, fallback on a triangle fan.') + fill = [[0, i - 1, i] for i in range(2, len(indices))] + else: + # Use real scanfill. + # See if its flipped the wrong way. + flip = None + for fi in fill: + if flip != None: + break + for i, vi in enumerate(fi): + if vi == 0 and fi[i - 1] == 1: + flip = False + break + elif vi == 1 and fi[i - 1] == 0: + flip = True + break + + if not flip: + for i, fi in enumerate(fill): + fill[i] = tuple([ii for ii in reversed(fi)]) + + return fill diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index c3352dd33ad..3c1b454e72e 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -356,163 +356,6 @@ class Mesh(bpy_types.ID): def edge_keys(self): return [edge_key for face in self.faces for edge_key in face.edge_keys] - @property - def edge_face_count_dict(self): - face_edge_keys = [face.edge_keys for face in self.faces] - face_edge_count = {} - for face_keys in face_edge_keys: - for key in face_keys: - try: - face_edge_count[key] += 1 - except: - face_edge_count[key] = 1 - - return face_edge_count - - @property - def edge_face_count(self): - edge_face_count_dict = self.edge_face_count_dict - return [edge_face_count_dict.get(ed.key, 0) for ed in self.edges] - - def edge_loops_from_faces(self, faces=None, seams=()): - """ - Edge loops defined by faces - - Takes me.faces or a list of faces and returns the edge loops - These edge loops are the edges that sit between quads, so they dont touch - 1 quad, note: not connected will make 2 edge loops, both only containing 2 edges. - - return a list of edge key lists - [ [(0,1), (4, 8), (3,8)], ...] - - return a list of edge vertex index lists - """ - - OTHER_INDEX = 2, 3, 0, 1 # opposite face index - - if faces is None: - faces = self.faces - - edges = {} - - for f in faces: -# if len(f) == 4: - if f.vertices_raw[3] != 0: - edge_keys = f.edge_keys - for i, edkey in enumerate(f.edge_keys): - edges.setdefault(edkey, []).append(edge_keys[OTHER_INDEX[i]]) - - for edkey in seams: - edges[edkey] = [] - - # Collect edge loops here - edge_loops = [] - - for edkey, ed_adj in edges.items(): - if 0 < len(ed_adj) < 3: # 1 or 2 - # Seek the first edge - context_loop = [edkey, ed_adj[0]] - edge_loops.append(context_loop) - if len(ed_adj) == 2: - other_dir = ed_adj[1] - else: - other_dir = None - - ed_adj[:] = [] - - flipped = False - - while 1: - # from knowing the last 2, look for th next. - ed_adj = edges[context_loop[-1]] - if len(ed_adj) != 2: - - if other_dir and flipped == False: # the original edge had 2 other edges - flipped = True # only flip the list once - context_loop.reverse() - ed_adj[:] = [] - context_loop.append(other_dir) # save 1 lookiup - - ed_adj = edges[context_loop[-1]] - if len(ed_adj) != 2: - ed_adj[:] = [] - break - else: - ed_adj[:] = [] - break - - i = ed_adj.index(context_loop[-2]) - context_loop.append(ed_adj[not i]) - - # Dont look at this again - ed_adj[:] = [] - - return edge_loops - - def edge_loops_from_edges(self, edges=None): - """ - Edge loops defined by edges - - Takes me.edges or a list of edges and returns the edge loops - - return a list of vertex indices. - [ [1, 6, 7, 2], ...] - - closed loops have matching start and end values. - """ - line_polys = [] - - # Get edges not used by a face - if edges is None: - edges = self.edges - - if not hasattr(edges, "pop"): - edges = edges[:] - - edge_dict = {ed.key: ed for ed in self.edges if ed.select} - - while edges: - current_edge = edges.pop() - vert_end, vert_start = current_edge.vertices[:] - line_poly = [vert_start, vert_end] - - ok = True - while ok: - ok = False - #for i, ed in enumerate(edges): - i = len(edges) - while i: - i -= 1 - ed = edges[i] - v1, v2 = ed.vertices - if v1 == vert_end: - line_poly.append(v2) - vert_end = line_poly[-1] - ok = 1 - del edges[i] - # break - elif v2 == vert_end: - line_poly.append(v1) - vert_end = line_poly[-1] - ok = 1 - del edges[i] - #break - elif v1 == vert_start: - line_poly.insert(0, v2) - vert_start = line_poly[0] - ok = 1 - del edges[i] - # break - elif v2 == vert_start: - line_poly.insert(0, v1) - vert_start = line_poly[0] - ok = 1 - del edges[i] - #break - line_polys.append(line_poly) - - return line_polys - class MeshEdge(StructRNA): __slots__ = () diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index 44d81ba53df..89802d7ba5c 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -36,6 +36,7 @@ class MeshSelectInteriorFaces(bpy.types.Operator): return (ob and ob.type == 'MESH') def execute(self, context): + from bpy_extras import mesh_utils ob = context.active_object context.tool_settings.mesh_select_mode = False, False, True is_editmode = (ob.mode == 'EDIT') @@ -47,7 +48,7 @@ class MeshSelectInteriorFaces(bpy.types.Operator): face_list = mesh.faces[:] face_edge_keys = [face.edge_keys for face in face_list] - edge_face_count = mesh.edge_face_count_dict + edge_face_count = mesh_utils.edge_face_count_dict(mesh) def test_interior(index): for key in face_edge_keys[index]: diff --git a/release/scripts/startup/bl_operators/uvcalc_follow_active.py b/release/scripts/startup/bl_operators/uvcalc_follow_active.py index ad5ec15ff80..7cd2ee83906 100644 --- a/release/scripts/startup/bl_operators/uvcalc_follow_active.py +++ b/release/scripts/startup/bl_operators/uvcalc_follow_active.py @@ -25,6 +25,8 @@ import bpy def extend(obj, operator, EXTEND_MODE): + from bpy_extras import mesh_utils + me = obj.data me_verts = me.vertices # script will fail without UVs @@ -170,7 +172,7 @@ def extend(obj, operator, EXTEND_MODE): edge_faces[edkey] = [i] if EXTEND_MODE == 'LENGTH': - edge_loops = me.edge_loops_from_faces(face_sel, [ed.key for ed in me.edges if ed.use_seam]) + edge_loops = mesh_utils.edge_loops_from_faces(me, face_sel, [ed.key for ed in me.edges if ed.use_seam]) me_verts = me.vertices for loop in edge_loops: looplen = [0.0] -- cgit v1.2.3 From ea19f154004cb28b684c70be8b937e0056c715dc Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 26 May 2011 09:20:30 +0000 Subject: BUGFIX: Sequencer strips.elements was broken when strip was trimmed (personal bug report, no number) When trimmed the seq->len was being reduced from the offsets (initial and final). This was the length passed to the elements. This had two problems: 1) it would not allow you to change the elements not visible (although you likely want to change them as well). 2) the element[0] was always the seq->strips[0].stripdata[0], regardless of the initial trim. Anyhoo it's all working now. Thanks Campbell for helping out with this one. --- source/blender/makesrna/intern/rna_sequencer.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 90ae95894b0..6d4e9bb476c 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -107,6 +107,23 @@ static void rna_SequenceEditor_sequences_all_next(CollectionPropertyIterator *it } /* internal use */ +static int rna_SequenceEditor_elements_length(PointerRNA *ptr) +{ + Sequence *seq= (Sequence*)ptr->data; + + /* Hack? copied from sequencer.c::reload_sequence_new_file() */ + size_t olen = MEM_allocN_len(seq->strip->stripdata)/sizeof(struct StripElem); + + /* the problem with seq->strip->len and seq->len is that it's discounted from the offset (hard cut trim) */ + return (int) olen; +} + +static void rna_SequenceEditor_elements_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Sequence *seq= (Sequence*)ptr->data; + rna_iterator_array_begin(iter, (void*)seq->strip->stripdata, sizeof(StripElem), rna_SequenceEditor_elements_length(ptr), 0, NULL); +} + static void rna_Sequence_frame_change_update(Scene *scene, Sequence *seq) { Editing *ed= seq_give_editing(scene, FALSE); @@ -1222,9 +1239,10 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); prop= RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", "strip->len"); + RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", NULL); RNA_def_property_struct_type(prop, "SequenceElement"); RNA_def_property_ui_text(prop, "Elements", ""); + RNA_def_property_collection_funcs(prop, "rna_SequenceEditor_elements_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_SequenceEditor_elements_length", 0, 0); rna_def_filter_video(srna); rna_def_proxy(srna); @@ -1291,9 +1309,10 @@ static void rna_def_movie(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); prop= RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", "strip->len"); + RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", NULL); RNA_def_property_struct_type(prop, "SequenceElement"); RNA_def_property_ui_text(prop, "Elements", ""); + RNA_def_property_collection_funcs(prop, "rna_SequenceEditor_elements_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_SequenceEditor_elements_length", 0, 0); prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_ui_text(prop, "File", ""); -- cgit v1.2.3 From 26252bb3154395965f5499bd5264474f9d93b787 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 09:33:51 +0000 Subject: correct spelling error and some pep8 changes. --- build_files/cmake/cmake_netbeans_project.py | 5 ++- build_files/cmake/cmake_qtcreator_project.py | 36 ++++++++++------------ build_files/cmake/project_info.py | 2 +- .../examples/bpy.types.BlendDataLibraries.load.py | 2 +- release/scripts/modules/bpy_extras/mesh_utils.py | 6 ++-- release/scripts/modules/bpy_extras/view3d_utils.py | 2 +- .../startup/bl_operators/uvcalc_follow_active.py | 2 +- .../scripts/startup/bl_ui/properties_data_empty.py | 4 +-- .../startup/bl_ui/properties_object_constraint.py | 4 +-- release/scripts/startup/bl_ui/space_image.py | 2 +- 10 files changed, 31 insertions(+), 34 deletions(-) diff --git a/build_files/cmake/cmake_netbeans_project.py b/build_files/cmake/cmake_netbeans_project.py index c8bedb55148..6afca8f3b6a 100755 --- a/build_files/cmake/cmake_netbeans_project.py +++ b/build_files/cmake/cmake_netbeans_project.py @@ -33,7 +33,7 @@ Windows not supported so far from project_info import * import os -from os.path import join, dirname, normpath, abspath, splitext, relpath, exists +from os.path import join, dirname, normpath, relpath, exists def create_nb_project_main(): @@ -50,7 +50,6 @@ def create_nb_project_main(): includes.sort() PROJECT_NAME = "Blender" - FILE_NAME = PROJECT_NAME.lower() # --------------- NB spesific defines = [("%s=%s" % cdef) if cdef[1] else cdef[0] for cdef in defines] @@ -76,7 +75,7 @@ def create_nb_project_main(): if not exists(PROJECT_DIR_NB): os.mkdir(PROJECT_DIR_NB) - SOURCE_DIR_REL = relpath(SOURCE_DIR, PROJECT_DIR) + # SOURCE_DIR_REL = relpath(SOURCE_DIR, PROJECT_DIR) f = open(join(PROJECT_DIR_NB, "project.xml"), 'w') diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index e38b2228cca..3de15567727 100755 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -34,54 +34,52 @@ example linux usage from project_info import * import os -from os.path import join, dirname, normpath, abspath, splitext, relpath, exists - import sys def create_qtc_project_main(): files = list(source_list(SOURCE_DIR, filename_check=is_project_file)) - files_rel = [relpath(f, start=PROJECT_DIR) for f in files] + files_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files] files_rel.sort() # --- qtcreator specific, simple format if SIMPLE_PROJECTFILE: # --- qtcreator specific, simple format PROJECT_NAME = "Blender" - f = open(join(PROJECT_DIR, "%s.files" % PROJECT_NAME), 'w') + f = open(os.path.join(PROJECT_DIR, "%s.files" % PROJECT_NAME), 'w') f.write("\n".join(files_rel)) - f = open(join(PROJECT_DIR, "%s.includes" % PROJECT_NAME), 'w') - f.write("\n".join(sorted(list(set(dirname(f) for f in files_rel if is_c_header(f)))))) + f = open(os.path.join(PROJECT_DIR, "%s.includes" % PROJECT_NAME), 'w') + f.write("\n".join(sorted(list(set(os.path.dirname(f) for f in files_rel if is_c_header(f)))))) - qtc_prj = join(PROJECT_DIR, "%s.creator" % PROJECT_NAME) + qtc_prj = os.path.join(PROJECT_DIR, "%s.creator" % PROJECT_NAME) f = open(qtc_prj, 'w') f.write("[General]\n") - qtc_cfg = join(PROJECT_DIR, "%s.config" % PROJECT_NAME) - if not exists(qtc_cfg): + qtc_cfg = os.path.join(PROJECT_DIR, "%s.config" % PROJECT_NAME) + if not os.path.exists(qtc_cfg): f = open(qtc_cfg, 'w') f.write("// ADD PREDEFINED MACROS HERE!\n") else: includes, defines = cmake_advanced_info() # for some reason it doesnt give all internal includes - includes = list(set(includes) | set(dirname(f) for f in files_rel if is_c_header(f))) + includes = list(set(includes) | set(os.path.dirname(f) for f in files_rel if is_c_header(f))) includes.sort() PROJECT_NAME = "Blender" FILE_NAME = PROJECT_NAME.lower() - f = open(join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w') + f = open(os.path.join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w') f.write("\n".join(files_rel)) - f = open(join(PROJECT_DIR, "%s.includes" % FILE_NAME), 'w') + f = open(os.path.join(PROJECT_DIR, "%s.includes" % FILE_NAME), 'w') f.write("\n".join(sorted(includes))) - qtc_prj = join(PROJECT_DIR, "%s.creator" % FILE_NAME) + qtc_prj = os.path.join(PROJECT_DIR, "%s.creator" % FILE_NAME) f = open(qtc_prj, 'w') f.write("[General]\n") - qtc_cfg = join(PROJECT_DIR, "%s.config" % FILE_NAME) + qtc_cfg = os.path.join(PROJECT_DIR, "%s.config" % FILE_NAME) f = open(qtc_cfg, 'w') f.write("// ADD PREDEFINED MACROS HERE!\n") defines_final = [("#define %s %s" % item) for item in defines] @@ -95,21 +93,21 @@ def create_qtc_project_main(): def create_qtc_project_python(): files = list(source_list(SOURCE_DIR, filename_check=is_py)) - files_rel = [relpath(f, start=PROJECT_DIR) for f in files] + files_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files] files_rel.sort() # --- qtcreator specific, simple format PROJECT_NAME = "Blender_Python" FILE_NAME = PROJECT_NAME.lower() - f = open(join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w') + f = open(os.path.join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w') f.write("\n".join(files_rel)) - qtc_prj = join(PROJECT_DIR, "%s.creator" % FILE_NAME) + qtc_prj = os.path.join(PROJECT_DIR, "%s.creator" % FILE_NAME) f = open(qtc_prj, 'w') f.write("[General]\n") - qtc_cfg = join(PROJECT_DIR, "%s.config" % FILE_NAME) - if not exists(qtc_cfg): + qtc_cfg = os.path.join(PROJECT_DIR, "%s.config" % FILE_NAME) + if not os.path.exists(qtc_cfg): f = open(qtc_cfg, 'w') f.write("// ADD PREDEFINED MACROS HERE!\n") diff --git a/build_files/cmake/project_info.py b/build_files/cmake/project_info.py index c25fbf4128d..db12884469b 100755 --- a/build_files/cmake/project_info.py +++ b/build_files/cmake/project_info.py @@ -46,7 +46,7 @@ __all__ = ( import sys import os -from os.path import join, dirname, normpath, abspath, splitext, relpath, exists +from os.path import join, dirname, normpath, abspath, splitext, exists SOURCE_DIR = join(dirname(__file__), "..", "..") SOURCE_DIR = normpath(SOURCE_DIR) diff --git a/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py b/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py index 594f36e4340..42e2a71cc70 100644 --- a/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py +++ b/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py @@ -23,7 +23,7 @@ with bpy.data.libraries.load(filepath) as (data_from, data_to): setattr(data_to, attr, getattr(data_from, attr)) -# the 'data_to' variables lists are +# the 'data_to' variables lists are with bpy.data.libraries.load(filepath) as (data_from, data_to): data_to.scenes = ["Scene"] diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py index ee7bceedb6e..9ec8ee98e41 100644 --- a/release/scripts/modules/bpy_extras/mesh_utils.py +++ b/release/scripts/modules/bpy_extras/mesh_utils.py @@ -162,6 +162,7 @@ def edge_loops_from_faces(mesh, faces=None, seams=()): return edge_loops + def edge_loops_from_edges(mesh, edges=None): """ Edge loops defined by edges @@ -227,8 +228,7 @@ def edge_loops_from_edges(mesh, edges=None): return line_polys - -def ngon_tessellate(from_data, indices, fix_loops=True): +def ngon_tesselate(from_data, indices, fix_loops=True): ''' Takes a polyline of indices (fgon) and returns a list of face indicie lists. @@ -238,7 +238,7 @@ def ngon_tessellate(from_data, indices, fix_loops=True): indices: a list of indices to use this list is the ordered closed polyline to fill, and can be a subset of the data given. fix_loops: If this is enabled polylines that use loops to make multiple polylines are delt with correctly. ''' - + from mathutils import Vector vector_to_tuple = Vector.to_tuple diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py index 7d37b94982f..ef2e20c4908 100644 --- a/release/scripts/modules/bpy_extras/view3d_utils.py +++ b/release/scripts/modules/bpy_extras/view3d_utils.py @@ -45,7 +45,7 @@ def region_2d_to_vector_3d(region, rv3d, coord): )) w = (out[0] * persinv[0][3]) + (out[1] * persinv[1][3]) + (out[2] * persinv[2][3]) + persinv[3][3] - + return ((out * persinv) / w) - rv3d.view_matrix.inverted()[3].xyz else: return rv3d.view_matrix.inverted()[2].xyz.normalized() diff --git a/release/scripts/startup/bl_operators/uvcalc_follow_active.py b/release/scripts/startup/bl_operators/uvcalc_follow_active.py index 7cd2ee83906..edd09d9c66b 100644 --- a/release/scripts/startup/bl_operators/uvcalc_follow_active.py +++ b/release/scripts/startup/bl_operators/uvcalc_follow_active.py @@ -26,7 +26,7 @@ import bpy def extend(obj, operator, EXTEND_MODE): from bpy_extras import mesh_utils - + me = obj.data me_verts = me.vertices # script will fail without UVs diff --git a/release/scripts/startup/bl_ui/properties_data_empty.py b/release/scripts/startup/bl_ui/properties_data_empty.py index 80f83e7fabe..5a0d327f90d 100644 --- a/release/scripts/startup/bl_ui/properties_data_empty.py +++ b/release/scripts/startup/bl_ui/properties_data_empty.py @@ -44,9 +44,9 @@ class DATA_PT_empty(DataButtonsPanel, bpy.types.Panel): # layout.template_image(ob, "data", None) layout.template_ID(ob, "data", open="image.open", unlink="image.unlink") - row = layout.row(align = True) + row = layout.row(align=True) row.prop(ob, "color", text="Transparency", index=3, slider=True) - row = layout.row(align = True) + row = layout.row(align=True) row.prop(ob, "empty_image_offset", text="Offset X", index=0) row.prop(ob, "empty_image_offset", text="Offset Y", index=1) diff --git a/release/scripts/startup/bl_ui/properties_object_constraint.py b/release/scripts/startup/bl_ui/properties_object_constraint.py index 2ca18744eb6..7c2fe76fe14 100644 --- a/release/scripts/startup/bl_ui/properties_object_constraint.py +++ b/release/scripts/startup/bl_ui/properties_object_constraint.py @@ -666,9 +666,9 @@ class ConstraintButtonsPanel(): row = col.row() row.prop(con, "map_to_z_from", expand=False, text="") row.label(text=" -> Z") - + split = layout.split() - + col = split.column() col.label(text="Destination:") col.row().prop(con, "map_to", expand=True) diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 44a1c814e28..9f69ca17076 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -437,7 +437,7 @@ class IMAGE_PT_game_properties(bpy.types.Panel): rd = context.scene.render sima = context.space_data # display even when not in game mode because these settings effect the 3d view - return (sima and sima.image) # and (rd.engine == 'BLENDER_GAME') + return (sima and sima.image) # and (rd.engine == 'BLENDER_GAME') def draw(self, context): layout = self.layout -- cgit v1.2.3 From 686859afadb71c19381774b6eac28f2454a0ab49 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 May 2011 09:46:51 +0000 Subject: Use proper checking for image source --- source/blender/blenkernel/intern/image.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 22d19c5484f..f17438c2b00 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -381,9 +381,7 @@ Image *BKE_add_image_file(const char *name) ima= image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE); BLI_strncpy(ima->name, name, sizeof(ima->name)); - /* do a wild guess! */ - if(BLI_testextensie(name, ".avi") || BLI_testextensie(name, ".mov") - || BLI_testextensie(name, ".mpg") || BLI_testextensie(name, ".mp4")) + if(BLI_testextensie_array(name, imb_ext_movie)) ima->source= IMA_SRC_MOVIE; return ima; -- cgit v1.2.3 From 042a3ff3822254e33371e1dd782dd721ce3d0ec9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 26 May 2011 09:58:22 +0000 Subject: Fix #27445: various operators missing with some non-english system languages. In the case of this bug e.g. material.new became MATERiAL_OT_new, due to different capitalization of "i" in Turkish. Fixed by not using the locale dependent toupper/tolower functions. --- source/blender/blenlib/BLI_string.h | 3 +++ source/blender/blenlib/intern/string.c | 18 ++++++++++++++++++ source/blender/windowmanager/intern/wm_operators.c | 17 ++++++++++------- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 635c38e1d13..69702f72026 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -147,6 +147,9 @@ void BLI_timestr(double _time, char *str); /* time var is global */ int BLI_utf8_invalid_byte(const char *str, int length); int BLI_utf8_invalid_strip(char *str, int length); +void BLI_ascii_strtolower(char *str, int len); +void BLI_ascii_strtoupper(char *str, int len); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index ee5bd17c901..11de8a3d45c 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -469,3 +469,21 @@ int BLI_utf8_invalid_strip(char *str, int length) return tot; } +void BLI_ascii_strtolower(char *str, int len) +{ + int i; + + for(i=0; i= 'A' && str[i] <= 'Z') + str[i] += 'a' - 'A'; +} + +void BLI_ascii_strtoupper(char *str, int len) +{ + int i; + + for(i=0; i= 'a' && str[i] <= 'z') + str[i] -= 'a' - 'A'; +} + diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 8ac7a3d7eb6..78610d48a92 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -56,6 +56,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" /*for WM_operator_pystring */ #include "BLI_math.h" +#include "BLI_string.h" #include "BLI_utildefines.h" #include "BLO_readfile.h" @@ -441,10 +442,12 @@ void WM_operator_py_idname(char *to, const char *from) { char *sep= strstr(from, "_OT_"); if(sep) { - int i, ofs= (sep-from); - - for(i=0; i Date: Thu, 26 May 2011 10:21:09 +0000 Subject: Fix #27480: armature multimodifier was not working in edit mode. --- source/blender/modifiers/intern/MOD_armature.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 95579147dbb..a0ee047e319 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -127,8 +127,8 @@ static void deformVerts(ModifierData *md, Object *ob, modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ armature_deform_verts(amd->object, ob, derivedData, vertexCos, NULL, - numVerts, amd->deformflag, - (float(*)[3])amd->prevCos, amd->defgrp_name); + numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); + /* free cache */ if(amd->prevCos) { MEM_freeN(amd->prevCos); @@ -145,8 +145,16 @@ static void deformVertsEM( if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); - armature_deform_verts(amd->object, ob, dm, vertexCos, NULL, numVerts, - amd->deformflag, NULL, amd->defgrp_name); + modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ + + armature_deform_verts(amd->object, ob, dm, vertexCos, NULL, + numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); + + /* free cache */ + if(amd->prevCos) { + MEM_freeN(amd->prevCos); + amd->prevCos= NULL; + } if(!derivedData) dm->release(dm); } -- cgit v1.2.3 From d7f42721f879781e12f750fdf803bab712114811 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 26 May 2011 10:25:51 +0000 Subject: Fix #27465: used light groups did not get linked in with materials automatically. --- source/blender/blenloader/intern/readfile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9666990f110..bf00abf1008 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -12200,6 +12200,9 @@ static void expand_material(FileData *fd, Main *mainvar, Material *ma) if(ma->nodetree) expand_nodetree(fd, mainvar, ma->nodetree); + + if(ma->group) + expand_doit(fd, mainvar, ma->group); } static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la) -- cgit v1.2.3 From 514de547ac8315c4be2ff76a22494f60145896b9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 11:45:25 +0000 Subject: update to build system excluding parts of the python bundle. --- build_files/scons/tools/Blender.py | 20 ++++++---- source/creator/CMakeLists.txt | 80 +++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 46 deletions(-) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 4bfa1851acb..8dbed82ed84 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -449,10 +449,16 @@ def WinPyBundle(target=None, source=None, env=None): shutil.rmtree(py_target, False, printexception) exclude_re=[re.compile('.*/test/.*'), re.compile('^config/.*'), + re.compile('^config-*/.*'), re.compile('^distutils/.*'), re.compile('^idlelib/.*'), re.compile('^lib2to3/.*'), - re.compile('^tkinter/.*')] + re.compile('^tkinter/.*'), + re.compile('^_tkinter_d.pyd'), + re.compile('^turtledemo'), + re.compile('^turtle.py'), + ] + print "Unpacking '" + py_tar + "' to '" + py_target + "'" untar_pybundle(py_tar,py_target,exclude_re) @@ -569,17 +575,17 @@ def UnixPyBundle(target=None, source=None, env=None): run("cp -R '%s' '%s'" % (py_src, os.path.dirname(py_target))) run("rm -rf '%s/distutils'" % py_target) run("rm -rf '%s/lib2to3'" % py_target) - run("rm -rf '%s/idlelib'" % py_target) - run("rm -rf '%s/tkinter'" % py_target) run("rm -rf '%s/config'" % py_target) - + run("rm -rf '%s/config-*'" % py_target) run("rm -rf '%s/site-packages'" % py_target) run("mkdir '%s/site-packages'" % py_target) # python needs it.' - + run("rm -rf '%s/idlelib'" % py_target) + run("rm -rf '%s/tkinter'" % py_target) + run("rm -rf '%s/turtledemo'" % py_target) + run("rm -r '%s/turtle.py'" % py_target) run("rm -f '%s/lib-dynload/_tkinter.so'" % py_target) + run("find '%s' -type d -name 'test' -prune -exec rm -rf {} ';'" % py_target) - run("find '%s' -type d -name 'config-*' -prune -exec rm -rf {} ';'" % py_target) - run("find '%s' -type d -name 'turtledemo' -prune -exec rm -rf {} ';'" % py_target) run("find '%s' -type d -name '__pycache__' -exec rm -rf {} ';'" % py_target) run("find '%s' -name '*.py[co]' -exec rm -rf {} ';'" % py_target) run("find '%s' -name '*.so' -exec strip -s {} ';'" % py_target) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 06b8d4decec..289a625ac59 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -193,8 +193,8 @@ if(WITH_PYTHON_MODULE) PROPERTIES PREFIX "" OUTPUT_NAME bpy - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ # only needed on windows + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin # only needed on windows ) if(WIN32) @@ -270,7 +270,7 @@ if(UNIX AND NOT APPLE) ) install( - DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/ + DIRECTORY ${CMAKE_SOURCE_DIR}/release/text DESTINATION ${TARGETDIR} PATTERN ".svn" EXCLUDE ) @@ -317,7 +317,7 @@ if(UNIX AND NOT APPLE) ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/32x32 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/48x48 ${CMAKE_SOURCE_DIR}/release/freedesktop/icons/256x256 - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/ + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor PATTERN ".svn" EXCLUDE PATTERN "*.svg" EXCLUDE ) @@ -334,7 +334,7 @@ if(UNIX AND NOT APPLE) DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1 ) install( - DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/ + DIRECTORY ${CMAKE_SOURCE_DIR}/release/text DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/blender PATTERN ".svn" EXCLUDE ) @@ -353,7 +353,7 @@ if(UNIX AND NOT APPLE) install( DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale - DESTINATION ${TARGETDIR_VER}/datafiles/ + DESTINATION ${TARGETDIR_VER}/datafiles PATTERN ".svn" EXCLUDE ) endif() @@ -362,7 +362,7 @@ if(UNIX AND NOT APPLE) # # install( # DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins - # DESTINATION ${TARGETDIR_VER}/ + # DESTINATION ${TARGETDIR_VER} # PATTERN ".svn" EXCLUDE # ) @@ -370,7 +370,7 @@ if(UNIX AND NOT APPLE) # install(CODE "message(\"copying blender scripts...\")") install( DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts - DESTINATION ${TARGETDIR_VER}/ + DESTINATION ${TARGETDIR_VER} PATTERN ".svn" EXCLUDE PATTERN "__pycache__" EXCLUDE ) @@ -381,9 +381,9 @@ if(UNIX AND NOT APPLE) # install(CODE "message(\"copying a subset of the systems python...\")") install( DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION} - DESTINATION ${TARGETDIR_VER}/python/lib/ + DESTINATION ${TARGETDIR_VER}/python/lib PATTERN ".svn" EXCLUDE - PATTERN "__pycache__" EXCLUDE # ./distutils + PATTERN "__pycache__" EXCLUDE # * any cache * PATTERN "distutils" EXCLUDE # ./distutils PATTERN "lib2to3" EXCLUDE # ./lib2to3 PATTERN "config" EXCLUDE # ./config @@ -391,8 +391,10 @@ if(UNIX AND NOT APPLE) PATTERN "site-packages/*" EXCLUDE # ./site-packages/* PATTERN "tkinter" EXCLUDE # ./tkinter PATTERN "lib-dynload/_tkinter.*" EXCLUDE # ./lib-dynload/_tkinter.co + PATTERN "idlelib" EXCLUDE # ./idlelib PATTERN "test" EXCLUDE # ./test PATTERN "turtledemo" EXCLUDE # ./turtledemo + PATTERN "turtle.py" EXCLUDE # ./turtle.py ) # # doesnt work, todo @@ -409,8 +411,8 @@ elseif(WIN32) ) install( # same as linux!, deduplicate - DIRECTORY ${CMAKE_SOURCE_DIR}/release/text/ - DESTINATION ${TARGETDIR}/ + DIRECTORY ${CMAKE_SOURCE_DIR}/release/text + DESTINATION ${TARGETDIR} PATTERN ".svn" EXCLUDE ) @@ -426,25 +428,25 @@ elseif(WIN32) ) install( DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale - DESTINATION ${TARGETDIR_VER}/datafiles/ + DESTINATION ${TARGETDIR_VER}/datafiles PATTERN ".svn" EXCLUDE ) if(NOT CMAKE_CL_64) install( FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) install( FILES ${LIBDIR}/iconv/lib/iconv.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) endif() endif() install( # same as linux!, deduplicate - DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/ + DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale DESTINATION ${TARGETDIR_VER}/datafiles/locale PATTERN ".svn" EXCLUDE ) @@ -453,7 +455,7 @@ elseif(WIN32) # # install( # DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins - # DESTINATION ${TARGETDIR_VER}/ + # DESTINATION ${TARGETDIR_VER} # PATTERN ".svn" EXCLUDE # ) @@ -461,19 +463,19 @@ elseif(WIN32) # install(CODE "message(\"copying blender scripts...\")") install( # same as linux!, deduplicate DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts - DESTINATION ${TARGETDIR_VER}/ + DESTINATION ${TARGETDIR_VER} PATTERN ".svn" EXCLUDE PATTERN "__pycache__" EXCLUDE ) # TODO, multiple targets? - install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS Release) - install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS RelWithDebInfo) - install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR}/ CONFIGURATIONS MinSizeRel) + install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR} CONFIGURATIONS Release) + install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR} CONFIGURATIONS RelWithDebInfo) + install(FILES ${LIBDIR}/python/lib/python32.dll DESTINATION ${TARGETDIR} CONFIGURATIONS MinSizeRel) install( FILES ${LIBDIR}/python/lib/python32_d.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} CONFIGURATIONS Debug ) @@ -485,8 +487,8 @@ elseif(WIN32) CODE " message(\"creating ${TARGETDIR_VER}/python/lib\") - file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/\") - file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib/\") + file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python\") + file(MAKE_DIRECTORY \"${TARGETDIR_VER}/python/lib\") message(\"done creating dir\") " ) @@ -494,7 +496,7 @@ elseif(WIN32) install( CODE " - execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\" + execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\" \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\") " CONFIGURATIONS Release @@ -502,7 +504,7 @@ elseif(WIN32) install( CODE " - execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\" + execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\" \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\") " CONFIGURATIONS RelWithDebInfo @@ -510,7 +512,7 @@ elseif(WIN32) install( CODE " - execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\" + execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\" \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32.tar.gz\") " CONFIGURATIONS MinSizeRel @@ -518,7 +520,7 @@ elseif(WIN32) install( CODE " - execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib/\" + execute_process(COMMAND \"${CMAKE_COMMAND}\" -E chdir \"${TARGETDIR_VER}/python/lib\" \"${CMAKE_COMMAND}\" -E tar xzfv \"${LIBDIR}/release/python32_d.tar.gz\") " CONFIGURATIONS Debug @@ -533,26 +535,26 @@ elseif(WIN32) # gettext and png are statically linked on win64 install( FILES ${LIBDIR}/zlib/lib/zlib.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) else() install( FILES ${LIBDIR}/png/lib/libpng.dll ${LIBDIR}/zlib/lib/zlib.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) endif() if(MSVC) install( FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) else() install( FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) endif() @@ -564,7 +566,7 @@ elseif(WIN32) ${LIBDIR}/ffmpeg/lib/avdevice-52.dll ${LIBDIR}/ffmpeg/lib/avutil-50.dll ${LIBDIR}/ffmpeg/lib/swscale-0.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) endif() @@ -573,7 +575,7 @@ elseif(WIN32) install( FILES ${LIBDIR}/sndfile/lib/libsndfile-1.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) endif() @@ -582,7 +584,7 @@ elseif(WIN32) FILES ${LIBDIR}/openal/lib/OpenAL32.dll ${LIBDIR}/openal/lib/wrap_oal.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) endif() @@ -591,7 +593,7 @@ elseif(WIN32) install( FILES ${LIBDIR}/sdl/lib/SDL.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) endif() endif() @@ -600,13 +602,13 @@ elseif(WIN32) install( FILES ${LIBDIR}/thumbhandler/lib/BlendThumb.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) else() install( FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll - DESTINATION ${TARGETDIR}/ + DESTINATION ${TARGETDIR} ) endif() @@ -660,7 +662,7 @@ elseif(APPLE) install( FILES ${SOURCEDIR}/Contents/PkgInfo - DESTINATION ${TARGETDIR}/blender.app/Contents/ + DESTINATION ${TARGETDIR}/blender.app/Contents ) install_dir( -- cgit v1.2.3 From e6d396d17de4105a5c10297e3375b88e04341651 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 12:15:42 +0000 Subject: fix for installing blender as a python module with cmake. --- source/creator/CMakeLists.txt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 289a625ac59..aea48d88b47 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -278,17 +278,11 @@ if(UNIX AND NOT APPLE) else() # main blender binary if(WITH_PYTHON_MODULE) - get_target_property(_module_name blender OUTPUT_NAME) - if(NOT _module_suffix) - set(_module_suffix "${SUFFIX}") - endif() - install( - PROGRAMS "${TARGETDIR}/${_module_name}.so" # XXX, *nix only + TARGETS blender + LIBRARY DESTINATION ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages ) - - unset(_module_name) else() install( PROGRAMS ${TARGETDIR}/blender -- cgit v1.2.3 From df823d8896d6d1d81bd9a5f662c5f14f32f19bb9 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Thu, 26 May 2011 12:23:11 +0000 Subject: Since we don't support win2k or older anymore, remove old shortname code. Finally nice full names. --- source/blender/blenlib/intern/path_util.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 1f4b0ffdd5c..47e50e375f0 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1691,7 +1691,6 @@ void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name) #ifdef _WIN32 if(GetModuleFileName(0, fullname, maxlen)) { - GetShortPathName(fullname, 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); @@ -1744,18 +1743,6 @@ void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name) if (strcmp(name, fullname)) { printf("guessing '%s' == '%s'\n", name, fullname); } -#endif - -#ifdef _WIN32 - // in windows change long filename to short filename because - // win2k doesn't know how to parse a commandline with lots of - // spaces and double-quotes. There's another solution to this - // with spawnv(P_WAIT, bprogname, argv) instead of system() but - // that's even uglier - GetShortPathName(fullname, fullname, maxlen); -#if defined(DEBUG) - printf("Shortname = '%s'\n", fullname); -#endif #endif } } -- cgit v1.2.3 From 155d5893337dd4bd632f8a669850356875b19414 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 13:38:16 +0000 Subject: add the property as an argument to enum item functions, not used yet but needed for dynamic python enums. --- source/blender/editors/animation/keyingsets.c | 2 +- source/blender/editors/armature/poselib.c | 2 +- source/blender/editors/include/ED_keyframing.h | 2 +- source/blender/editors/mesh/editmesh_mods.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 6 +++--- source/blender/editors/object/object_edit.c | 4 ++-- source/blender/editors/object/object_hook.c | 2 +- source/blender/editors/object/object_modifier.c | 2 +- source/blender/editors/object/object_relations.c | 2 +- source/blender/editors/object/object_vgroup.c | 2 +- source/blender/editors/sculpt_paint/paint_vertex.c | 2 +- source/blender/makesrna/RNA_enum_types.h | 23 +++++++++++----------- source/blender/makesrna/RNA_types.h | 4 +++- source/blender/makesrna/intern/rna_access.c | 4 ++-- source/blender/makesrna/intern/rna_actuator.c | 2 +- source/blender/makesrna/intern/rna_brush.c | 2 +- source/blender/makesrna/intern/rna_constraint.c | 4 ++-- source/blender/makesrna/intern/rna_image.c | 2 +- .../blender/makesrna/intern/rna_internal_types.h | 3 ++- source/blender/makesrna/intern/rna_material.c | 2 +- source/blender/makesrna/intern/rna_nodetree.c | 6 +++--- source/blender/makesrna/intern/rna_object.c | 4 ++-- source/blender/makesrna/intern/rna_object_force.c | 2 +- source/blender/makesrna/intern/rna_particle.c | 8 ++++---- source/blender/makesrna/intern/rna_rna.c | 4 ++-- source/blender/makesrna/intern/rna_scene.c | 6 +++--- source/blender/makesrna/intern/rna_sculpt_paint.c | 2 +- source/blender/makesrna/intern/rna_sensor.c | 2 +- source/blender/makesrna/intern/rna_space.c | 6 +++--- source/blender/makesrna/intern/rna_texture.c | 2 +- source/blender/makesrna/intern/rna_wm.c | 7 +++---- source/blender/windowmanager/intern/wm_operators.c | 16 +++++++-------- 32 files changed, 71 insertions(+), 68 deletions(-) diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 10886615976..c525c9af626 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -696,7 +696,7 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformK /* Menu of All Keying Sets ----------------------------- */ /* Dynamically populate an enum of Keying Sets */ -EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(ptr), int *free) +EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Scene *scene = CTX_data_scene(C); KeyingSet *ks; diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 9e0e9374d5d..5b4da1a38df 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -483,7 +483,7 @@ void POSELIB_OT_pose_add (wmOperatorType *ot) /* ----- */ /* can be called with C == NULL */ -static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *ob = get_poselib_object(C); bAction *act = (ob) ? ob->poselib : NULL; diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 6523a897713..294b9b8475a 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -211,7 +211,7 @@ struct KeyingSet *ANIM_get_keyingset_for_autokeying(struct Scene *scene, const c void ANIM_keying_sets_menu_setup(struct bContext *C, const char title[], const char op_name[]); /* Dynamically populate an enum of Keying Sets */ -struct EnumPropertyItem *ANIM_keying_sets_enum_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); +struct EnumPropertyItem *ANIM_keying_sets_enum_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); /* Check if KeyingSet can be used in the current context */ short ANIM_keyingset_context_ok_poll(struct bContext *C, struct KeyingSet *ks); diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 18f3b807f86..b5da36756b5 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -1250,7 +1250,7 @@ static int select_similar_exec(bContext *C, wmOperator *op) return similar_face_select_exec(C, op); } -static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *obedit= CTX_data_edit_object(C); EnumPropertyItem *item= NULL; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index dfd1ac730ac..dc744c49fae 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -762,7 +762,7 @@ static EnumPropertyItem extrude_items[] = { {0, NULL, 0, NULL, NULL}}; -static EnumPropertyItem *mesh_extrude_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *mesh_extrude_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { EnumPropertyItem *item= NULL; Object *obedit= CTX_data_edit_object(C); @@ -5263,7 +5263,7 @@ static int blend_from_shape_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem *shape_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *shape_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *obedit= CTX_data_edit_object(C); Mesh *me= (obedit) ? obedit->data : NULL; @@ -5975,7 +5975,7 @@ static EnumPropertyItem merge_type_items[]= { {5, "COLLAPSE", 0, "Collapse", ""}, {0, NULL, 0, NULL, NULL}}; -static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *obedit= CTX_data_edit_object(C); EnumPropertyItem *item= NULL; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 91980ddf228..527b97a6082 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1873,7 +1873,7 @@ static void rand_timeoffs(Scene *scene, View3D *v3d) } -static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { EnumPropertyItem *input = object_mode_items; EnumPropertyItem *item= NULL; @@ -2119,7 +2119,7 @@ static EnumPropertyItem game_properties_copy_operations[] ={ static EnumPropertyItem gameprops_items[]= { {0, NULL, 0, NULL, NULL}}; -static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *ob= ED_object_active_context(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 78937299645..2d547da41f6 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -563,7 +563,7 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *ob = CTX_data_edit_object(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index d5bf894ac8c..5996037cd2d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -584,7 +584,7 @@ static int modifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *ob= ED_object_active_context(C); EnumPropertyItem *item= NULL, *md_item; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 8078bfbeb93..f7158e4b4ec 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -360,7 +360,7 @@ static int make_proxy_exec (bContext *C, wmOperator *op) } /* Generic itemf's for operators that take library args */ -static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { EnumPropertyItem item_tmp= {0}, *item= NULL; int totitem= 0; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 53562caf1b5..43448198ae1 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1966,7 +1966,7 @@ static int set_active_group_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; EnumPropertyItem tmp = {0, "", 0, "", ""}; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 14e9626212a..ecdf49a321a 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -942,7 +942,7 @@ void PAINT_OT_weight_sample(wmOperatorType *ot) } /* samples cursor location, and gives menu with vertex groups to activate */ -static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { if (C) { wmWindow *win= CTX_wm_window(C); diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 0bda47b4c7c..fc415dc8082 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -112,19 +112,20 @@ extern EnumPropertyItem ramp_blend_items[]; struct bContext; struct PointerRNA; -EnumPropertyItem *rna_TransformOrientation_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); -EnumPropertyItem *rna_Sensor_type_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); -EnumPropertyItem *rna_Actuator_type_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); +struct PropertyRNA; +EnumPropertyItem *rna_TransformOrientation_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *rna_Sensor_type_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *rna_Actuator_type_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); /* Generic functions, return an enum from library data, index is the position * in the linked list can add more for different types as needed */ -EnumPropertyItem *RNA_action_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); -EnumPropertyItem *RNA_action_local_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); -EnumPropertyItem *RNA_group_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); -EnumPropertyItem *RNA_group_local_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); -EnumPropertyItem *RNA_image_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); -EnumPropertyItem *RNA_image_local_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); -EnumPropertyItem *RNA_scene_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); -EnumPropertyItem *RNA_scene_local_itemf(struct bContext *C, struct PointerRNA *ptr, int *free); +EnumPropertyItem *RNA_action_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *RNA_action_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *RNA_group_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *RNA_group_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *RNA_image_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *RNA_image_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *RNA_scene_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *RNA_scene_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); #endif /* RNA_ENUM_TYPES_H */ diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index ec6f05c0e6a..b3f2ae01c99 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -39,6 +39,7 @@ extern "C" { struct ParameterList; struct FunctionRNA; struct PropertyRNA; +struct EnumPropertyRNA; struct StructRNA; struct BlenderRNA; struct IDProperty; @@ -255,7 +256,8 @@ typedef struct EnumPropertyItem { const char *description; } EnumPropertyItem; -typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, int *free); +/* this is a copy of 'PropEnumItemFunc' defined in rna_internal_types.h */ +typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, struct PropertyRNA *prop, int *free); typedef struct PropertyRNA PropertyRNA; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index ff54ac6254f..1db43b72a1e 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1096,9 +1096,9 @@ void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, En int tot= 0; if (prop->flag & PROP_ENUM_NO_CONTEXT) - *item= eprop->itemf(NULL, ptr, free); + *item= eprop->itemf(NULL, ptr, prop, free); else - *item= eprop->itemf(C, ptr, free); + *item= eprop->itemf(C, ptr, prop, free); if(totitem) { if(*item) { diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 2afba954be3..116f5185980 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -411,7 +411,7 @@ static void rna_StateActuator_state_set(PointerRNA *ptr, const int *values) } /* Always keep in alphabetical order */ -EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, int *free) +EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { EnumPropertyItem *item= NULL; Object *ob= NULL; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 7bb56380ba5..a6e26583a6a 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -235,7 +235,7 @@ static float rna_Brush_get_alpha(PointerRNA *ptr) return brush_alpha(me); } -static EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { static EnumPropertyItem prop_default_items[]= { {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index e7604b2beb4..d90db814329 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -243,7 +243,7 @@ static void rna_Constraint_ik_type_set(struct PointerRNA *ptr, int value) } } -static EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { Object *ob= (Object*)ptr->id.data; bConstraint *con= (bConstraint*)ptr->data; @@ -254,7 +254,7 @@ static EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *C, PointerRN return space_object_items; } -static EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { bConstraint *con= (bConstraint*)ptr->data; bConstraintTypeInfo *cti= constraint_get_typeinfo(con); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 3db90c2de0e..98a89a2524e 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -143,7 +143,7 @@ char *rna_ImageUser_path(PointerRNA *ptr) return BLI_strdup(""); } -static EnumPropertyItem *rna_Image_source_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Image_source_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { Image *ima= (Image*)ptr->data; EnumPropertyItem *item= NULL; diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index a59db183453..946aef9b317 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -41,6 +41,7 @@ struct FunctionRNA; struct ReportList; struct CollectionPropertyIterator; struct bContext; +struct EnumProperty; struct IDProperty; struct GHash; struct Main; @@ -88,7 +89,7 @@ typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr); typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value); typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr); typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value); -typedef EnumPropertyItem *(*PropEnumItemFunc)(struct bContext *C, struct PointerRNA *ptr, int *free); +typedef EnumPropertyItem *(*PropEnumItemFunc)(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); typedef PointerRNA (*PropPointerGetFunc)(struct PointerRNA *ptr); typedef StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr); typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 0e9629f973d..fdb41295b75 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -272,7 +272,7 @@ static void rna_Material_use_nodes_set(PointerRNA *ptr, int value) ED_node_shader_default(ma); } -static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { Material *ma= (Material*)ptr->id.data; EnumPropertyItem *item= NULL; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index d55534bb1b5..d41fb42d1eb 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -367,7 +367,7 @@ static EnumPropertyItem *renderresult_layers_add_enum(RenderLayer *rl) return item; } -static EnumPropertyItem *rna_Node_image_layer_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Node_image_layer_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { bNode *node= (bNode*)ptr->data; Image *ima = (Image *)node->id; @@ -384,7 +384,7 @@ static EnumPropertyItem *rna_Node_image_layer_itemf(bContext *C, PointerRNA *ptr return item; } -static EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { bNode *node= (bNode*)ptr->data; Scene *sce = (Scene *)node->id; @@ -401,7 +401,7 @@ static EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *C, PointerRNA *ptr return item; } -static EnumPropertyItem *rna_Node_channel_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Node_channel_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { bNode *node= (bNode*)ptr->data; EnumPropertyItem *item= NULL; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 4407ca8ad4e..5e1b22dbc9e 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -379,7 +379,7 @@ static void rna_Object_parent_type_set(PointerRNA *ptr, int value) ED_object_parent(ob, ob->parent, value, ob->parsubstr); } -static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { Object *ob= (Object*)ptr->data; EnumPropertyItem *item= NULL; @@ -410,7 +410,7 @@ static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *C, PointerRNA *p return item; } -static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { Object *ob= (Object*)ptr->data; EnumPropertyItem *item= NULL; diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 65c7b351622..9df76959122 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -678,7 +678,7 @@ static void rna_softbody_update(Main *bmain, Scene *scene, PointerRNA *ptr) } -static EnumPropertyItem *rna_Effector_shape_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Effector_shape_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { Object *ob= NULL; diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index fa69fad253f..6c9540908c5 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -702,7 +702,7 @@ static void rna_ParticleDupliWeight_name_get(PointerRNA *ptr, char *str) strcpy(str, "No object"); } -static EnumPropertyItem *rna_Particle_from_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Particle_from_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { //if(part->type==PART_REACTOR) // return part_reactor_from_items; @@ -710,7 +710,7 @@ static EnumPropertyItem *rna_Particle_from_itemf(bContext *C, PointerRNA *ptr, i return part_from_items; } -static EnumPropertyItem *rna_Particle_dist_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Particle_dist_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { ParticleSettings *part = ptr->id.data; @@ -720,7 +720,7 @@ static EnumPropertyItem *rna_Particle_dist_itemf(bContext *C, PointerRNA *ptr, i return part_dist_items; } -static EnumPropertyItem *rna_Particle_draw_as_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Particle_draw_as_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { ParticleSettings *part = ptr->id.data; @@ -730,7 +730,7 @@ static EnumPropertyItem *rna_Particle_draw_as_itemf(bContext *C, PointerRNA *ptr return part_draw_as_items; } -static EnumPropertyItem *rna_Particle_ren_as_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_Particle_ren_as_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { ParticleSettings *part = ptr->id.data; diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index de2b551909c..8faff2e26a9 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -697,7 +697,7 @@ static int rna_StringProperty_max_length_get(PointerRNA *ptr) return ((StringPropertyRNA*)prop)->maxlength; } -static EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { PropertyRNA *prop= (PropertyRNA*)ptr->data; EnumPropertyRNA *eprop; @@ -713,7 +713,7 @@ static EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, PointerRNA return eprop->item; } - return eprop->itemf(C, ptr, free); + return eprop->itemf(C, ptr, prop, free); } /* XXX - not sure this is needed? */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 44dcabe40f9..b4bbde43caa 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -597,7 +597,7 @@ static void rna_RenderSettings_qtcodecsettings_codecType_set(PointerRNA *ptr, in rd->qtcodecsettings.codecType = quicktime_videocodecType_from_rnatmpvalue(value); } -static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_codecType_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_codecType_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { EnumPropertyItem *item= NULL; EnumPropertyItem tmp = {0, "", 0, "", ""}; @@ -638,7 +638,7 @@ static void rna_RenderSettings_qtcodecsettings_audiocodecType_set(PointerRNA *pt rd->qtcodecsettings.audiocodecType = quicktime_audiocodecType_from_rnatmpvalue(value); } -static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_audiocodecType_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_audiocodecType_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { EnumPropertyItem *item= NULL; EnumPropertyItem tmp = {0, "", 0, "", ""}; @@ -709,7 +709,7 @@ static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value) BLI_strncpy(rd->engine, type->idname, sizeof(rd->engine)); } -static EnumPropertyItem *rna_RenderSettings_engine_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_RenderSettings_engine_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { RenderEngineType *type; EnumPropertyItem *item= NULL; diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index da536f95cba..452131d829c 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -127,7 +127,7 @@ static void rna_ParticleEdit_tool_set(PointerRNA *ptr, int value) pset->brushtype = value; } -static EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { Scene *scene= CTX_data_scene(C); Object *ob= (scene->basact)? scene->basact->object: NULL; diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 5bf398ae3a7..5cc8539f187 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -115,7 +115,7 @@ static void rna_Sensor_type_set(struct PointerRNA *ptr, int value) } /* Always keep in alphabetical order */ -EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, int *free) +EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { EnumPropertyItem *item= NULL; Object *ob=NULL; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 5d45a63b05b..463df7ae233 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -218,7 +218,7 @@ static PointerRNA rna_CurrentOrientation_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_TransformOrientation, BLI_findlink(&scene->transform_spaces, v3d->twmode - V3D_MANIP_CUSTOM)); } -EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, int *free) +EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { Scene *scene = NULL; ListBase *transform_spaces; @@ -468,7 +468,7 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value) ED_space_image_set(NULL, sima, sc->scene, sc->scene->obedit, (Image*)value.data); } -static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { SpaceImage *sima= (SpaceImage*)ptr->data; EnumPropertyItem *item= NULL; @@ -840,7 +840,7 @@ static void rna_BackgroundImage_opacity_set(PointerRNA *ptr, float value) bgpic->blend = 1.0f - value; } -static EnumPropertyItem *rna_SpaceProperties_texture_context_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_SpaceProperties_texture_context_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index a750fa3765f..3a80207ba15 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -285,7 +285,7 @@ static int rna_TextureSlot_output_node_get(PointerRNA *ptr) } -static EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { MTex *mtex= ptr->data; Tex *tex= mtex->tex; diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index e8b127b68bb..8a094d6eef1 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -467,7 +467,7 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value) } } -static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { int map_type= rna_wmKeyMapItem_map_type_get(ptr); @@ -477,7 +477,7 @@ static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *C, PointerRNA *ptr, else return event_type_items; } -static EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { int map_type= rna_wmKeyMapItem_map_type_get(ptr); @@ -486,7 +486,7 @@ static EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *C, PointerRNA *ptr else return event_value_items; } -static EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { wmWindowManager *wm = CTX_wm_manager(C); wmKeyConfig *kc; @@ -1842,4 +1842,3 @@ void RNA_def_wm(BlenderRNA *brna) } #endif /* RNA_RUNTIME */ - diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 78610d48a92..7f404f719ac 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3651,38 +3651,38 @@ static EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(pt } /* can add more as needed */ -EnumPropertyItem *RNA_action_itemf(bContext *C, PointerRNA *ptr, int *do_free) +EnumPropertyItem *RNA_action_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *do_free) { return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, FALSE); } -EnumPropertyItem *RNA_action_local_itemf(bContext *C, PointerRNA *ptr, int *do_free) +EnumPropertyItem *RNA_action_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *do_free) { return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, TRUE); } -EnumPropertyItem *RNA_group_itemf(bContext *C, PointerRNA *ptr, int *do_free) +EnumPropertyItem *RNA_group_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *do_free) { return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, FALSE); } -EnumPropertyItem *RNA_group_local_itemf(bContext *C, PointerRNA *ptr, int *do_free) +EnumPropertyItem *RNA_group_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *do_free) { return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, TRUE); } -EnumPropertyItem *RNA_image_itemf(bContext *C, PointerRNA *ptr, int *do_free) +EnumPropertyItem *RNA_image_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *do_free) { return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, FALSE); } -EnumPropertyItem *RNA_image_local_itemf(bContext *C, PointerRNA *ptr, int *do_free) +EnumPropertyItem *RNA_image_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *do_free) { return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, TRUE); } -EnumPropertyItem *RNA_scene_itemf(bContext *C, PointerRNA *ptr, int *do_free) +EnumPropertyItem *RNA_scene_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *do_free) { return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, FALSE); } -EnumPropertyItem *RNA_scene_local_itemf(bContext *C, PointerRNA *ptr, int *do_free) +EnumPropertyItem *RNA_scene_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *do_free) { return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, TRUE); } -- cgit v1.2.3 From 57c3c9e70f0f5ad043f07ddaa25ed7d0cd5020e0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 16:07:28 +0000 Subject: support for dynamic items in bpy.props.EnumProperty(), the items keyword argument can optionally be a function rather then a list. --- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/RNA_define.h | 1 + source/blender/makesrna/intern/makesrna.c | 2 +- source/blender/makesrna/intern/rna_access.c | 8 ++ source/blender/makesrna/intern/rna_define.c | 6 + .../blender/makesrna/intern/rna_internal_types.h | 1 + source/blender/python/intern/bpy_props.c | 142 +++++++++++++++++++-- 7 files changed, 151 insertions(+), 10 deletions(-) diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index a9f7d9f246f..e0feba3f2fd 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -743,6 +743,7 @@ int RNA_property_string_default_length(PointerRNA *ptr, PropertyRNA *prop); int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value); int RNA_property_enum_get_default(PointerRNA *ptr, PropertyRNA *prop); +void *RNA_property_enum_py_data_get(PropertyRNA *prop); PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop); void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value); diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index f52a69182b5..b076393ef3d 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -90,6 +90,7 @@ PropertyRNA *RNA_def_string_file_name(StructOrFunctionRNA *cont, const char *ide PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description); PropertyRNA *RNA_def_enum_flag(StructOrFunctionRNA *cont, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description); void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc); +void RNA_def_enum_py_data(PropertyRNA *prop, void *py_data); PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); PropertyRNA *RNA_def_float_vector(StructOrFunctionRNA *cont, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax); diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index fe6fc91eff4..f3f539feb99 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -2223,7 +2223,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr } case PROP_ENUM: { EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; - fprintf(f, "\t%s, %s, %s, ", rna_function_string(eprop->get), rna_function_string(eprop->set), rna_function_string(eprop->itemf)); + fprintf(f, "\t%s, %s, %s, NULL, ", rna_function_string(eprop->get), rna_function_string(eprop->set), rna_function_string(eprop->itemf)); if(eprop->item) fprintf(f, "rna_%s%s_%s_items, ", srna->identifier, strnest, prop->identifier); else diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 1db43b72a1e..8a7b5bb5966 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2120,6 +2120,14 @@ int RNA_property_enum_get_default(PointerRNA *ptr, PropertyRNA *prop) return eprop->defaultvalue; } +void *RNA_property_enum_py_data_get(PropertyRNA *prop) +{ + EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; + + BLI_assert(RNA_property_type(prop) == PROP_ENUM); + + return eprop->py_data; +} PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop) { diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index d66f0042d88..fa3e3fa8ec3 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -2276,6 +2276,12 @@ void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc) eprop->itemf= itemfunc; } +void RNA_def_enum_py_data(PropertyRNA *prop, void *py_data) +{ + EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; + eprop->py_data= py_data; +} + PropertyRNA *RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax) { diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 946aef9b317..771d2afcd96 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -251,6 +251,7 @@ typedef struct EnumPropertyRNA { PropEnumGetFunc get; PropEnumSetFunc set; PropEnumItemFunc itemf; + void *py_data; /* store py callback here */ EnumPropertyItem *item; int totitem; diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index b0159154490..dfa0e90b3a3 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -47,6 +47,8 @@ #include "../generic/py_capi_utils.h" +extern BPy_StructRNA *bpy_context_module; + static EnumPropertyItem property_flag_items[]= { {PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""}, {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animateable", ""}, @@ -741,6 +743,95 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i return items; } +static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int *free) +{ + PyGILState_STATE gilstate; + + PyObject *py_func= RNA_property_enum_py_data_get(prop); + PyObject *self= NULL; + PyObject *args; + PyObject *items; /* returned from the function call */ + + EnumPropertyItem *eitems= NULL; + int err= 0; + + bpy_context_set(C, &gilstate); + + args= PyTuple_New(2); + + /* first get self */ + /* operators can store their own instance for later use */ + if(ptr->data) { + void **instance = RNA_struct_instance(ptr); + + if(instance) { + if(*instance) { + self= *instance; + Py_INCREF(self); + } + } + } + if(self == NULL) { + self= pyrna_struct_CreatePyObject(ptr); + } + + PyTuple_SET_ITEM(args, 0, self); + + /* now get the context */ + PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module); + Py_INCREF(bpy_context_module); + + items= PyObject_CallObject(py_func, args); + + Py_DECREF(args); + + if(items==NULL) { + err= -1; + } + else { + PyObject *items_fast; + int defvalue_dummy=0; + + if(!(items_fast= PySequence_Fast(items, "EnumProperty(...): return value from the callback was not a sequence"))) { + err= -1; + } + else { + eitems= enum_items_from_py(items_fast, NULL, &defvalue_dummy, (RNA_property_flag(prop) & PROP_ENUM_FLAG)!=0); + + Py_DECREF(items_fast); + + if(!eitems) { + err= -1; + } + } + + Py_DECREF(items); + } + + if(err != -1) { /* worked */ + *free= 1; + } + else { + /* since we return to C code we can't leave the error */ + PyCodeObject *f_code= (PyCodeObject *)PyFunction_GET_CODE(py_func); + PyErr_Print(); + PyErr_Clear(); + + /* use py style error */ + fprintf(stderr, "File \"%s\", line %d, in %s\n", + _PyUnicode_AsString(f_code->co_filename), + f_code->co_firstlineno, + _PyUnicode_AsString(((PyFunctionObject *)py_func)->func_name) + ); + + eitems= DummyRNA_NULL_items; + } + + + bpy_context_clear(C, &gilstate); + return eitems; +} + PyDoc_STRVAR(BPy_EnumProperty_doc, ".. function:: EnumProperty(items, name=\"\", description=\"\", default=\"\", options={'ANIMATABLE'})\n" "\n" @@ -752,8 +843,8 @@ BPY_PROPDEF_DESC_DOC " :type default: string or set\n" " :arg options: Enumerator in ['HIDDEN', 'ANIMATABLE', 'ENUM_FLAG'].\n" " :type options: set\n" -" :arg items: sequence of enum items formatted: [(identifier, name, description), ...] where the identifier is used for python access and other values are used for the interface.\n" -" :type items: sequence of string triplets\n" +" :arg items: sequence of enum items formatted: [(identifier, name, description), ...] where the identifier is used for python access and other values are used for the interface. For dynamic values a callback can be passed which returns a list in the format described, taking 2 arguments - self and context argument\n" +" :type items: sequence of string triplets or a function\n" ); static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) { @@ -772,6 +863,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) PropertyRNA *prop; PyObject *pyopts= NULL; int opts=0; + short is_itemf= FALSE; if (!PyArg_ParseTupleAndKeywords(args, kw, "s#O|ssOO!:EnumProperty", @@ -784,26 +876,58 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) BPY_PROPDEF_CHECK(EnumProperty, property_flag_enum_items) - if(!(items_fast= PySequence_Fast(items, "EnumProperty(...): expected a sequence of tuples for the enum items"))) { - return NULL; + /* items can be a list or a callable */ + if(PyFunction_Check(items)) { /* dont use PyCallable_Check because we need the function code for errors */ + PyCodeObject *f_code= (PyCodeObject *)PyFunction_GET_CODE(items); + if(f_code->co_argcount != 2) { + PyErr_Format(PyExc_ValueError, + "EnumProperty(...): expected 'items' function to take 2 arguments, not %d", + f_code->co_argcount); + return NULL; + } + + if(def) { + /* note, using type error here is odd but python does this for invalid arguments */ + PyErr_SetString(PyExc_TypeError, + "EnumProperty(...): 'default' can't be set when 'items' is a function"); + return NULL; + } + + is_itemf= TRUE; + eitems= DummyRNA_NULL_items; } + else { + if(!(items_fast= PySequence_Fast(items, "EnumProperty(...): expected a sequence of tuples for the enum items or a function"))) { + return NULL; + } - eitems= enum_items_from_py(items_fast, def, &defvalue, (opts & PROP_ENUM_FLAG)!=0); + eitems= enum_items_from_py(items_fast, def, &defvalue, (opts & PROP_ENUM_FLAG)!=0); - Py_DECREF(items_fast); + Py_DECREF(items_fast); - if(!eitems) - return NULL; + if(!eitems) { + return NULL; + } + } if(opts & PROP_ENUM_FLAG) prop= RNA_def_enum_flag(srna, id, eitems, defvalue, name, description); else prop= RNA_def_enum(srna, id, eitems, defvalue, name, description); + if(is_itemf) { + RNA_def_enum_funcs(prop, bpy_props_enum_itemf); + RNA_def_enum_py_data(prop, (void *)items); + /* Py_INCREF(items); */ /* watch out!, if user is tricky they can probably crash blender if they manage to free the callback, take care! */ + } + if(pyopts) { if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN); if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); } RNA_def_property_duplicate_pointers(srna, prop); - MEM_freeN(eitems); + + if(is_itemf == FALSE) { + MEM_freeN(eitems); + } } Py_RETURN_NONE; } -- cgit v1.2.3 From c6705e464f0eaa53564f8c41ccd6c7956d7f4837 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 18:11:59 +0000 Subject: use a dynamic enum for addons, annoyingly the enum was being generated from python for each of the addon buttons (~14 times per draw) which was noticeably slow, so disabling 'expand' for now. Eventually it would be good to have the expanded buttons all using the same result from itemf(). --- release/scripts/startup/bl_ui/__init__.py | 36 ++++++++++++------------- release/scripts/startup/bl_ui/space_userpref.py | 3 ++- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index 2f933fb5771..bf63c6071b9 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -85,26 +85,26 @@ def register(): from bpy.props import StringProperty, EnumProperty WindowManager = bpy.types.WindowManager + def addon_filter_items(self, context): + import addon_utils + + items = [('All', "All", ""), + ('Enabled', "Enabled", ""), + ('Disabled', "Disabled", ""), + ] + + items_unique = set() + + for mod in addon_utils.modules(space_userpref.USERPREF_PT_addons._addons_fake_modules): + info = addon_utils.module_bl_info(mod) + items_unique.add(info["category"]) + + items.extend([(cat, cat, "") for cat in sorted(items_unique)]) + return items + WindowManager.addon_search = StringProperty(name="Search", description="Search within the selected filter") WindowManager.addon_filter = EnumProperty( - items=[('All', "All", ""), - ('Enabled', "Enabled", ""), - ('Disabled', "Disabled", ""), - ('3D View', "3D View", ""), - ('Add Curve', "Add Curve", ""), - ('Add Mesh', "Add Mesh", ""), - ('Animation', "Animation", ""), - ('Development', "Development", ""), - ('Game Engine', "Game Engine", ""), - ('Import-Export', "Import-Export", ""), - ('Mesh', "Mesh", ""), - ('Object', "Object", ""), - ('Render', "Render", ""), - ('Rigging', "Rigging", ""), - ('Text Editor', "Text Editor", ""), - ('System', "System", ""), - ('Other', "Other", ""), - ], + items=addon_filter_items, name="Category", description="Filter add-ons by category", ) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index d4ebae04c34..e34755ae72e 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -889,7 +889,8 @@ class USERPREF_PT_addons(bpy.types.Panel): split = layout.split(percentage=0.2) col = split.column() col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM') - col.prop(context.window_manager, "addon_filter", expand=True) + col.label(text="Categories") + col.prop(context.window_manager, "addon_filter", text="") # , expand=True, too slow with dynamic enum. col.label(text="Supported Level") col.prop(context.window_manager, "addon_support", expand=True) -- cgit v1.2.3 From 78d41d061bb0bd1a16f533d1f5f0664d27556db6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 19:13:01 +0000 Subject: sphinx docstrng formatting (some lines were getting really long) --- source/blender/python/generic/mathutils_Color.c | 3 +- source/blender/python/generic/mathutils_Euler.c | 9 ++- source/blender/python/generic/mathutils_Matrix.c | 26 +++++--- .../blender/python/generic/mathutils_Quaternion.c | 10 +++- source/blender/python/generic/mathutils_Vector.c | 15 +++-- source/blender/python/intern/bpy_props.c | 11 +++- source/blender/python/intern/bpy_rna.c | 70 +++++++++++++++------- 7 files changed, 99 insertions(+), 45 deletions(-) diff --git a/source/blender/python/generic/mathutils_Color.c b/source/blender/python/generic/mathutils_Color.c index 5bba2f77432..09e3493cd09 100644 --- a/source/blender/python/generic/mathutils_Color.c +++ b/source/blender/python/generic/mathutils_Color.c @@ -93,7 +93,8 @@ PyDoc_STRVAR(Color_copy_doc, " :return: A copy of the color.\n" " :rtype: :class:`Color`\n" "\n" -" .. note:: use this to get a copy of a wrapped color with no reference to the original data.\n" +" .. note:: use this to get a copy of a wrapped color with\n" +" no reference to the original data.\n" ); static PyObject *Color_copy(ColorObject *self) { diff --git a/source/blender/python/generic/mathutils_Euler.c b/source/blender/python/generic/mathutils_Euler.c index 9d50b5327e1..9adf0ee905b 100644 --- a/source/blender/python/generic/mathutils_Euler.c +++ b/source/blender/python/generic/mathutils_Euler.c @@ -185,7 +185,8 @@ static PyObject *Euler_zero(EulerObject * self) PyDoc_STRVAR(Euler_rotate_axis_doc, ".. method:: rotate_axis(axis, angle)\n" "\n" -" Rotates the euler a certain amount and returning a unique euler rotation (no 720 degree pitches).\n" +" Rotates the euler a certain amount and returning a unique euler rotation\n" +" (no 720 degree pitches).\n" "\n" " :arg axis: single character in ['X, 'Y', 'Z'].\n" " :type axis: string\n" @@ -247,7 +248,8 @@ static PyObject *Euler_rotate(EulerObject * self, PyObject *value) PyDoc_STRVAR(Euler_make_compatible_doc, ".. method:: make_compatible(other)\n" "\n" -" Make this euler compatible with another, so interpolating between them works as intended.\n" +" Make this euler compatible with another,\n" +" so interpolating between them works as intended.\n" "\n" " .. note:: the rotation order is not taken into account for this function.\n" ); @@ -279,7 +281,8 @@ PyDoc_STRVAR(Euler_copy_doc, " :return: A copy of the euler.\n" " :rtype: :class:`Euler`\n" "\n" -" .. note:: use this to get a copy of a wrapped euler with no reference to the original data.\n" +" .. note:: use this to get a copy of a wrapped euler with\n" +" no reference to the original data.\n" ); static PyObject *Euler_copy(EulerObject *self) { diff --git a/source/blender/python/generic/mathutils_Matrix.c b/source/blender/python/generic/mathutils_Matrix.c index 7ec5cb7e44a..982a8e63282 100644 --- a/source/blender/python/generic/mathutils_Matrix.c +++ b/source/blender/python/generic/mathutils_Matrix.c @@ -195,7 +195,8 @@ PyDoc_STRVAR(C_Matrix_Rotation_doc, " :type angle: float\n" " :arg size: The size of the rotation matrix to construct [2, 4].\n" " :type size: int\n" -" :arg axis: a string in ['X', 'Y', 'Z'] or a 3D Vector Object (optional when size is 2).\n" +" :arg axis: a string in ['X', 'Y', 'Z'] or a 3D Vector Object\n" +" (optional when size is 2).\n" " :type axis: string or :class:`Vector`\n" " :return: A new rotation matrix.\n" " :rtype: :class:`Matrix`\n" @@ -407,7 +408,9 @@ PyDoc_STRVAR(C_Matrix_OrthoProjection_doc, "\n" " Create a matrix to represent an orthographic projection.\n" "\n" -" :arg axis: Can be any of the following: ['X', 'Y', 'XY', 'XZ', 'YZ'], where a single axis is for a 2D matrix. Or a vector for an arbitrary axis\n" +" :arg axis: Can be any of the following: ['X', 'Y', 'XY', 'XZ', 'YZ'],\n" +" where a single axis is for a 2D matrix.\n" +" Or a vector for an arbitrary axis\n" " :type axis: string or :class:`Vector`\n" " :arg size: The size of the projection matrix to construct [2, 4].\n" " :type size: int\n" @@ -513,11 +516,13 @@ PyDoc_STRVAR(C_Matrix_Shear_doc, "\n" " Create a matrix to represent an shear transformation.\n" "\n" -" :arg plane: Can be any of the following: ['X', 'Y', 'XY', 'XZ', 'YZ'], where a single axis is for a 2D matrix only.\n" +" :arg plane: Can be any of the following: ['X', 'Y', 'XY', 'XZ', 'YZ'],\n" +" where a single axis is for a 2D matrix only.\n" " :type plane: string\n" " :arg size: The size of the shear matrix to construct [2, 4].\n" " :type size: int\n" -" :arg factor: The factor of shear to apply. For a 3 or 4 *size* matrix pass a pair of floats corrasponding with the *plane* axis.\n" +" :arg factor: The factor of shear to apply. For a 3 or 4 *size* matrix\n" +" pass a pair of floats corrasponding with the *plane* axis.\n" " :type factor: float or float pair\n" " :return: A new shear matrix.\n" " :rtype: :class:`Matrix`\n" @@ -660,11 +665,15 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self) PyDoc_STRVAR(Matrix_to_euler_doc, ".. method:: to_euler(order, euler_compat)\n" "\n" -" Return an Euler representation of the rotation matrix (3x3 or 4x4 matrix only).\n" +" Return an Euler representation of the rotation matrix\n" +" (3x3 or 4x4 matrix only).\n" "\n" -" :arg order: Optional rotation order argument in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX'].\n" +" :arg order: Optional rotation order argument in\n" +" ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX'].\n" " :type order: string\n" -" :arg euler_compat: Optional euler argument the new euler will be made compatible with (no axis flipping between them). Useful for converting a series of matrices to animation curves.\n" +" :arg euler_compat: Optional euler argument the new euler will be made\n" +" compatible with (no axis flipping between them).\n" +" Useful for converting a series of matrices to animation curves.\n" " :type euler_compat: :class:`Euler`\n" " :return: Euler representation of the matrix.\n" " :rtype: :class:`Euler`\n" @@ -1174,7 +1183,8 @@ PyDoc_STRVAR(Matrix_identity_doc, "\n" " Set the matrix to the identity matrix.\n" "\n" -" .. note:: An object with zero location and rotation, a scale of one, will have an identity matrix.\n" +" .. note:: An object with zero location and rotation, a scale of one,\n" +" will have an identity matrix.\n" "\n" " .. seealso:: \n" ); diff --git a/source/blender/python/generic/mathutils_Quaternion.c b/source/blender/python/generic/mathutils_Quaternion.c index 00a6c36b3ad..90447e7093a 100644 --- a/source/blender/python/generic/mathutils_Quaternion.c +++ b/source/blender/python/generic/mathutils_Quaternion.c @@ -72,9 +72,12 @@ PyDoc_STRVAR(Quaternion_to_euler_doc, "\n" " Return Euler representation of the quaternion.\n" "\n" -" :arg order: Optional rotation order argument in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX'].\n" +" :arg order: Optional rotation order argument in\n" +" ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX'].\n" " :type order: string\n" -" :arg euler_compat: Optional euler argument the new euler will be made compatible with (no axis flipping between them). Useful for converting a series of matrices to animation curves.\n" +" :arg euler_compat: Optional euler argument the new euler will be made\n" +" compatible with (no axis flipping between them).\n" +" Useful for converting a series of matrices to animation curves.\n" " :type euler_compat: :class:`Euler`\n" " :return: Euler representation of the quaternion.\n" " :rtype: :class:`Euler`\n" @@ -417,7 +420,8 @@ PyDoc_STRVAR(Quaternion_copy_doc, " :return: A copy of the quaternion.\n" " :rtype: :class:`Quaternion`\n" "\n" -" .. note:: use this to get a copy of a wrapped quaternion with no reference to the original data.\n" +" .. note:: use this to get a copy of a wrapped quaternion with\n" +" no reference to the original data.\n" ); static PyObject *Quaternion_copy(QuaternionObject *self) { diff --git a/source/blender/python/generic/mathutils_Vector.c b/source/blender/python/generic/mathutils_Vector.c index 91c58d3a0f0..fd8d1b5f481 100644 --- a/source/blender/python/generic/mathutils_Vector.c +++ b/source/blender/python/generic/mathutils_Vector.c @@ -107,9 +107,11 @@ PyDoc_STRVAR(Vector_normalize_doc, "\n" " Normalize the vector, making the length of the vector always 1.0.\n" "\n" -" .. warning:: Normalizing a vector where all values are zero results in all axis having a nan value (not a number).\n" +" .. warning:: Normalizing a vector where all values are zero results\n" +" in all axis having a nan value (not a number).\n" "\n" -" .. note:: Normalize works for vectors of all sizes, however 4D Vectors w axis is left untouched.\n" +" .. note:: Normalize works for vectors of all sizes,\n" +" however 4D Vectors w axis is left untouched.\n" ); static PyObject *Vector_normalize(VectorObject *self) { @@ -565,7 +567,8 @@ PyDoc_STRVAR(Vector_angle_doc, "\n" " :arg other: another vector to compare the angle with\n" " :type other: :class:`Vector`\n" -" :arg fallback: return this value when the angle cant be calculated (zero length vector)\n" +" :arg fallback: return this value when the angle cant be calculated\n" +" (zero length vector)\n" " :type fallback: any\n" " :return: angle in radians or fallback when given\n" " :rtype: float\n" @@ -618,7 +621,8 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) PyDoc_STRVAR(Vector_rotation_difference_doc, ".. function:: difference(other)\n" "\n" -" Returns a quaternion representing the rotational difference between this vector and another.\n" +" Returns a quaternion representing the rotational difference between this\n" +" vector and another.\n" "\n" " :arg other: second vector.\n" " :type other: :class:`Vector`\n" @@ -764,7 +768,8 @@ PyDoc_STRVAR(Vector_copy_doc, " :return: A copy of the vector.\n" " :rtype: :class:`Vector`\n" "\n" -" .. note:: use this to get a copy of a wrapped vector with no reference to the original data.\n" +" .. note:: use this to get a copy of a wrapped vector with\n" +" no reference to the original data.\n" ); static PyObject *Vector_copy(VectorObject *self) { diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index dfa0e90b3a3..0ee9d7e5bd5 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -839,11 +839,18 @@ PyDoc_STRVAR(BPy_EnumProperty_doc, "\n" BPY_PROPDEF_NAME_DOC BPY_PROPDEF_DESC_DOC -" :arg default: The default value for this enum, A string when *ENUM_FLAG* is disabled otherwise a set which may only contain string identifiers used in *items*.\n" +" :arg default: The default value for this enum, A string when *ENUM_FLAG*\n" +" is disabled otherwise a set which may only contain string identifiers\n" +" used in *items*.\n" " :type default: string or set\n" " :arg options: Enumerator in ['HIDDEN', 'ANIMATABLE', 'ENUM_FLAG'].\n" " :type options: set\n" -" :arg items: sequence of enum items formatted: [(identifier, name, description), ...] where the identifier is used for python access and other values are used for the interface. For dynamic values a callback can be passed which returns a list in the format described, taking 2 arguments - self and context argument\n" +" :arg items: sequence of enum items formatted:\n" +" [(identifier, name, description), ...] where the identifier is used\n" +" for python access and other values are used for the interface.\n" +" For dynamic values a callback can be passed which returns a list in\n" +" the same format as the static list.\n" +" This function must take 2 arguments (self, context)\n" " :type items: sequence of string triplets or a function\n" ); static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 90a83a794f1..c4b6e0dfb76 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -2530,12 +2530,14 @@ static PyMappingMethods pyrna_struct_as_mapping= { PyDoc_STRVAR(pyrna_struct_keys_doc, ".. method:: keys()\n" "\n" -" Returns the keys of this objects custom properties (matches pythons dictionary function of the same name).\n" +" Returns the keys of this objects custom properties (matches pythons\n" +" dictionary function of the same name).\n" "\n" " :return: custom property keys.\n" " :rtype: list of strings\n" "\n" -" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes support custom properties.\n" +" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes\n" +" support custom properties.\n" ); static PyObject *pyrna_struct_keys(BPy_PropertyRNA *self) { @@ -2557,12 +2559,14 @@ static PyObject *pyrna_struct_keys(BPy_PropertyRNA *self) PyDoc_STRVAR(pyrna_struct_items_doc, ".. method:: items()\n" "\n" -" Returns the items of this objects custom properties (matches pythons dictionary function of the same name).\n" +" Returns the items of this objects custom properties (matches pythons\n" +" dictionary function of the same name).\n" "\n" " :return: custom property key, value pairs.\n" " :rtype: list of key, value tuples\n" "\n" -" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes support custom properties.\n" +" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone`\n" +" classes support custom properties.\n" ); static PyObject *pyrna_struct_items(BPy_PropertyRNA *self) { @@ -2584,12 +2588,14 @@ static PyObject *pyrna_struct_items(BPy_PropertyRNA *self) PyDoc_STRVAR(pyrna_struct_values_doc, ".. method:: values()\n" "\n" -" Returns the values of this objects custom properties (matches pythons dictionary function of the same name).\n" +" Returns the values of this objects custom properties (matches pythons\n" +" dictionary function of the same name).\n" "\n" " :return: custom property values.\n" " :rtype: list\n" "\n" -" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes support custom properties.\n" +" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone`\n" +" classes support custom properties.\n" ); static PyObject *pyrna_struct_values(BPy_PropertyRNA *self) { @@ -2688,7 +2694,8 @@ PyDoc_STRVAR(pyrna_struct_path_resolve_doc, "\n" " :arg path: path which this property resolves.\n" " :type path: string\n" -" :arg coerce: optional argument, when True, the property will be converted into its python representation.\n" +" :arg coerce: optional argument, when True, the property will be converted\n" +" into its python representation.\n" " :type coerce: boolean\n" ); static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args) @@ -2743,9 +2750,11 @@ PyDoc_STRVAR(pyrna_struct_path_from_id_doc, "\n" " Returns the data path from the ID to this object (string).\n" "\n" -" :arg property: Optional property name which can be used if the path is to a property of this object.\n" +" :arg property: Optional property name which can be used if the path is\n" +" to a property of this object.\n" " :type property: string\n" -" :return: The path from :class:`bpy_struct.id_data` to this struct and property (when given).\n" +" :return: The path from :class:`bpy_struct.id_data`\n" +" to this struct and property (when given).\n" " :rtype: str\n" ); static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args) @@ -2827,7 +2836,8 @@ static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self) PyDoc_STRVAR(pyrna_struct_type_recast_doc, ".. method:: type_recast()\n" "\n" -" Return a new instance, this is needed because types such as textures can be changed at runtime.\n" +" Return a new instance, this is needed because types\n" +" such as textures can be changed at runtime.\n" "\n" " :return: a new instance of this object with the type initialized again.\n" " :rtype: subclass of :class:`bpy_struct`\n" @@ -3437,7 +3447,8 @@ static PyGetSetDef pyrna_struct_getseters[]= { PyDoc_STRVAR(pyrna_prop_collection_keys_doc, ".. method:: keys()\n" "\n" -" Return the identifiers of collection members (matching pythons dict.keys() functionality).\n" +" Return the identifiers of collection members\n" +" (matching pythons dict.keys() functionality).\n" "\n" " :return: the identifiers for each member of this collection.\n" " :rtype: list of stings\n" @@ -3470,7 +3481,8 @@ static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self) PyDoc_STRVAR(pyrna_prop_collection_items_doc, ".. method:: items()\n" "\n" -" Return the identifiers of collection members (matching pythons dict.items() functionality).\n" +" Return the identifiers of collection members\n" +" (matching pythons dict.items() functionality).\n" "\n" " :return: (key, value) pairs for each member of this collection.\n" " :rtype: list of tuples\n" @@ -3511,7 +3523,8 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self) PyDoc_STRVAR(pyrna_prop_collection_values_doc, ".. method:: values()\n" "\n" -" Return the values of collection (matching pythons dict.values() functionality).\n" +" Return the values of collection\n" +" (matching pythons dict.values() functionality).\n" "\n" " :return: the members of this collection.\n" " :rtype: list\n" @@ -3525,14 +3538,17 @@ static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self) PyDoc_STRVAR(pyrna_struct_get_doc, ".. method:: get(key, default=None)\n" "\n" -" Returns the value of the custom property assigned to key or default when not found (matches pythons dictionary function of the same name).\n" +" Returns the value of the custom property assigned to key or default\n" +" when not found (matches pythons dictionary function of the same name).\n" "\n" " :arg key: The key assosiated with the custom property.\n" " :type key: string\n" -" :arg default: Optional argument for the value to return if *key* is not found.\n" +" :arg default: Optional argument for the value to return if\n" +" *key* is not found.\n" " :type default: Undefined\n" "\n" -" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone` classes support custom properties.\n" +" .. note:: Only :class:`ID`, :class:`Bone` and :class:`PoseBone`\n" +" classes support custom properties.\n" ); static PyObject *pyrna_struct_get(BPy_StructRNA *self, PyObject *args) { @@ -3571,7 +3587,8 @@ PyDoc_STRVAR(pyrna_struct_as_pointer_doc, " :return: int (memory address).\n" " :rtype: int\n" "\n" -" .. note:: This is intended only for advanced script writers who need to pass blender data to their own C/Python modules.\n" +" .. note:: This is intended only for advanced script writers who need to\n" +" pass blender data to their own C/Python modules.\n" ); static PyObject *pyrna_struct_as_pointer(BPy_StructRNA *self) { @@ -3581,11 +3598,13 @@ static PyObject *pyrna_struct_as_pointer(BPy_StructRNA *self) PyDoc_STRVAR(pyrna_prop_collection_get_doc, ".. method:: get(key, default=None)\n" "\n" -" Returns the value of the item assigned to key or default when not found (matches pythons dictionary function of the same name).\n" +" Returns the value of the item assigned to key or default when not found\n" +" (matches pythons dictionary function of the same name).\n" "\n" " :arg key: The identifier for the collection member.\n" " :type key: string\n" -" :arg default: Optional argument for the value to return if *key* is not found.\n" +" :arg default: Optional argument for the value to return if\n" +" *key* is not found.\n" " :type default: Undefined\n" ); static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args) @@ -6362,11 +6381,15 @@ void pyrna_free_types(void) PyDoc_STRVAR(pyrna_register_class_doc, ".. method:: register_class(cls)\n" "\n" -" Register a subclass of a blender type in (:class:`Panel`, :class:`Menu`, :class:`Header`, :class:`Operator`, :class:`KeyingSetInfo`, :class:`RenderEngine`).\n" +" Register a subclass of a blender type in (:class:`Panel`,\n" +" :class:`Menu`, :class:`Header`, :class:`Operator`,\n" +" :class:`KeyingSetInfo`, :class:`RenderEngine`).\n" "\n" -" If the class has a *register* class method it will be called before registration.\n" +" If the class has a *register* class method it will be called\n" +" before registration.\n" "\n" -" .. note:: :exc:`ValueError` exception is raised if the class is not a subclass of a registerable blender class.\n" +" .. note:: :exc:`ValueError` exception is raised if the class is not a\n" +" subclass of a registerable blender class.\n" "\n" ); PyMethodDef meth_bpy_register_class= {"register_class", pyrna_register_class, METH_O, pyrna_register_class_doc}; @@ -6492,7 +6515,8 @@ PyDoc_STRVAR(pyrna_unregister_class_doc, "\n" " Unload the python class from blender.\n" "\n" -" If the class has an *unregister* class method it will be called before unregistering.\n" +" If the class has an *unregister* class method it will be called\n" +" before unregistering.\n" ); PyMethodDef meth_bpy_unregister_class= {"unregister_class", pyrna_unregister_class, METH_O, pyrna_unregister_class_doc}; static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_class) -- cgit v1.2.3 From 06fea1a0ff01590e88ef210edd2314615e077400 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 20:45:19 +0000 Subject: split BLO_library_append_named_part into 2 function, one that adds objects into the scene and another that just links/appends. --- source/blender/blenloader/BLO_readfile.h | 18 +++- source/blender/blenloader/intern/readfile.c | 100 +++++++++++---------- source/blender/python/intern/bpy_library.c | 2 +- source/blender/windowmanager/intern/wm_operators.c | 4 +- 4 files changed, 74 insertions(+), 50 deletions(-) diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index d9594f7da75..85d4b936c51 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -213,18 +213,32 @@ int BLO_is_a_library(const char *path, char *dir, char *group); struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, const char *filepath); + /** * Link/Append a named datablock from an external blend file. * + * @param mainl The main database to link from (not the active one). + * @param bh The blender file handle. + * @param idname The name of the datablock (without the 2 char ID prefix) + * @param idcode The kind of datablock to link. + * @return the appended ID when found. + */ +struct ID *BLO_library_append_named_part(struct Main *mainl, BlendHandle** bh, const char *idname, const int idcode); + +/** + * Link/Append a named datablock from an external blend file. + * optionally instance the object in the scene when the flags are set. + * * @param C The context, when NULL instancing object in the scene isnt done. * @param mainl The main database to link from (not the active one). * @param bh The blender file handle. * @param idname The name of the datablock (without the 2 char ID prefix) * @param idcode The kind of datablock to link. * @param flag Options for linking, used for instancing. - * @return Boolean, 0 when the datablock could not be found. + * @return the appended ID when found. */ -struct ID *BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *idname, int idcode, short flag); +struct ID *BLO_library_append_named_part_ex(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *idname, const int idcode, const short flag); + void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag); void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index bf00abf1008..03cd6e188c4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -12806,24 +12806,17 @@ static void give_base_to_groups(Main *mainvar, Scene *scene) } /* returns true if the item was found - * but it may already have already been appended/linked */ -static ID *append_named_part(const bContext *C, Main *mainl, FileData *fd, const char *idname, int idcode, short flag) +* but it may already have already been appended/linked */ +static ID *append_named_part(Main *mainl, FileData *fd, const char *idname, const short idcode) { - Scene *scene= CTX_data_scene(C); /* can be NULL */ - Object *ob; - Base *base; BHead *bhead; ID *id= NULL; - int endloop=0; int found=0; - bhead = blo_firstbhead(fd); - while(bhead && endloop==0) { - - if(bhead->code==ENDB) endloop= 1; - else if(bhead->code==idcode) { + for(bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) { + if(bhead->code==idcode) { const char *idname_test= bhead_id_name(fd, bhead); - + if(strcmp(idname_test + 2, idname)==0) { found= 1; id= is_yet_read(fd, mainl, bhead); @@ -12839,38 +12832,12 @@ static ID *append_named_part(const bContext *C, Main *mainl, FileData *fd, const } } - /* TODO, move out of append and into own func the caller can use */ - if(scene && id && (GS(id->name) == ID_OB)) { /* loose object: give a base */ - base= MEM_callocN( sizeof(Base), "app_nam_part"); - BLI_addtail(&scene->base, base); - - ob= (Object *)id; - - /* link at active layer (view3d->lay if in context, else scene->lay */ - if((flag & FILE_ACTIVELAY)) { - View3D *v3d = CTX_wm_view3d(C); - if (v3d) { - ob->lay = v3d->layact; - } else { - ob->lay = scene->lay; - } - } - ob->mode= 0; - base->lay= ob->lay; - base->object= ob; - ob->id.us++; - - if(flag & FILE_AUTOSELECT) { - base->flag |= SELECT; - base->object->flag = base->flag; - /* do NOT make base active here! screws up GUI stuff, if you want it do it on src/ level */ - } - } - endloop= 1; + break; } } - - bhead = blo_nextbhead(fd, bhead); + else if(bhead->code==ENDB) { + break; + } } /* if we found the id but the id is NULL, this is really bad */ @@ -12879,10 +12846,53 @@ static ID *append_named_part(const bContext *C, Main *mainl, FileData *fd, const return found ? id : NULL; } -ID *BLO_library_append_named_part(const bContext *C, Main *mainl, BlendHandle** bh, const char *idname, int idcode, short flag) +static ID *append_named_part_ex(const bContext *C, Main *mainl, FileData *fd, const char *idname, const int idcode, const int flag) +{ + ID *id= append_named_part(mainl, fd, idname, idcode); + + if(id && (GS(id->name) == ID_OB)) { /* loose object: give a base */ + Scene *scene= CTX_data_scene(C); /* can be NULL */ + if(scene) { + Base *base; + Object *ob; + + base= MEM_callocN( sizeof(Base), "app_nam_part"); + BLI_addtail(&scene->base, base); + + ob= (Object *)id; + + /* link at active layer (view3d->lay if in context, else scene->lay */ + if((flag & FILE_ACTIVELAY)) { + View3D *v3d = CTX_wm_view3d(C); + ob->lay = v3d ? v3d->layact : scene->lay; + } + + ob->mode= 0; + base->lay= ob->lay; + base->object= ob; + ob->id.us++; + + if(flag & FILE_AUTOSELECT) { + base->flag |= SELECT; + base->object->flag = base->flag; + /* do NOT make base active here! screws up GUI stuff, if you want it do it on src/ level */ + } + } + } + + return id; +} + +ID *BLO_library_append_named_part(Main *mainl, BlendHandle** bh, const char *idname, const int idcode) +{ + FileData *fd= (FileData*)(*bh); + return append_named_part(mainl, fd, idname, idcode); +} + +ID *BLO_library_append_named_part_ex(const bContext *C, Main *mainl, BlendHandle** bh, const char *idname, const int idcode, const short flag) { FileData *fd= (FileData*)(*bh); - return append_named_part(C, mainl, fd, idname, idcode, flag); + return append_named_part_ex(C, mainl, fd, idname, idcode, flag); } static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r) @@ -12891,7 +12901,7 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r) for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) { if (bhead->code == GS(id->name)) { - + if (BLI_streq(id->name, bhead_id_name(fd, bhead))) { id->flag &= ~LIB_READ; id->flag |= LIB_TEST; diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index 49d5eaea9be..10e97573447 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -340,7 +340,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) // printf(" %s\n", item_str); if(item_str) { - ID *id= BLO_library_append_named_part(NULL, mainl, &(self->blo_handle), item_str, code, self->flag); + ID *id= BLO_library_append_named_part(mainl, &(self->blo_handle), item_str, code); if(id) { #ifdef USE_RNA_DATABLOCKS PointerRNA id_ptr; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 7f404f719ac..f5a1b6b0298 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1642,12 +1642,12 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* here appending/linking starts */ mainl = BLO_library_append_begin(C, &bh, libname); if(totfiles == 0) { - BLO_library_append_named_part(C, mainl, &bh, name, idcode, flag); + BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag); } else { RNA_BEGIN(op->ptr, itemptr, "files") { RNA_string_get(&itemptr, "name", name); - BLO_library_append_named_part(C, mainl, &bh, name, idcode, flag); + BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag); } RNA_END; } -- cgit v1.2.3 From 78b8e4a437b34a3956283dae08a6718a01b00e63 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 21:04:01 +0000 Subject: remove BLI_streq() since it was hardly used, also replace string search with BLI_findstring(). --- source/blender/blenlib/BLI_string.h | 7 ------- source/blender/blenlib/intern/string.c | 5 ----- source/blender/blenloader/intern/readfile.c | 4 ++-- source/blender/editors/armature/editarmature_sketch.c | 6 +++--- source/blender/editors/interface/interface.c | 15 +++++---------- 5 files changed, 10 insertions(+), 27 deletions(-) diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 69702f72026..408809661cf 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -122,13 +122,6 @@ __attribute__ ((format (printf, 1, 2))) #endif ; - /** - * Compare two strings - * - * @retval True if the strings are equal, false otherwise. - */ -int BLI_streq(const char *a, const char *b); - /** * Compare two strings without regard to case. * diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 11de8a3d45c..8e0314ec17f 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -212,11 +212,6 @@ char *BLI_replacestr(char *str, const char *oldText, const char *newText) } } -int BLI_streq(const char *a, const char *b) -{ - return (strcmp(a, b)==0); -} - int BLI_strcaseeq(const char *a, const char *b) { return (BLI_strcasecmp(a, b)==0); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 03cd6e188c4..5f984a9268d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1082,7 +1082,7 @@ int BLO_is_a_library(const char *path, char *dir, char *group) /* now we know that we are in a blend file and it is safe to assume that gp actually points to a group */ - if (BLI_streq("Screen", gp)==0) + if (strcmp("Screen", gp)!=0) BLI_strncpy(group, gp, GROUP_MAX); } return 1; @@ -12902,7 +12902,7 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r) for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) { if (bhead->code == GS(id->name)) { - if (BLI_streq(id->name, bhead_id_name(fd, bhead))) { + if (strcmp(id->name, bhead_id_name(fd, bhead))==0) { id->flag &= ~LIB_READ; id->flag |= LIB_TEST; // printf("read lib block %s\n", id->name); diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index ccb9a45af37..97f85b92b32 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -374,16 +374,16 @@ static void sk_autoname(bContext *C, ReebArc *arc) int valid = 0; int caps = 0; - if (BLI_streq(side, "")) + if (side[0] == '\0') { valid = 1; } - else if (BLI_streq(side, "R") || BLI_streq(side, "L")) + else if (strcmp(side, "R")==0 || strcmp(side, "L")==0) { valid = 1; caps = 1; } - else if (BLI_streq(side, "r") || BLI_streq(side, "l")) + else if (strcmp(side, "r")==0 || strcmp(side, "l")==0) { valid = 1; caps = 0; diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e70b793cfb0..da479fe7ca3 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1848,29 +1848,24 @@ void uiFreeInactiveBlocks(const bContext *C, ListBase *lb) void uiBlockSetRegion(uiBlock *block, ARegion *region) { - ListBase *lb; + ListBase *lb= ®ion->uiblocks; uiBlock *oldblock= NULL; - lb= ®ion->uiblocks; - /* each listbase only has one block with this name, free block * if is already there so it can be rebuilt from scratch */ if(lb) { - for (oldblock= lb->first; oldblock; oldblock= oldblock->next) - if (BLI_streq(oldblock->name, block->name)) - break; + oldblock= BLI_findstring(lb, block->name, offsetof(uiBlock, name)); if (oldblock) { oldblock->active= 0; oldblock->panel= NULL; } + + /* at the beginning of the list! for dynamical menus/blocks */ + BLI_addhead(lb, block); } block->oldblock= oldblock; - - /* at the beginning of the list! for dynamical menus/blocks */ - if(lb) - BLI_addhead(lb, block); } uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, short dt) -- cgit v1.2.3 From 4b9a63c6d3b6fc90259bea708355d678d3681bc3 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Thu, 26 May 2011 21:57:02 +0000 Subject: == FFMPEG == * removed a lot of old cruft code for ancient ffmpeg versions * made it compile again against latest ffmpeg / libav GIT (also shouldn't break distro ffmpegs, since those API changes have been introduced over a year ago. If it nevertheless breaks, please send me an email) --- intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp | 23 ++--- source/blender/blenkernel/intern/writeffmpeg.c | 120 ++++++++----------------- source/blender/imbuf/intern/anim_movie.c | 14 +-- source/blender/imbuf/intern/util.c | 28 +----- source/blender/makesrna/intern/rna_scene.c | 1 - source/gameengine/VideoTexture/VideoFFmpeg.cpp | 16 ++-- source/gameengine/VideoTexture/VideoFFmpeg.h | 1 + 7 files changed, 68 insertions(+), 135 deletions(-) diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp index ea6e0c549fa..e748235e40e 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp @@ -52,6 +52,10 @@ int AUD_FFMPEGReader::decode(AVPacket* packet, AUD_Buffer& buffer) int read_length, data_size; + AVPacket tmp_pkt; + + av_init_packet(&tmp_pkt); + // as long as there is still data in the package while(audio_pkg_size > 0) { @@ -64,15 +68,14 @@ int AUD_FFMPEGReader::decode(AVPacket* packet, AUD_Buffer& buffer) // read samples from the packet data_size = buf_size - buf_pos; - /*read_length = avcodec_decode_audio3(m_codecCtx, - (int16_t*)(((data_t*)buffer.getBuffer())+buf_pos), - &data_size, - packet);*/ - read_length = avcodec_decode_audio2(m_codecCtx, - (int16_t*)(((data_t*)buffer.getBuffer()) + buf_pos), - &data_size, - audio_pkg_data, - audio_pkg_size); + + tmp_pkt.data = audio_pkg_data; + tmp_pkt.size = audio_pkg_size; + + read_length = avcodec_decode_audio3( + m_codecCtx, + (int16_t*)(((data_t*)buffer.getBuffer()) + buf_pos), + &data_size, &tmp_pkt); // read error, next packet! if(read_length < 0) @@ -112,7 +115,7 @@ void AUD_FFMPEGReader::init() for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++) { - if((m_formatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) + if((m_formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) && (m_stream < 0)) { m_stream=i; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 9b1c3b2ddb8..dbb4bd48629 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -39,19 +39,6 @@ #include #include -#if LIBAVFORMAT_VERSION_INT < (49 << 16) -#define FFMPEG_OLD_FRAME_RATE 1 -#else -#define FFMPEG_CODEC_IS_POINTER 1 -#define FFMPEG_CODEC_TIME_BASE 1 -#endif - -#if LIBAVFORMAT_VERSION_INT >= (52 << 16) -#define OUTFILE_PB (outfile->pb) -#else -#define OUTFILE_PB (&outfile->pb) -#endif - #if defined(WIN32) && (!(defined snprintf)) #define snprintf _snprintf #endif @@ -114,24 +101,12 @@ static void delete_picture(AVFrame* f) } } -#ifdef FFMPEG_CODEC_IS_POINTER -static AVCodecContext* get_codec_from_stream(AVStream* stream) -{ - return stream->codec; -} -#else -static AVCodecContext* get_codec_from_stream(AVStream* stream) -{ - return &stream->codec; -} -#endif - static int write_audio_frame(void) { AVCodecContext* c = NULL; AVPacket pkt; - c = get_codec_from_stream(audio_stream); + c = audio_stream->codec; av_init_packet(&pkt); pkt.size = 0; @@ -153,17 +128,15 @@ static int write_audio_frame(void) if(c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE) { -#ifdef FFMPEG_CODEC_TIME_BASE pkt.pts = av_rescale_q(c->coded_frame->pts, - c->time_base, audio_stream->time_base); -#else - pkt.pts = c->coded_frame->pts; -#endif + c->time_base, audio_stream->time_base); fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts); } pkt.stream_index = audio_stream->index; - pkt.flags |= PKT_FLAG_KEY; + + pkt.flags |= AV_PKT_FLAG_KEY; + if (av_interleaved_write_frame(outfile, &pkt) != 0) { fprintf(stderr, "Error writing audio packet!\n"); return -1; @@ -263,10 +236,10 @@ static int write_video_frame(RenderData *rd, AVFrame* frame, ReportList *reports { int outsize = 0; int ret, success= 1; - AVCodecContext* c = get_codec_from_stream(video_stream); -#ifdef FFMPEG_CODEC_TIME_BASE + AVCodecContext* c = video_stream->codec; + frame->pts = rd->cfra - rd->sfra; -#endif + if (rd->mode & R_FIELDS) { frame->top_field_first = ((rd->mode & R_ODDFIELD) != 0); } @@ -278,19 +251,15 @@ static int write_video_frame(RenderData *rd, AVFrame* frame, ReportList *reports av_init_packet(&packet); if (c->coded_frame->pts != AV_NOPTS_VALUE) { -#ifdef FFMPEG_CODEC_TIME_BASE packet.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_stream->time_base); -#else - packet.pts = c->coded_frame->pts; -#endif fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts); } else { fprintf(stderr, "Video Frame PTS: not set\n"); } if (c->coded_frame->key_frame) - packet.flags |= PKT_FLAG_KEY; + packet.flags |= AV_PKT_FLAG_KEY; packet.stream_index = video_stream->index; packet.data = video_buffer; packet.size = outsize; @@ -312,7 +281,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports) { uint8_t* rendered_frame; - AVCodecContext* c = get_codec_from_stream(video_stream); + AVCodecContext* c = video_stream->codec; int width = c->width; int height = c->height; AVFrame* rgb_frame; @@ -396,7 +365,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop) switch(prop->type) { case IDP_STRING: fprintf(stderr, "%s.\n", IDP_String(prop)); - rv = av_set_string(c, prop->name, IDP_String(prop)); + av_set_string3(c, prop->name, IDP_String(prop), 1, &rv); break; case IDP_FLOAT: fprintf(stderr, "%g.\n", IDP_Float(prop)); @@ -407,7 +376,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop) if (param) { if (IDP_Int(prop)) { - rv = av_set_string(c, name, param); + av_set_string3(c, name, param, 1, &rv); } else { return; } @@ -459,9 +428,9 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex /* Set up the codec context */ - c = get_codec_from_stream(st); + c = st->codec; c->codec_id = codec_id; - c->codec_type = CODEC_TYPE_VIDEO; + c->codec_type = AVMEDIA_TYPE_VIDEO; /* Get some values from the current render settings */ @@ -469,7 +438,6 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex c->width = rectx; c->height = recty; -#ifdef FFMPEG_CODEC_TIME_BASE /* FIXME: Really bad hack (tm) for NTSC support */ if (ffmpeg_type == FFMPEG_DV && rd->frs_sec != 25) { c->time_base.den = 2997; @@ -482,20 +450,6 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex c->time_base.den = rd->frs_sec * 100000; c->time_base.num = ((double) rd->frs_sec_base) * 100000; } -#else - /* FIXME: Really bad hack (tm) for NTSC support */ - if (ffmpeg_type == FFMPEG_DV && rd->frs_sec != 25) { - c->frame_rate = 2997; - c->frame_rate_base = 100; - } else if ((double) ((int) rd->frs_sec_base) == - rd->frs_sec_base) { - c->frame_rate = rd->frs_sec; - c->frame_rate_base = rd->frs_sec_base; - } else { - c->frame_rate = rd->frs_sec * 100000; - c->frame_rate_base = ((double) rd->frs_sec_base)*100000; - } -#endif c->gop_size = ffmpeg_gop_size; c->bit_rate = ffmpeg_video_bitrate*1000; @@ -519,7 +473,7 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex c->pix_fmt = PIX_FMT_YUV422P; } - if (codec_id == CODEC_ID_XVID) { + if (ffmpeg_type == FFMPEG_XVID) { /* arghhhh ... */ c->pix_fmt = PIX_FMT_YUV420P; c->codec_tag = (('D'<<24) + ('I'<<16) + ('V'<<8) + 'X'); @@ -586,9 +540,9 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex st = av_new_stream(of, 1); if (!st) return NULL; - c = get_codec_from_stream(st); + c = st->codec; c->codec_id = codec_id; - c->codec_type = CODEC_TYPE_AUDIO; + c->codec_type = AVMEDIA_TYPE_AUDIO; c->sample_rate = rd->ffcodecdata.audio_mixrate; c->bit_rate = ffmpeg_audio_bitrate*1000; @@ -666,13 +620,13 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report BKE_report(reports, RPT_ERROR, "No valid formats found."); return 0; } - fmt = guess_format(NULL, exts[0], NULL); + fmt = av_guess_format(NULL, exts[0], NULL); if (!fmt) { BKE_report(reports, RPT_ERROR, "No valid formats found."); return 0; } - of = av_alloc_format_context(); + of = avformat_alloc_context(); if (!of) { BKE_report(reports, RPT_ERROR, "Error opening output file"); return 0; @@ -713,7 +667,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report fmt->video_codec = CODEC_ID_H264; break; case FFMPEG_XVID: - fmt->video_codec = CODEC_ID_XVID; + fmt->video_codec = CODEC_ID_MPEG4; break; case FFMPEG_FLV: fmt->video_codec = CODEC_ID_FLV1; @@ -772,7 +726,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report return 0; } if (!(fmt->flags & AVFMT_NOFILE)) { - if (url_fopen(&of->pb, name, URL_WRONLY) < 0) { + if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) { BKE_report(reports, RPT_ERROR, "Could not open file for writing."); return 0; } @@ -780,7 +734,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report av_write_header(of); outfile = of; - dump_format(of, 0, name, 1); + av_dump_format(of, 0, name, 1); return 1; } @@ -807,7 +761,7 @@ void flush_ffmpeg(void) int outsize = 0; int ret = 0; - AVCodecContext* c = get_codec_from_stream(video_stream); + AVCodecContext* c = video_stream->codec; /* get the delayed frames */ while (1) { AVPacket packet; @@ -822,19 +776,15 @@ void flush_ffmpeg(void) break; } if (c->coded_frame->pts != AV_NOPTS_VALUE) { -#ifdef FFMPEG_CODEC_TIME_BASE packet.pts = av_rescale_q(c->coded_frame->pts, c->time_base, video_stream->time_base); -#else - packet.pts = c->coded_frame->pts; -#endif fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts); } else { fprintf(stderr, "Video Frame PTS: not set\n"); } if (c->coded_frame->key_frame) { - packet.flags |= PKT_FLAG_KEY; + packet.flags |= AV_PKT_FLAG_KEY; } packet.stream_index = video_stream->index; packet.data = video_buffer; @@ -845,7 +795,7 @@ void flush_ffmpeg(void) break; } } - avcodec_flush_buffers(get_codec_from_stream(video_stream)); + avcodec_flush_buffers(video_stream->codec); } /* ********************************************************************** @@ -902,7 +852,7 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo if(audio_stream) { - AVCodecContext* c = get_codec_from_stream(audio_stream); + AVCodecContext* c = audio_stream->codec; AUD_DeviceSpecs specs; specs.channels = c->channels; specs.format = AUD_FORMAT_S16; @@ -945,7 +895,7 @@ int append_ffmpeg(RenderData *rd, int frame, int *pixels, int rectx, int recty, success= (avframe && write_video_frame(rd, avframe, reports)); if (ffmpeg_autosplit) { - if (url_ftell(OUTFILE_PB) > FFMPEG_AUTOSPLIT_SIZE) { + if (avio_tell(outfile->pb) > FFMPEG_AUTOSPLIT_SIZE) { end_ffmpeg(); ffmpeg_autosplit_count++; success &= start_ffmpeg_impl(rd, rectx, recty, reports); @@ -974,7 +924,7 @@ void end_ffmpeg(void) audio_mixdown_device = 0; } - if (video_stream && get_codec_from_stream(video_stream)) { + if (video_stream && video_stream->codec) { fprintf(stderr, "Flushing delayed frames...\n"); flush_ffmpeg (); } @@ -985,8 +935,8 @@ void end_ffmpeg(void) /* Close the video codec */ - if (video_stream && get_codec_from_stream(video_stream)) { - avcodec_close(get_codec_from_stream(video_stream)); + if (video_stream && video_stream->codec) { + avcodec_close(video_stream->codec); printf("zero video stream %p\n", video_stream); video_stream = 0; } @@ -1007,7 +957,7 @@ void end_ffmpeg(void) } if (outfile && outfile->oformat) { if (!(outfile->oformat->flags & AVFMT_NOFILE)) { - url_fclose(OUTFILE_PB); + avio_close(outfile->pb); } } if (outfile) { @@ -1101,12 +1051,12 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int switch (o->type) { case FF_OPT_TYPE_INT: case FF_OPT_TYPE_INT64: - val.i = o->default_val; + val.i = o->default_val.i64; idp_type = IDP_INT; break; case FF_OPT_TYPE_DOUBLE: case FF_OPT_TYPE_FLOAT: - val.f = o->default_val; + val.f = o->default_val.dbl; idp_type = IDP_FLOAT; break; case FF_OPT_TYPE_STRING: @@ -1314,7 +1264,7 @@ void ffmpeg_set_preset(RenderData *rd, int preset) case FFMPEG_PRESET_XVID: if(preset == FFMPEG_PRESET_XVID) { rd->ffcodecdata.type = FFMPEG_AVI; - rd->ffcodecdata.codec = CODEC_ID_XVID; + rd->ffcodecdata.codec = CODEC_ID_MPEG4; } else if(preset == FFMPEG_PRESET_THEORA) { rd->ffcodecdata.type = FFMPEG_OGG; // XXX broken @@ -1357,7 +1307,7 @@ void ffmpeg_verify_image_type(RenderData *rd) } } else if(rd->imtype == R_XVID) { - if(rd->ffcodecdata.codec != CODEC_ID_XVID) { + if(rd->ffcodecdata.codec != CODEC_ID_MPEG4) { ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID); audio= 1; } diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 4de96bb17bc..ba7d2541cae 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -559,14 +559,14 @@ static int startffmpeg(struct anim * anim) { return -1; } - dump_format(pFormatCtx, 0, anim->name, 0); + av_dump_format(pFormatCtx, 0, anim->name, 0); /* Find the first video stream */ videoStream=-1; for(i=0; inb_streams; i++) if(get_codec_from_stream(pFormatCtx->streams[i])->codec_type - == CODEC_TYPE_VIDEO) { + == AVMEDIA_TYPE_VIDEO) { videoStream=i; break; } @@ -830,10 +830,10 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { && position - (anim->curposition + 1) < anim->preseek) { while(av_read_frame(anim->pFormatCtx, &packet)>=0) { if (packet.stream_index == anim->videoStream) { - avcodec_decode_video( + avcodec_decode_video2( anim->pCodecCtx, anim->pFrame, &frameFinished, - packet.data, packet.size); + &packet); if (frameFinished) { anim->curposition++; @@ -915,9 +915,9 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { while(av_read_frame(anim->pFormatCtx, &packet)>=0) { if(packet.stream_index == anim->videoStream) { - avcodec_decode_video(anim->pCodecCtx, - anim->pFrame, &frameFinished, - packet.data, packet.size); + avcodec_decode_video2(anim->pCodecCtx, + anim->pFrame, &frameFinished, + &packet); if (seek_by_bytes && preseek_count > 0) { preseek_count--; diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 3e4136cbef9..879ed37cc50 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -62,13 +62,6 @@ #include #include #include - -#if LIBAVFORMAT_VERSION_INT < (49 << 16) -#define FFMPEG_OLD_FRAME_RATE 1 -#else -#define FFMPEG_CODEC_IS_POINTER 1 -#endif - #endif #define UTIL_DEBUG 0 @@ -241,19 +234,6 @@ void do_init_ffmpeg(void) } } -#ifdef FFMPEG_CODEC_IS_POINTER -static AVCodecContext* get_codec_from_stream(AVStream* stream) -{ - return stream->codec; -} -#else -static AVCodecContext* get_codec_from_stream(AVStream* stream) -{ - return &stream->codec; -} -#endif - - static int isffmpeg (const char *filename) { AVFormatContext *pFormatCtx; unsigned int i; @@ -284,15 +264,15 @@ static int isffmpeg (const char *filename) { return 0; } - if(UTIL_DEBUG) dump_format(pFormatCtx, 0, filename, 0); + if(UTIL_DEBUG) av_dump_format(pFormatCtx, 0, filename, 0); /* Find the first video stream */ videoStream=-1; for(i=0; inb_streams; i++) if(pFormatCtx->streams[i] && - get_codec_from_stream(pFormatCtx->streams[i]) && - (get_codec_from_stream(pFormatCtx->streams[i])->codec_type==CODEC_TYPE_VIDEO)) + pFormatCtx->streams[i]->codec && + (pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)) { videoStream=i; break; @@ -303,7 +283,7 @@ static int isffmpeg (const char *filename) { return 0; } - pCodecCtx = get_codec_from_stream(pFormatCtx->streams[videoStream]); + pCodecCtx = pFormatCtx->streams[videoStream]->codec; /* Find the decoder for the video stream */ pCodec=avcodec_find_decoder(pCodecCtx->codec_id); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b4bbde43caa..79184f1667b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2149,7 +2149,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {CODEC_ID_HUFFYUV, "HUFFYUV", 0, "HuffYUV", ""}, {CODEC_ID_DVVIDEO, "DV", 0, "DV", ""}, {CODEC_ID_H264, "H264", 0, "H.264", ""}, - {CODEC_ID_XVID, "XVID", 0, "Xvid", ""}, {CODEC_ID_THEORA, "THEORA", 0, "Theora", ""}, {CODEC_ID_FLV1, "FLASH", 0, "Flash Video", ""}, {CODEC_ID_FFV1, "FFV1", 0, "FFmpeg video codec #1", ""}, diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 63dbc5bb7ba..f8274756c8b 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -182,7 +182,7 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV { if(formatCtx->streams[i] && get_codec_from_stream(formatCtx->streams[i]) && - (get_codec_from_stream(formatCtx->streams[i])->codec_type==CODEC_TYPE_VIDEO)) + (get_codec_from_stream(formatCtx->streams[i])->codec_type==AVMEDIA_TYPE_VIDEO)) { videoStream=i; break; @@ -368,9 +368,9 @@ void *VideoFFmpeg::cacheThread(void *data) BLI_remlink(&video->m_packetCacheBase, cachePacket); // use m_frame because when caching, it is not used in main thread // we can't use currentFrame directly because we need to convert to RGB first - avcodec_decode_video(video->m_codecCtx, + avcodec_decode_video2(video->m_codecCtx, video->m_frame, &frameFinished, - cachePacket->packet.data, cachePacket->packet.size); + &cachePacket->packet); if(frameFinished) { AVFrame * input = video->m_frame; @@ -641,7 +641,7 @@ void VideoFFmpeg::openCam (char * file, short camIdx) if (m_captRate <= 0.f) m_captRate = defFrameRate; sprintf(rateStr, "%f", m_captRate); - av_parse_video_frame_rate(&frameRate, rateStr); + av_parse_video_rate(&frameRate, rateStr); // populate format parameters // need to specify the time base = inverse of rate formatParams.time_base.num = frameRate.den; @@ -924,10 +924,10 @@ AVFrame *VideoFFmpeg::grabFrame(long position) { if (packet.stream_index == m_videoStream) { - avcodec_decode_video( + avcodec_decode_video2( m_codecCtx, m_frame, &frameFinished, - packet.data, packet.size); + &packet); if (frameFinished) { m_curPosition = (long)((packet.dts-startTs) * (m_baseFrameRate*timeBase) + 0.5); @@ -999,9 +999,9 @@ AVFrame *VideoFFmpeg::grabFrame(long position) { if(packet.stream_index == m_videoStream) { - avcodec_decode_video(m_codecCtx, + avcodec_decode_video2(m_codecCtx, m_frame, &frameFinished, - packet.data, packet.size); + &packet); // remember dts to compute exact frame number dts = packet.dts; if (frameFinished && !posFound) diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index 9b09c485329..f95c1198eaa 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -34,6 +34,7 @@ extern "C" { #include #include #include +#include #include #include "DNA_listBase.h" #include "BLI_threads.h" -- cgit v1.2.3 From d9fa6db75ba2e38436d9e72a0454b2ba0dcaa359 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 22:20:29 +0000 Subject: weight paint mirror, move duplicate code into a function. --- source/blender/editors/sculpt_paint/paint_vertex.c | 83 +++++++++++----------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index ecdf49a321a..0380dba7592 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -288,6 +288,43 @@ static void make_vertexcol(Object *ob) /* single ob */ } +/* mirror_vgroup is set to -1 when invalid */ +static void wpaint_mirror_vgroup_ensure(Object *ob, int *vgroup_mirror) +{ + bDeformGroup *defgroup= BLI_findlink(&ob->defbase, ob->actdef - 1); + + if(defgroup) { + bDeformGroup *curdef; + int mirrdef; + char name[MAXBONENAME]; + + flip_side_name(name, defgroup->name, FALSE); + + if(strcmp(name, defgroup->name) != 0) { + for (curdef= ob->defbase.first, mirrdef; curdef; curdef=curdef->next, mirrdef++) { + if (!strcmp(curdef->name, name)) { + break; + } + } + + if(curdef==NULL) { + int olddef= ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */ + curdef= ED_vgroup_add_name(ob, name); + ob->actdef= olddef; + } + + /* curdef should never be NULL unless this is + * a lamp and ED_vgroup_add_name fails */ + if(curdef) { + *vgroup_mirror= mirrdef; + return; + } + } + } + + *vgroup_mirror= -1; +} + static void copy_vpaint_prev(VPaint *vp, unsigned int *mcol, int tot) { if(vp->vpaint_prev) { @@ -383,32 +420,11 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) } vgroup= ob->actdef-1; - - /* directly copied from weight_paint, should probaby split into a separate function */ + /* if mirror painting, find the other group */ if(me->editflag & ME_EDIT_MIRROR_X) { - bDeformGroup *defgroup= BLI_findlink(&ob->defbase, ob->actdef-1); - if(defgroup) { - bDeformGroup *curdef; - int actdef= 0; - char name[32]; - - flip_side_name(name, defgroup->name, FALSE); - - for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++) - if (!strcmp(curdef->name, name)) - break; - if(curdef==NULL) { - int olddef= ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */ - curdef= ED_vgroup_add_name (ob, name); - ob->actdef= olddef; - } - - if(curdef && curdef!=defgroup) - vgroup_mirror= actdef; - } + wpaint_mirror_vgroup_ensure(ob, &vgroup_mirror); } - /* end copy from weight_paint*/ copy_wpaint_prev(wp, me->dvert, me->totvert); @@ -1351,26 +1367,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED /* if mirror painting, find the other group */ if(me->editflag & ME_EDIT_MIRROR_X) { - bDeformGroup *defgroup= BLI_findlink(&ob->defbase, ob->actdef-1); - if(defgroup) { - bDeformGroup *curdef; - int actdef= 0; - char name[32]; - - flip_side_name(name, defgroup->name, FALSE); - - for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++) - if (!strcmp(curdef->name, name)) - break; - if(curdef==NULL) { - int olddef= ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */ - curdef= ED_vgroup_add_name (ob, name); - ob->actdef= olddef; - } - - if(curdef && curdef!=defgroup) - wpd->vgroup_mirror= actdef; - } + wpaint_mirror_vgroup_ensure(ob, &wpd->vgroup_mirror); } return 1; -- cgit v1.2.3 From e070975ae44d85d0f6e13b261815f6c395692521 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 22:48:06 +0000 Subject: missed this in recent commit. --- source/gameengine/Converter/KX_BlenderSceneConverter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 684ed0b06f9..58089cc4b2d 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -994,7 +994,7 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha int i=0; LinkNode *n= names; while(n) { - BLO_library_append_named_part(C, main_tmp, &bpy_openlib, (char *)n->link, idcode, 0); + BLO_library_append_named_part(main_tmp, &bpy_openlib, (char *)n->link, idcode); n= (LinkNode *)n->next; i++; } @@ -1012,7 +1012,7 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha int i=0; LinkNode *n= names; while(n) { - BLO_library_append_named_part(C, main_tmp, &bpy_openlib, (char *)n->link, ID_AC, 0); + BLO_library_append_named_part(main_tmp, &bpy_openlib, (char *)n->link, ID_AC); n= (LinkNode *)n->next; i++; } -- cgit v1.2.3 From f1d3982bf670890b686a200f95ec8008f6d28f23 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Thu, 26 May 2011 23:19:15 +0000 Subject: == FFMPEG == Added some API compatibility code again, since some API-changes weren't even documented (they even didn't do a proper version-bump, arghh!) If it breaks again, please tell! --- source/blender/blenkernel/intern/writeffmpeg.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index dbb4bd48629..662763525e0 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -61,6 +61,21 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#if (LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105) +#define FFMPEG_HAVE_AVIO 1 +#endif + +#if (LIBAVFORMAT_VERSION_MAJOR >= 53) && (LIBAVFORMAT_VERSION_MINOR >= 3) +#define FFMPEG_HAVE_DEFAULT_VAL_UNION 1 +#endif + +#ifndef FFMPEG_HAVE_AVIO +#define AVIO_FLAG_WRITE URL_WRONLY +#define avio_open url_fopen +#define avio_tell url_ftell +#define avio_close url_fclose +#endif + extern void do_init_ffmpeg(void); static int ffmpeg_type = 0; @@ -1051,12 +1066,20 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int switch (o->type) { case FF_OPT_TYPE_INT: case FF_OPT_TYPE_INT64: +#ifdef FFMPEG_HAVE_DEFAULT_VAL_UNION val.i = o->default_val.i64; +#else + val.i = o->default_val; +#endif idp_type = IDP_INT; break; case FF_OPT_TYPE_DOUBLE: case FF_OPT_TYPE_FLOAT: +#ifdef FFMPEG_HAVE_DEFAULT_VAL_UNION val.f = o->default_val.dbl; +#else + val.f = o->default_val; +#endif idp_type = IDP_FLOAT; break; case FF_OPT_TYPE_STRING: -- cgit v1.2.3 From 72499b070ad5e66c9ee0f2df3f58f4e723339e04 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 23:29:40 +0000 Subject: own recent commits caused crash with the grease pencil in camera view, always pass rv3d argument now. also found a bug where hex_to_rgb could use un-initialized memory. --- source/blender/blenlib/intern/math_color.c | 4 ++++ source/blender/editors/gpencil/gpencil_edit.c | 2 +- source/blender/editors/gpencil/gpencil_paint.c | 2 +- source/blender/editors/space_view3d/view3d_draw.c | 3 --- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 512086f0e17..ef1d5da56d8 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -194,6 +194,10 @@ void hex_to_rgb(char *hexcol, float *r, float *g, float *b) CLAMP(*g, 0.0f, 1.0f); CLAMP(*b, 0.0f, 1.0f); } + else { + /* avoid using un-initialized vars */ + *r= *g= *b= 0.0f; + } } void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv) diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 27f2598d515..42ffefa6bd4 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -453,7 +453,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect) /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border(scene, ar, v3d, NULL, subrect, -1); /* negative shift */ + ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, subrect, -1); /* negative shift */ return 1; } } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 2a4b583276e..f4da734473d 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1131,7 +1131,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border(p->scene, p->ar, v3d, NULL, &p->subrect_data, -1); /* negative shift */ + ED_view3d_calc_camera_border(p->scene, p->ar, v3d, rv3d, &p->subrect_data, -1); /* negative shift */ p->subrect= &p->subrect_data; } } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index b134878624f..573951da4ca 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -876,9 +876,6 @@ void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, Region float dx= 0.0f, dy= 0.0f; view3d_viewborder_size_get(scene, ar, size); - - if (rv3d == NULL) - rv3d = ar->regiondata; size[0]= size[0]*zoomfac; size[1]= size[1]*zoomfac; -- cgit v1.2.3 From 50289e62cb0357406cec2d166d81ab4db51d7cde Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Thu, 26 May 2011 23:51:02 +0000 Subject: == FFMPEG == ... and another funny version patch, since OpenSuse obviously used some version "in-between" --- source/blender/blenkernel/intern/writeffmpeg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 662763525e0..27ae8ec2aba 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -76,6 +76,12 @@ #define avio_close url_fclose #endif +/* make OpenSuSe special "in-between" ffmpeg 0.6.2 version(tm) happy... + Arrrrgh */ +#ifndef AVIO_FLAG_WRITE +#define AVIO_FLAG_WRITE URL_WRONLY +#endif + extern void do_init_ffmpeg(void); static int ffmpeg_type = 0; -- cgit v1.2.3 From 0381c444fdbed601248ac5c0b01702d36e1934d5 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Fri, 27 May 2011 07:47:42 +0000 Subject: == FFMPEG == Fixed and added additional ffmpeg cruft checking. Oh dear. --- source/blender/blenkernel/intern/writeffmpeg.c | 12 ++++++++++-- source/blender/imbuf/intern/anim_movie.c | 8 ++++++++ source/blender/imbuf/intern/util.c | 9 +++++++++ source/gameengine/VideoTexture/VideoFFmpeg.h | 2 ++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 27ae8ec2aba..48930ae2eb8 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -61,14 +61,18 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#if (LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105) +#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105)) #define FFMPEG_HAVE_AVIO 1 #endif -#if (LIBAVFORMAT_VERSION_MAJOR >= 53) && (LIBAVFORMAT_VERSION_MINOR >= 3) +#if (LIBAVFORMAT_VERSION_MAJOR > 53) || ((LIBAVFORMAT_VERSION_MAJOR >= 53) && (LIBAVFORMAT_VERSION_MINOR >= 1)) #define FFMPEG_HAVE_DEFAULT_VAL_UNION 1 #endif +#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) +#define FFMPEG_HAVE_AV_DUMP_FORMAT 1 +#endif + #ifndef FFMPEG_HAVE_AVIO #define AVIO_FLAG_WRITE URL_WRONLY #define avio_open url_fopen @@ -82,6 +86,10 @@ #define AVIO_FLAG_WRITE URL_WRONLY #endif +#ifndef FFMPEG_HAVE_AV_DUMP_FORMAT +#define av_dump_format dump_format +#endif + extern void do_init_ffmpeg(void); static int ffmpeg_type = 0; diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index ba7d2541cae..a0051d85c5b 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -108,6 +108,14 @@ #define FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT #endif +#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) +#define FFMPEG_HAVE_AV_DUMP_FORMAT 1 +#endif + +#ifndef FFMPEG_HAVE_AV_DUMP_FORMAT +#define av_dump_format dump_format +#endif + #endif //WITH_FFMPEG #ifdef WITH_REDCODE diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 879ed37cc50..3eed69f4c52 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -62,6 +62,15 @@ #include #include #include + +#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) +#define FFMPEG_HAVE_AV_DUMP_FORMAT 1 +#endif + +#ifndef FFMPEG_HAVE_AV_DUMP_FORMAT +#define av_dump_format dump_format +#endif + #endif #define UTIL_DEBUG 0 diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index f95c1198eaa..70c7a840cb8 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -34,7 +34,9 @@ extern "C" { #include #include #include +#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) #include +#endif #include #include "DNA_listBase.h" #include "BLI_threads.h" -- cgit v1.2.3 From d369a6aaaf3d3c44bb2c3cde34fde053633ec799 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 27 May 2011 09:57:53 +0000 Subject: Windows installer and Path changes, fixing various issues: * Windows installer not working for non-admin users and multiple users * Addon scripts not installing next to user configuration * Portable install not being taken into account in all places The main problem was the windows installer was installing system scripts in AppData next to the user configuration directory, which is not shared between users. Now these are installed in ProgramFiles, and only addon scripts added by the users go to AppData. On all platforms, addon scripts were sometimes getting installed between system scripts, because the scripts folder in the executable directory was given precedence over the user configuration folder, that is no longer done now. So addons now behave like user configuration, they are preserved even if you download a newer build of the same blender version. If you have an installation of 2.57 on windows, the addon install location will not change until we do the version bump to 2.58, to avoid conflicts with the existing the installed 2.57 version. The old behavior of giving precedence to the local folder was done to support portable install, where all configuration is written to the local folder. This is now implemented differently: if and only if a "config" folder exists in the local folder, portable install will be assumed, and files will only be written to that local folder. --- build_files/scons/tools/btools.py | 5 +- release/scripts/startup/bl_operators/wm.py | 8 +++ release/windows/installer/00.sconsblender.nsi | 81 +++++++++----------------- source/blender/blenlib/BLI_path_util.h | 5 -- source/blender/blenlib/intern/path_util.c | 76 +++++++++++++++--------- source/blender/editors/space_file/space_file.c | 2 +- source/blender/python/intern/bpy.c | 2 +- source/blender/python/intern/bpy_interface.c | 2 +- source/blender/windowmanager/intern/wm_files.c | 2 +- source/creator/creator.c | 2 - source/gameengine/Ketsji/KX_PythonInit.cpp | 2 +- 11 files changed, 88 insertions(+), 99 deletions(-) diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index fe6b092598c..accdde0d2cf 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -615,10 +615,7 @@ def NSIS_Installer(target=None, source=None, env=None): else: if len(df)>0: dp_tmp = dp[l:] - if dp_tmp.find('python\\lib') > -1: - datafiles += "\n" +r'SetOutPath $INSTDIR'+dp[l:]+"\n\n" - else: - datafiles += "\n"+r'SetOutPath $BLENDERHOME'+dp[l:]+"\n\n" + datafiles += "\n" +r'SetOutPath $INSTDIR'+dp[l:]+"\n\n" for f in df: outfile = os.path.join(dp,f) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 53c8d562297..3f4a061c4ac 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -940,6 +940,14 @@ class WM_OT_copy_prev_settings(bpy.types.Operator): self.report({'ERROR'}, "Source path %r exists" % path_src) else: shutil.copytree(path_src, path_dst) + + # in 2.57 and earlier windows installers, system scripts were copied + # into the configuration directory, don't want to copy those + system_script = os.path.join(path_dst, 'scripts/modules/bpy_types.py') + if os.path.isfile(system_script): + shutil.rmtree(os.path.join(path_dst, 'scripts')) + shutil.rmtree(os.path.join(path_dst, 'plugins')) + # dont loose users work if they open the splash later. if bpy.data.is_saved is bpy.data.is_dirty is False: bpy.ops.wm.read_homefile() diff --git a/release/windows/installer/00.sconsblender.nsi b/release/windows/installer/00.sconsblender.nsi index 03f62f0df48..42a9b1c13b6 100644 --- a/release/windows/installer/00.sconsblender.nsi +++ b/release/windows/installer/00.sconsblender.nsi @@ -33,11 +33,11 @@ RequestExecutionLevel admin !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY -Page custom DataLocation DataLocationOnLeave !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_WELCOME +UninstPage custom un.OptionalRemoveConfig un.OptionalRemoveConfigOnLeave !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH @@ -62,7 +62,6 @@ UninstallIcon "[RELDIR]\00.installer.ico" LangString DESC_StartMenu ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)" LangString DESC_DesktopShortcut ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop." LangString DESC_BlendRegister ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc." - LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Specify User Data Location" ;-------------------------------- ;Data @@ -76,15 +75,15 @@ DirText "Use the field below to specify the folder where you want Blender to be SilentUnInstall normal -Var BLENDERHOME Var SHORTVERSION ; This is blender_version_decimal() from path_util.c +Var BLENDERCONFIG +Var REMOVECONFIG ; Custom controls Var HWND -Var HWND_APPDATA -Var HWND_INSTDIR -Var HWND_HOMEDIR +Var HWND_KEEPCONFIG +Var HWND_REMOVECONFIG Function .onInit ClearErrors @@ -103,9 +102,12 @@ Function .onInit FunctionEnd Function un.onInit + SetShellVarContext current + StrCpy $BLENDERCONFIG "$APPDATA\Blender Foundation\Blender" + SetShellVarContext all FunctionEnd -Function DataLocation +Function un.OptionalRemoveConfig nsDialogs::Create /NOUNLOAD 1018 Pop $HWND @@ -113,45 +115,27 @@ Function DataLocation Abort ${EndIf} - ${NSD_CreateLabel} 0 0 100% 24u "Please specify where you wish to install Blender's user data files. Be aware that if you choose to use your Application Data directory, your preferences and scripts will only be accessible by the current user account." - ${NSD_CreateRadioButton} 0 50 100% 12u "Use Application Data directory (recommended)" - Pop $HWND_APPDATA - ${NSD_CreateRadioButton} 0 80 100% 12u "Use installation directory" - Pop $HWND_INSTDIR - ${NSD_CreateRadioButton} 0 110 100% 12u "I have defined a %HOME% variable, please install files there" - Pop $HWND_HOMEDIR - - ${If} ${AtMostWinME} - GetDlgItem $0 $HWND $HWND_APPDATA - EnableWindow $0 0 - SendMessage $HWND_INSTDIR ${BM_SETCHECK} 1 0 - ${Else} - SendMessage $HWND_APPDATA ${BM_SETCHECK} 1 0 - ${EndIf} + ${NSD_CreateRadioButton} 0 50 100% 12u "Keep configuration files, autosaved .blend files and installed addons (recommended)" + Pop $HWND_KEEPCONFIG + ${NSD_CreateRadioButton} 0 80 100% 12u "Remove all files, including configuration files, autosaved .blend files and installed addons" + Pop $HWND_REMOVECONFIG + + SendMessage $HWND_KEEPCONFIG ${BM_SETCHECK} 1 0 nsDialogs::Show FunctionEnd -Function DataLocationOnLeave - ${NSD_GetState} $HWND_APPDATA $R0 +Function un.OptionalRemoveConfigOnLeave + ${NSD_GetState} $HWND_REMOVECONFIG $R0 ${If} $R0 == "1" - SetShellVarContext current - StrCpy $BLENDERHOME "$APPDATA\Blender Foundation\Blender" - SetShellVarContext all + StrCpy $REMOVECONFIG "1" ${Else} - ${NSD_GetState} $HWND_INSTDIR $R0 - ${If} $R0 == "1" - StrCpy $BLENDERHOME $INSTDIR - ${Else} - ${NSD_GetState} $HWND_HOMEDIR $R0 - ${If} $R0 == "1" - ReadEnvStr $BLENDERHOME "HOME" - ${EndIf} - ${EndIf} + StrCpy $REMOVECONFIG "0" ${EndIf} FunctionEnd + Section "Blender [VERSION] (required)" InstallFiles SectionIn RO @@ -160,7 +144,7 @@ Section "Blender [VERSION] (required)" InstallFiles ; The contents of Blender installation root dir [ROOTDIRCONTS] - ; All datafiles (python, scripts, config) + ; All datafiles (python, scripts, datafiles) [DODATAFILES] SetOutPath $INSTDIR @@ -169,7 +153,6 @@ Section "Blender [VERSION] (required)" InstallFiles ${EndIf} ; Write the installation path into the registry WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "Install_Dir" "$INSTDIR" - WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir" "$BLENDERHOME" WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" "[SHORTVERSION]" ; Write the uninstall keys for Windows WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender" @@ -204,7 +187,7 @@ Section "Open .blend files with Blender" BlendRegister ExecWait '"$INSTDIR\blender.exe" -r' SectionEnd -UninstallText "This will uninstall Blender [VERSION], and all installed files. Before continuing make sure you have created backup of all the files you may want to keep: startup.blend, bookmarks.txt, recent-files.txt. Hit 'Uninstall' to continue." +UninstallText "This will uninstall Blender [VERSION], and all installed files. Hit 'Uninstall' to continue." Section "Uninstall" ; Remove registry keys @@ -212,7 +195,6 @@ Section "Uninstall" SetRegView 64 ${EndIf} - ReadRegStr $BLENDERHOME HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir" ReadRegStr $SHORTVERSION HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Blender" DeleteRegKey HKLM "SOFTWARE\BlenderFoundation" @@ -226,21 +208,10 @@ Section "Uninstall" Delete "$INSTDIR\uninstall.exe" - MessageBox MB_YESNO "Recursively erase contents of $BLENDERHOME\$SHORTVERSION\scripts? NOTE: This includes all installed scripts and *any* file and directory you have manually created, installed later or copied. This also including .blend files." IDNO NextNoScriptRemove - RMDir /r "$BLENDERHOME\$SHORTVERSION\scripts" -NextNoScriptRemove: - MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\config? NOTE: This includes your startup.blend, bookmarks and any other file and directory you may have created in that directory" IDNO NextNoConfigRemove - RMDir /r "$BLENDERHOME\$SHORTVERSION\config" -NextNoConfigRemove: - MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\plugins? NOTE: This includes files and subdirectories in this directory" IDNO NextNoPluginRemove - RMDir /r "$BLENDERHOME\$SHORTVERSION\plugins" -NextNoPluginRemove: - ; Try to remove dirs, but leave them if they contain anything - RMDir "$BLENDERHOME\$SHORTVERSION\plugins" - RMDir "$BLENDERHOME\$SHORTVERSION\config" - RMDir "$BLENDERHOME\$SHORTVERSION\scripts" - RMDir "$BLENDERHOME\$SHORTVERSION" - RMDir "$BLENDERHOME" + ${If} $REMOVECONFIG == "1" + RMDir /r "$BLENDERCONFIG\$SHORTVERSION" + ${Endif} + ; Remove shortcuts Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*" Delete "$DESKTOP\Blender.lnk" diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 360cd1ea9ab..81fc8a50db6 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -50,11 +50,7 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check); /* folder_id */ /* general, will find based on user/local/system priority */ -#define BLENDER_CONFIG 1 #define BLENDER_DATAFILES 2 -#define BLENDER_SCRIPTS 3 -#define BLENDER_PLUGINS 4 -#define BLENDER_PYTHON 5 /* user-specific */ #define BLENDER_USER_CONFIG 31 @@ -64,7 +60,6 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check); #define BLENDER_USER_AUTOSAVE 35 /* system */ -#define BLENDER_SYSTEM_CONFIG 51 /* optional */ #define BLENDER_SYSTEM_DATAFILES 52 #define BLENDER_SYSTEM_SCRIPTS 53 #define BLENDER_SYSTEM_PLUGINS 54 diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 47e50e375f0..5056961c8d6 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -902,10 +902,23 @@ static int get_path_local(char *targetpath, const char *folder_name, const char return 0; } +static int is_portable_install(void) +{ + /* detect portable install by the existance of config folder */ + const int ver= BLENDER_VERSION; + char path[FILE_MAX]; + + return get_path_local(path, "config", NULL, ver); +} + static int get_path_user(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar, const int ver) { char user_path[FILE_MAX]; const char *user_base_path; + + /* for portable install, user path is always local */ + if (is_portable_install()) + return get_path_local(targetpath, folder_name, subfolder_name, ver); user_path[0] = '\0'; @@ -1011,6 +1024,26 @@ static int get_path_system(char *targetpath, const char *folder_name, const char } } +#if defined(WIN32) && BLENDER_VERSION < 258 + +static int path_have_257_script_install(void) +{ + const int ver= BLENDER_VERSION; + char path[FILE_MAX] = ""; + char system_pyfile[FILE_MAX]; + + if (get_path_user(path, "scripts", NULL, "BLENDER_USER_SCRIPTS", ver)) { + BLI_join_dirfile(system_pyfile, sizeof(system_pyfile), path, "modules/bpy_types.py"); + + if (BLI_exists(system_pyfile)) + return 1; + } + + return 0; +} + +#endif + /* get a folder out of the 'folder_id' presets for paths */ /* returns the path if found, NULL string if not */ char *BLI_get_folder(int folder_id, const char *subfolder) @@ -1020,13 +1053,12 @@ char *BLI_get_folder(int folder_id, const char *subfolder) switch (folder_id) { case BLENDER_DATAFILES: /* general case */ - if (get_path_local(path, "datafiles", subfolder, ver)) break; if (get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver)) break; + if (get_path_local(path, "datafiles", subfolder, ver)) break; if (get_path_system(path, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES", ver)) break; return NULL; case BLENDER_USER_DATAFILES: - if (get_path_local(path, "datafiles", subfolder, ver)) break; if (get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver)) break; return NULL; @@ -1036,35 +1068,28 @@ char *BLI_get_folder(int folder_id, const char *subfolder) return NULL; case BLENDER_USER_AUTOSAVE: - if (get_path_local(path, "autosave", subfolder, ver)) break; if (get_path_user(path, "autosave", subfolder, "BLENDER_USER_DATAFILES", ver)) break; return NULL; - case BLENDER_CONFIG: /* general case */ - if (get_path_local(path, "config", subfolder, ver)) break; - if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG", ver)) break; - if (get_path_system(path, "config", subfolder, "BLENDER_SYSTEM_CONFIG", ver)) break; - return NULL; - case BLENDER_USER_CONFIG: - if (get_path_local(path, "config", subfolder, ver)) break; if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG", ver)) break; return NULL; - case BLENDER_SYSTEM_CONFIG: - if (get_path_local(path, "config", subfolder, ver)) break; - if (get_path_system(path, "config", subfolder, "BLENDER_SYSTEM_CONFIG", ver)) break; - return NULL; - - case BLENDER_SCRIPTS: /* general case */ - if (get_path_local(path, "scripts", subfolder, ver)) break; - if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver)) break; - if (get_path_system(path, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS", ver)) break; - return NULL; - case BLENDER_USER_SCRIPTS: - if (get_path_local(path, "scripts", subfolder, ver)) break; - if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver)) break; +#if defined(WIN32) && BLENDER_VERSION < 258 + /* if we have a 2.57 installation, then we may have system script + * files in the user configuration folder. avoid using that folder + * if they are there, until the version gets bumped to 2.58, so + * we can be sure that folder only has addons etc. */ + if (path_have_257_script_install()) { + if (get_path_local(path, "scripts", subfolder, ver)) break; + } + else +#endif + { + if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver)) break; + } + return NULL; case BLENDER_SYSTEM_SCRIPTS: @@ -1072,11 +1097,6 @@ char *BLI_get_folder(int folder_id, const char *subfolder) if (get_path_system(path, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS", ver)) break; return NULL; - case BLENDER_PYTHON: /* general case */ - if (get_path_local(path, "python", subfolder, ver)) break; - if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON", ver)) break; - return NULL; - case BLENDER_SYSTEM_PYTHON: if (get_path_local(path, "python", subfolder, ver)) break; if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON", ver)) break; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index ec0d9806bca..18270bfaa26 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -606,7 +606,7 @@ void ED_spacetype_file(void) void ED_file_init(void) { - char *cfgdir = BLI_get_folder(BLENDER_CONFIG, NULL); + char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL); fsmenu_read_system(fsmenu_get()); diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index afafc9b4534..450151ee870 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -239,7 +239,7 @@ void BPy_init_modules( void ) PyObject *mod; /* Needs to be first since this dir is needed for future modules */ - char *modpath= BLI_get_folder(BLENDER_SCRIPTS, "modules"); + char *modpath= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "modules"); if(modpath) { // printf("bpy: found module path '%s'.\n", modpath); PyObject *sys_path= PySys_GetObject("path"); /* borrow */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index acd23887af0..e6f4c5713a1 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -197,7 +197,7 @@ void BPY_python_start(int argc, const char **argv) PyImport_ExtendInittab(bpy_internal_modules); /* allow to use our own included python */ - PyC_SetHomePath(BLI_get_folder(BLENDER_PYTHON, NULL)); + PyC_SetHomePath(BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL)); /* Python 3.2 now looks for '2.57/python/include/python3.2d/pyconfig.h' to parse * from the 'sysconfig' module which is used by 'site', so for now disable site. diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ea77fca4712..1f005ba6021 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -544,7 +544,7 @@ void WM_read_history(void) struct RecentFile *recent; char *line; int num; - char *cfgdir = BLI_get_folder(BLENDER_CONFIG, NULL); + char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL); if (!cfgdir) return; diff --git a/source/creator/creator.c b/source/creator/creator.c index 0c29c807554..016c461600c 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -314,7 +314,6 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data) printf ("\nEnvironment Variables:\n"); printf (" $BLENDER_USER_CONFIG Directory for user configuration files.\n"); - printf (" $BLENDER_SYSTEM_CONFIG Directory for system wide configuration files.\n"); printf (" $BLENDER_USER_SCRIPTS Directory for user scripts.\n"); printf (" $BLENDER_SYSTEM_SCRIPTS Directory for system wide scripts.\n"); printf (" $BLENDER_USER_DATAFILES Directory for user data files (icons, translations, ..).\n"); @@ -1087,7 +1086,6 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 1, NULL, "--factory-startup", "\n\tSkip reading the "STRINGIFY(BLENDER_STARTUP_FILE)" in the users home directory", set_factory_startup, NULL); /* TODO, add user env vars? */ - BLI_argsAdd(ba, 1, NULL, "--env-system-config", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_CONFIG)" environment variable", set_env, NULL); BLI_argsAdd(ba, 1, NULL, "--env-system-datafiles", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_DATAFILES)" environment variable", set_env, NULL); BLI_argsAdd(ba, 1, NULL, "--env-system-scripts", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_SCRIPTS)" environment variable", set_env, NULL); BLI_argsAdd(ba, 1, NULL, "--env-system-plugins", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_PLUGINS)" environment variable", set_env, NULL); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index a3738995db3..c8a6ae5a6d0 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1781,7 +1781,7 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur PyImport_ExtendInittab(bge_internal_modules); /* find local python installation */ - PyC_SetHomePath(BLI_get_folder(BLENDER_PYTHON, NULL)); + PyC_SetHomePath(BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL)); Py_Initialize(); -- cgit v1.2.3