mirror of
https://github.com/godotengine/godot-tests.git
synced 2025-12-31 13:48:10 +03:00
Merge pull request #26 from godotengine/comment-cleanup
Comment cleanup for the cubic interpolate with.
This commit is contained in:
@@ -1,17 +1,6 @@
|
||||
extends Sprite2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
var camera = get_node("../Head/FirstPersonCamera")
|
||||
var firstPerson = get_node("..")
|
||||
|
||||
@@ -5,12 +5,12 @@ extends MeshInstance3D
|
||||
|
||||
var immediate:ImmediateMesh
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
|
||||
func _ready():
|
||||
immediate = ImmediateMesh.new()
|
||||
mesh = immediate
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
||||
func _process(_delta):
|
||||
immediate.clear_surfaces()
|
||||
|
||||
@@ -39,7 +39,6 @@ func _process(_delta):
|
||||
if not postBTipX:
|
||||
return
|
||||
immediate.surface_begin(Mesh.PRIMITIVE_LINE_STRIP, lineMaterial)
|
||||
# immediate.surface_set_color(Color(0, 0, 0))
|
||||
immediate.surface_add_vertex(preATipX.global_transform.origin)
|
||||
immediate.surface_add_vertex(aTipX.global_transform.origin)
|
||||
immediate.surface_add_vertex(bTipX.global_transform.origin)
|
||||
@@ -47,7 +46,6 @@ func _process(_delta):
|
||||
immediate.surface_end()
|
||||
|
||||
immediate.surface_begin(Mesh.PRIMITIVE_LINE_STRIP, lineMaterial)
|
||||
# immediate.surface_set_color(Color(0, 0, 0))
|
||||
immediate.surface_add_vertex(preATipY.global_transform.origin)
|
||||
immediate.surface_add_vertex(aTipY.global_transform.origin)
|
||||
immediate.surface_add_vertex(bTipY.global_transform.origin)
|
||||
@@ -55,7 +53,6 @@ func _process(_delta):
|
||||
immediate.surface_end()
|
||||
|
||||
immediate.surface_begin(Mesh.PRIMITIVE_LINE_STRIP, lineMaterial)
|
||||
# immediate.surface_set_color(Color(0, 0, 0))
|
||||
immediate.surface_add_vertex(preATipZ.global_transform.origin)
|
||||
immediate.surface_add_vertex(aTipZ.global_transform.origin)
|
||||
immediate.surface_add_vertex(bTipZ.global_transform.origin)
|
||||
|
||||
@@ -11,12 +11,12 @@ var tipXHistory = []
|
||||
var tipYHistory = []
|
||||
var tipZHistory = []
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
|
||||
func _ready():
|
||||
immediate = ImmediateMesh.new()
|
||||
mesh = immediate
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
||||
func _process(_delta):
|
||||
var interpolatedTipX = get_node(debugIndicatorPath + "/XAxis/TipEnd")
|
||||
var interpolatedTipY = get_node(debugIndicatorPath + "/YAxis/TipEnd")
|
||||
|
||||
@@ -9,7 +9,6 @@ var camera_angle_x_filtered:float = 0
|
||||
# This makes turning less responsive, but maybe easier to follow
|
||||
# when creating videos etc.
|
||||
const camera_angle_filter_coeff:float = 0.1
|
||||
#const camera_angle_filter_coeff:float = 0.001 #0.01
|
||||
|
||||
enum NavigationMode {
|
||||
NAVMODE_FPS,
|
||||
@@ -58,8 +57,6 @@ func _ready():
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
|
||||
func _physics_process(delta):
|
||||
# var head:Node3D = get_node("Head")
|
||||
|
||||
# Due to physics-process being run only 60 Hz and refresh rate
|
||||
# may differ from that, head is moved "in advance" before
|
||||
# the other parts.
|
||||
@@ -69,17 +66,8 @@ func _physics_process(delta):
|
||||
headDetachment = Vector3() # Start accumulating from zero again
|
||||
var _discard = move_and_slide()
|
||||
|
||||
# Tried to prevent strange jitter with this. Didn't help
|
||||
var lastUptime_us:int = -1
|
||||
|
||||
func _process(delta):
|
||||
# Tried to prevent strange jitter with this. Didn't help
|
||||
# var upTime_us = Time.get_ticks_usec()
|
||||
# var deltaOverride = float(upTime_us - lastUptime_us) / 1e6
|
||||
# if (deltaOverride < 0.1):
|
||||
# delta = deltaOverride
|
||||
# lastUptime_us = upTime_us
|
||||
|
||||
var manipulator = get_node("ManipulatorCollisionShape")
|
||||
var capsule = get_node("Capsule")
|
||||
var manipulatorMeshes = get_node("ManipulatorMeshes")
|
||||
@@ -113,7 +101,6 @@ func _process(delta):
|
||||
direction = Vector3()
|
||||
velocity = Vector3()
|
||||
velocity = Vector3()
|
||||
# accumulatedVelocity = Vector3()
|
||||
camera_change = Vector2()
|
||||
|
||||
return
|
||||
@@ -170,7 +157,6 @@ func fly(delta):
|
||||
|
||||
var correctedCoeff = pow(1 - flyAcceleration, delta)
|
||||
velocity = correctedCoeff * velocity + target * (1 - correctedCoeff)
|
||||
# print(velocity)
|
||||
|
||||
var translation = velocity * delta
|
||||
headDetachment += translation
|
||||
@@ -271,8 +257,6 @@ func aim6DOF(delta):
|
||||
transform.basis = tempBasis.orthonormalized()
|
||||
|
||||
func set_LocationOrientation(newTransform: Transform3D):
|
||||
# TODO: should relay this to _physics_process instead
|
||||
# TODO: 6DOF?
|
||||
transform = newTransform
|
||||
transform.basis = Basis()
|
||||
var newBasis = newTransform.basis
|
||||
@@ -282,6 +266,5 @@ func set_LocationOrientation(newTransform: Transform3D):
|
||||
camera_angle_y_filtered = camera_angle_y_unfiltered
|
||||
rotate_x(deg_to_rad(camera_angle_x_filtered))
|
||||
rotate_y(deg_to_rad(camera_angle_y_filtered))
|
||||
# firstPerson.camera_change = Vector2(0,0)
|
||||
|
||||
|
||||
|
||||
@@ -64,36 +64,26 @@ func loadFile(fileName):
|
||||
if (subStrings.size() >= (1 + (4 * 3))):
|
||||
var replayTime = subStrings[0].to_int() - readTimeShift
|
||||
|
||||
#Coordinates in Godot's native "EUS"-convention:
|
||||
# Coordinates in Godot's native "EUS"-convention:
|
||||
var origin = Vector3(0,0, 0)
|
||||
# var origin = Vector3(subStrings[1].to_float(), subStrings[2].to_float(), subStrings[3].to_float())
|
||||
|
||||
var unitVecX = Vector3(subStrings[4].to_float(), subStrings[5].to_float(), subStrings[6].to_float())
|
||||
var unitVecY = Vector3(subStrings[7].to_float(), subStrings[8].to_float(), subStrings[9].to_float())
|
||||
var unitVecZ = Vector3(subStrings[10].to_float(), subStrings[11].to_float(), subStrings[12].to_float())
|
||||
|
||||
# These convert NED-coordinates to godot's "EUS" on the fly
|
||||
# var origin = Vector3(subStrings[2].to_float(), -subStrings[3].to_float(), -subStrings[1].to_float())
|
||||
# var unitVecX = Vector3(subStrings[5].to_float(), -subStrings[6].to_float(), -subStrings[4].to_float())
|
||||
# var unitVecY = Vector3(subStrings[8].to_float(), -subStrings[9].to_float(), -subStrings[7].to_float())
|
||||
# var unitVecZ = Vector3(subStrings[11].to_float(), -subStrings[12].to_float(), -subStrings[10].to_float())
|
||||
|
||||
var basisTemp = Basis(unitVecX, unitVecY, unitVecZ).orthonormalized()
|
||||
# var tr = Transform(unitVecX, unitVecY, unitVecZ, origin)
|
||||
# print(basisTemp)
|
||||
|
||||
var quat = Quaternion(basisTemp)
|
||||
|
||||
loData[replayTime] = LOItem.new(origin, quat)
|
||||
for _i in range(readLineSkip):
|
||||
# To get sparser data for quaternion interpolation tests
|
||||
# To get sparser data for quaternion interpolation tests.
|
||||
file.get_line()
|
||||
|
||||
loDataKeys = loData.keys()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
# pass
|
||||
|
||||
#func _physics_process(delta):
|
||||
if loData.is_empty():
|
||||
return
|
||||
|
||||
@@ -194,29 +184,15 @@ func _process(_delta):
|
||||
# Causes some strange jitter
|
||||
quat = quat_a.slerpni(quat_b, fraction)
|
||||
QUAT_INTERPOLATION_METHOD.cubic_slerp:
|
||||
# If you want to test the interpolation method in PR
|
||||
# https://github.com/godotengine/godot/pull/63287
|
||||
# use cubic_interpolate-version below:
|
||||
# quat = quat_a.cubic_interpolate(quat_b, quat_pre_a, quat_post_b, fraction)
|
||||
|
||||
# "Traditional" version:
|
||||
quat = quat_a.spherical_cubic_interpolate(quat_b, quat_pre_a, quat_post_b, fraction)
|
||||
_:
|
||||
quat = quat_a
|
||||
|
||||
var basisTemp:Basis = Basis(quat)
|
||||
|
||||
# print("Original basis: ", basis)
|
||||
|
||||
# print("Original basis inverse: ", basis.inverse())
|
||||
|
||||
# Why is .transposed() needed for basis here?
|
||||
# In Godot 3.x (from where this code was copied from) it was not needed.
|
||||
# Addition: Dug a bit deeper with this. It seems that this may be related
|
||||
# to a change how Godot stores Basis (transposed or not). Some info:
|
||||
# https://github.com/godotengine/godot-proposals/issues/2738
|
||||
# Quick test: When printing identically rotated Basis in 3.x and 4.0 dev they
|
||||
# really seem to output differently ordered values.
|
||||
# Can live with this, so...
|
||||
|
||||
transform = Transform3D(basisTemp.transposed(), origin)
|
||||
|
||||
@@ -2,11 +2,7 @@ extends Node3D
|
||||
|
||||
@export var replaySpeed:float = 1
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
|
||||
if Input.is_action_just_pressed("reset_playback"):
|
||||
|
||||
@@ -5,11 +5,7 @@ extends Node3D
|
||||
@export var replayTimeLoopStart = 0
|
||||
@export var replayTimeLoopEnd = 100 * 1000
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
replayTime += delta * 1000 * replaySpeed
|
||||
if (replayTime > replayTimeLoopEnd):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# godot-40592
|
||||
# Cubic interpolate with test.
|
||||
|
||||
Test project from https://github.com/godotengine/godot/issues/40592
|
||||
Test project originally from https://github.com/godotengine/godot/issues/40592
|
||||
|
||||
## Bindings
|
||||
|
||||
|
||||
Reference in New Issue
Block a user