From c48761ef209707e9a68ce195f04221307ba1cf06 Mon Sep 17 00:00:00 2001 From: JariKo Date: Thu, 29 Oct 2026 12:47:09 +0200 Subject: [PATCH] Make F5 incremental and reduce iron maiden geometry, physics and idle updates --- Demon_v0.19/README_RU.md | 2 +- Demon_v0.19/apparatus_motion.gd | 18 +++-- Demon_v0.19/development.gd | 6 +- Demon_v0.19/economy_tests.gd | 21 +++--- Demon_v0.19/iron_maiden.gd | 1 + Demon_v0.19/iron_maiden_tests.gd | 12 ++++ Demon_v0.19/life.gd | 7 ++ Demon_v0.19/maiden_interior.gd | 55 ++++++++++++---- Demon_v0.19/maiden_performance_tests.gd | 88 +++++++++++++++++++++++++ Demon_v0.19/main.gd | 7 +- Demon_v0.19/mesh_walking.gd | 2 + Demon_v0.19/mesh_walking_tests.gd | 2 +- Demon_v0.19/tests.gd | 13 ++-- HANDOFF.md | 33 ++++++++++ 14 files changed, 231 insertions(+), 36 deletions(-) create mode 100644 Demon_v0.19/maiden_performance_tests.gd diff --git a/Demon_v0.19/README_RU.md b/Demon_v0.19/README_RU.md index bc63a9b..2b4cb07 100644 --- a/Demon_v0.19/README_RU.md +++ b/Demon_v0.19/README_RU.md @@ -18,7 +18,7 @@ Запуск: Demon.exe. Godot для игры устанавливать не нужно. -F5 — добавить 1000 золота, выставить максимальный опыт (уровень 10) и заполнить запас душ до 10 000 000. Повторные нажатия не дублируют очки навыков. +F5 — добавить 1000 золота, 1000 душ и один уровень (до уровня 10). За новый уровень даётся одно очко навыков; на максимальном уровне добавляются только валюты. Удержание клавиши не повторяет бонус. - Внизу появилась полоса опыта с уровнем и свободными очками навыков. - За золото покупаются новые типы орудий и их экземпляры. Улучшения, закалка и ранги орудий удалены из гримуара, строительства и расчёта наград. diff --git a/Demon_v0.19/apparatus_motion.gd b/Demon_v0.19/apparatus_motion.gd index af2ef90..8a188ad 100644 --- a/Demon_v0.19/apparatus_motion.gd +++ b/Demon_v0.19/apparatus_motion.gd @@ -6,6 +6,7 @@ var ropes=[] var heat_materials=[] var heat_light: OmniLight3D var heat=0.0 +var applied_heat=-1.0 var tension=0.0 var submerged=false var splash_count=0 @@ -57,6 +58,17 @@ func setup(game,development): func reset(): tension=0;heat=0;submerged=false + if d.selected==3:apply_heat() + +func apply_heat(): + if is_equal_approx(heat,applied_heat):return + applied_heat=heat + for mat in heat_materials:mat.set_shader_parameter("heat",heat) + heat_light.visible=heat>.001 + if d.device.get_meta("apparatus_model","")=="iron_maiden_v01": + heat_light.light_color=Color("ff2510").lerp(Color("ffad48"),smoothstep(.55,1.0,heat)) + heat_light.light_energy=pow(heat,1.5)*3.2 + else:heat_light.light_energy=heat*0.9 func update(dt,active): var i=g.index_of(g.working) @@ -88,8 +100,4 @@ func update(dt,active): var target=clampf(d.elapsed/3.0,0,1) if i>=0 and d.stage>0 else 0.0 if d.release_clock>0:target=heat heat=move_toward(heat,target,dt*(1.5 if target>heat else 0.3)) - for mat in heat_materials:mat.set_shader_parameter("heat",heat) - if d.device.get_meta("apparatus_model","")=="iron_maiden_v01": - heat_light.light_color=Color("ff2510").lerp(Color("ffad48"),smoothstep(.55,1.0,heat)) - heat_light.light_energy=pow(heat,1.5)*3.2 - else:heat_light.light_energy=heat*0.9 + apply_heat() diff --git a/Demon_v0.19/development.gd b/Demon_v0.19/development.gd index 4f85380..1ae8fda 100644 --- a/Demon_v0.19/development.gd +++ b/Demon_v0.19/development.gd @@ -119,9 +119,9 @@ func reward(amount=20): func test_boost(): g.coins+=1000 - g.essence=preload("res://progression.gd").MAX_RESOURCE - xp=Economy.XP_THRESHOLDS.back() - points=maxi(0,Economy.XP_THRESHOLDS.size()-1-g.speed_level-action_level-leadership) + g.essence+=1000 + var current=Economy.level(xp) + if current9: imp.patrol_angle+=1.05;imp.patrol_age=0;imp.patrol_target=patrol_point(imp) if imp.has("origin"):move_neighbour(imp,imp.patrol_target,dt) else:move_imp(imp,imp.patrol_target,dt) + if profiling:movement_us+=Time.get_ticks_usec()-tick;tick=Time.get_ticks_usec() imp.gait.update(dt,busy and imp.activity_time>0) + if profiling:gait_us+=Time.get_ticks_usec()-tick + if profiling:g.set_meta("life_profile",Vector3(activity_us,movement_us,gait_us)) for i in range(burns.size()-1,-1,-1): var b=burns[i];b.t+=dt for mat in b.materials:mat.set_shader_parameter("progress",b.t/1.7) diff --git a/Demon_v0.19/maiden_interior.gd b/Demon_v0.19/maiden_interior.gd index a8336e5..a47dbb5 100644 --- a/Demon_v0.19/maiden_interior.gd +++ b/Demon_v0.19/maiden_interior.gd @@ -6,6 +6,8 @@ const BRASS=Color("8b6842") const DARK=Color("14171c") var g var outer_metal +static var detail_cache={} +static var lining_cache={} # Regions of the existing Meshy atlas: bare iron and aged brass, with matching PBR maps. const IRON_REGION=Vector4(.41015625,.1875,.0234375,.0234375) const BRASS_REGION=Vector4(.6796875,.5859375,.0234375,.0234375) @@ -16,6 +18,9 @@ func metal(brass=false): return material func line_lining(model): for node in model.find_children("*Lining","MeshInstance3D",true,false): + node.cast_shadow=GeometryInstance3D.SHADOW_CASTING_SETTING_OFF + node.set_meta("no_walk_collision",true) + if lining_cache.has(node.name):node.mesh=lining_cache[node.name];continue var mesh=ArrayMesh.new();var transform=model.global_transform.affine_inverse()*node.global_transform for surface in range(node.mesh.get_surface_count()): var arrays=node.mesh.surface_get_arrays(surface);var uv=PackedVector2Array() @@ -26,6 +31,27 @@ func line_lining(model): mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES,arrays) mesh.surface_set_material(surface,metal()) node.mesh=mesh + lining_cache[node.name]=mesh +func tube(root,a,b,radius,color): + var mesh=CylinderMesh.new();mesh.top_radius=radius;mesh.bottom_radius=radius;mesh.height=a.distance_to(b) + mesh.radial_segments=8;mesh.rings=0 + var node=g.mesh_node(root,mesh,(a+b)*.5,color) + node.quaternion=Quaternion(Vector3.UP,(b-a).normalized()) +func rivet(root,p,size,color): + var mesh=SphereMesh.new();mesh.radius=.5;mesh.height=1;mesh.radial_segments=8;mesh.rings=4 + var node=g.mesh_node(root,mesh,p,color);node.scale=size +func restore_detail(root,title): + if not detail_cache.has(title):return false + for record in detail_cache[title]: + var node=MeshInstance3D.new();node.mesh=record.mesh;node.transform=record.transform + node.set_meta("no_walk_collision",true) + node.cast_shadow=GeometryInstance3D.SHADOW_CASTING_SETTING_OFF;root.add_child(node) + return true +func remember_detail(root,title): + var meshes=[] + for node in root.get_children(): + if node is MeshInstance3D:meshes.append({"mesh":node.mesh,"transform":node.transform}) + detail_cache[title]=meshes func point(height,angle,inset=.012): var shape=PROFILE[0] for j in range(PROFILE.size()-1): @@ -33,25 +59,26 @@ func point(height,angle,inset=.012): shape=PROFILE[j].lerp(PROFILE[j+1],inverse_lerp(PROFILE[j].x,PROFILE[j+1].x,height));break return Vector3(cos(angle)*(shape.y*.86-inset),height,-sin(angle)*(shape.z*.70-inset)) func arc(root,height,a,b,radius,color,inset=.012): - for k in range(20):g.line(root,point(height,lerpf(a,b,float(k)/20),inset),point(height,lerpf(a,b,float(k+1)/20),inset),radius,color) + for k in range(20):tube(root,point(height,lerpf(a,b,float(k)/20),inset),point(height,lerpf(a,b,float(k+1)/20),inset),radius,color) func section(parent,origin,a,b,title): var root=Node3D.new();parent.add_child(root);root.name=title;root.position=-origin + if restore_detail(root,title):return root # Raised steel perimeter, inset brass seams and small round rivets. for h in [.31,.76,1.28,1.80,2.16]: arc(root,h,a+.035,b-.035,.013,IRON) arc(root,h+.027,a+.06,b-.06,.006,BRASS,.018) - for k in range(7):g.ball(root,point(h,lerpf(a+.08,b-.08,float(k)/6),.027),Vector3.ONE*.035,BRASS) + for k in range(7):rivet(root,point(h,lerpf(a+.08,b-.08,float(k)/6),.027),Vector3.ONE*.035,BRASS) for k in range(1,5): var angle=lerpf(a,b,float(k)/5) for j in range(12): var h=.32+j*.151 - g.line(root,point(h,angle,.025),point(h+.151,angle,.025),.010,IRON) + tube(root,point(h,angle,.025),point(h+.151,angle,.025),.010,IRON) # Shallow embossed diamonds on each panel; decoration stays close to the lining. for h in [1.02,1.55,2.00]: var angle=(a+b)*.5;var spread=(b-a)*.13 var corners=[point(h+.11,angle,.035),point(h,angle+spread,.035),point(h-.11,angle,.035),point(h,angle-spread,.035)] - for k in range(4):g.line(root,corners[k],corners[(k+1)%4],.008,BRASS) - g.ball(root,point(h,angle,.039),Vector3.ONE*.043,BRASS) + for k in range(4):tube(root,corners[k],corners[(k+1)%4],.008,BRASS) + rivet(root,point(h,angle,.039),Vector3.ONE*.043,BRASS) for side in [-1,1]: for k in range(24): var u=float(k)/24;var v=float(k+1)/24 @@ -59,8 +86,9 @@ func section(parent,origin,a,b,title): var radius=.115*(1-u)+.018;var next_radius=.115*(1-v)+.018 var p=point(h+sin(t)*radius,angle+side*(spread*.62+cos(t)*radius*spread/.13),.045) var q=point(h+sin(next)*next_radius,angle+side*(spread*.62+cos(next)*next_radius*spread/.13),.045) - g.line(root,p,q,.007,BRASS) + tube(root,p,q,.007,BRASS) merge(root) + remember_detail(root,title) return root func merge(root): # Batch fixed decorations by metal, separately for the body and each moving leaf. @@ -76,7 +104,7 @@ func merge(root): for key in batches: var mesh=batches[key].tool.commit();var mat=metal(batches[key].color==BRASS) mesh.surface_set_material(0,mat) - var node=MeshInstance3D.new();node.mesh=mesh;root.add_child(node) + var node=MeshInstance3D.new();node.mesh=mesh;node.set_meta("no_walk_collision",true);node.cast_shadow=GeometryInstance3D.SHADOW_CASTING_SETTING_OFF;root.add_child(node) func build(game,model,left,right): g=game outer_metal=model.find_child("Body",true,false).mesh.surface_get_material(0) @@ -85,12 +113,13 @@ func build(game,model,left,right): section(left,left.position,PI,PI*1.5,"InnerLeftDetail") section(right,right.position,PI*1.5,TAU,"InnerRightDetail") var floor_root=Node3D.new();model.add_child(floor_root);floor_root.name="InnerGrate" - var plate=g.cylinder(floor_root,Vector3(0,.24,0),.61,.035,DARK);plate.scale.z=.61 - for j in range(-7,8): - var x=j*.072;var reach=sqrt(maxf(0,1-pow(x/.58,2)))*.34 - g.box(floor_root,Vector3(x,.268,0),Vector3(.026,.027,reach*2),IRON) - for z in [-.23,0,.23]:g.box(floor_root,Vector3(0,.259,z),Vector3(1.02,.018,.022),BRASS) - merge(floor_root) + if not restore_detail(floor_root,"InnerGrate"): + var plate=g.cylinder(floor_root,Vector3(0,.24,0),.61,.035,DARK);plate.scale.z=.61 + for j in range(-7,8): + var x=j*.072;var reach=sqrt(maxf(0,1-pow(x/.58,2)))*.34 + g.box(floor_root,Vector3(x,.268,0),Vector3(.026,.027,reach*2),IRON) + for z in [-.23,0,.23]:g.box(floor_root,Vector3(0,.259,z),Vector3(1.02,.018,.022),BRASS) + merge(floor_root);remember_detail(floor_root,"InnerGrate") var bounce=OmniLight3D.new();model.add_child(bounce);bounce.name="InteriorBounce" bounce.position=Vector3(0,1.35,.06);bounce.omni_range=1.65;bounce.light_color=Color("d7ae7d");bounce.light_energy=.32 model.set_meta("interior_detail",true) diff --git a/Demon_v0.19/maiden_performance_tests.gd b/Demon_v0.19/maiden_performance_tests.gd new file mode 100644 index 0000000..00f9743 --- /dev/null +++ b/Demon_v0.19/maiden_performance_tests.gd @@ -0,0 +1,88 @@ +extends RefCounted +var failures=0 +var records=[] +func check(ok,label): + if not ok:failures+=1;push_error("MAIDEN PERFORMANCE QA: "+label) +func sample(g,label,frames=120): + var times=[] + var life_cost=Vector3.ZERO + g.set_meta("profile_life",true) + for frame in range(frames+30): + g.workshop.spawn_clock=-100.0 + var start=Time.get_ticks_usec() + await g.get_tree().process_frame + await RenderingServer.frame_post_draw + if frame>=30: + times.append(float(Time.get_ticks_usec()-start)/1000.0) + life_cost+=g.get_meta("life_profile",Vector3.ZERO) + times.sort() + var record={"phase":label,"median_ms":times[times.size()/2],"p95_ms":times[int(times.size()*.95)], + "process_ms":Performance.get_monitor(Performance.TIME_PROCESS)*1000, + "physics_ms":Performance.get_monitor(Performance.TIME_PHYSICS_PROCESS)*1000, + "nodes":Performance.get_monitor(Performance.OBJECT_NODE_COUNT), + "objects":Performance.get_monitor(Performance.OBJECT_COUNT), + "draws":Performance.get_monitor(Performance.RENDER_TOTAL_DRAW_CALLS_IN_FRAME), + "primitives":Performance.get_monitor(Performance.RENDER_TOTAL_PRIMITIVES_IN_FRAME), + "video_mb":Performance.get_monitor(Performance.RENDER_VIDEO_MEM_USED)/1048576.0, + "burns":g.life.burns.size(),"heat":g.workshop.stations[0].motion.heat if not g.workshop.stations.is_empty() else 0.0, + "imp_activity_ms":life_cost.x/frames/1000,"imp_movement_ms":life_cost.y/frames/1000,"imp_gait_ms":life_cost.z/frames/1000} + records.append(record);print("MAIDEN_PROFILE ",JSON.stringify(record)) + return record +func run(g): + await g.get_tree().create_timer(.3).timeout + g.start_game();g.reset_shift();g.game_started=true;g.paused=false;g.menu.show_page("") + DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED);Engine.max_fps=0 + var w=g.workshop;g.player.position=Vector3(1,0,2);g.camera.size=17 + await sample(g,"empty_room") + var started=Time.get_ticks_usec();var d=w.add_station(3,Vector3(3,0,0)) + w.rebuild_nav() + print("MAIDEN_BUILD_MS ",float(Time.get_ticks_usec()-started)/1000.0) + for mesh in d.device.find_children("*","MeshInstance3D",true,false): + var triangles=0 + for surface in range(mesh.mesh.get_surface_count()): + var arrays=mesh.mesh.surface_get_arrays(surface) + var indices=arrays[Mesh.ARRAY_INDEX] + triangles+=(indices.size() if indices!=null and indices.size()>0 else arrays[Mesh.ARRAY_VERTEX].size())/3 + print("MAIDEN_GEOMETRY ",mesh.get_parent().name,"/",mesh.name," triangles=",triangles) + g.player.position=w.approach(d);g.avatar.reset_gait() + var baseline=await sample(g,"maiden_idle") + var station_nodes=d.device.find_children("*","",true,false).size() + for cycle in range(3): + w.spawn();var soul=g.souls.back();soul.required=[3];soul.entering=false;soul.entry_time=1 + g.set_soul_reveal(soul.visual,1);w.attach(soul,0) + var root=soul.node;var target=g.done+1 + for step in range(24): + w.step_station(d,.1,true) + await g.get_tree().process_frame + if cycle==0:await sample(g,"maiden_hot",45) + for step in range(60): + if d.soul<0:break + w.step_station(d,.1,true) + await g.get_tree().process_frame + check(g.done==target and d.soul<0,"cycle completes once") + # Cleanup must run through the normal game process, including life.update. + w.spawn_clock=-100.0 + await g.get_tree().create_timer(6.5).timeout + check(not is_instance_valid(root) and g.life.burns.is_empty(),"normal frames remove soul and burn effects") + var cooled=await sample(g,"cooled_%d"%cycle) + check(d.motion.heat<.001 and d.motion.heat_light.light_energy<.001,"heat and light return to idle") + check(d.device.find_children("*","",true,false).size()==station_nodes and g.souls.is_empty(),"no accumulating station nodes or souls after repeated cycles") + # Timings are diagnostic: imp activities and thermal clocks change over time. + check(cooled.video_mb