Recache last undo step
This commit is contained in:
parent
6c8eaa04c4
commit
0eda8e5be5
|
@ -2209,7 +2209,7 @@ class ArmoryExporter:
|
|||
if not material.use_nodes:
|
||||
material.use_nodes = True
|
||||
|
||||
sd, is_transluc, is_overlays, is_decals = make_material.parse(material, o, self.materialToObjectDict, ArmoryExporter.renderpath_id)
|
||||
sd, is_transluc, is_overlays, is_decals = make_material.parse(material, o, self.materialToObjectDict, self.materialToArmObjectDict, ArmoryExporter.renderpath_id)
|
||||
|
||||
if is_transluc:
|
||||
transluc_used = True
|
||||
|
@ -2259,7 +2259,9 @@ class ArmoryExporter:
|
|||
o['contexts'] = []
|
||||
mat_users = dict()
|
||||
mat_users[mat] = self.defaultMaterialObjects
|
||||
make_material.parse(mat, o, mat_users, ArmoryExporter.renderpath_id)
|
||||
mat_armusers = dict()
|
||||
mat_armusers[mat] = [o]
|
||||
make_material.parse(mat, o, mat_users, mat_armusers, ArmoryExporter.renderpath_id)
|
||||
self.output['material_datas'].append(o)
|
||||
bpy.data.materials.remove(mat)
|
||||
|
||||
|
@ -2386,8 +2388,8 @@ class ArmoryExporter:
|
|||
self.boneParentArray = {}
|
||||
self.materialToObjectDict = dict()
|
||||
self.defaultMaterialObjects = []
|
||||
self.materialToGameObjectDict = dict()
|
||||
self.objectToGameObjectDict = dict()
|
||||
self.materialToArmObjectDict = dict()
|
||||
self.objectToArmObjectDict = dict()
|
||||
self.uvprojectUsersArray = [] # For processing decals
|
||||
self.export_default_material = False # If no material is assigned, provide default to mimick cycles
|
||||
self.active_layers = []
|
||||
|
@ -2617,8 +2619,8 @@ class ArmoryExporter:
|
|||
if m.type == 'UV_PROJECT':
|
||||
# Mark all projectors as decals
|
||||
for pnode in m.projectors:
|
||||
o = self.objectToGameObjectDict[bobject]
|
||||
po = self.objectToGameObjectDict[pnode.object]
|
||||
o = self.objectToArmObjectDict[bobject]
|
||||
po = self.objectToArmObjectDict[pnode.object]
|
||||
po['type'] = 'decal_object'
|
||||
po['material_refs'] = [o['material_refs'][0] + '_decal'] # Will fetch a proper context used in render path
|
||||
break
|
||||
|
@ -2827,17 +2829,17 @@ class ArmoryExporter:
|
|||
o['traits'].append(navigation_trait)
|
||||
|
||||
# Map objects to game objects
|
||||
self.objectToGameObjectDict[bobject] = o
|
||||
self.objectToArmObjectDict[bobject] = o
|
||||
|
||||
# Map objects to materials, can be used in later stages
|
||||
for i in range(len(bobject.material_slots)):
|
||||
mat = bobject.material_slots[i].material
|
||||
if mat in self.materialToObjectDict:
|
||||
self.materialToObjectDict[mat].append(bobject)
|
||||
self.materialToGameObjectDict[mat].append(o)
|
||||
self.materialToArmObjectDict[mat].append(o)
|
||||
else:
|
||||
self.materialToObjectDict[mat] = [bobject]
|
||||
self.materialToGameObjectDict[mat] = [o]
|
||||
self.materialToArmObjectDict[mat] = [o]
|
||||
|
||||
# Export constraints
|
||||
if len(bobject.constraints) > 0:
|
||||
|
|
|
@ -49,6 +49,10 @@ def on_scene_update_post(context):
|
|||
if len(ops) > 0 and last_operator != ops[-1]:
|
||||
last_operator = ops[-1]
|
||||
operators_changed = True
|
||||
# Undo was performed - Blender clears the complete operator stack, undo last known operator atleast
|
||||
if len(ops) == 0 and last_operator != None:
|
||||
op_changed(last_operator, bpy.context.obj)
|
||||
last_operator = None
|
||||
|
||||
# Player running
|
||||
state.krom_running = False
|
||||
|
@ -125,22 +129,23 @@ def on_scene_update_post(context):
|
|||
obj = bpy.context.object
|
||||
if obj != None:
|
||||
if operators_changed:
|
||||
# Recache mesh data
|
||||
if ops[-1].bl_idname == 'OBJECT_OT_modifier_add' or \
|
||||
ops[-1].bl_idname == 'OBJECT_OT_modifier_remove' or \
|
||||
ops[-1].bl_idname == 'OBJECT_OT_transform_apply' or \
|
||||
ops[-1].bl_idname == 'OBJECT_OT_shade_smooth' or \
|
||||
ops[-1].bl_idname == 'OBJECT_OT_shade_flat':
|
||||
obj.data.mesh_cached = False
|
||||
|
||||
op_changed(ops[-1], obj)
|
||||
if obj.active_material != None and obj.active_material.is_updated:
|
||||
if obj.active_material.lock_cache == True: # is_cached was set to true
|
||||
obj.active_material.lock_cache = False
|
||||
else:
|
||||
obj.active_material.is_cached = False
|
||||
|
||||
last_py_path = None
|
||||
def op_changed(op, obj):
|
||||
# Recache mesh data
|
||||
if op.bl_idname == 'OBJECT_OT_modifier_add' or \
|
||||
op.bl_idname == 'OBJECT_OT_modifier_remove' or \
|
||||
op.bl_idname == 'OBJECT_OT_transform_apply' or \
|
||||
op.bl_idname == 'OBJECT_OT_shade_smooth' or \
|
||||
op.bl_idname == 'OBJECT_OT_shade_flat':
|
||||
obj.data.mesh_cached = False
|
||||
|
||||
last_py_path = None
|
||||
@persistent
|
||||
def on_load_post(context):
|
||||
global last_py_path
|
||||
|
|
|
@ -132,7 +132,6 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
|
|||
write_data.write_main(is_play, in_viewport, is_publish)
|
||||
|
||||
def compile_project(target_name=None, is_publish=False, watch=False, patch=False):
|
||||
ffmpeg_path = armutils.get_ffmpeg_path()
|
||||
wrd = bpy.data.worlds['Arm']
|
||||
|
||||
# Set build command
|
||||
|
@ -147,9 +146,10 @@ def compile_project(target_name=None, is_publish=False, watch=False, patch=False
|
|||
kha_target_name = make_utils.get_kha_target(target_name)
|
||||
cmd = [node_path, khamake_path, kha_target_name]
|
||||
|
||||
ffmpeg_path = armutils.get_ffmpeg_path() # Path to binary
|
||||
if ffmpeg_path != '':
|
||||
cmd.append('--ffmpeg')
|
||||
cmd.append('"' + ffmpeg_path + '"')
|
||||
cmd.append(ffmpeg_path) # '"' + ffmpeg_path + '"'
|
||||
|
||||
if target_name == '' or target_name == '--run':
|
||||
cmd.append('-g')
|
||||
|
|
|
@ -16,12 +16,13 @@ import material.make_decal as make_decal
|
|||
rpass_hook = None
|
||||
mesh_make = make_mesh.make
|
||||
|
||||
def parse(material, mat_data, mat_users, rid):
|
||||
def parse(material, mat_data, mat_users, mat_armusers, rid):
|
||||
wrd = bpy.data.worlds['Arm']
|
||||
mat_state.material = material
|
||||
mat_state.nodes = material.node_tree.nodes
|
||||
mat_state.mat_data = mat_data
|
||||
mat_state.mat_users = mat_users
|
||||
mat_state.mat_armusers = mat_armusers
|
||||
mat_state.output_node = cycles.node_by_type(mat_state.nodes, 'OUTPUT_MATERIAL')
|
||||
if mat_state.output_node == None:
|
||||
return None
|
||||
|
|
|
@ -31,7 +31,7 @@ def make_texture(image_node, tex_name):
|
|||
return None
|
||||
|
||||
ext = s[1].lower()
|
||||
do_convert = ext != 'jpg' and ext != 'png' and ext != 'hdr' # Convert image
|
||||
do_convert = ext != 'jpg' and ext != 'png' and ext != 'hdr' and ext != 'mp4' # Convert image
|
||||
if do_convert:
|
||||
tex['file'] = tex['file'].rsplit('.', 1)[0] + '.jpg'
|
||||
# log.warn(matname + '/' + image.name + ' - image format is not (jpg/png/hdr), converting to jpg.')
|
||||
|
@ -104,15 +104,15 @@ def make_texture(image_node, tex_name):
|
|||
tex['u_addressing'] = 'clamp'
|
||||
tex['v_addressing'] = 'clamp'
|
||||
|
||||
# if image.source == 'MOVIE': # Just append movie texture trait for now
|
||||
# movie_trait = {}
|
||||
# movie_trait['type'] = 'Script'
|
||||
# movie_trait['class_name'] = 'armory.trait.internal.MovieTexture'
|
||||
# movie_trait['parameters'] = [tex['file']]
|
||||
# for o in self.materialToGameObjectDict[material]:
|
||||
# o['traits'].append(movie_trait)
|
||||
# tex['source'] = 'movie'
|
||||
# tex['file'] = '' # MovieTexture will load the video
|
||||
if image.source == 'MOVIE': # Just append movie texture trait for now
|
||||
movie_trait = {}
|
||||
movie_trait['type'] = 'Script'
|
||||
movie_trait['class_name'] = 'armory.trait.internal.MovieTexture'
|
||||
movie_trait['parameters'] = [tex['file']]
|
||||
for o in mat_state.mat_armusers[mat_state.material]:
|
||||
o['traits'].append(movie_trait)
|
||||
tex['source'] = 'movie'
|
||||
tex['file'] = '' # MovieTexture will load the video
|
||||
|
||||
return tex
|
||||
|
||||
|
|
Loading…
Reference in a new issue