Make F5 incremental and reduce iron maiden geometry, physics and idle updates
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user