X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=blender_export.py;h=54a02e81310a2300b73ab1a3e3038239a1a92229;hb=3494503be52ee50b21e78c8ada30620210db6511;hp=f9b8f6925120eb57da1fd0760681f93d44153e7a;hpb=eeb975ff643ea701c6567c965620437f097e9636;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/blender_export.py b/blender_export.py index f9b8f69..54a02e8 100644 --- a/blender_export.py +++ b/blender_export.py @@ -1,10 +1,9 @@ -import bpy, blf, math, gpu, os +import bpy, math, gpu, os import cProfile from ctypes import * from mathutils import * from gpu_extras.batch import batch_for_shader from bpy_extras import mesh_utils -from bpy_extras import view3d_utils bl_info = { "name":"Skaterift .mdl exporter", @@ -2277,12 +2276,9 @@ class SR_INTERFACE(bpy.types.Panel): active_object = context.active_object if not active_object: return - amount = max( 0, len(context.selected_objects)-1 ) - - row = _.layout.row() - row.operator( 'skaterift.copy_entity_data', \ - text=F'Copy entity data to {amount} other objects' ) - if amount == 0: row.enabled=False + _.layout.operator( 'skaterift.copy_entity_data', \ + text=F'Copy entity data to {len(context.selected_objects)-1} '+\ + F'other objects' ) box = _.layout.box() row = box.row() @@ -2290,13 +2286,13 @@ class SR_INTERFACE(bpy.types.Panel): row.label( text=active_object.name ) row.scale_y = 1.5 - def _draw_prop_collection( source, data ): #{ + def _draw_prop_collection( data ): #{ nonlocal box row = box.row() row.alignment = 'CENTER' row.enabled = False row.scale_y = 1.5 - row.label( text=F'{source}' ) + row.label( text=F'{data[0]}' ) if hasattr(type(data[0]),'sr_inspector'):#{ type(data[0]).sr_inspector( box, data ) @@ -2316,9 +2312,7 @@ class SR_INTERFACE(bpy.types.Panel): text=F'Mirror attributes to {mb.name}' ) #} - _draw_prop_collection( \ - F'bpy.types.Bone["{bones.active.name}"].SR_data',\ - [bones.active.SR_data ] ) + _draw_prop_collection( [bones.active.SR_data ] ) #} else: #{ row = box.row() @@ -2329,26 +2323,18 @@ class SR_INTERFACE(bpy.types.Panel): #} #} elif active_object.type == 'LIGHT': #{ - _draw_prop_collection( \ - F'bpy.types.Light["{active_object.data.name}"].SR_data', \ - [active_object.data.SR_data] ) + _draw_prop_collection( [active_object.data.SR_data] ) #} elif active_object.type in ['EMPTY','CURVE','MESH']:#{ box.prop( active_object.SR_data, "ent_type" ) ent_type = active_object.SR_data.ent_type col = getattr( active_object.SR_data, ent_type, None ) - if col != None and len(col)!=0: - _draw_prop_collection( \ - F'bpy.types.Object["{active_object.name}"].SR_data.{ent_type}[0]', \ - col ) + if col != None and len(col)!=0: _draw_prop_collection( col ) if active_object.type == 'MESH':#{ col = getattr( active_object.data.SR_data, ent_type, None ) - if col != None and len(col)!=0: - _draw_prop_collection( \ - F'bpy.types.Mesh["{active_object.data.name}"].SR_data.{ent_type}[0]', \ - col ) + if col != None and len(col)!=0: _draw_prop_collection( col ) #} #} #} @@ -3383,7 +3369,6 @@ class SR_MATERIAL_PROPERTIES(bpy.types.PropertyGroup): # ---------------------------------------------------------------------------- # cv_view_draw_handler = None -cv_view_pixel_handler = None cv_view_shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') cv_view_verts = [] cv_view_colours = [] @@ -4121,7 +4106,8 @@ def cv_draw_route( route, dij ): #} #} -def cv_draw():#{ +def cv_draw(): +#{ global cv_view_shader global cv_view_verts global cv_view_colours @@ -4354,31 +4340,7 @@ def cv_draw():#{ #} cv_draw_lines() -#} - -def pos3d_to_2d( pos ):#{ - return view3d_utils.location_3d_to_region_2d( \ - bpy.context.region, \ - bpy.context.space_data.region_3d, pos ) -#} - -def cv_draw_pixel():#{ - if not bpy.context.scene.SR_data.gizmos: return - blf.size(0,10) - blf.color(0, 1.0,1.0,1.0,0.9) - blf.enable(0,blf.SHADOW) - blf.shadow(0,3,0.0,0.0,0.0,1.0) - for obj in bpy.context.collection.objects:#{ - ent_type = obj_ent_type( obj ) - - if ent_type != 'none':#{ - co = pos3d_to_2d( obj.location ) - - if not co: continue - blf.position(0,co[0],co[1],0) - blf.draw(0,ent_type) - #} - #} + return #} classes = [ SR_INTERFACE, SR_MATERIAL_PANEL,\ @@ -4430,11 +4392,9 @@ def register(): bpy.types.Material.SR_data = \ bpy.props.PointerProperty(type=SR_MATERIAL_PROPERTIES) - global cv_view_draw_handler, cv_view_pixel_handler + global cv_view_draw_handler cv_view_draw_handler = bpy.types.SpaceView3D.draw_handler_add(\ cv_draw,(),'WINDOW','POST_VIEW') - cv_view_pixel_handler = bpy.types.SpaceView3D.draw_handler_add(\ - cv_draw_pixel,(),'WINDOW','POST_PIXEL') #} def unregister(): @@ -4442,9 +4402,8 @@ def unregister(): for c in classes: bpy.utils.unregister_class(c) - global cv_view_draw_handler, cv_view_pixel_handler + global cv_view_draw_handler bpy.types.SpaceView3D.draw_handler_remove(cv_view_draw_handler,'WINDOW') - bpy.types.SpaceView3D.draw_handler_remove(cv_view_pixel_handler,'WINDOW') #} # ---------------------------------------------------------------------------- #