Skip to content

Commit

Permalink
feat(vqm): implement VQM group
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrechette committed Nov 14, 2024
1 parent 233230a commit 8d13ae8
Show file tree
Hide file tree
Showing 5 changed files with 1,258 additions and 0 deletions.
85 changes: 85 additions & 0 deletions includes/rtm/experimental/impl/vqm_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#pragma once

////////////////////////////////////////////////////////////////////////////////
// The MIT License (MIT)
//
// Copyright (c) 2024 Nicholas Frechette & Realtime Math contributors
//
// 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 "rtm/math.h"
#include "rtm/version.h"
#include "rtm/experimental/types.h"
#include "rtm/impl/compiler_utils.h"

RTM_IMPL_FILE_PRAGMA_PUSH

namespace rtm
{
RTM_IMPL_VERSION_NAMESPACE_BEGIN

namespace rtm_impl
{
//////////////////////////////////////////////////////////////////////////
// This is a helper struct to allow a single consistent API between
// various VQM transform types when the semantics are identical but the return
// type differs. Implicit coercion is used to return the desired value
// at the call site.
//////////////////////////////////////////////////////////////////////////
struct vqm_identity_impl
{
RTM_DISABLE_SECURITY_COOKIE_CHECK RTM_FORCE_INLINE RTM_SIMD_CALL operator vqmd() const RTM_NO_EXCEPT
{
vqmd result;
result.rotation = quat_identity();
result.translation = vector_zero();
result.x_axis = vector_set(1.0, 0.0, 0.0, 0.0);
result.y_axis = vector_set(0.0, 1.0, 0.0, 0.0);
result.z_axis = vector_set(0.0, 0.0, 1.0, 0.0);

return result;
}

RTM_DISABLE_SECURITY_COOKIE_CHECK RTM_FORCE_INLINE RTM_SIMD_CALL operator vqmf() const RTM_NO_EXCEPT
{
vqmf result;
result.rotation = quat_identity();
result.translation = vector_zero();
result.x_axis = vector_set(1.0F, 0.0F, 0.0F, 0.0F);
result.y_axis = vector_set(0.0F, 1.0F, 0.0F, 0.0F);
result.z_axis = vector_set(0.0F, 0.0F, 1.0F, 0.0F);

return result;
}
};
}

//////////////////////////////////////////////////////////////////////////
// Returns the identity VQM transform.
//////////////////////////////////////////////////////////////////////////
RTM_DISABLE_SECURITY_COOKIE_CHECK RTM_FORCE_INLINE constexpr rtm_impl::vqm_identity_impl RTM_SIMD_CALL vqm_identity() RTM_NO_EXCEPT
{
return rtm_impl::vqm_identity_impl();
}

RTM_IMPL_VERSION_NAMESPACE_END
}

RTM_IMPL_FILE_PRAGMA_POP
60 changes: 60 additions & 0 deletions includes/rtm/experimental/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#pragma once

////////////////////////////////////////////////////////////////////////////////
// The MIT License (MIT)
//
// Copyright (c) 2024 Nicholas Frechette & Realtime Math contributors
//
// 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 "rtm/math.h"
#include "rtm/version.h"
#include "rtm/impl/compiler_utils.h"

RTM_IMPL_FILE_PRAGMA_PUSH

namespace rtm
{
RTM_IMPL_VERSION_NAMESPACE_BEGIN

struct vqmd
{
// The internal format is meant to be opaque, use vqm_* accessors
quatd rotation;
vector4d translation;
vector4d x_axis;
vector4d y_axis;
vector4d z_axis;
};

struct vqmf
{
// The internal format is meant to be opaque, use vqm_* accessors
quatf rotation;
vector4f translation;
vector4f x_axis;
vector4f y_axis;
vector4f z_axis;
};

RTM_IMPL_VERSION_NAMESPACE_END
}

RTM_IMPL_FILE_PRAGMA_POP
Loading

0 comments on commit 8d13ae8

Please sign in to comment.