-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(+ mono and (visual) shader integration)
- Loading branch information
Showing
85 changed files
with
3,845 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/*************************************************************************/ | ||
/* vector4.cpp */ | ||
/*************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/*************************************************************************/ | ||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ | ||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/*************************************************************************/ | ||
|
||
#include "vector4.h" | ||
|
||
#include "core/math/basis.h" | ||
#include "core/string/ustring.h" | ||
|
||
void Vector4::set_axis(const int p_axis, const real_t p_value) { | ||
ERR_FAIL_INDEX(p_axis, AXIS_COUNT); | ||
coord[p_axis] = p_value; | ||
} | ||
|
||
real_t Vector4::get_axis(const int p_axis) const { | ||
ERR_FAIL_INDEX_V(p_axis, AXIS_COUNT, 0); | ||
return operator[](p_axis); | ||
} | ||
|
||
Vector4 Vector4::clamp(const Vector4 &p_min, const Vector4 &p_max) const { | ||
return Vector4( | ||
CLAMP(x, p_min.x, p_max.x), | ||
CLAMP(y, p_min.y, p_max.y), | ||
CLAMP(z, p_min.z, p_max.z), | ||
CLAMP(w, p_min.w, p_max.w)); | ||
} | ||
|
||
void Vector4::snap(const Vector4 p_step) { | ||
x = Math::snapped(x, p_step.x); | ||
y = Math::snapped(y, p_step.y); | ||
z = Math::snapped(z, p_step.z); | ||
w = Math::snapped(w, p_step.w); | ||
} | ||
|
||
Vector4 Vector4::snapped(const Vector4 p_step) const { | ||
Vector4 v = *this; | ||
v.snap(p_step); | ||
return v; | ||
} | ||
|
||
Vector4 Vector4::limit_length(const real_t p_len) const { | ||
const real_t l = length(); | ||
Vector4 v = *this; | ||
if (l > 0 && p_len < l) { | ||
v /= l; | ||
v *= p_len; | ||
} | ||
|
||
return v; | ||
} | ||
|
||
Vector4 Vector4::cubic_interpolate(const Vector4 &p_b, const Vector4 &p_pre_a, const Vector4 &p_post_b, const real_t p_weight) const { | ||
Vector4 res = *this; | ||
res.x = Math::cubic_interpolate(res.x, p_b.x, p_pre_a.x, p_post_b.x, p_weight); | ||
res.y = Math::cubic_interpolate(res.y, p_b.y, p_pre_a.y, p_post_b.y, p_weight); | ||
res.z = Math::cubic_interpolate(res.z, p_b.z, p_pre_a.z, p_post_b.z, p_weight); | ||
res.w = Math::cubic_interpolate(res.w, p_b.w, p_pre_a.w, p_post_b.w, p_weight); | ||
return res; | ||
} | ||
|
||
Vector4 Vector4::move_toward(const Vector4 &p_to, const real_t p_delta) const { | ||
Vector4 v = *this; | ||
Vector4 vd = p_to - v; | ||
real_t len = vd.length(); | ||
return len <= p_delta || len < (real_t)CMP_EPSILON ? p_to : v + vd / len * p_delta; | ||
} | ||
|
||
bool Vector4::is_equal_approx(const Vector4 &p_v) const { | ||
return Math::is_equal_approx(x, p_v.x) && Math::is_equal_approx(y, p_v.y) && Math::is_equal_approx(z, p_v.z) && Math::is_equal_approx(w, p_v.w); | ||
} | ||
|
||
Vector4::operator String() const { | ||
return "(" + String::num_real(x, false) + ", " + String::num_real(y, false) + ", " + String::num_real(z, false) + ", " + String::num_real(w, false) + ")"; | ||
} |
Oops, something went wrong.