Compare commits
8 Commits
ecdb759206
...
v1.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 516e143901 | |||
| 7e38a43301 | |||
| 3d87e2f885 | |||
| 17b4ec2cde | |||
| cc7dffbb9a | |||
| 5c24fb9fbb | |||
| 318e79a7b4 | |||
| fc7e3e2f44 |
82
.github/workflows/cmake-multi-platform.yml
vendored
Normal file
82
.github/workflows/cmake-multi-platform.yml
vendored
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
|
||||||
|
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
|
||||||
|
name: CMake on multiple platforms
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
|
||||||
|
fail-fast: false
|
||||||
|
|
||||||
|
# Set up a matrix to run the following 3 configurations:
|
||||||
|
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
|
||||||
|
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
|
||||||
|
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
|
||||||
|
#
|
||||||
|
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
build_type: [Release]
|
||||||
|
c_compiler: [gcc, clang, cl]
|
||||||
|
include:
|
||||||
|
- os: windows-latest
|
||||||
|
c_compiler: cl
|
||||||
|
cpp_compiler: cl
|
||||||
|
- os: ubuntu-latest
|
||||||
|
c_compiler: gcc
|
||||||
|
cpp_compiler: g++
|
||||||
|
- os: ubuntu-latest
|
||||||
|
c_compiler: clang
|
||||||
|
cpp_compiler: clang++
|
||||||
|
- os: macos-latest
|
||||||
|
c_compiler: clang
|
||||||
|
cpp_compiler: clang++
|
||||||
|
exclude:
|
||||||
|
- os: windows-latest
|
||||||
|
c_compiler: gcc
|
||||||
|
- os: windows-latest
|
||||||
|
c_compiler: clang
|
||||||
|
- os: ubuntu-latest
|
||||||
|
c_compiler: cl
|
||||||
|
- os: macos-latest
|
||||||
|
c_compiler: gcc
|
||||||
|
- os: macos-latest
|
||||||
|
c_compiler: cl
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set reusable strings
|
||||||
|
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
|
||||||
|
id: strings
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
|
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||||
|
run: >
|
||||||
|
cmake -B ${{ steps.strings.outputs.build-output-dir }}
|
||||||
|
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
|
||||||
|
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
|
||||||
|
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||||
|
-S ${{ github.workspace }}
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
|
||||||
|
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
working-directory: ${{ steps.strings.outputs.build-output-dir }}
|
||||||
|
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
|
||||||
|
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||||
|
run: ctest --build-config ${{ matrix.build_type }}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required (VERSION 3.16)
|
cmake_minimum_required (VERSION 3.16)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// KRAABB.h
|
// KRAABB.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional> // for hash<>
|
#include <functional> // for hash<>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
@@ -53,6 +54,7 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
static AABB Create(const Vector3& minPoint, const Vector3& maxPoint);
|
static AABB Create(const Vector3& minPoint, const Vector3& maxPoint);
|
||||||
static AABB Create(const Vector3& corner1, const Vector3& corner2, const Matrix4& modelMatrix);
|
static AABB Create(const Vector3& corner1, const Vector3& corner2, const Matrix4& modelMatrix);
|
||||||
|
static AABB Create(const AABB& modelSpaceExtents, const Matrix4& modelMatrix);
|
||||||
static AABB Create();
|
static AABB Create();
|
||||||
|
|
||||||
void scale(const Vector3& s);
|
void scale(const Vector3& s);
|
||||||
@@ -69,6 +71,7 @@ public:
|
|||||||
bool intersectsRay(const Vector3& v1, const Vector3& dir) const;
|
bool intersectsRay(const Vector3& v1, const Vector3& dir) const;
|
||||||
bool intersectsSphere(const Vector3& center, float radius) const;
|
bool intersectsSphere(const Vector3& center, float radius) const;
|
||||||
void encapsulate(const AABB& b);
|
void encapsulate(const AABB& b);
|
||||||
|
void encapsulate(const Vector3& v);
|
||||||
|
|
||||||
bool operator ==(const AABB& b) const;
|
bool operator ==(const AABB& b) const;
|
||||||
bool operator !=(const AABB& b) const;
|
bool operator !=(const AABB& b) const;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// hitinfo.h
|
// hitinfo.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
class KRNode;
|
class KRNode;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// hydra.h
|
// hydra.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Matrix2.h
|
// Matrix2.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -28,10 +28,10 @@
|
|||||||
// authors and should not be interpreted as representing official policies, either expressed
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
|
#include <type_traits>
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace hydra {
|
namespace hydra {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Matrix2x3.h
|
// Matrix2x3.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -29,10 +29,11 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
#include <type_traits>
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace hydra {
|
namespace hydra {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Matrix4.h
|
// Matrix4.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -29,11 +29,11 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
#include "vector4.h"
|
#include "vector4.h"
|
||||||
|
#include <type_traits>
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace hydra {
|
namespace hydra {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Quaternion.h
|
// Quaternion.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace hydra {
|
namespace hydra {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// KRFloat.h
|
// KRFloat.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// KRTriangle.h
|
// KRTriangle.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace hydra {
|
namespace hydra {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// vector2.h
|
// vector2.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <functional> // for hash<>
|
#include <functional> // for hash<>
|
||||||
#include <limits> // for std::numeric_limits<>
|
#include <limits> // for std::numeric_limits<>
|
||||||
#include <math.h> // for sqrtf
|
#include <math.h> // for sqrtf
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace hydra {
|
namespace hydra {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// vector2i.h
|
// vector2i.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <functional> // for hash<>
|
#include <functional> // for hash<>
|
||||||
#include <limits> // for std::numeric_limits<>
|
#include <limits> // for std::numeric_limits<>
|
||||||
#include <math.h> // for sqrtf
|
#include <math.h> // for sqrtf
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace hydra {
|
namespace hydra {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Vector3.h
|
// Vector3.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional> // for hash<>
|
#include <functional> // for hash<>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
#include "vector4.h"
|
#include "vector4.h"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Vector3i.h
|
// Vector3i.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional> // for hash<>
|
#include <functional> // for hash<>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include "vector2i.h"
|
#include "vector2i.h"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Vector4.h
|
// Vector4.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2022 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional> // for hash<>
|
#include <functional> // for hash<>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace hydra {
|
namespace hydra {
|
||||||
|
|
||||||
|
|||||||
23
src/aabb.cpp
23
src/aabb.cpp
@@ -2,7 +2,7 @@
|
|||||||
// aabb.cpp
|
// aabb.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "../include/hydra.h"
|
#include "../include/hydra.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "krhelpers.h"
|
#include "krhelpers.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace hydra {
|
namespace hydra {
|
||||||
|
|
||||||
@@ -91,6 +92,13 @@ AABB AABB::Create(const Vector3& corner1, const Vector3& corner2, const Matrix4&
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AABB AABB::Create(const AABB& modelSpaceExtents, const Matrix4& modelMatrix)
|
||||||
|
{
|
||||||
|
AABB r;
|
||||||
|
r.init(modelSpaceExtents.min, modelSpaceExtents.max, modelMatrix);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
bool AABB::operator ==(const AABB& b) const
|
bool AABB::operator ==(const AABB& b) const
|
||||||
{
|
{
|
||||||
return min == b.min && max == b.max;
|
return min == b.min && max == b.max;
|
||||||
@@ -366,9 +374,20 @@ void AABB::encapsulate(const AABB& b)
|
|||||||
if (b.max.z > max.z) max.z = b.max.z;
|
if (b.max.z > max.z) max.z = b.max.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AABB::encapsulate(const Vector3& v)
|
||||||
|
{
|
||||||
|
if (v.x < min.x) min.x = v.x;
|
||||||
|
if (v.y < min.y) min.y = v.y;
|
||||||
|
if (v.z < min.z) min.z = v.z;
|
||||||
|
|
||||||
|
if (v.x > max.x) max.x = v.x;
|
||||||
|
if (v.y > max.y) max.y = v.y;
|
||||||
|
if (v.z > max.z) max.z = v.z;
|
||||||
|
}
|
||||||
|
|
||||||
Vector3 AABB::nearestPoint(const Vector3& v) const
|
Vector3 AABB::nearestPoint(const Vector3& v) const
|
||||||
{
|
{
|
||||||
return Vector3::Create(KRCLAMP(v.x, min.x, max.x), KRCLAMP(v.y, min.y, max.y), KRCLAMP(v.z, min.z, max.z));
|
return Vector3::Create(std::clamp(v.x, min.x, max.x), std::clamp(v.y, min.y, max.y), std::clamp(v.z, min.z, max.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace hydra
|
} // namespace hydra
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// hitinfo.cpp
|
// hitinfo.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// krhelpers.h
|
// krhelpers.h
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -33,9 +33,6 @@
|
|||||||
|
|
||||||
#include "../include/hydra.h"
|
#include "../include/hydra.h"
|
||||||
|
|
||||||
#define KRMIN(x,y) ((x) < (y) ? (x) : (y))
|
|
||||||
#define KRMAX(x,y) ((x) > (y) ? (x) : (y))
|
|
||||||
#define KRCLAMP(x, min, max) (KRMAX(KRMIN(x, max), min))
|
|
||||||
#define KRALIGN(x) ((x + 3) & ~0x03)
|
#define KRALIGN(x) ((x + 3) & ~0x03)
|
||||||
|
|
||||||
float const PI = 3.141592653589793f;
|
float const PI = 3.141592653589793f;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// matrix2.cpp
|
// matrix2.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// matrix23.cpp
|
// matrix23.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// matrix4.cpp
|
// matrix4.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "../include/hydra.h"
|
#include "../include/hydra.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace hydra {
|
namespace hydra {
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// quaternion.cpp
|
// quaternion.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// scalar.cpp
|
// scalar.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// KRTriangle.cpp
|
// KRTriangle.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Vector2.cpp
|
// Vector2.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -291,12 +291,12 @@ float Vector2::Dot(const Vector2& v1, const Vector2& v2)
|
|||||||
|
|
||||||
Vector2 Vector2::Min(const Vector2& v1, const Vector2& v2)
|
Vector2 Vector2::Min(const Vector2& v1, const Vector2& v2)
|
||||||
{
|
{
|
||||||
return Vector2::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y));
|
return Vector2::Create(std::min(v1.x, v2.x), std::min(v1.y, v2.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Vector2::Max(const Vector2& v1, const Vector2& v2)
|
Vector2 Vector2::Max(const Vector2& v1, const Vector2& v2)
|
||||||
{
|
{
|
||||||
return Vector2::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y));
|
return Vector2::Create(std::max(v1.x, v2.x), std::max(v1.y, v2.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namepsace hydra
|
} // namepsace hydra
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Vector2i.cpp
|
// Vector2i.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -285,12 +285,12 @@ int Vector2i::Dot(const Vector2i& v1, const Vector2i& v2)
|
|||||||
|
|
||||||
Vector2i Vector2i::Min(const Vector2i& v1, const Vector2i& v2)
|
Vector2i Vector2i::Min(const Vector2i& v1, const Vector2i& v2)
|
||||||
{
|
{
|
||||||
return Vector2i::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y));
|
return Vector2i::Create(std::min(v1.x, v2.x), std::min(v1.y, v2.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Vector2i::Max(const Vector2i& v1, const Vector2i& v2)
|
Vector2i Vector2i::Max(const Vector2i& v1, const Vector2i& v2)
|
||||||
{
|
{
|
||||||
return Vector2i::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y));
|
return Vector2i::Create(std::max(v1.x, v2.x), std::max(v1.y, v2.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namepsace hydra
|
} // namepsace hydra
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Vector3.cpp
|
// Vector3.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -458,12 +458,12 @@ float Vector3::Dot(const Vector3& v1, const Vector3& v2)
|
|||||||
|
|
||||||
Vector3 Vector3::Min(const Vector3& v1, const Vector3& v2)
|
Vector3 Vector3::Min(const Vector3& v1, const Vector3& v2)
|
||||||
{
|
{
|
||||||
return Vector3::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y), KRMIN(v1.z, v2.z));
|
return Vector3::Create(std::min(v1.x, v2.x), std::min(v1.y, v2.y), std::min(v1.z, v2.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Vector3::Max(const Vector3& v1, const Vector3& v2)
|
Vector3 Vector3::Max(const Vector3& v1, const Vector3& v2)
|
||||||
{
|
{
|
||||||
return Vector3::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y), KRMAX(v1.z, v2.z));
|
return Vector3::Create(std::max(v1.x, v2.x), std::max(v1.y, v2.y), std::max(v1.z, v2.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vector3::operator >(const Vector3& b) const
|
bool Vector3::operator >(const Vector3& b) const
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Vector3i.cpp
|
// Vector3i.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -373,12 +373,12 @@ int Vector3i::Dot(const Vector3i& v1, const Vector3i& v2)
|
|||||||
|
|
||||||
Vector3i Vector3i::Min(const Vector3i& v1, const Vector3i& v2)
|
Vector3i Vector3i::Min(const Vector3i& v1, const Vector3i& v2)
|
||||||
{
|
{
|
||||||
return Vector3i::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y), KRMIN(v1.z, v2.z));
|
return Vector3i::Create(std::min(v1.x, v2.x), std::min(v1.y, v2.y), std::min(v1.z, v2.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3i Vector3i::Max(const Vector3i& v1, const Vector3i& v2)
|
Vector3i Vector3i::Max(const Vector3i& v1, const Vector3i& v2)
|
||||||
{
|
{
|
||||||
return Vector3i::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y), KRMAX(v1.z, v2.z));
|
return Vector3i::Create(std::max(v1.x, v2.x), std::max(v1.y, v2.y), std::max(v1.z, v2.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vector3i::operator >(const Vector3i& b) const
|
bool Vector3i::operator >(const Vector3i& b) const
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Vector4.cpp
|
// Vector4.cpp
|
||||||
// Kraken Engine / Hydra
|
// Kraken Engine / Hydra
|
||||||
//
|
//
|
||||||
// Copyright 2023 Kearwood Gilbert. All rights reserved.
|
// Copyright 2026 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
@@ -351,12 +351,12 @@ float Vector4::Dot(const Vector4& v1, const Vector4& v2)
|
|||||||
|
|
||||||
Vector4 Vector4::Min(const Vector4& v1, const Vector4& v2)
|
Vector4 Vector4::Min(const Vector4& v1, const Vector4& v2)
|
||||||
{
|
{
|
||||||
return Vector4::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y), KRMIN(v1.z, v2.z), KRMIN(v1.w, v2.w));
|
return Vector4::Create(std::min(v1.x, v2.x), std::min(v1.y, v2.y), std::min(v1.z, v2.z), std::min(v1.w, v2.w));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 Vector4::Max(const Vector4& v1, const Vector4& v2)
|
Vector4 Vector4::Max(const Vector4& v1, const Vector4& v2)
|
||||||
{
|
{
|
||||||
return Vector4::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y), KRMAX(v1.z, v2.z), KRMAX(v1.w, v2.w));
|
return Vector4::Create(std::max(v1.x, v2.x), std::max(v1.y, v2.y), std::max(v1.z, v2.z), std::max(v1.w, v2.w));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vector4::operator >(const Vector4& b) const
|
bool Vector4::operator >(const Vector4& b) const
|
||||||
|
|||||||
Reference in New Issue
Block a user