Skip to content

File BarycentricCoordinates.h

File List > Amplitude > Math > BarycentricCoordinates.h

Go to the documentation of this file

// Copyright (c) 2024-present Sparky Studios. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#ifndef _AM_MATH_BARYCENTRIC_COORDINATES_H
#define _AM_MATH_BARYCENTRIC_COORDINATES_H

#include <SparkyStudios/Audio/Amplitude/Math/Geometry.h>

namespace SparkyStudios::Audio::Amplitude
{
    struct AM_API_PUBLIC BarycentricCoordinates
    {
        static bool RayTriangleIntersection(
            const AmVector3& rayOrigin, const AmVector3& rayDirection, const Triangle& triangle, BarycentricCoordinates& result);

        BarycentricCoordinates();

        BarycentricCoordinates(const AmVector3& position, const Triangle& triangle);

        [[nodiscard]] bool IsValid() const;

        AmReal32 m_U;

        AmReal32 m_V;

        AmReal32 m_W;
    };
} // namespace SparkyStudios::Audio::Amplitude

#endif // _AM_MATH_BARYCENTRIC_COORDINATES_H