Skip to content

Commit

Permalink
Add more collision shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
Giwayume committed Jun 15, 2022
1 parent a682d24 commit 09607c6
Show file tree
Hide file tree
Showing 87 changed files with 1,236 additions and 7 deletions.
443 changes: 443 additions & 0 deletions Config/BlueprintProfiles.gd

Large diffs are not rendered by default.

64 changes: 63 additions & 1 deletion SceneComponents/CustomMesh/CPratform.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,67 @@ extends CustomCollisionMesh

# Called when the node enters the scene tree for the first time.
func create_collision_area():
generate_cube(.3, .3, .5)

var static_mesh = ""
if definition.has("static_mesh_asset_path"):
static_mesh = definition.static_mesh_asset_path

if static_mesh == "BloodstainedRotN/Content/Core/Environment/ACT02_VIL/Meshes/VillageBridge.uasset":
generate_village_bridge()
else:
generate_cube(.3, .3, .5)
.create_collision_area()

func generate_village_bridge():
var depth = 6
var halfdepth = depth / 2

var area = Area.new()
area.set_script(node_selection_area_script)
area.selectable_parent = self
var collision_polygon = CollisionPolygon.new()
collision_polygon.polygon = PoolVector2Array([
Vector2(0, 0),
Vector2(0, .6),
Vector2(.139095, .460957),
Vector2(2.94865, -1.78992),
Vector2(2.8361, -1.93039),
Vector2(.425754, 0)
])
collision_polygon.depth = depth
collision_polygon.transform.origin = Vector3(0, 0, 0)
area.add_child(collision_polygon)
collision_area = area

var cv = ImmediateGeometry.new()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(0, 0, -halfdepth))
cv.add_vertex(Vector3(0, .6, -halfdepth))
cv.add_vertex(Vector3(0.139095, 0.460957, -halfdepth))
cv.add_vertex(Vector3(2.94865, -1.78992, -halfdepth))
cv.add_vertex(Vector3(2.8361, -1.93039, -halfdepth))
cv.add_vertex(Vector3(.425754, 0, -halfdepth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(0, 0, halfdepth))
cv.add_vertex(Vector3(0, .6, halfdepth))
cv.add_vertex(Vector3(0.139095, 0.460957, halfdepth))
cv.add_vertex(Vector3(2.94865, -1.78992, halfdepth))
cv.add_vertex(Vector3(2.8361, -1.93039, halfdepth))
cv.add_vertex(Vector3(.425754, 0, halfdepth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINES)
cv.add_vertex(Vector3(0, 0, halfdepth))
cv.add_vertex(Vector3(0, 0, -halfdepth))
cv.add_vertex(Vector3(0, .6, halfdepth))
cv.add_vertex(Vector3(0, .6, -halfdepth))
cv.add_vertex(Vector3(0.139095, 0.460957, halfdepth))
cv.add_vertex(Vector3(0.139095, 0.460957, -halfdepth))
cv.add_vertex(Vector3(2.94865, -1.78992, halfdepth))
cv.add_vertex(Vector3(2.94865, -1.78992, -halfdepth))
cv.add_vertex(Vector3(2.8361, -1.93039, halfdepth))
cv.add_vertex(Vector3(2.8361, -1.93039, -halfdepth))
cv.add_vertex(Vector3(.425754, 0, halfdepth))
cv.add_vertex(Vector3(.425754, 0, -halfdepth))
cv.end()
collision_visualization = cv
232 changes: 226 additions & 6 deletions SceneComponents/CustomMesh/CustomCollisionMesh.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func on_3d_model_loaded(new_loaded_model):
func create_collision_area():
# Child class creates area & visualization first

collision_area.set_script(node_selection_area_script)
collision_area.selectable_parent = self
collision_area.name = "CollisionArea"
collision_area.collision_layer = PhysicsLayers3d.layers.editor_select_collider
collision_area.collision_mask = PhysicsLayers3d.layers.none
Expand Down Expand Up @@ -71,8 +73,6 @@ func set_hidden(hidden: bool):

func generate_cube(wx, wz, h):
var area = Area.new()
area.set_script(node_selection_area_script)
area.selectable_parent = self
var collision_shape = CollisionShape.new()
var box_shape = BoxShape.new()
box_shape.extents = Vector3(wx, h, wz)
Expand Down Expand Up @@ -116,8 +116,6 @@ func generate_cube(wx, wz, h):

func generate_wedge_slope(wx, wz, h):
var area = Area.new()
area.set_script(node_selection_area_script)
area.selectable_parent = self
var collision_polygon = CollisionPolygon.new()
collision_polygon.polygon = PoolVector2Array([
Vector2(0, 0),
Expand Down Expand Up @@ -155,8 +153,6 @@ func generate_wedge_slope(wx, wz, h):

func generate_box_slope(wx, wz, hl, hr):
var area = Area.new()
area.set_script(node_selection_area_script)
area.selectable_parent = self
var collision_shape = CollisionShape.new()
var box_shape = BoxShape.new()
box_shape.extents = Vector3(wx / 2, min(hl, hr) / 2, -wz / 2)
Expand Down Expand Up @@ -207,3 +203,227 @@ func generate_box_slope(wx, wz, hl, hr):
cv.end()
collision_visualization = cv

func generate_sectioned_slope_2(s1, s2, depth):
var area = Area.new()
area.set_script(node_selection_area_script)
area.selectable_parent = self
var collision_polygon = CollisionPolygon.new()
collision_polygon.polygon = PoolVector2Array([
Vector2(0, 0),
Vector2(.6, s1),
Vector2(1.2, s2),
Vector2(1.2, 0.0),
Vector2(0.6, 0.0)
])
collision_polygon.depth = depth
collision_polygon.transform.origin = Vector3(0, 0, -depth/2)
area.add_child(collision_polygon)
collision_area = area

var cv = ImmediateGeometry.new()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(0, 0, 0))
cv.add_vertex(Vector3(0.6, s1, 0))
cv.add_vertex(Vector3(0.6, s1, -depth))
cv.add_vertex(Vector3(0, 0, -depth))
cv.add_vertex(Vector3(0, 0, 0))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(0.6, s1, 0))
cv.add_vertex(Vector3(1.2, s2, 0))
cv.add_vertex(Vector3(1.2, s2, -depth))
cv.add_vertex(Vector3(0.6, s1, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(1.2, s2, 0))
cv.add_vertex(Vector3(1.2, 0, 0))
cv.add_vertex(Vector3(0, 0, 0))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(1.2, s2, -depth))
cv.add_vertex(Vector3(1.2, 0, -depth))
cv.add_vertex(Vector3(0, 0, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(1.2, 0, 0))
cv.add_vertex(Vector3(1.2, 0, -depth))
cv.end()
collision_visualization = cv

func generate_sectioned_slope_3(s1, s2, s3, depth):
var area = Area.new()
area.set_script(node_selection_area_script)
area.selectable_parent = self
var collision_polygon = CollisionPolygon.new()
collision_polygon.polygon = PoolVector2Array([
Vector2(0, 0),
Vector2(.6, s1),
Vector2(1.2, s2),
Vector2(1.8, s3),
Vector2(1.8, 0.0),
Vector2(1.2, 0.0),
Vector2(0.6, 0.0)
])
collision_polygon.depth = depth
collision_polygon.transform.origin = Vector3(0, 0, -depth/2)
area.add_child(collision_polygon)
collision_area = area

var cv = ImmediateGeometry.new()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(0, 0, 0))
cv.add_vertex(Vector3(0.6, s1, 0))
cv.add_vertex(Vector3(0.6, s1, -depth))
cv.add_vertex(Vector3(0, 0, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(0.6, s1, 0))
cv.add_vertex(Vector3(1.2, s2, 0))
cv.add_vertex(Vector3(1.2, s2, -depth))
cv.add_vertex(Vector3(0.6, s1, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(1.2, s2, 0))
cv.add_vertex(Vector3(1.8, s3, 0))
cv.add_vertex(Vector3(1.8, s3, -depth))
cv.add_vertex(Vector3(1.2, s2, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(1.8, s3, 0))
cv.add_vertex(Vector3(1.8, 0, 0))
cv.add_vertex(Vector3(0, 0, 0))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(1.8, s3, -depth))
cv.add_vertex(Vector3(1.8, 0, -depth))
cv.add_vertex(Vector3(0, 0, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(1.8, 0, 0))
cv.add_vertex(Vector3(1.8, 0, -depth))
cv.end()
collision_visualization = cv

func generate_sectioned_slope_4(s1, s2, s3, s4, depth):
var area = Area.new()
area.set_script(node_selection_area_script)
area.selectable_parent = self
var collision_polygon = CollisionPolygon.new()
collision_polygon.polygon = PoolVector2Array([
Vector2(0, 0),
Vector2(.6, s1),
Vector2(1.2, s2),
Vector2(1.8, s3),
Vector2(2.4, s4),
Vector2(2.4, 0.0),
Vector2(1.8, 0.0),
Vector2(1.2, 0.0),
Vector2(0.6, 0.0)
])
collision_polygon.depth = depth
collision_polygon.transform.origin = Vector3(0, 0, -depth/2)
area.add_child(collision_polygon)
collision_area = area

var cv = ImmediateGeometry.new()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(0, 0, 0))
cv.add_vertex(Vector3(0.6, s1, 0))
cv.add_vertex(Vector3(0.6, s1, -depth))
cv.add_vertex(Vector3(0, 0, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(0.6, s1, 0))
cv.add_vertex(Vector3(1.2, s2, 0))
cv.add_vertex(Vector3(1.2, s2, -depth))
cv.add_vertex(Vector3(0.6, s1, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(1.2, s2, 0))
cv.add_vertex(Vector3(1.8, s3, 0))
cv.add_vertex(Vector3(1.8, s3, -depth))
cv.add_vertex(Vector3(1.2, s2, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(1.8, s3, 0))
cv.add_vertex(Vector3(2.4, s4, 0))
cv.add_vertex(Vector3(2.4, s4, -depth))
cv.add_vertex(Vector3(1.8, s3, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(2.4, s4, 0))
cv.add_vertex(Vector3(2.4, 0, 0))
cv.add_vertex(Vector3(0, 0, 0))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(2.4, s4, -depth))
cv.add_vertex(Vector3(2.4, 0, -depth))
cv.add_vertex(Vector3(0, 0, -depth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_STRIP)
cv.add_vertex(Vector3(2.4, 0, 0))
cv.add_vertex(Vector3(2.4, 0, -depth))
cv.end()
collision_visualization = cv

func generate_octagon(ix, ox, h, depth):
var halfdepth = depth / 2
var area = Area.new()
area.set_script(node_selection_area_script)
area.selectable_parent = self
var collision_polygon = CollisionPolygon.new()
collision_polygon.polygon = PoolVector2Array([
Vector2(-ox, h),
Vector2(-ix, h + .6),
Vector2(ix, h + .6),
Vector2(ox, h),
Vector2(ox, 0),
Vector2(ix, -.6),
Vector2(-ix, -.6),
Vector2(-ox, 0)
])
collision_polygon.depth = depth
collision_polygon.transform.origin = Vector3(0, 0, 0)
area.add_child(collision_polygon)
collision_area = area

var cv = ImmediateGeometry.new()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(-ox, h, -halfdepth))
cv.add_vertex(Vector3(-ix, h + .6, -halfdepth))
cv.add_vertex(Vector3(ix, h + .6, -halfdepth))
cv.add_vertex(Vector3(ox, h, -halfdepth))
cv.add_vertex(Vector3(ox, 0, -halfdepth))
cv.add_vertex(Vector3(ix, -.6, -halfdepth))
cv.add_vertex(Vector3(-ix, -.6, -halfdepth))
cv.add_vertex(Vector3(-ox, 0, -halfdepth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINE_LOOP)
cv.add_vertex(Vector3(-ox, h, halfdepth))
cv.add_vertex(Vector3(-ix, h + .6, halfdepth))
cv.add_vertex(Vector3(ix, h + .6, halfdepth))
cv.add_vertex(Vector3(ox, h, halfdepth))
cv.add_vertex(Vector3(ox, 0, halfdepth))
cv.add_vertex(Vector3(ix, -.6, halfdepth))
cv.add_vertex(Vector3(-ix, -.6, halfdepth))
cv.add_vertex(Vector3(-ox, 0, halfdepth))
cv.end()
cv.begin(Mesh.PRIMITIVE_LINES)
cv.add_vertex(Vector3(-ox, h, halfdepth))
cv.add_vertex(Vector3(-ox, h, -halfdepth))
cv.add_vertex(Vector3(-ix, h + .6, halfdepth))
cv.add_vertex(Vector3(-ix, h + .6, -halfdepth))
cv.add_vertex(Vector3(ix, h + .6, halfdepth))
cv.add_vertex(Vector3(ix, h + .6, -halfdepth))
cv.add_vertex(Vector3(ox, h, halfdepth))
cv.add_vertex(Vector3(ox, h, -halfdepth))
cv.add_vertex(Vector3(ox, 0, halfdepth))
cv.add_vertex(Vector3(ox, 0, -halfdepth))
cv.add_vertex(Vector3(ix, -.6, halfdepth))
cv.add_vertex(Vector3(ix, -.6, -halfdepth))
cv.add_vertex(Vector3(-ix, -.6, halfdepth))
cv.add_vertex(Vector3(-ix, -.6, -halfdepth))
cv.add_vertex(Vector3(-ox, 0, halfdepth))
cv.add_vertex(Vector3(-ox, 0, -halfdepth))
cv.end()
collision_visualization = cv
6 changes: 6 additions & 0 deletions SceneComponents/CustomMesh/PBMrBlockNature_1_1.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends CustomCollisionMesh

# Called when the node enters the scene tree for the first time.
func create_collision_area():
generate_octagon(.3, 1.5, .6, 6)
.create_collision_area()
6 changes: 6 additions & 0 deletions SceneComponents/CustomMesh/PBMrBlockNature_1_1.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://SceneComponents/CustomMesh/PBMrBlockNature_1_1.gd" type="Script" id=1]

[node name="PBMrBlockNature_1_1" type="Spatial"]
script = ExtResource( 1 )
6 changes: 6 additions & 0 deletions SceneComponents/CustomMesh/PBMrBlockNature_1_2.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends CustomCollisionMesh

# Called when the node enters the scene tree for the first time.
func create_collision_area():
generate_octagon(.6, 1.8, .6, 6)
.create_collision_area()
6 changes: 6 additions & 0 deletions SceneComponents/CustomMesh/PBMrBlockNature_1_2.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://SceneComponents/CustomMesh/PBMrBlockNature_1_2.gd" type="Script" id=1]

[node name="PBMrBlockNature_1_2" type="Spatial"]
script = ExtResource( 1 )
6 changes: 6 additions & 0 deletions SceneComponents/CustomMesh/PBMrBlockNature_1_3.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends CustomCollisionMesh

# Called when the node enters the scene tree for the first time.
func create_collision_area():
generate_octagon(.9, 2.1, .6, 6)
.create_collision_area()
6 changes: 6 additions & 0 deletions SceneComponents/CustomMesh/PBMrBlockNature_1_3.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://SceneComponents/CustomMesh/PBMrBlockNature_1_3.gd" type="Script" id=1]

[node name="PBMrBlockNature_1_3" type="Spatial"]
script = ExtResource( 1 )
6 changes: 6 additions & 0 deletions SceneComponents/CustomMesh/PBMrBlockNature_2_1.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends CustomCollisionMesh

# Called when the node enters the scene tree for the first time.
func create_collision_area():
generate_octagon(.3, 1.5, 1.2, 6)
.create_collision_area()
6 changes: 6 additions & 0 deletions SceneComponents/CustomMesh/PBMrBlockNature_2_1.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://SceneComponents/CustomMesh/PBMrBlockNature_2_1.gd" type="Script" id=1]

[node name="PBMrBlockNature_2_1" type="Spatial"]
script = ExtResource( 1 )
6 changes: 6 additions & 0 deletions SceneComponents/CustomMesh/PBMrBlockNature_2_2.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends CustomCollisionMesh

# Called when the node enters the scene tree for the first time.
func create_collision_area():
generate_octagon(.6, 1.8, 1.2, 6)
.create_collision_area()
Loading

0 comments on commit 09607c6

Please sign in to comment.