Detect navigation

This commit is contained in:
Lubos Lenco 2016-12-07 10:37:08 +01:00
parent bdd1599355
commit 1b03951f54
4 changed files with 12 additions and 4 deletions

View file

@ -2406,6 +2406,7 @@ class ArmoryExporter:
def preprocess(self):
ArmoryExporter.exportAllFlag = True
ArmoryExporter.export_physics = False # Indicates whether rigid body is exported
ArmoryExporter.export_navigation = False
if not hasattr(ArmoryExporter, 'compress_enabled'):
ArmoryExporter.compress_enabled = False
if not hasattr(ArmoryExporter, 'in_viewport'):
@ -2562,6 +2563,7 @@ class ArmoryExporter:
trait_prefix = 'armory.trait.'
# TODO: temporary, export single mesh navmesh as obj
if t.class_name_prop == 'NavMesh' and bobject.type == 'MESH' and bpy.data.worlds['Arm'].arm_navigation != 'Disabled':
ArmoryExporter.export_navigation = True
nav_path = armutils.get_fp() + '/build/compiled/Assets/navigation'
if not os.path.exists(nav_path):
os.makedirs(nav_path)

View file

@ -43,6 +43,7 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
raw_shaders_path = sdk_path + 'armory/Shaders/'
assets_path = sdk_path + 'armory/Assets/'
export_physics = bpy.data.worlds['Arm'].arm_physics != 'Disabled'
export_navigation = bpy.data.worlds['Arm'].arm_navigation != 'Disabled'
assets.reset()
# Build node trees
@ -60,6 +61,7 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
# Export scene data
assets.embedded_data = sorted(list(set(assets.embedded_data)))
physics_found = False
navigation_found = False
ArmoryExporter.compress_enabled = is_publish
ArmoryExporter.in_viewport = in_viewport
for scene in bpy.data.scenes:
@ -69,10 +71,15 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
exporter.execute(bpy.context, asset_path)
if physics_found == False and ArmoryExporter.export_physics:
physics_found = True
if navigation_found == False and ArmoryExporter.export_navigation:
navigation_found = True
assets.add(asset_path)
if physics_found == False: # Disable physics anyway if no rigid body exported
export_physics = False
if navigation_found == False:
export_navigation = False
# Clean compiled variants if cache is disabled
if bpy.data.worlds['Arm'].arm_cache_shaders == False:
@ -115,7 +122,7 @@ def export_data(fp, sdk_path, is_play=False, is_publish=False, in_viewport=False
write_data.write_compiledglsl()
# Write khafile.js
write_data.write_khafilejs(is_play, export_physics, dce_full=is_publish)
write_data.write_khafilejs(is_play, export_physics, export_navigation, dce_full=is_publish)
# Write Main.hx - depends on write_khafilejs for writing number of assets
write_data.write_main(is_play, in_viewport, is_publish)

View file

@ -39,7 +39,7 @@ def init_properties():
bpy.types.World.arm_navigation = EnumProperty(
items = [('Disabled', 'Disabled', 'Disabled'),
('Recast', 'Recast', 'Recast')],
name = "Navigation", default='Disabled')
name = "Navigation", default='Recast')
bpy.types.World.arm_khafile = StringProperty(name = "Khafile", description="Source appended to khafile.js")
bpy.types.World.arm_command_line = StringProperty(name = "Command Line", description="Commands appended to khamake")
bpy.types.World.arm_minimize = BoolProperty(name="Minimize Data", description="Export scene data in binary", default=True, update=assets.invalidate_compiled_data)

View file

@ -8,7 +8,7 @@ def add_armory_library(sdk_path, name):
return ('project.addLibrary("../' + bpy.path.relpath(sdk_path + '/' + name)[2:] + '");\n').replace('\\', '/')
# Write khafile.js
def write_khafilejs(is_play, export_physics, dce_full=False):
def write_khafilejs(is_play, export_physics, export_navigation, dce_full=False):
sdk_path = armutils.get_sdk_path()
@ -37,7 +37,6 @@ project.addSources('Sources');
ammojs_path = ammojs_path.replace('\\', '/')
f.write("project.addAssets('" + ammojs_path + "');\n")
export_navigation = wrd.arm_navigation != 'Disabled'
if export_navigation:
f.write("project.addDefine('arm_navigation');\n")
f.write(add_armory_library(sdk_path + '/lib/', 'haxerecast'))