mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
Merge branch 'main' into dev
This commit is contained in:
commit
6b4d5b868a
5 changed files with 24 additions and 18 deletions
|
|
@ -180,7 +180,6 @@ bool PhysicsSolver::calcCollisionNegY(
|
|||
if (vel.y >= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
hitbox.groundVelocity = {};
|
||||
for (int ix = 0; ix <= glm::ceil((half.x - E) * 2); ix++) {
|
||||
glm::vec3 coord;
|
||||
coord.x = (pos.x - half.x + E) + ix;
|
||||
|
|
@ -202,6 +201,7 @@ bool PhysicsSolver::calcCollisionNegY(
|
|||
vel.y = -hitbox.elasticity * vel.y;
|
||||
pos.y = newy;
|
||||
}
|
||||
hitbox.groundVelocity = {};
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -398,6 +398,10 @@ void PhysicsSolver::step(
|
|||
for (auto hitbox : hitboxes) {
|
||||
float linearDamping = hitbox->linearDamping;
|
||||
|
||||
if (hitbox->grounded) {
|
||||
linearDamping = 10.0f; // TODO: add friction to material
|
||||
}
|
||||
|
||||
glm::vec3& vel = hitbox->velocity;
|
||||
auto diff = hitbox->groundVelocity - vel;
|
||||
vel.x += diff.x * delta * linearDamping;
|
||||
|
|
@ -407,7 +411,7 @@ void PhysicsSolver::step(
|
|||
vel.y /= 1.0f + delta * linearDamping * hitbox->verticalDamping;
|
||||
}
|
||||
if (!hitbox->grounded) {
|
||||
hitbox->groundVelocity = {};
|
||||
hitbox->groundVelocity *= 1.0f - delta;
|
||||
}
|
||||
|
||||
updateSensors(*hitbox);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
static std::locale locale("en_US.UTF-8");
|
||||
|
||||
std::string util::escape(std::string_view s, bool escapeUnicode) {
|
||||
std::stringstream ss;
|
||||
ss << '"';
|
||||
|
|
@ -507,39 +509,34 @@ double util::parse_double(const std::string& str, size_t offset, size_t len) {
|
|||
|
||||
std::wstring util::lower_case(const std::wstring& str) {
|
||||
std::wstring result = str;
|
||||
static const std::locale loc("");
|
||||
for (uint i = 0; i < result.length(); i++) {
|
||||
result[i] = static_cast<wchar_t>(std::tolower(str[i], loc));
|
||||
result[i] = static_cast<wchar_t>(std::tolower(str[i], locale));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring util::upper_case(const std::wstring& str) {
|
||||
std::wstring result = str;
|
||||
static const std::locale loc("");
|
||||
for (uint i = 0; i < result.length(); i++) {
|
||||
result[i] = static_cast<wchar_t>(std::toupper(str[i], loc));
|
||||
result[i] = static_cast<wchar_t>(std::toupper(str[i], locale));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring util::capitalized(const std::wstring& str) {
|
||||
if (str.empty()) return str;
|
||||
static const std::locale loc("");
|
||||
return std::wstring({static_cast<wchar_t>(std::toupper(str[0], loc))}) +
|
||||
return std::wstring({static_cast<wchar_t>(std::toupper(str[0], locale))}) +
|
||||
str.substr(1);
|
||||
}
|
||||
|
||||
std::string util::capitalized(const std::string& str) {
|
||||
if (str.empty()) return str;
|
||||
static const std::locale loc("");
|
||||
return std::string({static_cast<char>(std::toupper(str[0], loc))}) +
|
||||
return std::string({static_cast<char>(std::toupper(str[0], locale))}) +
|
||||
str.substr(1);
|
||||
}
|
||||
|
||||
std::wstring util::pascal_case(const std::wstring& str) {
|
||||
if (str.empty()) return str;
|
||||
static const std::locale loc("");
|
||||
std::wstring result = str;
|
||||
bool upper = true;
|
||||
for (uint i = 0; i < result.length(); i++) {
|
||||
|
|
@ -547,7 +544,7 @@ std::wstring util::pascal_case(const std::wstring& str) {
|
|||
if (c <= ' ') {
|
||||
upper = true;
|
||||
} else if (upper) {
|
||||
result[i] = static_cast<wchar_t>(std::toupper(str[i], loc));
|
||||
result[i] = static_cast<wchar_t>(std::toupper(str[i], locale));
|
||||
upper = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue