Merge branch 'master' into blender2.8
This commit is contained in:
@@ -48,29 +48,17 @@ import os
|
||||
import sys
|
||||
|
||||
|
||||
def clear_scene():
|
||||
import bpy
|
||||
unique_obs = set()
|
||||
for scene in bpy.data.scenes:
|
||||
for obj in scene.objects[:]:
|
||||
scene.objects.unlink(obj)
|
||||
unique_obs.add(obj)
|
||||
|
||||
# remove obdata, for now only worry about the startup scene
|
||||
for bpy_data_iter in (bpy.data.objects, bpy.data.meshes, bpy.data.lamps, bpy.data.cameras):
|
||||
for id_data in bpy_data_iter:
|
||||
bpy_data_iter.remove(id_data)
|
||||
|
||||
|
||||
def batch_import(operator="",
|
||||
path="",
|
||||
save_path="",
|
||||
match="",
|
||||
start=0,
|
||||
end=sys.maxsize,
|
||||
):
|
||||
def batch_import(
|
||||
operator="",
|
||||
path="",
|
||||
save_path="",
|
||||
match="",
|
||||
start=0,
|
||||
end=sys.maxsize,
|
||||
):
|
||||
import addon_utils
|
||||
_reset_all = addon_utils.reset_all # XXX, hack
|
||||
_disable_all = addon_utils.disable_all # XXX, hack
|
||||
|
||||
import fnmatch
|
||||
|
||||
@@ -116,11 +104,12 @@ def batch_import(operator="",
|
||||
|
||||
# hack so loading the new file doesn't undo our loaded addons
|
||||
addon_utils.reset_all = lambda: None # XXX, hack
|
||||
addon_utils.disable_all = lambda: None # XXX, hack
|
||||
|
||||
bpy.ops.wm.read_factory_settings()
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
|
||||
addon_utils.reset_all = _reset_all # XXX, hack
|
||||
clear_scene()
|
||||
addon_utils.disable_all = _disable_all # XXX, hack
|
||||
|
||||
result = op(filepath=f)
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
import math
|
||||
|
||||
USE_QUICK_RENDER = False
|
||||
IS_BMESH = hasattr(__import__("bpy").types, "LoopColors")
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# utility functions
|
||||
@@ -203,13 +202,8 @@ def defaults_object(obj):
|
||||
|
||||
mesh.show_normal_vertex = True
|
||||
|
||||
# lame!
|
||||
if IS_BMESH:
|
||||
for poly in mesh.polygons:
|
||||
poly.use_smooth = True
|
||||
else:
|
||||
for face in mesh.faces:
|
||||
face.use_smooth = True
|
||||
for poly in mesh.polygons:
|
||||
poly.use_smooth = True
|
||||
|
||||
|
||||
def defaults_modifier(mod):
|
||||
@@ -220,16 +214,14 @@ def defaults_modifier(mod):
|
||||
# -----------------------------------------------------------------------------
|
||||
# models (utils)
|
||||
|
||||
def mesh_bmesh_poly_elems(poly, elems):
|
||||
vert_start = poly.loop_start
|
||||
vert_total = poly.loop_total
|
||||
return elems[vert_start:vert_start + vert_total]
|
||||
|
||||
if IS_BMESH:
|
||||
def mesh_bmesh_poly_elems(poly, elems):
|
||||
vert_start = poly.loop_start
|
||||
vert_total = poly.loop_total
|
||||
return elems[vert_start:vert_start + vert_total]
|
||||
|
||||
def mesh_bmesh_poly_vertices(poly):
|
||||
return [loop.vertex_index
|
||||
for loop in mesh_bmesh_poly_elems(poly, poly.id_data.loops)]
|
||||
def mesh_bmesh_poly_vertices(poly):
|
||||
return [loop.vertex_index
|
||||
for loop in mesh_bmesh_poly_elems(poly, poly.id_data.loops)]
|
||||
|
||||
|
||||
def mesh_bounds(mesh):
|
||||
@@ -258,21 +250,14 @@ def mesh_uv_add(obj):
|
||||
|
||||
uv_lay = obj.data.uv_textures.new()
|
||||
|
||||
if IS_BMESH:
|
||||
# XXX, odd that we need to do this. until UV's and texface
|
||||
# are separated we will need to keep it
|
||||
uv_loops = obj.data.uv_layers[-1]
|
||||
uv_list = uv_loops.data[:]
|
||||
for poly in obj.data.polygons:
|
||||
poly_uvs = mesh_bmesh_poly_elems(poly, uv_list)
|
||||
for i, c in enumerate(poly_uvs):
|
||||
c.uv = uvs[i % 4]
|
||||
else:
|
||||
for uv in uv_lay.data:
|
||||
uv.uv1 = uvs[0]
|
||||
uv.uv2 = uvs[1]
|
||||
uv.uv3 = uvs[2]
|
||||
uv.uv4 = uvs[3]
|
||||
# XXX, odd that we need to do this. until UV's and texface
|
||||
# are separated we will need to keep it
|
||||
uv_loops = obj.data.uv_layers[-1]
|
||||
uv_list = uv_loops.data[:]
|
||||
for poly in obj.data.polygons:
|
||||
poly_uvs = mesh_bmesh_poly_elems(poly, uv_list)
|
||||
for i, c in enumerate(poly_uvs):
|
||||
c.uv = uvs[i % 4]
|
||||
|
||||
return uv_lay
|
||||
|
||||
@@ -296,21 +281,12 @@ def mesh_vcol_add(obj, mode=0):
|
||||
|
||||
mesh = obj.data
|
||||
|
||||
if IS_BMESH:
|
||||
col_list = vcol_lay.data[:]
|
||||
for poly in mesh.polygons:
|
||||
face_verts = mesh_bmesh_poly_vertices(poly)
|
||||
poly_cols = mesh_bmesh_poly_elems(poly, col_list)
|
||||
for i, c in enumerate(poly_cols):
|
||||
c.color = colors_get(face_verts[i])
|
||||
else:
|
||||
for i, col in enumerate(vcol_lay.data):
|
||||
face_verts = mesh.faces[i].vertices
|
||||
col.color1 = colors_get(face_verts[0])
|
||||
col.color2 = colors_get(face_verts[1])
|
||||
col.color3 = colors_get(face_verts[2])
|
||||
if len(face_verts) == 4:
|
||||
col.color4 = colors_get(face_verts[3])
|
||||
col_list = vcol_lay.data[:]
|
||||
for poly in mesh.polygons:
|
||||
face_verts = mesh_bmesh_poly_vertices(poly)
|
||||
poly_cols = mesh_bmesh_poly_elems(poly, col_list)
|
||||
for i, c in enumerate(poly_cols):
|
||||
c.color = colors_get(face_verts[i])
|
||||
|
||||
return vcol_lay
|
||||
|
||||
@@ -470,10 +446,7 @@ def modifier_build_add(scene, obj):
|
||||
defaults_modifier(mod)
|
||||
|
||||
# ensure we display some faces
|
||||
if IS_BMESH:
|
||||
totface = len(obj.data.polygons)
|
||||
else:
|
||||
totface = len(obj.data.faces)
|
||||
totface = len(obj.data.polygons)
|
||||
|
||||
mod.frame_start = totface // 2
|
||||
mod.frame_duration = totface
|
||||
|
||||
@@ -65,6 +65,7 @@ op_blacklist = (
|
||||
"wm.blenderplayer_start",
|
||||
"wm.recover_auto_save",
|
||||
"wm.quit_blender",
|
||||
"wm.window_close",
|
||||
"wm.url_open",
|
||||
"wm.doc_view",
|
||||
"wm.doc_edit",
|
||||
@@ -308,16 +309,7 @@ def run_ops(operators, setup_func=None, reset=True):
|
||||
|
||||
# contexts
|
||||
def ctx_clear_scene(): # copied from batch_import.py
|
||||
unique_obs = set()
|
||||
for scene in bpy.data.scenes:
|
||||
for obj in scene.objects[:]:
|
||||
scene.objects.unlink(obj)
|
||||
unique_obs.add(obj)
|
||||
|
||||
# remove obdata, for now only worry about the startup scene
|
||||
for bpy_data_iter in (bpy.data.objects, bpy.data.meshes, bpy.data.lamps, bpy.data.cameras):
|
||||
for id_data in bpy_data_iter:
|
||||
bpy_data_iter.remove(id_data)
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
|
||||
|
||||
def ctx_editmode_mesh():
|
||||
|
||||
Reference in New Issue
Block a user