Compare commits
3 Commits
v1.0.0
...
17b4ec2cde
| Author | SHA1 | Date | |
|---|---|---|---|
| 17b4ec2cde | |||
| cc7dffbb9a | |||
| 5c24fb9fbb |
@@ -2,7 +2,7 @@
|
||||
// KRAABB.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
void init();
|
||||
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 AABB& modelSpaceExtents, const Matrix4& modelMatrix);
|
||||
static AABB Create();
|
||||
|
||||
void scale(const Vector3& s);
|
||||
@@ -69,6 +70,7 @@ public:
|
||||
bool intersectsRay(const Vector3& v1, const Vector3& dir) const;
|
||||
bool intersectsSphere(const Vector3& center, float radius) const;
|
||||
void encapsulate(const AABB& b);
|
||||
void encapsulate(const Vector3& v);
|
||||
|
||||
bool operator ==(const AABB& b) const;
|
||||
bool operator !=(const AABB& b) const;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// hitinfo.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// hydra.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Matrix2.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Matrix2x3.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Matrix4.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Quaternion.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// KRFloat.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// KRTriangle.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// vector2.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// vector2i.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Vector3.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Vector3i.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Vector4.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
20
src/aabb.cpp
20
src/aabb.cpp
@@ -2,7 +2,7 @@
|
||||
// aabb.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
@@ -91,6 +91,13 @@ AABB AABB::Create(const Vector3& corner1, const Vector3& corner2, const Matrix4&
|
||||
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
|
||||
{
|
||||
return min == b.min && max == b.max;
|
||||
@@ -366,6 +373,17 @@ void AABB::encapsulate(const AABB& b)
|
||||
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
|
||||
{
|
||||
return Vector3::Create(KRCLAMP(v.x, min.x, max.x), KRCLAMP(v.y, min.y, max.y), KRCLAMP(v.z, min.z, max.z));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// hitinfo.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// krhelpers.h
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// matrix2.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// matrix23.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// matrix4.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// quaternion.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// scalar.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// KRTriangle.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Vector2.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Vector2i.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Vector3.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Vector3i.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Vector4.cpp
|
||||
// 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
|
||||
// permitted provided that the following conditions are met:
|
||||
|
||||
Reference in New Issue
Block a user