diff --git a/blender/make.py b/blender/make.py index fa35516c..3927bdd7 100755 --- a/blender/make.py +++ b/blender/make.py @@ -195,7 +195,13 @@ def patch_project(): os.chdir(fp) export_data(fp, sdk_path, is_play=True) -def build_project(is_play=False, is_publish=False, in_viewport=False): +def build_project(is_play=False, is_publish=False, in_viewport=False, target=None): + wrd = bpy.data.worlds['Arm'] + + # Set target + if target == None: + state.target = wrd.arm_project_target.lower() + # Clear flag state.in_viewport = False @@ -204,7 +210,6 @@ def build_project(is_play=False, is_publish=False, in_viewport=False): log.clear() # Set camera in active scene - wrd = bpy.data.worlds['Arm'] active_scene = bpy.context.screen.scene if wrd.arm_play_active_scene else bpy.data.scenes[wrd.arm_project_scene] if active_scene.camera == None: for o in active_scene.objects: @@ -250,8 +255,6 @@ def build_project(is_play=False, is_publish=False, in_viewport=False): with open('Sources/' + bpy.data.worlds['Arm'].arm_project_package + '/' + text.name, 'w') as f: f.write(text.as_string()) - # Save internal assets - # Export data export_data(fp, sdk_path, is_play=is_play, is_publish=is_publish, in_viewport=in_viewport) @@ -303,39 +306,39 @@ def watch_patch(): state.compileproc_finished = True def play_project(self, in_viewport): + wrd = bpy.data.worlds['Arm'] + + # Store area if armutils.with_krom() and in_viewport and bpy.context.area.type == 'VIEW_3D': state.play_area = bpy.context.area + # Set target + if in_viewport or wrd.arm_play_runtime == 'Krom': + state.target = 'krom' + elif wrd.arm_play_runtime == 'Native': + state.target = 'native' + else: + state.target = 'html5' + # Build data - build_project(is_play=True, in_viewport=in_viewport) + build_project(is_play=True, in_viewport=in_viewport, target=state.target) state.in_viewport = in_viewport - wrd = bpy.data.worlds['Arm'] - - # Native - if in_viewport == False and wrd.arm_play_runtime == 'Native': + # Compile + mode = 'play' + if state.target == 'native': state.compileproc = compile_project(target_name='--run') - mode = 'play' - threading.Timer(0.1, watch_compile, [mode]).start() - # Viewport - elif armutils.with_krom() and in_viewport: + elif state.target == 'krom': + if in_viewport: + mode = 'play_viewport' state.compileproc = compile_project(target_name='krom') - mode = 'play_viewport' - threading.Timer(0.1, watch_compile, [mode]).start() - # Krom - elif in_viewport == False and wrd.arm_play_runtime == 'Krom': - w, h = armutils.get_render_resolution() - state.compileproc = compile_project(target_name='krom') - mode = 'play' - threading.Timer(0.1, watch_compile, [mode]).start() - # Electron, Browser - else: + else: # Electron, Browser w, h = armutils.get_render_resolution() write_data.write_electronjs(w, h) write_data.write_indexhtml(w, h) state.compileproc = compile_project(target_name='html5') - mode = 'play' - threading.Timer(0.1, watch_compile, [mode]).start() + + threading.Timer(0.1, watch_compile, [mode]).start() def on_compiled(mode): # build, play, play_viewport, publish log.clear() @@ -343,7 +346,7 @@ def on_compiled(mode): # build, play, play_viewport, publish # Print info if mode == 'publish': - target_name = make_utils.get_kha_target(bpy.data.worlds['Arm'].arm_publish_target) + target_name = make_utils.get_kha_target(bpy.data.worlds['Arm'].arm_project_target) print('Project published') files_path = armutils.get_fp() + '/build/' + target_name if target_name == 'html5': @@ -454,7 +457,7 @@ def publish_project(): bpy.data.worlds['Arm'].arm_minimize = True clean_project() build_project(is_publish=True) - state.compileproc = compile_project(target_name=bpy.data.worlds['Arm'].arm_publish_target, is_publish=True) + state.compileproc = compile_project(target_name=bpy.data.worlds['Arm'].arm_project_target, is_publish=True) threading.Timer(0.1, watch_compile, ['publish']).start() bpy.data.worlds['Arm'].arm_minimize = minimize assets.invalidate_enabled = True diff --git a/blender/make_material.py b/blender/make_material.py index d4d3e0c4..0b83ca58 100755 --- a/blender/make_material.py +++ b/blender/make_material.py @@ -5,9 +5,9 @@ import armutils import os import nodes import log +import make_state as state -# UV Map names of current material user -uvlayers = [''] +uvlayers = [''] # UV Map names of current material user def is_pow(num): return ((num & (num - 1)) == 0) and num != 0 @@ -525,7 +525,11 @@ def parse_occlusion_socket(self, occlusion_input, material, c, defs, tree, node, add_occlusion_const(res, c, factor) def parse_height_socket(self, height_input, material, c, defs, tree, node, factor): - if height_input.is_linked: + # Not all targets can tessellate + if state.target != 'krom' and state.target != 'native': + return + wrd = bpy.data.worlds['Arm'] + if height_input.is_linked and wrd.tessellation_enabled: height_node = nodes.find_node_by_link(tree, node, height_input) add_height_tex(self, height_node, material, c, defs) parse_image_vector(height_node, defs, tree, '_HeightTex1') diff --git a/blender/make_state.py b/blender/make_state.py index e9224f73..00d75b71 100644 --- a/blender/make_state.py +++ b/blender/make_state.py @@ -1,4 +1,5 @@ +target = 'krom' in_viewport = False playproc = None compileproc = None diff --git a/blender/props.py b/blender/props.py index 8b1638a0..bf8842df 100755 --- a/blender/props.py +++ b/blender/props.py @@ -27,7 +27,6 @@ def init_properties(): name="Target", default='html5', description='Build paltform') bpy.types.World.arm_project_target = target_prop - bpy.types.World.arm_publish_target = target_prop bpy.types.World.arm_project_name = StringProperty(name="Name", description="Exported project name", default="") bpy.types.World.arm_project_package = StringProperty(name="Package", description="Package name for scripts", default="arm") bpy.types.World.arm_play_active_scene = BoolProperty(name="Play Active Scene", description="Load currently edited scene when launching player", default=True) @@ -264,6 +263,7 @@ def init_properties(): bpy.types.World.force_no_culling = bpy.props.BoolProperty(name="Force No Culling", default=False) bpy.types.World.force_anisotropic_filtering = bpy.props.BoolProperty(name="Force Anisotropic Filtering", default=True) bpy.types.World.npot_texture_repeat = bpy.props.BoolProperty(name="Non-Power of 2 Texture Repeat", description="Enable texture repeat mode for non-power of two textures", default=False) + bpy.types.World.tessellation_enabled = bpy.props.BoolProperty(name="Tessellation", description="Enable tessellation for height maps on supported targets", default=True) # Lighting flags bpy.types.World.diffuse_oren_nayar = bpy.props.BoolProperty(name="Oren Nayar Diffuse", default=False, update=assets.invalidate_shader_cache) bpy.types.World.voxelgi = bpy.props.BoolProperty(name="VGI", description="Voxel-based Global Illumination", default=False, update=assets.invalidate_shader_cache) diff --git a/blender/props_ui.py b/blender/props_ui.py index 14992946..be0dd9d2 100644 --- a/blender/props_ui.py +++ b/blender/props_ui.py @@ -332,8 +332,9 @@ class WorldPropsPanel(bpy.types.Panel): layout.prop(wrd, 'generate_fog_amountb') layout.label('Flags') - layout.prop(wrd, 'force_no_culling') + layout.prop(wrd, 'tessellation_enabled') layout.prop(wrd, 'force_anisotropic_filtering') + layout.prop(wrd, 'force_no_culling') layout.prop(wrd, 'npot_texture_repeat') layout.prop(wrd, 'diffuse_oren_nayar') layout.prop(wrd, 'voxelgi') @@ -427,7 +428,7 @@ class ArmoryProjectPanel(bpy.types.Panel): layout.prop_search(wrd, 'arm_khafile', bpy.data, 'texts', 'Khafile') layout.prop_search(wrd, 'arm_command_line', bpy.data, 'texts', 'Command Line') layout.operator('arm.publish') - layout.prop(wrd, 'arm_publish_target') + layout.prop(wrd, 'arm_project_target') layout.prop(wrd, 'arm_project_advanced') if wrd.arm_project_advanced: diff --git a/blender/write_data.py b/blender/write_data.py index b16cf109..be70f24b 100755 --- a/blender/write_data.py +++ b/blender/write_data.py @@ -2,6 +2,7 @@ import bpy import os import assets import armutils +import make_state as state def add_armory_library(sdk_path, name): return ('project.addLibrary("../' + bpy.path.relpath(sdk_path + '/' + name)[2:] + '");\n').replace('\\', '/') @@ -31,10 +32,10 @@ project.addSources('Sources'); if export_physics: f.write("project.addDefine('arm_physics');\n") f.write(add_armory_library(sdk_path + '/lib/', 'haxebullet')) - # TODO: include for js only - ammojs_path = sdk_path + '/lib/haxebullet/js/ammo/ammo.js' - ammojs_path = ammojs_path.replace('\\', '/') - f.write("project.addAssets('" + ammojs_path + "');\n") + if state.target == 'krom' or state.target == 'html5': + ammojs_path = sdk_path + '/lib/haxebullet/js/ammo/ammo.js' + ammojs_path = ammojs_path.replace('\\', '/') + f.write("project.addAssets('" + ammojs_path + "');\n") if dce_full: f.write("project.addParameter('-dce full');")