Files
o3de/Gems/WhiteBox/Code/Source/WhiteBoxToolApiReflection.cpp
T
Esteban Papp 1f9b284de2 Merge branch 'development' into cmake/SPEC-7179
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Editor/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin_precompiled.h
#	Code/Editor/Plugins/EditorCommon/EditorCommon_precompiled.h
#	Code/Editor/Plugins/EditorCommon/stdafx.cpp
#	Code/Editor/Plugins/FFMPEGPlugin/FFMPEGPlugin_precompiled.h
#	Code/Editor/Plugins/PerforcePlugin/PerforcePlugin_precompiled.h
#	Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsTool_precompiled.h
#	Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFramework_precompiled.h
#	Code/Tools/AssetProcessor/native/precompiled.h
#	Code/Tools/Standalone/StandaloneTools_precompiled.h
#	Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer_precompiled.h
#	Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageProcessing_precompiled.h
#	Gems/Atom/RHI/DX12/Code/Source/RHI/Atom_RHI_DX12_precompiled.h
#	Gems/Atom/RHI/Metal/Code/Include/Platform/Mac/Atom_RHI_Metal_precompiled_Platform.h
#	Gems/Atom/RHI/Metal/Code/Include/Platform/iOS/Atom_RHI_Metal_precompiled_Platform.h
#	Gems/Atom/RHI/Metal/Code/Source/Atom_RHI_Metal_precompiled.h
#	Gems/Atom/RHI/Metal/Code/atom_rhi_metal_common_files.cmake
#	Gems/Atom/RHI/Null/Code/Source/Atom_RHI_Null_precompiled.h
#	Gems/Atom/RHI/Null/Code/atom_rhi_null_common_files.cmake
#	Gems/Atom/RHI/Vulkan/Code/Include/Platform/Android/Atom_RHI_Vulkan_precompiled_Platform.h
#	Gems/Atom/RHI/Vulkan/Code/Include/Platform/Linux/Atom_RHI_Vulkan_precompiled_Platform.h
#	Gems/Atom/RHI/Vulkan/Code/Include/Platform/Mac/Atom_RHI_Vulkan_precompiled_Platform.h
#	Gems/Atom/RHI/Vulkan/Code/Include/Platform/Windows/Atom_RHI_Vulkan_precompiled_Platform.h
#	Gems/Atom/RHI/Vulkan/Code/Source/Atom_RHI_Vulkan_precompiled.h
#	Gems/Atom/RHI/Vulkan/Code/Source/RHI/SwapChain.cpp
#	Gems/Atom/RHI/Vulkan/Code/atom_rhi_vulkan_common_files.cmake
#	Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/AtomFont_precompiled.h
#	Gems/Blast/Code/Source/StdAfx.cpp
#	Gems/Camera/Code/Source/Camera_precompiled.h
#	Gems/EMotionFX/Code/Source/EMotionFX_precompiled.h
#	Gems/FastNoise/Code/Source/FastNoise_precompiled.h
#	Gems/Gestures/Code/Source/Gestures_precompiled.h
#	Gems/GradientSignal/Code/Source/GradientSignal_precompiled.h
#	Gems/GraphCanvas/Code/precompiled.h
#	Gems/ImGui/Code/Source/ImGui_precompiled.h
#	Gems/InAppPurchases/Code/Source/InAppPurchases_precompiled.h
#	Gems/LmbrCentral/Code/Source/LmbrCentral_precompiled.h
#	Gems/LmbrCentral/Code/Tests/ShapeGeometryUtilTest.cpp
#	Gems/LyShine/Code/Editor/UiCanvasEditor_precompiled.h
#	Gems/LyShine/Code/Source/Animation/LyShine_precompiled.h
#	Gems/LyShine/Code/Source/LyShine_precompiled.h
#	Gems/LyShineExamples/Code/Source/LyShineExamples_precompiled.h
#	Gems/Maestro/Code/Source/Cinematics/Maestro_precompiled.h
#	Gems/Maestro/Code/Source/Maestro_precompiled.h
#	Gems/MessagePopup/Code/Source/MessagePopup_precompiled.h
#	Gems/Metastream/Code/Source/Metastream_precompiled.h
#	Gems/Microphone/Code/Source/Microphone_precompiled.h
#	Gems/Multiplayer/Code/Source/Multiplayer_precompiled.h
#	Gems/PhysX/Code/NumericalMethods/Source/NumericalMethods_precompiled.h
#	Gems/PhysX/Code/Source/PhysXUnsupported_precompiled.h
#	Gems/PhysX/Code/Source/PhysX_precompiled.h
#	Gems/PhysX/Code/physx_unsupported_files.cmake
#	Gems/PhysXDebug/Code/Source/PhysXDebugUnsupported_precompiled.h
#	Gems/PhysXDebug/Code/Source/PhysXDebug_precompiled.h
#	Gems/ScriptCanvas/Code/Editor/precompiled.h
#	Gems/ScriptCanvas/Code/Source/precompiled.h
#	Gems/ScriptCanvasDeveloper/Code/Source/precompiled.h
#	Gems/ScriptCanvasPhysics/Code/Source/ScriptCanvasPhysics_precompiled.h
#	Gems/ScriptEvents/Code/Source/precompiled.h
#	Gems/ScriptEvents/Code/Tests/Editor/EditorTests.cpp
#	Gems/ScriptedEntityTweener/Code/Source/ScriptedEntityTweener_precompiled.h
#	Gems/SliceFavorites/Code/Source/SliceFavorites_precompiled.h
#	Gems/StartingPointCamera/Code/Source/StartingPointCamera_precompiled.h
#	Gems/StartingPointInput/Code/Source/StartingPointInput_precompiled.h
#	Gems/StartingPointMovement/Code/Source/StartingPointMovement_precompiled.h
#	Gems/SurfaceData/Code/Source/SurfaceData_precompiled.h
#	Gems/TextureAtlas/Code/Source/TextureAtlas_precompiled.h
#	Gems/TickBusOrderViewer/Code/Source/TickBusOrderViewer_precompiled.h
#	Gems/Twitch/Code/Source/Twitch_precompiled.h
#	Gems/VirtualGamepad/Code/Source/VirtualGamepad_precompiled.h
#	Gems/WhiteBox/Code/Source/WhiteBoxUnsupported_precompiled.h
#	Gems/WhiteBox/Code/Source/WhiteBox_precompiled.h
2021-07-16 15:42:37 -07:00

269 lines
14 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "EditorWhiteBoxComponentModeBus.h"
#include "WhiteBoxToolApiReflection.h"
#include <AzCore/RTTI/BehaviorContext.h>
#include <WhiteBox/EditorWhiteBoxComponentBus.h>
#include <WhiteBox/WhiteBoxComponentBus.h>
#include <WhiteBox/WhiteBoxToolApi.h>
namespace WhiteBox
{
// placeholder type for white box free functions
struct WhiteBoxUtil
{
};
WhiteBoxMesh* WhiteBoxMeshFromHandle(const WhiteBoxMeshHandle& whiteBoxMeshHandle)
{
return reinterpret_cast<WhiteBox::WhiteBoxMesh*>(whiteBoxMeshHandle.m_whiteBoxMeshAddress);
}
template<typename Tag>
void GenericHandleReflect(AZ::BehaviorContext* behaviorContext, const char* name)
{
behaviorContext->Class<typename WhiteBox::GenericHandle<Tag>>(name)
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.api")
->template Constructor<int>()
->Method("IsValid", &GenericHandle<Tag>::IsValid)
->Method("Index", &GenericHandle<Tag>::Index);
}
void Reflect(AZ::ReflectContext* context)
{
// SerializeContext registration is needed to convert python lists into AZStd::vector
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<Api::FaceHandle>();
serializeContext->RegisterGenericType<Api::FaceHandles>();
serializeContext->Class<Api::FaceVertHandles>();
serializeContext->RegisterGenericType<Api::FaceVertHandlesList>();
serializeContext->Class<Api::VertexHandle>();
serializeContext->RegisterGenericType<Api::VertexHandles>();
serializeContext->RegisterGenericType<AZStd::array<Api::VertexHandle, 3>>();
}
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
GenericHandleReflect<Api::VertexHandleTag>(behaviorContext, "VertexHandle");
GenericHandleReflect<Api::FaceHandleTag>(behaviorContext, "FaceHandle");
GenericHandleReflect<Api::EdgeHandleTag>(behaviorContext, "EdgeHandle");
GenericHandleReflect<Api::HalfedgeHandleTag>(behaviorContext, "HalfedgeHandle");
behaviorContext->Class<Api::FaceVertHandles>("FaceVertHandles")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.api")
->Property("VertexHandles", BehaviorValueProperty(&Api::FaceVertHandles::m_vertexHandles));
behaviorContext->Class<Api::EdgeTypes>()
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.api")
->Property("Mesh", BehaviorValueProperty(&Api::EdgeTypes::m_mesh))
->Property("User", BehaviorValueProperty(&Api::EdgeTypes::m_user));
behaviorContext->Class<Api::PolygonHandle>("PolygonHandle")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.api")
->Property("FaceHandles", BehaviorValueProperty(&Api::PolygonHandle::m_faceHandles));
behaviorContext->Class<WhiteBoxMeshHandle>("WhiteBoxMeshHandle")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.api")
->Method(
"InitializeAsUnitCube",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle)
{
return Api::InitializeAsUnitCube(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle));
})
->Method(
"MeshFaceCount",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle)
{
return Api::MeshFaceCount(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle));
})
->Method(
"FacePolygonHandle",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, const Api::FaceHandle faceHandle)
{
return Api::FacePolygonHandle(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), faceHandle);
})
->Method(
"AddVertex",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, const AZ::Vector3& vertex)
{
return Api::AddVertex(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), vertex);
})
->Method(
"VertexPosition",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, Api::VertexHandle vertexHandle)
{
return Api::VertexPosition(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), vertexHandle);
})
->Method(
"VertexPositions",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, const Api::VertexHandles& vertexHandles)
{
return Api::VertexPositions(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), vertexHandles);
})
->Method(
"TranslatePolygonAppend",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, const Api::PolygonHandle& polygonHandle,
const float distance)
{
return Api::TranslatePolygonAppend(
*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), polygonHandle, distance);
})
->Method(
"TranslatePolygon",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, const Api::PolygonHandle& polygonHandle,
const float distance)
{
return Api::TranslatePolygon(
*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), polygonHandle, distance);
})
->Method(
"CalculateNormals",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle)
{
return Api::CalculateNormals(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle));
})
->Method(
"CalculatePlanarUVs",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle)
{
return Api::CalculatePlanarUVs(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle));
})
->Method(
"HideEdge",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, Api::EdgeHandle edgeHandle)
{
return Api::HideEdge(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), edgeHandle);
})
->Method(
"FlipEdge",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, Api::EdgeHandle edgeHandle)
{
return Api::FlipEdge(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), edgeHandle);
})
->Method(
"AddPolygon",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, const Api::FaceVertHandlesList& faceVertHandles)
{
return Api::AddPolygon(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), faceVertHandles);
})
->Method(
"AddTriPolygon",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, Api::VertexHandle v0, Api::VertexHandle v1,
Api::VertexHandle v2)
{
return Api::AddTriPolygon(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), v0, v1, v2);
})
->Method(
"AddQuadPolygon",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle, Api::VertexHandle v0, Api::VertexHandle v1,
Api::VertexHandle v2, Api::VertexHandle v3)
{
return Api::AddQuadPolygon(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle), v0, v1, v2, v3);
})
->Method(
"Clear",
[](WhiteBoxMeshHandle* whiteBoxMeshHandle)
{
return Api::Clear(*WhiteBoxMeshFromHandle(*whiteBoxMeshHandle));
});
behaviorContext->EnumProperty<(int)DefaultShapeType::Cube>("CUBE")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.enum");
behaviorContext->EnumProperty<(int)DefaultShapeType::Tetrahedron>("TETRAHEDRON")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.enum");
behaviorContext->EnumProperty<(int)DefaultShapeType::Icosahedron>("ICOSAHEDRON")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.enum");
behaviorContext->EnumProperty<(int)DefaultShapeType::Cylinder>("CYLINDER")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.enum");
behaviorContext->EnumProperty<(int)DefaultShapeType::Sphere>("SPHERE")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.enum");
behaviorContext->EBus<EditorWhiteBoxComponentModeRequestBus>("EditorWhiteBoxComponentModeRequestBus")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.request.bus")
->Event(
"MarkWhiteBoxIntersectionDataDirty",
&EditorWhiteBoxComponentModeRequestBus::Events::MarkWhiteBoxIntersectionDataDirty);
behaviorContext->EBus<EditorWhiteBoxComponentRequestBus>("EditorWhiteBoxComponentRequestBus")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.request.bus")
->Event("GetWhiteBoxMeshHandle", &EditorWhiteBoxComponentRequestBus::Events::GetWhiteBoxMeshHandle)
->Event("SerializeWhiteBox", &EditorWhiteBoxComponentRequestBus::Events::SerializeWhiteBox)
->Event("SetDefaultShape", &EditorWhiteBoxComponentRequestBus::Events::SetDefaultShape);
behaviorContext->EBus<EditorWhiteBoxComponentNotificationBus>("EditorWhiteBoxComponentNotificationBus")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.notification.bus")
->Event(
"OnWhiteBoxMeshModified", &EditorWhiteBoxComponentNotificationBus::Events::OnWhiteBoxMeshModified);
behaviorContext->EBus<WhiteBoxComponentRequestBus>("WhiteBoxComponentRequestBus")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.request.bus")
->Event("WhiteBoxIsVisible", &WhiteBoxComponentRequestBus::Events::WhiteBoxIsVisible);
behaviorContext->Class<WhiteBoxUtil>("util")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Module, "whitebox.api")
->Method(
"MakeFaceVertHandles",
[](Api::VertexHandle v0, Api::VertexHandle v1, Api::VertexHandle v2)
{
return Api::FaceVertHandles{v0, v1, v2};
})
->Method(
"MakeEntityComponentIdPair",
[](AZ::u64 entityId, AZ::u64 componentId)
{
return AZ::EntityComponentIdPair(AZ::EntityId(entityId), componentId);
});
}
}
} // namespace WhiteBox
namespace AZ
{
AZ_TYPE_INFO_SPECIALIZE(WhiteBox::WhiteBoxMeshHandle, "{95A2A7F0-C758-494E-BE1E-F673D13E812D}")
AZ_TYPE_INFO_SPECIALIZE(
WhiteBox::GenericHandle<WhiteBox::Api::VertexHandleTag>, "{708A5B3C-E377-40CE-9572-BEB64C849D40}")
AZ_TYPE_INFO_SPECIALIZE(
WhiteBox::GenericHandle<WhiteBox::Api::FaceHandleTag>, "{950009BC-8991-4749-9D5C-08C62AF34E7B}")
AZ_TYPE_INFO_SPECIALIZE(
WhiteBox::GenericHandle<WhiteBox::Api::EdgeHandleTag>, "{2169BFE7-8676-4572-B57E-494577059FB5}")
AZ_TYPE_INFO_SPECIALIZE(
WhiteBox::GenericHandle<WhiteBox::Api::HalfedgeHandleTag>, "{50AD7640-2A57-4311-B3DE-7BB08B1B70E5}")
AZ_TYPE_INFO_SPECIALIZE(WhiteBox::Api::PolygonHandle, "{CE09B0D7-3076-4EAC-ADA7-7418A31EE9AE}")
AZ_TYPE_INFO_SPECIALIZE(WhiteBox::Api::EdgeTypes, "{15581F2B-E80B-4264-AE26-659B5D214552}")
AZ_TYPE_INFO_SPECIALIZE(WhiteBox::Api::FaceVertHandles, "{F6B9150B-CC89-48A2-AB89-D18740CC6FA2}")
AZ_TYPE_INFO_SPECIALIZE(WhiteBox::WhiteBoxUtil, "{8D46CA40-1B9A-440E-A9A3-0CDD5773BB4A}")
} // namespace AZ