Merge pull request #521 from aws-lumberyard-dev/Atom/olexl/ATOM-15301_gems
Adding nullptr checks in Gems/ for Get3DEngine()main
commit
ea5dc5eb24
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:46757cf327aa9ed60ded1f3025140bc065569634f69e5aaba0b83086fa7642e0
|
||||
size 786
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:44150d202f318598e939bf29a543b6edaa0d2cf7455989a2d0da916ba7c83384
|
||||
size 833
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:44570118c315725d13affcc87b0eb4fb01f01cf67f9da0a4e066a347e096a36f
|
||||
size 757
|
||||
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 53.2 (72643) - https://sketchapp.com -->
|
||||
<title>icon / Rendering / OccluderArea</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<path d="M12,22.5 C6.20101013,22.5 1.5,17.7989899 1.5,12 C1.5,6.20101013 6.20101013,1.5 12,1.5 C17.7989899,1.5 22.5,6.20101013 22.5,12 C22.5,17.7989899 17.7989899,22.5 12,22.5 Z M12,14 C13.1045695,14 14,13.1045695 14,12 C14,10.8954305 13.1045695,10 12,10 C10.8954305,10 10,10.8954305 10,12 C10,13.1045695 10.8954305,14 12,14 Z M18.3868414,14 C19.4914109,14 20.3868414,13.1045695 20.3868414,12 C20.3868414,10.8954305 19.4914109,10 18.3868414,10 C17.2822719,10 16.3868414,10.8954305 16.3868414,12 C16.3868414,13.1045695 17.2822719,14 18.3868414,14 Z M15.1019653,17.9303924 C15.8830139,18.711441 17.1493438,18.711441 17.9303924,17.9303924 C18.711441,17.1493438 18.711441,15.8830139 17.9303924,15.1019653 C17.1493438,14.3209167 15.8830139,14.3209167 15.1019653,15.1019653 C14.3209167,15.8830139 14.3209167,17.1493438 15.1019653,17.9303924 Z M10,18.3868414 C10,19.4914109 10.8954305,20.3868414 12,20.3868414 C13.1045695,20.3868414 14,19.4914109 14,18.3868414 C14,17.2822719 13.1045695,16.3868414 12,16.3868414 C10.8954305,16.3868414 10,17.2822719 10,18.3868414 Z M6.0696076,15.1019653 C5.28855901,15.8830139 5.28855901,17.1493438 6.0696076,17.9303924 C6.85065618,18.711441 8.11698614,18.711441 8.89803472,17.9303924 C9.67908331,17.1493438 9.67908331,15.8830139 8.89803472,15.1019653 C8.11698614,14.3209167 6.85065618,14.3209167 6.0696076,15.1019653 Z M5.61315864,10 C4.50858914,10 3.61315864,10.8954305 3.61315864,12 C3.61315864,13.1045695 4.50858914,14 5.61315864,14 C6.71772814,14 7.61315864,13.1045695 7.61315864,12 C7.61315864,10.8954305 6.71772814,10 5.61315864,10 Z M8.89803472,6.0696076 C8.11698614,5.28855901 6.85065618,5.28855901 6.0696076,6.0696076 C5.28855901,6.85065618 5.28855901,8.11698614 6.0696076,8.89803472 C6.85065618,9.67908331 8.11698614,9.67908331 8.89803472,8.89803472 C9.67908331,8.11698614 9.67908331,6.85065618 8.89803472,6.0696076 Z M14,5.61315864 C14,4.50858914 13.1045695,3.61315864 12,3.61315864 C10.8954305,3.61315864 10,4.50858914 10,5.61315864 C10,6.71772814 10.8954305,7.61315864 12,7.61315864 C13.1045695,7.61315864 14,6.71772814 14,5.61315864 Z M17.9303924,8.89803472 C18.711441,8.11698614 18.711441,6.85065618 17.9303924,6.0696076 C17.1493438,5.28855901 15.8830139,5.28855901 15.1019653,6.0696076 C14.3209167,6.85065618 14.3209167,8.11698614 15.1019653,8.89803472 C15.8830139,9.67908331 17.1493438,9.67908331 17.9303924,8.89803472 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="icon-/-Rendering-/-OccluderArea" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="Shape" fill="#B29EDF" fill-rule="nonzero" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.0 KiB |
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 53.2 (72643) - https://sketchapp.com -->
|
||||
<title>icon / Rendering / Portal</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<path d="M14.517566,6.64449841 C14.4862224,5.82082247 15.6751896,5.9793848 16.5161788,6.39348521 C17.3571681,6.80758562 18.6334298,7.44931482 19.9151842,8.76676198 C21.1969385,10.0842091 22,11.7883198 22,14.2740524 C22,16.7597851 20.5934573,18.7231154 18.642653,20.1339802 C16.6918487,21.544845 13.3232817,21.8346593 10.5903969,21.2554889 C7.85751214,20.6763185 6.98083219,19.4599445 5.82740123,18.6475608 C7.80862675,19.6319576 8.73776498,20.1539293 10.5903969,20.4505821 C12.4430289,20.7472349 14.8244045,20.4505821 16.3833038,19.6319576 C17.9422031,18.8133331 19.5050422,17.0119722 19.5050422,14.2740524 C19.5050422,13.1815784 19.2962704,12.3059389 18.642653,11.3434625 C17.8223782,10.1355767 16.9805858,9.83082202 16.2283235,9.40135632 C15.459699,8.96254944 14.8961383,8.938379 14.7128347,8.5 C14.5037649,8 14.5489097,7.46817436 14.517566,6.64449841 Z M11.1203684,18.0713788 C11.151712,18.8950547 9.96274479,18.7364924 9.12175555,18.322392 C8.28076632,17.9082916 7.00450455,17.2665624 5.72275024,15.9491152 C4.44099593,14.6316681 3.63793439,12.9275574 3.63793439,10.4418248 C3.63793439,7.95609214 5.04447713,5.99276183 6.99528141,4.58189699 C8.94608569,3.17103215 12.3146526,2.88121794 15.0475374,3.46038831 C17.7804223,4.03955868 18.6571022,5.25593271 19.8105332,6.06831644 C17.8293076,5.08391964 16.9001694,4.56194794 15.0475374,4.26529513 C13.1949055,3.96864232 10.8135299,4.26529513 9.25463061,5.08391964 C7.69573131,5.90254414 6.13289218,7.70390502 6.13289218,10.4418248 C6.13289218,11.5342988 6.34166399,12.4099383 6.99528141,13.3724147 C7.81555623,14.5803005 8.65734858,14.8850552 9.40961086,15.3145209 C10.1782354,15.7533278 10.7417961,15.7774982 10.9250997,16.2158772 C11.1341694,16.7158772 11.0890247,17.2477028 11.1203684,18.0713788 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="icon-/-Rendering-/-Portal" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="Combined-Shape" fill="#B29EDF" fill-rule="nonzero" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.4 KiB |
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7288c80d906ec59271ccd4db168d318f4c5b4fd65fca6077acbf4aaeb76b9e24
|
||||
size 4081
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:486816ea8e6cb090f8d78e26d9ed6a73aca8e5d6c5fb6bcb3cb2fff8277053db
|
||||
size 4687
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:aca391fc79c7b5400465bcdaa3a1c21a0fbb3dd042420b6511ecf568048ee6ec
|
||||
size 4558
|
||||
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 53.2 (72643) - https://sketchapp.com -->
|
||||
<title>icon / Rendering / VisArea</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<path d="M12.8297892,22.115864 L12.8297892,20.0124936 C14.103246,20.0124936 15.3311908,19.7112171 16.43691,19.1414855 L17.4003209,21.0112467 C15.9983797,21.7336092 14.4403828,22.115864 12.8297892,22.115864 Z M18.860139,19.6325541 L17.4703431,18.053746 C18.4119229,17.2248906 19.1457469,16.1831791 19.6046973,15.0161068 L21.5621511,15.7858742 C20.9804267,17.2651506 20.0515045,18.5838168 18.860139,19.6325541 Z M22.031453,13.5797044 L19.9449645,13.3137474 C19.9843719,13.0045883 20.0056358,12.6917971 20.0083786,12.3853481 C20.0086874,11.3699357 19.8460795,10.4483615 19.5235313,9.57435394 L21.4968148,8.84612341 C21.9059719,9.95481503 22.1121329,11.123225 22.1117081,12.3949496 C22.1081938,12.7931346 22.0813141,13.1885334 22.031453,13.5797044 Z M20.39174,6.69848997 L18.6516615,7.88013888 C17.9470794,6.84258187 17.0033925,5.98401691 15.9037572,5.38177023 L16.9141212,3.53695809 C18.3064516,4.29950756 19.5001229,5.38550793 20.39174,6.69848997 Z M14.6364032,2.63367544 L14.1082344,4.66965311 C13.5053261,4.51324796 12.8822768,4.42845324 12.263034,4.41861054 C11.5170364,4.41762756 10.9040515,4.4856197 10.2975241,4.62909554 L9.8133284,2.58221453 C10.5830076,2.40014467 11.3592205,2.31404732 12.2809488,2.31537089 C13.082804,2.32797496 13.8720485,2.43538824 14.6364032,2.63367544 Z M7.57411663,3.40663596 L8.53255422,5.27895129 C7.41666002,5.85017715 6.44989295,6.68220981 5.71670117,7.69978909 L4.01016911,6.4701893 C4.93790195,5.18261115 6.16088944,4.13006648 7.57411663,3.40663596 Z M2.83910547,8.60208351 L4.7925298,9.38201986 C4.44476094,10.2530398 4.25466333,11.1832634 4.2353434,12.1229817 C4.23368987,12.5846086 4.24837874,12.8885633 4.28375497,13.2016972 L2.19368033,13.4378229 C2.14863195,13.0390756 2.13005497,12.6546647 2.13219847,12.0977636 C2.15690623,10.8866588 2.39800703,9.70685624 2.83910547,8.60208351 Z M2.73614577,15.2315548 L4.71138512,14.5086462 C5.14252836,15.6866805 5.85152947,16.7450008 6.77339853,17.5957427 L5.34691803,19.1414855 C4.1804236,18.0649923 3.28272837,16.7250098 2.73614577,15.2315548 Z M6.84342079,20.8813639 L7.85977016,19.0398424 C8.950253,19.641688 10.1699339,19.9778835 11.440246,20.0133111 L11.3816083,22.115864 C9.77371271,22.0710217 8.22595333,21.6443938 6.84342079,20.8813639 Z M12.1218708,5.93906802 L14.6218708,10.939068 L9.62187084,10.939068 L12.1218708,5.93906802 Z M13.4312199,12.25 L17.9312199,12.25 L17.9312199,16.75 L13.4312199,16.75 L13.4312199,12.25 Z M9.21724378,17 C7.8365319,17 6.71724378,15.8807119 6.71724378,14.5 C6.71724378,13.1192881 7.8365319,12 9.21724378,12 C10.5979557,12 11.7172438,13.1192881 11.7172438,14.5 C11.7172438,15.8807119 10.5979557,17 9.21724378,17 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="icon-/-Rendering-/-VisArea" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="Combined-Shape" fill="#B29EDF" fill-rule="nonzero" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.3 KiB |
@ -1,12 +0,0 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
add_subdirectory(Code)
|
||||
@ -1,105 +0,0 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
ly_add_target(
|
||||
NAME Visibility.Static STATIC
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
visibility_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Source
|
||||
PUBLIC
|
||||
Include
|
||||
BUILD_DEPENDENCIES
|
||||
PUBLIC
|
||||
Legacy::CryCommon
|
||||
)
|
||||
|
||||
ly_add_target(
|
||||
NAME Visibility ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
visibility_shared_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Source
|
||||
PUBLIC
|
||||
Include
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Gem::Visibility.Static
|
||||
)
|
||||
|
||||
if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
|
||||
ly_add_target(
|
||||
NAME Visibility.Editor.Static STATIC
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
visibility_editor_files.cmake
|
||||
COMPILE_DEFINITIONS
|
||||
PUBLIC
|
||||
VISIBILITY_EDITOR
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Source
|
||||
PUBLIC
|
||||
Include
|
||||
BUILD_DEPENDENCIES
|
||||
PUBLIC
|
||||
Legacy::Editor.Headers
|
||||
Legacy::EditorCore
|
||||
AZ::AzToolsFramework
|
||||
Gem::Visibility.Static
|
||||
)
|
||||
|
||||
ly_add_target(
|
||||
NAME Visibility.Editor GEM_MODULE
|
||||
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
visibility_editor_shared_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Source
|
||||
PUBLIC
|
||||
Include
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Gem::Visibility.Editor.Static
|
||||
)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
# Tests
|
||||
################################################################################
|
||||
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
if(PAL_TRAIT_BUILD_HOST_TOOLS)
|
||||
ly_add_target(
|
||||
NAME Visibility.Editor.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
visibility_editor_tests_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
Tests
|
||||
Source
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzTest
|
||||
Gem::Visibility.Editor.Static
|
||||
)
|
||||
ly_add_googletest(
|
||||
NAME Gem::Visibility.Editor.Tests
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/ComponentBus.h>
|
||||
|
||||
#include "OccluderAreaComponentBus.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
/// Request bus for the EditorOccluderComponent.
|
||||
class EditorOccluderAreaRequests
|
||||
: public OccluderAreaRequests
|
||||
, public AZ::FixedVertices<AZ::Vector3>
|
||||
{
|
||||
public:
|
||||
virtual void SetDisplayFilled(bool displayFilled) = 0;
|
||||
virtual void SetCullDistRatio(float cullDistRatio) = 0;
|
||||
virtual void SetUseInIndoors(bool inDoors) = 0;
|
||||
virtual void SetDoubleSide(bool doubleSided) = 0;
|
||||
virtual void UpdateOccluderAreaObject() = 0;
|
||||
|
||||
protected:
|
||||
~EditorOccluderAreaRequests() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement EditorOccluderAreaComponentRequests
|
||||
using EditorOccluderAreaRequestBus = AZ::EBus<EditorOccluderAreaRequests, AZ::ComponentBus>;
|
||||
|
||||
/// Editor notification bus for EditorOccluderAreaComponent.
|
||||
class EditorOccluderAreaNotifications
|
||||
: public AZ::ComponentBus
|
||||
{
|
||||
public:
|
||||
virtual void OnVerticesChangedInspector() {}
|
||||
|
||||
protected:
|
||||
~EditorOccluderAreaNotifications() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement EditorOccluderAreaNotifications.
|
||||
using EditorOccluderAreaNotificationBus = AZ::EBus<EditorOccluderAreaNotifications>;
|
||||
|
||||
} // namespace Visibility
|
||||
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/ComponentBus.h>
|
||||
|
||||
#include "PortalComponentBus.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
/// Request bus for the EditorPortalComponent.
|
||||
class EditorPortalRequests
|
||||
: public PortalRequests
|
||||
, public AZ::FixedVertices<AZ::Vector3>
|
||||
{
|
||||
public:
|
||||
virtual void SetHeight(float height) = 0;
|
||||
virtual void SetDisplayFilled(bool filled) = 0;
|
||||
virtual void SetAffectedBySun(bool affectedBySun) = 0;
|
||||
virtual void SetViewDistRatio(float viewDistRatio) = 0;
|
||||
virtual void SetSkyOnly(bool skyOnly) = 0;
|
||||
virtual void SetOceanIsVisible(bool oceanVisible) = 0;
|
||||
virtual void SetUseDeepness(bool useDeepness) = 0;
|
||||
virtual void SetDoubleSide(bool doubleSided) = 0;
|
||||
virtual void SetLightBlending(bool lightBending) = 0;
|
||||
virtual void SetLightBlendValue(float lightBendAmount) = 0;
|
||||
virtual void UpdatePortalObject() = 0;
|
||||
|
||||
protected:
|
||||
~EditorPortalRequests() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement EditorPortalComponentRequests
|
||||
using EditorPortalRequestBus = AZ::EBus<EditorPortalRequests, AZ::ComponentBus>;
|
||||
|
||||
/// Editor notification bus for EditorPortalComponent.
|
||||
class EditorPortalNotifications
|
||||
: public AZ::ComponentBus
|
||||
{
|
||||
public:
|
||||
virtual void OnVerticesChangedInspector() {}
|
||||
|
||||
protected:
|
||||
~EditorPortalNotifications() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement EditorPortalNotifications.
|
||||
using EditorPortalNotificationBus = AZ::EBus<EditorPortalNotifications>;
|
||||
|
||||
} // namespace Visibility
|
||||
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/ComponentBus.h>
|
||||
|
||||
#include "VisAreaComponentBus.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
/// Request bus for the EditorVisAreaComponent.
|
||||
class EditorVisAreaComponentRequests
|
||||
: public VisAreaComponentRequests
|
||||
, public AZ::VariableVertices<AZ::Vector3>
|
||||
{
|
||||
public:
|
||||
virtual void SetHeight(float height) = 0;
|
||||
virtual void SetDisplayFilled(bool filled) = 0;
|
||||
virtual void SetAffectedBySun(bool affectedBySun) = 0;
|
||||
virtual void SetViewDistRatio(float viewDistRatio) = 0;
|
||||
virtual void SetOceanIsVisible(bool oceanVisible) = 0;
|
||||
virtual void UpdateVisAreaObject() = 0;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement EditorVisAreaComponentRequests.
|
||||
using EditorVisAreaComponentRequestBus = AZ::EBus<EditorVisAreaComponentRequests, AZ::ComponentBus>;
|
||||
|
||||
/// Notification bus for the EditorVisAreaComponent.
|
||||
class EditorVisAreaComponentNotifications
|
||||
: public AZ::ComponentBus
|
||||
, public AZ::VertexContainerNotificationInterface<AZ::Vector3>
|
||||
{
|
||||
public:
|
||||
/// Called when a new vertex is added to the vis area.
|
||||
void OnVertexAdded(size_t /*index*/) override {}
|
||||
|
||||
/// Called when a vertex is removed from the vis area.
|
||||
void OnVertexRemoved(size_t /*index*/) override {}
|
||||
|
||||
/// Called when a vertex is updated.
|
||||
void OnVertexUpdated(size_t /*index*/) override {}
|
||||
|
||||
/// Called when all vertices on the vis area are set.
|
||||
void OnVerticesSet(const AZStd::vector<AZ::Vector3>& /*vertices*/) override {}
|
||||
|
||||
/// Called when all vertices are removed from the vis area.
|
||||
void OnVerticesCleared() override {}
|
||||
|
||||
protected:
|
||||
~EditorVisAreaComponentNotifications() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement EditorVisAreaComponentNotifications.
|
||||
using EditorVisAreaComponentNotificationBus = AZ::EBus<EditorVisAreaComponentNotifications>;
|
||||
|
||||
} // namespace Visibility
|
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/ComponentBus.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/VertexContainerInterface.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
/// Request bus for the OccluderAreaComponent.
|
||||
class OccluderAreaRequests
|
||||
{
|
||||
public:
|
||||
virtual bool GetDisplayFilled() = 0;
|
||||
virtual float GetCullDistRatio() = 0;
|
||||
virtual bool GetUseInIndoors() = 0;
|
||||
virtual bool GetDoubleSide() = 0;
|
||||
|
||||
protected:
|
||||
~OccluderAreaRequests() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement OccluderAreaRequests.
|
||||
using OccluderAreaRequestBus = AZ::EBus<OccluderAreaRequests, AZ::ComponentBus>;
|
||||
|
||||
} // namespace Visibility
|
||||
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/ComponentBus.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/VertexContainerInterface.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
// Request bus for the PortalComponent.
|
||||
class PortalRequests
|
||||
{
|
||||
public:
|
||||
virtual float GetHeight() = 0;
|
||||
virtual bool GetDisplayFilled() = 0;
|
||||
virtual bool GetAffectedBySun() = 0;
|
||||
virtual float GetViewDistRatio() = 0;
|
||||
virtual bool GetSkyOnly() = 0;
|
||||
virtual bool GetOceanIsVisible() = 0;
|
||||
virtual bool GetUseDeepness() = 0;
|
||||
virtual bool GetDoubleSide() = 0;
|
||||
virtual bool GetLightBlending() = 0;
|
||||
virtual float GetLightBlendValue() = 0;
|
||||
|
||||
protected:
|
||||
~PortalRequests() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement PortalRequests.
|
||||
using PortalRequestBus = AZ::EBus<PortalRequests, AZ::ComponentBus>;
|
||||
|
||||
} // namespace Visibility
|
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/ComponentBus.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/VertexContainerInterface.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
/// Request bus for the VisAreaComponent.
|
||||
class VisAreaComponentRequests
|
||||
{
|
||||
public:
|
||||
virtual float GetHeight() = 0;
|
||||
virtual bool GetDisplayFilled() = 0;
|
||||
virtual bool GetAffectedBySun() = 0;
|
||||
virtual float GetViewDistRatio() = 0;
|
||||
virtual bool GetOceanIsVisible() = 0;
|
||||
|
||||
protected:
|
||||
~VisAreaComponentRequests() = default;
|
||||
};
|
||||
|
||||
/// Type to inherit to implement VisAreaComponentRequests.
|
||||
using VisAreaComponentRequestBus = AZ::EBus<VisAreaComponentRequests, AZ::ComponentBus>;
|
||||
|
||||
} // namespace Visibility
|
||||
@ -1,437 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Visibility_precompiled.h"
|
||||
#include "EditorOccluderAreaComponent.h"
|
||||
#include "EditorOccluderAreaComponentMode.h"
|
||||
|
||||
#include <AzCore/Math/Crc.h>
|
||||
#include <AzCore/Math/IntersectSegment.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzToolsFramework/Viewport/VertexContainerDisplay.h>
|
||||
#include <Editor/Objects/BaseObject.h>
|
||||
#include <Objects/EntityObject.h>
|
||||
|
||||
// Include files needed for writing DisplayEntity functions that access the DisplayContext directly.
|
||||
#include <EditorCoreAPI.h>
|
||||
|
||||
#include "MathConversion.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
void EditorOccluderAreaComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provides)
|
||||
{
|
||||
provides.push_back(AZ_CRC("EditorOccluderAreaService", 0xf943e16a));
|
||||
provides.push_back(AZ_CRC("OccluderAreaService", 0x2fefad66));
|
||||
provides.push_back(AZ_CRC("FixedVertexContainerService", 0x83f1bbf2));
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& requires)
|
||||
{
|
||||
requires.push_back(AZ_CRC("TransformService", 0x8ee22c50));
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
|
||||
{
|
||||
dependent.push_back(AZ_CRC("QuadShapeService", 0xe449b0fc));
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(AZ_CRC("EditorOccluderAreaService", 0xf943e16a));
|
||||
incompatible.push_back(AZ_CRC("OccluderAreaService", 0x2fefad66));
|
||||
incompatible.push_back(AZ_CRC("FixedVertexContainerService", 0x83f1bbf2));
|
||||
}
|
||||
|
||||
void EditorOccluderAreaConfiguration::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<EditorOccluderAreaConfiguration, OccluderAreaConfiguration>()
|
||||
->Version(1);
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<EditorOccluderAreaConfiguration>("OccluderArea Configuration", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true);
|
||||
|
||||
editContext->Class<OccluderAreaConfiguration>("OccluderArea Configuration", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &OccluderAreaConfiguration::m_displayFilled, "DisplayFilled", "Display the Occlude Area as a filled quad.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &OccluderAreaConfiguration::OnChange)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &OccluderAreaConfiguration::m_cullDistRatio, "CullDistRatio", "The range of the culling effect.")
|
||||
->Attribute(AZ::Edit::Attributes::Max, 100.0f)
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &OccluderAreaConfiguration::OnChange)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &OccluderAreaConfiguration::m_useInIndoors, "UseInIndoors", "Should this occluder work inside VisAreas.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &OccluderAreaConfiguration::OnChange)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &OccluderAreaConfiguration::m_doubleSide, "DoubleSide", "Should this occlude from both sides.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &OccluderAreaConfiguration::OnChange)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &OccluderAreaConfiguration::m_vertices, "Vertices", "Points that make up the OccluderArea.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &OccluderAreaConfiguration::OnVerticesChange)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<EditorOccluderAreaComponent, AzToolsFramework::Components::EditorComponentBase>()
|
||||
->Version(2)
|
||||
->Field("m_config", &EditorOccluderAreaComponent::m_config)
|
||||
->Field("ComponentMode", &EditorOccluderAreaComponent::m_componentModeDelegate)
|
||||
;
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<EditorOccluderAreaComponent>("OccluderArea", "An area that blocks objects behind it from rendering.")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Category, "Rendering")
|
||||
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Viewport/OccluderArea.png")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/OccluderArea.svg")
|
||||
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
|
||||
->Attribute(AZ::Edit::Attributes::HelpPageURL, "http://docs.aws.amazon.com/console/lumberyard/userguide/occluder-area-component")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &EditorOccluderAreaComponent::m_config, "m_config", "No Description")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &EditorOccluderAreaComponent::m_componentModeDelegate, "Component Mode", "OccluderArea Component Mode")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<EditorOccluderAreaRequestBus>("EditorOccluderAreaRequestBus")
|
||||
->Event("SetDisplayFilled", &EditorOccluderAreaRequestBus::Events::SetDisplayFilled)
|
||||
->Event("GetDisplayFilled", &EditorOccluderAreaRequestBus::Events::GetDisplayFilled)
|
||||
->VirtualProperty("DisplayFilled", "GetDisplayFilled", "SetDisplayFilled")
|
||||
|
||||
->Event("SetCullDistRatio", &EditorOccluderAreaRequestBus::Events::SetCullDistRatio)
|
||||
->Event("GetCullDistRatio", &EditorOccluderAreaRequestBus::Events::GetCullDistRatio)
|
||||
->VirtualProperty("CullDistRatio", "GetCullDistRatio", "SetCullDistRatio")
|
||||
|
||||
->Event("SetUseInIndoors", &EditorOccluderAreaRequestBus::Events::SetUseInIndoors)
|
||||
->Event("GetUseInIndoors", &EditorOccluderAreaRequestBus::Events::GetUseInIndoors)
|
||||
->VirtualProperty("UseInIndoors", "GetUseInIndoors", "SetUseInIndoors")
|
||||
|
||||
->Event("SetDoubleSide", &EditorOccluderAreaRequestBus::Events::SetDoubleSide)
|
||||
->Event("GetDoubleSide", &EditorOccluderAreaRequestBus::Events::GetDoubleSide)
|
||||
->VirtualProperty("DoubleSide", "GetDoubleSide", "SetDoubleSide")
|
||||
;
|
||||
|
||||
behaviorContext->Class<EditorOccluderAreaComponent>()->RequestBus("EditorOccluderAreaRequestBus");
|
||||
}
|
||||
|
||||
EditorOccluderAreaConfiguration::Reflect(context);
|
||||
}
|
||||
|
||||
void EditorOccluderAreaConfiguration::OnChange()
|
||||
{
|
||||
EditorOccluderAreaRequestBus::Event(m_entityId, &EditorOccluderAreaRequests::UpdateOccluderAreaObject);
|
||||
}
|
||||
|
||||
void EditorOccluderAreaConfiguration::OnVerticesChange()
|
||||
{
|
||||
EditorOccluderAreaRequestBus::Event(
|
||||
m_entityId, &EditorOccluderAreaRequests::UpdateOccluderAreaObject);
|
||||
EditorOccluderAreaNotificationBus::Event(
|
||||
m_entityId, &EditorOccluderAreaNotifications::OnVerticesChangedInspector);
|
||||
}
|
||||
|
||||
void EditorOccluderAreaConfiguration::SetEntityId(const AZ::EntityId entityId)
|
||||
{
|
||||
m_entityId = entityId;
|
||||
}
|
||||
|
||||
EditorOccluderAreaComponent::~EditorOccluderAreaComponent()
|
||||
{
|
||||
if (m_area)
|
||||
{
|
||||
GetIEditor()->Get3DEngine()->DeleteVisArea(m_area);
|
||||
m_area = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::Activate()
|
||||
{
|
||||
Base::Activate();
|
||||
|
||||
const AZ::EntityId entityId = GetEntityId();
|
||||
m_config.SetEntityId(entityId);
|
||||
|
||||
// NOTE: We create the vis-area here at activate, but destroy it in the destructor.
|
||||
// We have to do this, otherwise the vis-area is not saved into the level.
|
||||
// Unfortunately, at this time we cannot create the vis-areas at game runtime.
|
||||
// This means that dynamic slices cannot effectively contain vis areas until we fix
|
||||
// the core rendering system to allow that.
|
||||
const auto visGUID = static_cast<AZ::u64>(entityId);
|
||||
if(!m_area && GetIEditor())
|
||||
{
|
||||
m_area = GetIEditor()->Get3DEngine()->CreateVisArea(visGUID);
|
||||
}
|
||||
|
||||
m_componentModeDelegate.ConnectWithSingleComponentMode<
|
||||
EditorOccluderAreaComponent, EditorOccluderAreaComponentMode>(
|
||||
AZ::EntityComponentIdPair(entityId, GetId()), this);
|
||||
|
||||
EditorOccluderAreaRequestBus::Handler::BusConnect(entityId);
|
||||
AZ::FixedVerticesRequestBus<AZ::Vector3>::Handler::BusConnect(entityId);
|
||||
AZ::TransformNotificationBus::Handler::BusConnect(entityId);
|
||||
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(entityId);
|
||||
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusConnect(entityId);
|
||||
AzFramework::BoundsRequestBus::Handler::BusConnect(entityId);
|
||||
|
||||
UpdateOccluderAreaObject();
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::Deactivate()
|
||||
{
|
||||
m_componentModeDelegate.Disconnect();
|
||||
|
||||
AzFramework::BoundsRequestBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusDisconnect();
|
||||
AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect();
|
||||
AZ::FixedVerticesRequestBus<AZ::Vector3>::Handler::BusDisconnect();
|
||||
EditorOccluderAreaRequestBus::Handler::BusDisconnect();
|
||||
|
||||
Base::Deactivate();
|
||||
}
|
||||
|
||||
/// Update the object runtime after changes to the Configuration.
|
||||
/// Called by the default RequestBus SetXXX implementations,
|
||||
/// and used to initially set up the object the first time the
|
||||
/// Configuration are set.
|
||||
void EditorOccluderAreaComponent::UpdateOccluderAreaObject()
|
||||
{
|
||||
if (m_area)
|
||||
{
|
||||
AZStd::array<Vec3, 4> verts;
|
||||
|
||||
const Matrix34& wtm = AZTransformToLYTransform(GetWorldTM());
|
||||
for (size_t i = 0; i < m_config.m_vertices.size(); ++i)
|
||||
{
|
||||
verts[i] = wtm.TransformPoint(AZVec3ToLYVec3(m_config.m_vertices[i]));
|
||||
}
|
||||
|
||||
SVisAreaInfo info;
|
||||
info.fHeight = 0;
|
||||
info.vAmbientColor = Vec3(0, 0, 0);
|
||||
info.bAffectedByOutLights = false;
|
||||
info.bSkyOnly = false;
|
||||
info.fViewDistRatio = m_config.m_cullDistRatio;
|
||||
info.bDoubleSide = m_config.m_doubleSide;
|
||||
info.bUseDeepness = false;
|
||||
info.bUseInIndoors = m_config.m_useInIndoors;
|
||||
info.bOceanIsVisible = false;
|
||||
info.fPortalBlending = -1.0f;
|
||||
|
||||
const AZStd::string name = AZStd::string("OcclArea_") + GetEntity()->GetName();
|
||||
GetIEditor()->Get3DEngine()->UpdateVisArea(m_area, &verts[0], verts.size(), name.c_str(), info, false);
|
||||
|
||||
AzFramework::EntityBoundsUnionRequestBus::Broadcast(
|
||||
&AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId());
|
||||
}
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::SetDisplayFilled(const bool value)
|
||||
{
|
||||
m_config.m_displayFilled = value;
|
||||
UpdateOccluderAreaObject();
|
||||
}
|
||||
|
||||
bool EditorOccluderAreaComponent::GetDisplayFilled()
|
||||
{
|
||||
return m_config.m_displayFilled;
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::SetCullDistRatio(const float value)
|
||||
{
|
||||
m_config.m_cullDistRatio = value;
|
||||
UpdateOccluderAreaObject();
|
||||
}
|
||||
|
||||
float EditorOccluderAreaComponent::GetCullDistRatio()
|
||||
{
|
||||
return m_config.m_cullDistRatio;
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::SetUseInIndoors(const bool value)
|
||||
{
|
||||
m_config.m_useInIndoors = value;
|
||||
UpdateOccluderAreaObject();
|
||||
}
|
||||
|
||||
bool EditorOccluderAreaComponent::GetUseInIndoors()
|
||||
{
|
||||
return m_config.m_useInIndoors;
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::SetDoubleSide(const bool value)
|
||||
{
|
||||
m_config.m_doubleSide = value;
|
||||
UpdateOccluderAreaObject();
|
||||
}
|
||||
|
||||
bool EditorOccluderAreaComponent::GetDoubleSide()
|
||||
{
|
||||
return m_config.m_doubleSide;
|
||||
}
|
||||
|
||||
bool EditorOccluderAreaComponent::GetVertex(const size_t index, AZ::Vector3& vertex) const
|
||||
{
|
||||
if (index < m_config.m_vertices.size())
|
||||
{
|
||||
vertex = m_config.m_vertices[index];
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditorOccluderAreaComponent::UpdateVertex(const size_t index, const AZ::Vector3& vertex)
|
||||
{
|
||||
if (index < m_config.m_vertices.size())
|
||||
{
|
||||
m_config.m_vertices[index] = vertex;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::OnTransformChanged(const AZ::Transform& /*local*/, [[maybe_unused]] const AZ::Transform& world)
|
||||
{
|
||||
UpdateOccluderAreaObject();
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::DisplayEntityViewport(
|
||||
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo,
|
||||
AzFramework::DebugDisplayRequests& debugDisplay)
|
||||
{
|
||||
const AZ::Transform worldFromLocal = GetWorldTM();
|
||||
const AZ::Vector4 color(0.5f, 0.25f, 0.0f, 1.0f);
|
||||
const AZ::Vector4 selectedColor(1.0f, 0.5f, 0.0f, 1.0f);
|
||||
const float previousLineWidth = debugDisplay.GetLineWidth();
|
||||
|
||||
debugDisplay.DepthWriteOff();
|
||||
debugDisplay.PushMatrix(worldFromLocal);
|
||||
debugDisplay.SetColor(IsSelected() ? selectedColor : color);
|
||||
debugDisplay.SetLineWidth(5.0f);
|
||||
debugDisplay.SetAlpha(0.8f);
|
||||
|
||||
for (size_t i = 2; i < 4; i++)
|
||||
{
|
||||
// draw the plane
|
||||
if (m_config.m_displayFilled)
|
||||
{
|
||||
debugDisplay.SetAlpha(0.3f);
|
||||
debugDisplay.CullOff();
|
||||
debugDisplay.DrawTri(m_config.m_vertices[0], m_config.m_vertices[i - 1], m_config.m_vertices[i]);
|
||||
debugDisplay.CullOn();
|
||||
debugDisplay.SetAlpha(0.8f);
|
||||
}
|
||||
|
||||
debugDisplay.DrawLine(m_config.m_vertices[i - 2], m_config.m_vertices[i - 1]);
|
||||
debugDisplay.DrawLine(m_config.m_vertices[i - 1], m_config.m_vertices[i]);
|
||||
}
|
||||
|
||||
// draw the closing line
|
||||
debugDisplay.DrawLine(m_config.m_vertices[3], m_config.m_vertices[0]);
|
||||
|
||||
if (m_componentModeDelegate.AddedToComponentMode())
|
||||
{
|
||||
AzToolsFramework::VertexContainerDisplay::DisplayVertexContainerIndices(
|
||||
debugDisplay, AzToolsFramework::FixedVerticesArray<AZ::Vector3, 4>(m_config.m_vertices),
|
||||
GetWorldTM(), AZ::Vector3::CreateOne(), IsSelected());
|
||||
}
|
||||
|
||||
debugDisplay.DepthWriteOn();
|
||||
debugDisplay.SetLineWidth(previousLineWidth);
|
||||
debugDisplay.PopMatrix();
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponent::BuildGameEntity(AZ::Entity* gameEntity)
|
||||
{
|
||||
gameEntity->CreateComponent<OccluderAreaComponent>(m_config);
|
||||
}
|
||||
|
||||
AZ::Aabb EditorOccluderAreaComponent::GetEditorSelectionBoundsViewport(
|
||||
const AzFramework::ViewportInfo& /*viewportInfo*/)
|
||||
{
|
||||
return GetWorldBounds();
|
||||
}
|
||||
|
||||
bool EditorOccluderAreaComponent::EditorSelectionIntersectRayViewport(
|
||||
const AzFramework::ViewportInfo& /*viewportInfo*/, const AZ::Vector3& src,
|
||||
const AZ::Vector3& dir, float& distance)
|
||||
{
|
||||
const float rayLength = 1000.0f;
|
||||
AZ::Vector3 scaledDir = dir * rayLength;
|
||||
AZ::Vector3 end = src + scaledDir;
|
||||
float t;
|
||||
float intermediateT = std::numeric_limits<float>::max();
|
||||
bool didHit = false;
|
||||
|
||||
// Transform verts to world space for tris test
|
||||
AZStd::array<AZ::Vector3, 4> verts;
|
||||
const AZ::Transform& wtm = GetWorldTM();
|
||||
for (size_t i = 0; i < m_config.m_vertices.size(); ++i)
|
||||
{
|
||||
verts[i] = wtm.TransformPoint(m_config.m_vertices[i]);
|
||||
}
|
||||
|
||||
AZ::Vector3 normal;
|
||||
for (AZ::u8 i = 2; i < 4; ++i)
|
||||
{
|
||||
if (AZ::Intersect::IntersectSegmentTriangleCCW(src, end, verts[0], verts[i - 1], verts[i], normal, t) > 0)
|
||||
{
|
||||
intermediateT = AZStd::GetMin(t, intermediateT);
|
||||
didHit = true;
|
||||
}
|
||||
//Else if here as we shouldn't successfully ccw and cw intersect at the same time
|
||||
else if (AZ::Intersect::IntersectSegmentTriangle(src, end, verts[0], verts[i - 1], verts[i], normal, t) > 0)
|
||||
{
|
||||
intermediateT = AZStd::GetMin(t, intermediateT);
|
||||
didHit = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (didHit)
|
||||
{
|
||||
distance = intermediateT * rayLength;
|
||||
}
|
||||
return didHit;
|
||||
}
|
||||
|
||||
AZ::Aabb EditorOccluderAreaComponent::GetWorldBounds()
|
||||
{
|
||||
return GetLocalBounds().GetTransformedAabb(GetWorldTM());
|
||||
}
|
||||
|
||||
AZ::Aabb EditorOccluderAreaComponent::GetLocalBounds()
|
||||
{
|
||||
AZ::Aabb bbox = AZ::Aabb::CreateNull();
|
||||
for (const auto& vertex : m_config.m_vertices)
|
||||
{
|
||||
bbox.AddPoint(vertex);
|
||||
}
|
||||
return bbox;
|
||||
}
|
||||
} // namespace Visibility
|
||||
@ -1,129 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "OccluderAreaComponent.h"
|
||||
#include "EditorOccluderAreaComponentBus.h"
|
||||
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
||||
#include <AzFramework/Visibility/BoundsBus.h>
|
||||
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/ComponentMode/ComponentModeDelegate.h>
|
||||
#include <AzToolsFramework/Manipulators/EditorVertexSelection.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
class EditorOccluderAreaComponent;
|
||||
|
||||
class EditorOccluderAreaConfiguration
|
||||
: public OccluderAreaConfiguration
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO_LEGACY(EditorOccluderAreaConfiguration, "{032F466F-25CB-5460-AC2F-B04236C87878}", OccluderAreaConfiguration);
|
||||
AZ_CLASS_ALLOCATOR(EditorOccluderAreaConfiguration, AZ::SystemAllocator, 0);
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
void OnChange() override;
|
||||
void OnVerticesChange() override;
|
||||
|
||||
void SetEntityId(AZ::EntityId entityId);
|
||||
|
||||
private:
|
||||
AZ::EntityId m_entityId;
|
||||
};
|
||||
|
||||
class EditorOccluderAreaComponent
|
||||
: public AzToolsFramework::Components::EditorComponentBase
|
||||
, private EditorOccluderAreaRequestBus::Handler
|
||||
, private AZ::FixedVerticesRequestBus<AZ::Vector3>::Handler
|
||||
, private AzFramework::EntityDebugDisplayEventBus::Handler
|
||||
, private AzToolsFramework::EditorComponentSelectionRequestsBus::Handler
|
||||
, private AZ::TransformNotificationBus::Handler
|
||||
, public AzFramework::BoundsRequestBus::Handler
|
||||
{
|
||||
friend class EditorOccluderAreaConfiguration;
|
||||
|
||||
using Base = AzToolsFramework::Components::EditorComponentBase;
|
||||
|
||||
public:
|
||||
AZ_COMPONENT(EditorOccluderAreaComponent, "{1A209C7C-6C06-5AE6-AD60-22CD8D0DAEE3}", AzToolsFramework::Components::EditorComponentBase);
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provides);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& requires);
|
||||
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
EditorOccluderAreaComponent() = default;
|
||||
EditorOccluderAreaComponent(const EditorOccluderAreaComponent&) = delete;
|
||||
EditorOccluderAreaComponent& operator=(const EditorOccluderAreaComponent&) = delete;
|
||||
~EditorOccluderAreaComponent();
|
||||
|
||||
// AZ::Component overrides ...
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
void BuildGameEntity(AZ::Entity* gameEntity) override;
|
||||
|
||||
// TransformNotificationBus overrides ...
|
||||
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
||||
|
||||
// EditorComponentSelectionRequestsBus overrides ...
|
||||
AZ::Aabb GetEditorSelectionBoundsViewport(
|
||||
const AzFramework::ViewportInfo& viewportInfo) override;
|
||||
bool EditorSelectionIntersectRayViewport(
|
||||
const AzFramework::ViewportInfo& viewportInfo, const AZ::Vector3& src,
|
||||
const AZ::Vector3& dir, float& distance) override;
|
||||
bool SupportsEditorRayIntersect() override { return true; }
|
||||
|
||||
// BoundsRequestBus overrides ...
|
||||
AZ::Aabb GetWorldBounds() override;
|
||||
AZ::Aabb GetLocalBounds() override;
|
||||
|
||||
/// EditorOccluderAreaRequestBus overrides ...
|
||||
void SetDisplayFilled(bool value) override;
|
||||
bool GetDisplayFilled() override;
|
||||
void SetCullDistRatio(float value) override;
|
||||
float GetCullDistRatio() override;
|
||||
void SetUseInIndoors(bool value) override;
|
||||
bool GetUseInIndoors() override;
|
||||
void SetDoubleSide(bool value) override;
|
||||
bool GetDoubleSide() override;
|
||||
bool GetVertex(size_t index, AZ::Vector3& vertex) const override;
|
||||
bool UpdateVertex(size_t index, const AZ::Vector3& vertex) override;
|
||||
size_t Size() const override { return m_config.m_vertices.size(); }
|
||||
void UpdateOccluderAreaObject() override;
|
||||
|
||||
private:
|
||||
friend EditorOccluderAreaConfiguration;
|
||||
|
||||
// AzFramework::EntityDebugDisplayEventBus overrides ...
|
||||
void DisplayEntityViewport(
|
||||
const AzFramework::ViewportInfo& viewportInfo,
|
||||
AzFramework::DebugDisplayRequests& debugDisplay) override;
|
||||
|
||||
// Reflected members
|
||||
EditorOccluderAreaConfiguration m_config;
|
||||
|
||||
using ComponentModeDelegate = AzToolsFramework::ComponentModeFramework::ComponentModeDelegate;
|
||||
ComponentModeDelegate m_componentModeDelegate; ///< Responsible for detecting ComponentMode activation
|
||||
///< and creating a concrete ComponentMode.
|
||||
|
||||
// Unreflected members
|
||||
IVisArea* m_area = nullptr;
|
||||
};
|
||||
} // namespace Visibility
|
||||
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Visibility_precompiled.h"
|
||||
#include "EditorOccluderAreaComponentMode.h"
|
||||
|
||||
#include <AzToolsFramework/Manipulators/ManipulatorManager.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR_IMPL(EditorOccluderAreaComponentMode, AZ::SystemAllocator, 0)
|
||||
|
||||
EditorOccluderAreaComponentMode::EditorOccluderAreaComponentMode(
|
||||
const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType)
|
||||
: EditorBaseComponentMode(entityComponentIdPair, componentType)
|
||||
{
|
||||
CreateManipulators();
|
||||
|
||||
AZ::TransformNotificationBus::Handler::BusConnect(entityComponentIdPair.GetEntityId());
|
||||
EditorOccluderAreaNotificationBus::Handler::BusConnect(entityComponentIdPair.GetEntityId());
|
||||
}
|
||||
|
||||
EditorOccluderAreaComponentMode::~EditorOccluderAreaComponentMode()
|
||||
{
|
||||
EditorOccluderAreaNotificationBus::Handler::BusDisconnect();
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
m_vertexSelection.Destroy();
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponentMode::CreateManipulators()
|
||||
{
|
||||
using namespace AzToolsFramework;
|
||||
|
||||
m_vertexSelection.Create(
|
||||
AZ::EntityComponentIdPair(GetEntityId(), GetComponentId()), g_mainManipulatorManagerId,
|
||||
AZStd::make_unique<NullHoverSelection>(),
|
||||
TranslationManipulators::Dimensions::Three,
|
||||
ConfigureTranslationManipulatorAppearance3d);
|
||||
|
||||
m_vertexSelection.SetVertexPositionsUpdatedCallback([this]()
|
||||
{
|
||||
EditorOccluderAreaRequestBus::Event(
|
||||
GetEntityId(), &EditorOccluderAreaRequests::UpdateOccluderAreaObject);
|
||||
});
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponentMode::OnTransformChanged(
|
||||
const AZ::Transform& /*local*/, const AZ::Transform& world)
|
||||
{
|
||||
m_vertexSelection.RefreshSpace(world);
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponentMode::OnVerticesChangedInspector()
|
||||
{
|
||||
m_vertexSelection.RefreshLocal();
|
||||
}
|
||||
|
||||
void EditorOccluderAreaComponentMode::Refresh()
|
||||
{
|
||||
// destroy and recreate manipulators when container is modified (vertices are added or removed)
|
||||
m_vertexSelection.Destroy();
|
||||
CreateManipulators();
|
||||
}
|
||||
|
||||
AZStd::vector<AzToolsFramework::ActionOverride> EditorOccluderAreaComponentMode::PopulateActionsImpl()
|
||||
{
|
||||
return m_vertexSelection.ActionOverrides();
|
||||
}
|
||||
|
||||
bool EditorOccluderAreaComponentMode::HandleMouseInteraction(
|
||||
const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& mouseInteraction)
|
||||
{
|
||||
return m_vertexSelection.HandleMouse(mouseInteraction);
|
||||
}
|
||||
} // namespace Visibility
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorBaseComponentMode.h>
|
||||
#include <AzToolsFramework/Manipulators/EditorVertexSelection.h>
|
||||
|
||||
#include "EditorOccluderAreaComponentBus.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
class EditorOccluderAreaComponentMode
|
||||
: public AzToolsFramework::ComponentModeFramework::EditorBaseComponentMode
|
||||
, private AZ::TransformNotificationBus::Handler
|
||||
, private EditorOccluderAreaNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR_DECL
|
||||
|
||||
EditorOccluderAreaComponentMode(
|
||||
const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType);
|
||||
~EditorOccluderAreaComponentMode();
|
||||
|
||||
private:
|
||||
// EditorBaseComponentMode
|
||||
void Refresh() override;
|
||||
AZStd::vector<AzToolsFramework::ActionOverride> PopulateActionsImpl() override;
|
||||
bool HandleMouseInteraction(
|
||||
const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& mouseInteraction) override;
|
||||
|
||||
// Manipulator handling
|
||||
void CreateManipulators();
|
||||
|
||||
// TransformNotificationBus
|
||||
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
||||
|
||||
// OccluderAreaNotificationBus
|
||||
void OnVerticesChangedInspector() override;
|
||||
|
||||
AzToolsFramework::EditorVertexSelectionFixed<AZ::Vector3> m_vertexSelection; ///< Handles all manipulator interactions with vertices.
|
||||
};
|
||||
} // namespace Visibility
|
||||
@ -1,785 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Visibility_precompiled.h"
|
||||
#include "EditorPortalComponent.h"
|
||||
#include "EditorPortalComponentMode.h"
|
||||
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
// Include files needed for writing DisplayEntity functions that access the DisplayContext directly.
|
||||
#include <EditorCoreAPI.h>
|
||||
|
||||
#include <AzCore/Math/Crc.h>
|
||||
#include <AzCore/Math/IntersectSegment.h>
|
||||
#include <AzToolsFramework/Viewport/VertexContainerDisplay.h>
|
||||
#include <Editor/Objects/BaseObject.h>
|
||||
#include <MathConversion.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
void EditorPortalComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
{
|
||||
provided.push_back(AZ_CRC("EditorPortalService", 0x6ead38f6));
|
||||
provided.push_back(AZ_CRC("PortalService", 0x06076210));
|
||||
provided.push_back(AZ_CRC("FixedVertexContainerService", 0x83f1bbf2));
|
||||
}
|
||||
|
||||
void EditorPortalComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
|
||||
{
|
||||
required.push_back(AZ_CRC("TransformService", 0x8ee22c50));
|
||||
}
|
||||
|
||||
void EditorPortalComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
|
||||
{
|
||||
dependent.push_back(AZ_CRC("QuadShapeService", 0xe449b0fc));
|
||||
}
|
||||
|
||||
void EditorPortalComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(AZ_CRC("SphereShapeService", 0x90c8dc80));
|
||||
incompatible.push_back(AZ_CRC("SplineShapeService", 0x4d4b94a2));
|
||||
incompatible.push_back(AZ_CRC("PolygonPrismShapeService", 0x1cbc4ed4));
|
||||
incompatible.push_back(AZ_CRC("FixedVertexContainerService", 0x83f1bbf2));
|
||||
}
|
||||
|
||||
void EditorPortalConfiguration::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<EditorPortalConfiguration, PortalConfiguration>()
|
||||
->Version(1);
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<EditorPortalConfiguration>("Portal Configuration", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true);
|
||||
|
||||
editContext->Class<PortalConfiguration>("Portal Configuration", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_height, "Height", "How tall the Portal is.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnChange)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_displayFilled, "DisplayFilled", "Display the Portal as a filled volume.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnChange)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_affectedBySun, "AffectedBySun", "Allows sunlight to affect objects inside the Portal.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnChange)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_viewDistRatio, "ViewDistRatio", "Specifies how far the Portal is rendered.")
|
||||
->Attribute(AZ::Edit::Attributes::Max, 100.000000)
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.000000)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnChange)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_skyOnly, "SkyOnly", "Only the Sky Box will render when looking outside the Portal.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnChange)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_oceanIsVisible, "OceanIsVisible", "Ocean will be visible when looking outside the Portal.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnChange)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_useDeepness, "UseDeepness", "Portal will be treated as an object with volume rather than a plane.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnChange)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_doubleSide, "DoubleSide", "Cameras will be able to look through the portal from both sides.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnChange)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_lightBlending, "LightBlending", "Light from neighboring VisAreas will blend into the Portal.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnChange)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_lightBlendValue, "LightBlendValue", "How much to blend lights from neighboring VisAreas.")
|
||||
->Attribute(AZ::Edit::Attributes::Max, 1.000000)
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.000000)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnChange)
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::Default, &PortalConfiguration::m_vertices, "Vertices", "Points that make up the floor of the Portal.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &PortalConfiguration::OnVerticesChange)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPortalComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<EditorPortalComponent, AzToolsFramework::Components::EditorComponentBase>()
|
||||
->Version(2)
|
||||
->Field("m_config", &EditorPortalComponent::m_config)
|
||||
->Field("ComponentMode", &EditorPortalComponent::m_componentModeDelegate)
|
||||
;
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<EditorPortalComponent>("Portal", "An area that describes a visibility portal between VisAreas.")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Category, "Rendering")
|
||||
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Viewport/Portal.png")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/Portal.svg")
|
||||
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
|
||||
->Attribute(AZ::Edit::Attributes::HelpPageURL, "http://docs.aws.amazon.com/console/lumberyard/userguide/portal-component")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &EditorPortalComponent::m_config, "m_config", "No Description")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &EditorPortalComponent::m_componentModeDelegate, "Component Mode", "Portal Component Mode")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<EditorPortalRequestBus>("EditorPortalRequestBus")
|
||||
->Event("SetHeight", &EditorPortalRequestBus::Events::SetHeight)
|
||||
->Event("GetHeight", &EditorPortalRequestBus::Events::GetHeight)
|
||||
->VirtualProperty("Height", "GetHeight", "SetHeight")
|
||||
|
||||
->Event("SetDisplayFilled", &EditorPortalRequestBus::Events::SetDisplayFilled)
|
||||
->Event("GetDisplayFilled", &EditorPortalRequestBus::Events::GetDisplayFilled)
|
||||
->VirtualProperty("DisplayFilled", "GetDisplayFilled", "SetDisplayFilled")
|
||||
|
||||
->Event("SetAffectedBySun", &EditorPortalRequestBus::Events::SetAffectedBySun)
|
||||
->Event("GetAffectedBySun", &EditorPortalRequestBus::Events::GetAffectedBySun)
|
||||
->VirtualProperty("AffectedBySun", "GetAffectedBySun", "SetAffectedBySun")
|
||||
|
||||
->Event("SetViewDistRatio", &EditorPortalRequestBus::Events::SetViewDistRatio)
|
||||
->Event("GetViewDistRatio", &EditorPortalRequestBus::Events::GetViewDistRatio)
|
||||
->VirtualProperty("ViewDistRatio", "GetViewDistRatio", "SetViewDistRatio")
|
||||
|
||||
->Event("SetSkyOnly", &EditorPortalRequestBus::Events::SetSkyOnly)
|
||||
->Event("GetSkyOnly", &EditorPortalRequestBus::Events::GetSkyOnly)
|
||||
->VirtualProperty("SkyOnly", "GetSkyOnly", "SetSkyOnly")
|
||||
|
||||
->Event("SetOceanIsVisible", &EditorPortalRequestBus::Events::SetOceanIsVisible)
|
||||
->Event("GetOceanIsVisible", &EditorPortalRequestBus::Events::GetOceanIsVisible)
|
||||
->VirtualProperty("OceanIsVisible", "GetOceanIsVisible", "SetOceanIsVisible")
|
||||
|
||||
->Event("SetUseDeepness", &EditorPortalRequestBus::Events::SetUseDeepness)
|
||||
->Event("GetUseDeepness", &EditorPortalRequestBus::Events::GetUseDeepness)
|
||||
->VirtualProperty("UseDeepness", "GetUseDeepness", "SetUseDeepness")
|
||||
|
||||
->Event("SetDoubleSide", &EditorPortalRequestBus::Events::SetDoubleSide)
|
||||
->Event("GetDoubleSide", &EditorPortalRequestBus::Events::GetDoubleSide)
|
||||
->VirtualProperty("DoubleSide", "GetDoubleSide", "SetDoubleSide")
|
||||
|
||||
->Event("SetLightBlending", &EditorPortalRequestBus::Events::SetLightBlending)
|
||||
->Event("GetLightBlending", &EditorPortalRequestBus::Events::GetLightBlending)
|
||||
->VirtualProperty("LightBlending", "GetLightBlending", "SetLightBlending")
|
||||
|
||||
->Event("SetLightBlendValue", &EditorPortalRequestBus::Events::SetLightBlendValue)
|
||||
->Event("GetLightBlendValue", &EditorPortalRequestBus::Events::GetLightBlendValue)
|
||||
->VirtualProperty("LightBlendValue", "GetLightBlendValue", "SetLightBlendValue")
|
||||
;
|
||||
|
||||
behaviorContext->Class<EditorPortalComponent>()->RequestBus("EditorPortalRequestBus");
|
||||
}
|
||||
|
||||
EditorPortalConfiguration::Reflect(context);
|
||||
}
|
||||
|
||||
void EditorPortalConfiguration::OnChange()
|
||||
{
|
||||
EditorPortalRequestBus::Event(m_entityId, &EditorPortalRequests::UpdatePortalObject);
|
||||
}
|
||||
|
||||
void EditorPortalConfiguration::OnVerticesChange()
|
||||
{
|
||||
EditorPortalRequestBus::Event(m_entityId, &EditorPortalRequests::UpdatePortalObject);
|
||||
EditorPortalNotificationBus::Event(m_entityId, &EditorPortalNotifications::OnVerticesChangedInspector);
|
||||
}
|
||||
|
||||
void EditorPortalConfiguration::SetEntityId(const AZ::EntityId entityId)
|
||||
{
|
||||
m_entityId = entityId;
|
||||
}
|
||||
|
||||
EditorPortalComponent::~EditorPortalComponent()
|
||||
{
|
||||
if (m_area)
|
||||
{
|
||||
// reset the listener vis area in the unlucky case that we are deleting the
|
||||
// vis area where the listener is currently in
|
||||
// Audio: do we still need this?
|
||||
GetIEditor()->Get3DEngine()->DeleteVisArea(m_area);
|
||||
m_area = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPortalComponent::Activate()
|
||||
{
|
||||
Base::Activate();
|
||||
|
||||
const AZ::EntityId entityId = GetEntityId();
|
||||
m_config.SetEntityId(entityId);
|
||||
|
||||
// NOTE: We create the vis-area here at activated, but destroy it in the destructor.
|
||||
// We have to do this, otherwise the vis-area is not saved into the level.
|
||||
// Unfortunately, at this time we cannot create the vis-areas at game runtime.
|
||||
// This means that dynamic slices cannot effectively contain vis-areas until we fix the core rendering system to allow that.
|
||||
|
||||
const auto visGUID = static_cast<AZ::u64>(entityId);
|
||||
if(!m_area && GetIEditor())
|
||||
{
|
||||
m_area = GetIEditor()->Get3DEngine()->CreateVisArea(visGUID);
|
||||
}
|
||||
|
||||
m_AZCachedWorldTransform = AZ::Transform::CreateIdentity();
|
||||
m_cryCachedWorldTransform = Matrix34::CreateIdentity();
|
||||
|
||||
m_componentModeDelegate.ConnectWithSingleComponentMode<
|
||||
EditorPortalComponent, EditorPortalComponentMode>(
|
||||
AZ::EntityComponentIdPair(entityId, GetId()), this);
|
||||
|
||||
EditorPortalRequestBus::Handler::BusConnect(entityId);
|
||||
AZ::FixedVerticesRequestBus<AZ::Vector3>::Handler::BusConnect(entityId);
|
||||
AZ::TransformNotificationBus::Handler::BusConnect(entityId);
|
||||
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(entityId);
|
||||
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusConnect(entityId);
|
||||
AzFramework::BoundsRequestBus::Handler::BusConnect(entityId);
|
||||
|
||||
//Call OnTransformChanged manually to cache current transform since it won't be called
|
||||
//automatically for us when the level starts up.
|
||||
AZ::Transform worldTM;
|
||||
AZ::TransformBus::EventResult(worldTM, entityId, &AZ::TransformBus::Events::GetWorldTM);
|
||||
|
||||
//Use an identity transform for localTM because the
|
||||
//OnTransformChanged impl for this class doesn't need it
|
||||
OnTransformChanged(AZ::Transform::CreateIdentity(), worldTM);
|
||||
}
|
||||
|
||||
void EditorPortalComponent::Deactivate()
|
||||
{
|
||||
m_componentModeDelegate.Disconnect();
|
||||
|
||||
AzFramework::BoundsRequestBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusDisconnect(GetEntityId());
|
||||
AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect(GetEntityId());
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect(GetEntityId());
|
||||
AZ::FixedVerticesRequestBus<AZ::Vector3>::Handler::BusDisconnect();
|
||||
EditorPortalRequestBus::Handler::BusDisconnect();
|
||||
|
||||
Base::Deactivate();
|
||||
}
|
||||
|
||||
void EditorPortalComponent::SetHeight(const float height)
|
||||
{
|
||||
m_config.m_height = height;
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
float EditorPortalComponent::GetHeight()
|
||||
{
|
||||
return m_config.m_height;
|
||||
}
|
||||
|
||||
void EditorPortalComponent::SetDisplayFilled(const bool filled)
|
||||
{
|
||||
m_config.m_displayFilled = filled;
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
bool EditorPortalComponent::GetDisplayFilled()
|
||||
{
|
||||
return m_config.m_displayFilled;
|
||||
}
|
||||
|
||||
void EditorPortalComponent::SetAffectedBySun(const bool affectedBySun)
|
||||
{
|
||||
m_config.m_affectedBySun = affectedBySun;
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
bool EditorPortalComponent::GetAffectedBySun()
|
||||
{
|
||||
return m_config.m_affectedBySun;
|
||||
}
|
||||
|
||||
void EditorPortalComponent::SetViewDistRatio(const float viewDistRatio)
|
||||
{
|
||||
m_config.m_viewDistRatio = viewDistRatio;
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
float EditorPortalComponent::GetViewDistRatio()
|
||||
{
|
||||
return m_config.m_viewDistRatio;
|
||||
}
|
||||
|
||||
void EditorPortalComponent::SetSkyOnly(const bool skyOnly)
|
||||
{
|
||||
m_config.m_skyOnly = skyOnly;
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
bool EditorPortalComponent::GetSkyOnly()
|
||||
{
|
||||
return m_config.m_skyOnly;
|
||||
}
|
||||
|
||||
void EditorPortalComponent::SetOceanIsVisible(const bool oceanVisible)
|
||||
{
|
||||
m_config.m_oceanIsVisible = oceanVisible;
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
bool EditorPortalComponent::GetOceanIsVisible()
|
||||
{
|
||||
return m_config.m_oceanIsVisible;
|
||||
}
|
||||
|
||||
void EditorPortalComponent::SetUseDeepness(const bool useDeepness)
|
||||
{
|
||||
m_config.m_useDeepness = useDeepness;
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
bool EditorPortalComponent::GetUseDeepness()
|
||||
{
|
||||
return m_config.m_useDeepness;
|
||||
}
|
||||
|
||||
void EditorPortalComponent::SetDoubleSide(const bool doubleSided)
|
||||
{
|
||||
m_config.m_doubleSide = doubleSided;
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
bool EditorPortalComponent::GetDoubleSide()
|
||||
{
|
||||
return m_config.m_doubleSide;
|
||||
}
|
||||
|
||||
void EditorPortalComponent::SetLightBlending(const bool lightBending)
|
||||
{
|
||||
m_config.m_lightBlending = lightBending;
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
bool EditorPortalComponent::GetLightBlending()
|
||||
{
|
||||
return m_config.m_lightBlending;
|
||||
}
|
||||
|
||||
void EditorPortalComponent::SetLightBlendValue(const float lightBendAmount)
|
||||
{
|
||||
m_config.m_lightBlendValue = lightBendAmount;
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
float EditorPortalComponent::GetLightBlendValue()
|
||||
{
|
||||
return m_config.m_lightBlendValue;
|
||||
}
|
||||
|
||||
bool EditorPortalComponent::GetVertex(const size_t index, AZ::Vector3& vertex) const
|
||||
{
|
||||
if (index < m_config.m_vertices.size())
|
||||
{
|
||||
vertex = m_config.m_vertices[index];
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditorPortalComponent::UpdateVertex(const size_t index, const AZ::Vector3& vertex)
|
||||
{
|
||||
if (index < m_config.m_vertices.size())
|
||||
{
|
||||
m_config.m_vertices[index] = vertex;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Update the object runtime after changes to the Configuration.
|
||||
/// Called by the default RequestBus SetXXX implementations,
|
||||
/// and used to initially set up the object the first time the
|
||||
/// Configuration are set.
|
||||
void EditorPortalComponent::UpdatePortalObject()
|
||||
{
|
||||
if (m_area)
|
||||
{
|
||||
SVisAreaInfo info;
|
||||
info.vAmbientColor = Vec3(ZERO);
|
||||
info.bAffectedByOutLights = m_config.m_affectedBySun;
|
||||
info.bSkyOnly = m_config.m_skyOnly;
|
||||
info.fViewDistRatio = m_config.m_viewDistRatio;
|
||||
info.bDoubleSide = m_config.m_doubleSide;
|
||||
info.bUseDeepness = m_config.m_useDeepness;
|
||||
info.bUseInIndoors = true; //Does not apply to Portals (Portals are only in VisAreas)
|
||||
info.bOceanIsVisible = m_config.m_oceanIsVisible;
|
||||
info.fPortalBlending = -1.0f;
|
||||
|
||||
if (m_config.m_lightBlending)
|
||||
{
|
||||
info.fPortalBlending = m_config.m_lightBlendValue;
|
||||
}
|
||||
|
||||
AZStd::string name = AZStd::string("Portal_") + GetEntity()->GetName();
|
||||
|
||||
// Calculate scaled height
|
||||
// Height exists separate from plane points but we still want to scale it with the transform
|
||||
info.fHeight = m_config.m_height;
|
||||
|
||||
/*
|
||||
We have to derive at least 3 points and pass them to the vis area system
|
||||
For now that means getting the 4 points of the bottom face of the box.
|
||||
|
||||
If we want to send *all* points of a shape the vis system we need to make sure
|
||||
that Height is 0; otherwise it'll extend the AABB of the area upwards.
|
||||
*/
|
||||
|
||||
//Convert to Cry vectors and apply the transform to the given points
|
||||
AZStd::fixed_vector<Vec3, 4> verts(4);
|
||||
for (AZ::u32 i = 0; i < verts.size(); ++i)
|
||||
{
|
||||
verts[i] = AZVec3ToLYVec3(m_config.m_vertices[i]);
|
||||
verts[i] = m_cryCachedWorldTransform.TransformPoint(verts[i]);
|
||||
}
|
||||
|
||||
GetIEditor()->Get3DEngine()->UpdateVisArea(m_area, &verts[0], verts.size(), name.c_str(), info, true);
|
||||
|
||||
AzFramework::EntityBoundsUnionRequestBus::Broadcast(
|
||||
&AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId());
|
||||
}
|
||||
}
|
||||
|
||||
void EditorPortalComponent::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world)
|
||||
{
|
||||
//Cache the transform so that we don't have to retrieve it every time UpdatePortalObject is called
|
||||
m_AZCachedWorldTransform = world;
|
||||
m_cryCachedWorldTransform = AZTransformToLYTransform(m_AZCachedWorldTransform);
|
||||
|
||||
UpdatePortalObject();
|
||||
}
|
||||
|
||||
struct PortalQuadVertices
|
||||
{
|
||||
AZ::Vector3 floorLeftFront;
|
||||
AZ::Vector3 floorRightFront;
|
||||
AZ::Vector3 floorLeftBack;
|
||||
AZ::Vector3 floorRightBack;
|
||||
|
||||
AZ::Vector3 quadUpperLeftFront;
|
||||
AZ::Vector3 quadUpperRightFront;
|
||||
AZ::Vector3 quadUpperLeftBack;
|
||||
AZ::Vector3 quadUpperRightBack;
|
||||
|
||||
AZ::Vector3 portalUpperLeftFront;
|
||||
AZ::Vector3 portalUpperRightFront;
|
||||
AZ::Vector3 portalUpperLeftBack;
|
||||
AZ::Vector3 portalUpperRightBack;
|
||||
};
|
||||
|
||||
PortalQuadVertices EditorPortalComponent::CalculatePortalQuadVertices(VertTranslation vertTranslation)
|
||||
{
|
||||
PortalQuadVertices pqv;
|
||||
|
||||
//Untransformed quad corners
|
||||
const AZ::Vector3 lowerLeftFront = m_config.m_vertices[0];
|
||||
const AZ::Vector3 lowerRightFront = m_config.m_vertices[1];
|
||||
const AZ::Vector3 lowerLeftBack = m_config.m_vertices[3];
|
||||
const AZ::Vector3 lowerRightBack = m_config.m_vertices[2];
|
||||
|
||||
//Need to calculate the height of the quad after transformation
|
||||
const AZ::u32 quadPointCount = 4;
|
||||
AZ::Vector3 transformedQuadPoints[quadPointCount];
|
||||
|
||||
transformedQuadPoints[0] = m_AZCachedWorldTransform.TransformPoint(lowerLeftFront);
|
||||
transformedQuadPoints[1] = m_AZCachedWorldTransform.TransformPoint(lowerRightFront);
|
||||
transformedQuadPoints[2] = m_AZCachedWorldTransform.TransformPoint(lowerLeftBack);
|
||||
transformedQuadPoints[3] = m_AZCachedWorldTransform.TransformPoint(lowerRightBack);
|
||||
|
||||
const AZ::Vector3 translation = m_AZCachedWorldTransform.GetTranslation();
|
||||
|
||||
float minHeight = FLT_MAX;
|
||||
float maxHeight = FLT_MIN;
|
||||
|
||||
for (auto& transformedQuadPoint : transformedQuadPoints)
|
||||
{
|
||||
// remove translation from quad points so we can use them with the DisplayContext's usage of the transform
|
||||
if (vertTranslation == VertTranslation::Remove)
|
||||
{
|
||||
transformedQuadPoint -= translation;
|
||||
}
|
||||
|
||||
const float height = transformedQuadPoint.GetZ();
|
||||
if (height < minHeight)
|
||||
{
|
||||
minHeight = height;
|
||||
}
|
||||
if (height > maxHeight)
|
||||
{
|
||||
maxHeight = height;
|
||||
}
|
||||
}
|
||||
|
||||
pqv.floorLeftFront = AZ::Vector3(transformedQuadPoints[0].GetX(), transformedQuadPoints[0].GetY(), minHeight);
|
||||
pqv.floorRightFront = AZ::Vector3(transformedQuadPoints[1].GetX(), transformedQuadPoints[1].GetY(), minHeight);
|
||||
pqv.floorLeftBack = AZ::Vector3(transformedQuadPoints[2].GetX(), transformedQuadPoints[2].GetY(), minHeight);
|
||||
pqv.floorRightBack = AZ::Vector3(transformedQuadPoints[3].GetX(), transformedQuadPoints[3].GetY(), minHeight);
|
||||
|
||||
pqv.quadUpperLeftFront = AZ::Vector3(transformedQuadPoints[0].GetX(), transformedQuadPoints[0].GetY(), maxHeight);
|
||||
pqv.quadUpperRightFront = AZ::Vector3(transformedQuadPoints[1].GetX(), transformedQuadPoints[1].GetY(), maxHeight);
|
||||
pqv.quadUpperLeftBack = AZ::Vector3(transformedQuadPoints[2].GetX(), transformedQuadPoints[2].GetY(), maxHeight);
|
||||
pqv.quadUpperRightBack = AZ::Vector3(transformedQuadPoints[3].GetX(), transformedQuadPoints[3].GetY(), maxHeight);
|
||||
|
||||
pqv.portalUpperLeftFront = AZ::Vector3(transformedQuadPoints[0].GetX(), transformedQuadPoints[0].GetY(), maxHeight + m_config.m_height);
|
||||
pqv.portalUpperRightFront = AZ::Vector3(transformedQuadPoints[1].GetX(), transformedQuadPoints[1].GetY(), maxHeight + m_config.m_height);
|
||||
pqv.portalUpperLeftBack = AZ::Vector3(transformedQuadPoints[2].GetX(), transformedQuadPoints[2].GetY(), maxHeight + m_config.m_height);
|
||||
pqv.portalUpperRightBack = AZ::Vector3(transformedQuadPoints[3].GetX(), transformedQuadPoints[3].GetY(), maxHeight + m_config.m_height);
|
||||
|
||||
return pqv;
|
||||
}
|
||||
|
||||
void EditorPortalComponent::DisplayEntityViewport(
|
||||
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo,
|
||||
AzFramework::DebugDisplayRequests& debugDisplay)
|
||||
{
|
||||
/*
|
||||
IMPORTANT NOTE: This method may seem very complicated but it is an accurate visualization of
|
||||
how portals actually work. The legacy visualization used with the legacy portal entity is
|
||||
very misleading!
|
||||
|
||||
Portals always exist as a quad but if the quad becomes non-planar, from rotation or in the legacy
|
||||
system from a point being pulled up or down, the volume changes in a non-obvious way. Instead of portal
|
||||
existing as the shape defined by 4 points and extruded upwards, the portal actually remains planar.
|
||||
Any height difference that you add by making the shape non-planar is just applied to the height of the volume.
|
||||
|
||||
If this is confusing, please actually look at the visualization created by this method. Make sure
|
||||
that you rotate the portal in many weird contorted ways and examine how the visualization reacts.
|
||||
The portal volume is always going to be a box rotated on only X and Y axes that stretches up along the Z axis.
|
||||
|
||||
Important note on the complexity of this method:
|
||||
We cannot directly visualize the OBB of the portal with an AABB that we then transform. The OBB that's mentioned
|
||||
here is best imagined as the top plane being all points of the quad pulled up to the height of the highest quad's vert
|
||||
and the bottom plane being all points of the quad pulled down to the height of the lowest quad's vert. Trying to
|
||||
create an AABB from these points won't produce the correct visualization under complex rotations as the Min and Max
|
||||
of the AABB will either only encompass part of the bounding volume or be too large.
|
||||
*/
|
||||
|
||||
const PortalQuadVertices pqv = CalculatePortalQuadVertices(VertTranslation::Remove);
|
||||
|
||||
//Draw the outline of the OBB of the Portal's quad
|
||||
AZ::Color color(0.000f, 1.0f, 0.000f, 1.0f);
|
||||
debugDisplay.SetColor(AZ::Vector4(color.GetR(), color.GetG(), color.GetB(), 1.f));
|
||||
|
||||
//Remove all rotation from the transform
|
||||
const AZ::Quaternion rotation = AZ::Quaternion::CreateIdentity();
|
||||
|
||||
AZ::Transform worldTMOnlyZRot = m_AZCachedWorldTransform;
|
||||
worldTMOnlyZRot.SetRotation(rotation);
|
||||
|
||||
debugDisplay.PushMatrix(worldTMOnlyZRot);
|
||||
|
||||
//Draw the outline of the OBB of the portal quad
|
||||
|
||||
//Bottom
|
||||
debugDisplay.DrawLine(pqv.floorLeftFront, pqv.floorRightFront);
|
||||
debugDisplay.DrawLine(pqv.floorRightFront, pqv.floorRightBack);
|
||||
debugDisplay.DrawLine(pqv.floorRightBack, pqv.floorLeftBack);
|
||||
debugDisplay.DrawLine(pqv.floorLeftBack, pqv.floorLeftFront);
|
||||
//Top
|
||||
debugDisplay.DrawLine(pqv.quadUpperLeftFront, pqv.quadUpperRightFront);
|
||||
debugDisplay.DrawLine(pqv.quadUpperRightFront, pqv.quadUpperRightBack);
|
||||
debugDisplay.DrawLine(pqv.quadUpperRightBack, pqv.quadUpperLeftBack);
|
||||
debugDisplay.DrawLine(pqv.quadUpperLeftBack, pqv.quadUpperLeftFront);
|
||||
//Left
|
||||
debugDisplay.DrawLine(pqv.floorLeftFront, pqv.quadUpperLeftFront);
|
||||
debugDisplay.DrawLine(pqv.quadUpperLeftFront, pqv.quadUpperLeftBack);
|
||||
debugDisplay.DrawLine(pqv.quadUpperLeftBack, pqv.floorLeftBack);
|
||||
debugDisplay.DrawLine(pqv.floorLeftBack, pqv.floorLeftFront);
|
||||
//Right
|
||||
debugDisplay.DrawLine(pqv.floorRightFront, pqv.quadUpperRightFront);
|
||||
debugDisplay.DrawLine(pqv.quadUpperRightFront, pqv.quadUpperRightBack);
|
||||
debugDisplay.DrawLine(pqv.quadUpperRightBack, pqv.floorRightBack);
|
||||
debugDisplay.DrawLine(pqv.floorRightBack, pqv.floorRightFront);
|
||||
//Front
|
||||
debugDisplay.DrawLine(pqv.floorLeftFront, pqv.floorRightFront);
|
||||
debugDisplay.DrawLine(pqv.floorRightFront, pqv.quadUpperRightFront);
|
||||
debugDisplay.DrawLine(pqv.quadUpperRightFront, pqv.quadUpperLeftFront);
|
||||
debugDisplay.DrawLine(pqv.quadUpperLeftFront, pqv.floorLeftFront);
|
||||
//Back
|
||||
debugDisplay.DrawLine(pqv.floorLeftBack, pqv.floorRightBack);
|
||||
debugDisplay.DrawLine(pqv.floorRightBack, pqv.quadUpperRightBack);
|
||||
debugDisplay.DrawLine(pqv.quadUpperRightBack, pqv.quadUpperLeftBack);
|
||||
debugDisplay.DrawLine(pqv.quadUpperLeftBack, pqv.floorLeftBack);
|
||||
|
||||
//Now draw the entire portal volume (Previous OBB + extra height)
|
||||
if (m_config.m_displayFilled)
|
||||
{
|
||||
//Draw whole portal with less alpha
|
||||
debugDisplay.SetColor(AZ::Vector4(color.GetR(), color.GetG(), color.GetB(), 0.1f));
|
||||
|
||||
//Draw both winding orders for quads so they appear solid from all angles
|
||||
//Not drawing boxes because the corners of the quad may not be hit if the bounds are rotated oddly
|
||||
|
||||
//Bottom
|
||||
debugDisplay.DrawQuad(pqv.floorLeftFront, pqv.floorRightFront, pqv.floorRightBack, pqv.floorLeftBack);
|
||||
debugDisplay.DrawQuad(pqv.floorLeftFront, pqv.floorLeftBack, pqv.floorRightBack, pqv.floorRightFront);
|
||||
//Top
|
||||
debugDisplay.DrawQuad(pqv.portalUpperLeftFront, pqv.portalUpperRightFront, pqv.portalUpperRightBack, pqv.portalUpperLeftBack);
|
||||
debugDisplay.DrawQuad(pqv.portalUpperLeftFront, pqv.portalUpperLeftBack, pqv.portalUpperRightBack, pqv.portalUpperRightFront);
|
||||
//Left
|
||||
debugDisplay.DrawQuad(pqv.floorLeftFront, pqv.portalUpperLeftFront, pqv.portalUpperLeftBack, pqv.floorLeftBack);
|
||||
debugDisplay.DrawQuad(pqv.floorLeftFront, pqv.floorLeftBack, pqv.portalUpperLeftBack, pqv.portalUpperLeftFront);
|
||||
//Right
|
||||
debugDisplay.DrawQuad(pqv.floorRightFront, pqv.portalUpperRightFront, pqv.portalUpperRightBack, pqv.floorRightBack);
|
||||
debugDisplay.DrawQuad(pqv.floorRightFront, pqv.floorRightBack, pqv.portalUpperRightBack, pqv.portalUpperRightFront);
|
||||
//Front
|
||||
debugDisplay.DrawQuad(pqv.floorLeftFront, pqv.floorRightFront, pqv.portalUpperRightFront, pqv.portalUpperLeftFront);
|
||||
debugDisplay.DrawQuad(pqv.floorLeftFront, pqv.portalUpperLeftFront, pqv.portalUpperRightFront, pqv.floorRightFront);
|
||||
//Back
|
||||
debugDisplay.DrawQuad(pqv.floorLeftBack, pqv.floorRightBack, pqv.portalUpperRightBack, pqv.portalUpperLeftBack);
|
||||
debugDisplay.DrawQuad(pqv.floorLeftBack, pqv.portalUpperLeftBack, pqv.portalUpperRightBack, pqv.floorRightBack);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Bottom
|
||||
debugDisplay.DrawLine(pqv.floorLeftFront, pqv.floorRightFront);
|
||||
debugDisplay.DrawLine(pqv.floorRightFront, pqv.floorRightBack);
|
||||
debugDisplay.DrawLine(pqv.floorRightBack, pqv.floorLeftBack);
|
||||
debugDisplay.DrawLine(pqv.floorLeftBack, pqv.floorLeftFront);
|
||||
//Top
|
||||
debugDisplay.DrawLine(pqv.portalUpperLeftFront, pqv.portalUpperRightFront);
|
||||
debugDisplay.DrawLine(pqv.portalUpperRightFront, pqv.portalUpperRightBack);
|
||||
debugDisplay.DrawLine(pqv.portalUpperRightBack, pqv.portalUpperLeftBack);
|
||||
debugDisplay.DrawLine(pqv.portalUpperLeftBack, pqv.portalUpperLeftFront);
|
||||
//Left
|
||||
debugDisplay.DrawLine(pqv.floorLeftFront, pqv.portalUpperLeftFront);
|
||||
debugDisplay.DrawLine(pqv.portalUpperLeftFront, pqv.portalUpperLeftBack);
|
||||
debugDisplay.DrawLine(pqv.portalUpperLeftBack, pqv.floorLeftBack);
|
||||
debugDisplay.DrawLine(pqv.floorLeftBack, pqv.floorLeftFront);
|
||||
//Right
|
||||
debugDisplay.DrawLine(pqv.floorRightFront, pqv.portalUpperRightFront);
|
||||
debugDisplay.DrawLine(pqv.portalUpperRightFront, pqv.portalUpperRightBack);
|
||||
debugDisplay.DrawLine(pqv.portalUpperRightBack, pqv.floorRightBack);
|
||||
debugDisplay.DrawLine(pqv.floorRightBack, pqv.floorRightFront);
|
||||
//Front
|
||||
debugDisplay.DrawLine(pqv.floorLeftFront, pqv.floorRightFront);
|
||||
debugDisplay.DrawLine(pqv.floorRightFront, pqv.portalUpperRightFront);
|
||||
debugDisplay.DrawLine(pqv.portalUpperRightFront, pqv.portalUpperLeftFront);
|
||||
debugDisplay.DrawLine(pqv.portalUpperLeftFront, pqv.floorLeftFront);
|
||||
//Back
|
||||
debugDisplay.DrawLine(pqv.floorLeftBack, pqv.floorRightBack);
|
||||
debugDisplay.DrawLine(pqv.floorRightBack, pqv.portalUpperRightBack);
|
||||
debugDisplay.DrawLine(pqv.portalUpperRightBack, pqv.portalUpperLeftBack);
|
||||
debugDisplay.DrawLine(pqv.portalUpperLeftBack, pqv.floorLeftBack);
|
||||
}
|
||||
|
||||
if (m_componentModeDelegate.AddedToComponentMode())
|
||||
{
|
||||
AzToolsFramework::VertexContainerDisplay::DisplayVertexContainerIndices(
|
||||
debugDisplay, AzToolsFramework::FixedVerticesArray<AZ::Vector3, 4>(m_config.m_vertices),
|
||||
GetWorldTM(), AZ::Vector3::CreateOne(), IsSelected());
|
||||
}
|
||||
|
||||
debugDisplay.PopMatrix();
|
||||
}
|
||||
|
||||
void EditorPortalComponent::BuildGameEntity(AZ::Entity* gameEntity)
|
||||
{
|
||||
gameEntity->CreateComponent<PortalComponent>(m_config);
|
||||
}
|
||||
|
||||
AZ::Aabb EditorPortalComponent::GetEditorSelectionBoundsViewport(const AzFramework::ViewportInfo& /*viewportInfo*/)
|
||||
{
|
||||
const PortalQuadVertices pqv = CalculatePortalQuadVertices(VertTranslation::Keep);
|
||||
|
||||
AZ::Aabb bbox = AZ::Aabb::CreateNull();
|
||||
bbox.AddPoint(pqv.floorLeftFront);
|
||||
bbox.AddPoint(pqv.floorRightFront);
|
||||
bbox.AddPoint(pqv.floorLeftBack);
|
||||
bbox.AddPoint(pqv.floorRightBack);
|
||||
bbox.AddPoint(pqv.portalUpperLeftFront);
|
||||
return bbox;
|
||||
}
|
||||
|
||||
bool EditorPortalComponent::EditorSelectionIntersectRayViewport(
|
||||
const AzFramework::ViewportInfo& /*viewportInfo*/, const AZ::Vector3& src,
|
||||
const AZ::Vector3& dir, float& distance)
|
||||
{
|
||||
float t;
|
||||
float intermediateT = FLT_MAX;
|
||||
|
||||
const PortalQuadVertices pqv = CalculatePortalQuadVertices(VertTranslation::Keep);
|
||||
|
||||
//Count each quad for intersection hits, two hits implies we are intersecting the prism from outside of it (or from too far)
|
||||
AZ::u8 hits = 0;
|
||||
|
||||
//Bottom
|
||||
if (AZ::Intersect::IntersectRayQuad(src, dir, pqv.floorLeftFront, pqv.floorRightFront, pqv.floorRightBack, pqv.floorLeftBack, t))
|
||||
{
|
||||
++hits;
|
||||
intermediateT = AZStd::GetMin(t, intermediateT);
|
||||
}
|
||||
//Top
|
||||
if (AZ::Intersect::IntersectRayQuad(src, dir, pqv.portalUpperLeftFront, pqv.portalUpperRightFront, pqv.portalUpperRightBack, pqv.portalUpperLeftBack, t))
|
||||
{
|
||||
++hits;
|
||||
intermediateT = AZStd::GetMin(t, intermediateT);
|
||||
}
|
||||
|
||||
//Left
|
||||
if (AZ::Intersect::IntersectRayQuad(src, dir, pqv.floorLeftFront, pqv.portalUpperLeftFront, pqv.portalUpperLeftBack, pqv.floorLeftBack, t))
|
||||
{
|
||||
++hits;
|
||||
intermediateT = AZStd::GetMin(t, intermediateT);
|
||||
}
|
||||
//Right
|
||||
if (AZ::Intersect::IntersectRayQuad(src, dir, pqv.floorRightFront, pqv.portalUpperRightFront, pqv.portalUpperRightBack, pqv.floorRightBack, t))
|
||||
{
|
||||
++hits;
|
||||
intermediateT = AZStd::GetMin(t, intermediateT);
|
||||
}
|
||||
//Front
|
||||
if (AZ::Intersect::IntersectRayQuad(src, dir, pqv.floorLeftFront, pqv.floorRightFront, pqv.portalUpperRightFront, pqv.portalUpperLeftFront, t))
|
||||
{
|
||||
++hits;
|
||||
intermediateT = AZStd::GetMin(t, intermediateT);
|
||||
}
|
||||
//Back
|
||||
if (AZ::Intersect::IntersectRayQuad(src, dir, pqv.floorLeftBack, pqv.floorRightBack, pqv.portalUpperRightBack, pqv.portalUpperLeftBack, t))
|
||||
{
|
||||
++hits;
|
||||
intermediateT = AZStd::GetMin(t, intermediateT);
|
||||
}
|
||||
|
||||
if (hits > 0)
|
||||
{
|
||||
distance = intermediateT;
|
||||
}
|
||||
return hits >= 2;
|
||||
}
|
||||
|
||||
AZ::Aabb EditorPortalComponent::GetWorldBounds()
|
||||
{
|
||||
return GetLocalBounds().GetTransformedAabb(m_AZCachedWorldTransform);
|
||||
}
|
||||
|
||||
AZ::Aabb EditorPortalComponent::GetLocalBounds()
|
||||
{
|
||||
AZ::Aabb bbox = AZ::Aabb::CreateNull();
|
||||
for (const auto& vertex : m_config.m_vertices)
|
||||
{
|
||||
bbox.AddPoint(vertex);
|
||||
}
|
||||
return bbox;
|
||||
}
|
||||
} //namespace Visibility
|
||||
@ -1,148 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
||||
#include <AzFramework/Visibility/BoundsBus.h>
|
||||
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/ComponentMode/ComponentModeDelegate.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
|
||||
|
||||
#include "PortalComponent.h"
|
||||
#include "EditorPortalComponentBus.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
class EditorPortalComponent;
|
||||
struct PortalQuadVertices;
|
||||
|
||||
class EditorPortalConfiguration
|
||||
: public PortalConfiguration
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO_LEGACY(EditorPortalConfiguration, "{C9F99449-7A77-50C4-9ED3-D69B923BFDBD}", PortalConfiguration);
|
||||
AZ_CLASS_ALLOCATOR(EditorPortalConfiguration, AZ::SystemAllocator,0);
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
void OnChange() override;
|
||||
void OnVerticesChange() override;
|
||||
|
||||
void SetEntityId(AZ::EntityId entityId);
|
||||
|
||||
private:
|
||||
AZ::EntityId m_entityId;
|
||||
};
|
||||
|
||||
class EditorPortalComponent
|
||||
: public AzToolsFramework::Components::EditorComponentBase
|
||||
, private EditorPortalRequestBus::Handler
|
||||
, private AZ::FixedVerticesRequestBus<AZ::Vector3>::Handler
|
||||
, private AzFramework::EntityDebugDisplayEventBus::Handler
|
||||
, private AzToolsFramework::EditorComponentSelectionRequestsBus::Handler
|
||||
, public AZ::TransformNotificationBus::Handler
|
||||
, public AzFramework::BoundsRequestBus::Handler
|
||||
{
|
||||
friend class EditorPortalConfiguration;
|
||||
|
||||
using Base = AzToolsFramework::Components::EditorComponentBase;
|
||||
|
||||
public:
|
||||
AZ_COMPONENT(EditorPortalComponent, "{64525CDD-7DD4-5CEF-B545-559127DC834E}", AzToolsFramework::Components::EditorComponentBase);
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
||||
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
EditorPortalComponent() = default;
|
||||
EditorPortalComponent(const EditorPortalComponent&) = delete;
|
||||
EditorPortalComponent& operator=(const EditorPortalComponent&) = delete;
|
||||
~EditorPortalComponent() override;
|
||||
|
||||
// EditorComponentBase overrides ...
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
void BuildGameEntity(AZ::Entity* gameEntity) override;
|
||||
|
||||
// TransformNotificationBus overrides ...
|
||||
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
||||
|
||||
// EditorComponentSelectionRequestsBus overrides ...
|
||||
AZ::Aabb GetEditorSelectionBoundsViewport(
|
||||
const AzFramework::ViewportInfo& viewportInfo) override;
|
||||
bool EditorSelectionIntersectRayViewport(
|
||||
const AzFramework::ViewportInfo& viewportInfo, const AZ::Vector3& src,
|
||||
const AZ::Vector3& dir, float& distance) override;
|
||||
bool SupportsEditorRayIntersect() override { return true; }
|
||||
|
||||
// PortalRequestBus overrides ...
|
||||
void SetHeight(float height) override;
|
||||
float GetHeight() override;
|
||||
void SetDisplayFilled(bool filled) override;
|
||||
bool GetDisplayFilled() override;
|
||||
void SetAffectedBySun(bool affectedBySun) override;
|
||||
bool GetAffectedBySun() override;
|
||||
void SetViewDistRatio(float viewDistRatio) override;
|
||||
float GetViewDistRatio() override;
|
||||
void SetSkyOnly(bool skyOnly) override;
|
||||
bool GetSkyOnly() override;
|
||||
void SetOceanIsVisible(bool oceanVisible) override;
|
||||
bool GetOceanIsVisible() override;
|
||||
void SetUseDeepness(bool useDeepness) override;
|
||||
bool GetUseDeepness() override;
|
||||
void SetDoubleSide(bool doubleSided) override;
|
||||
bool GetDoubleSide() override;
|
||||
void SetLightBlending(bool lightBending) override;
|
||||
bool GetLightBlending() override;
|
||||
void SetLightBlendValue(float lightBendAmount) override;
|
||||
float GetLightBlendValue() override;
|
||||
bool GetVertex(size_t index, AZ::Vector3& vertex) const override;
|
||||
bool UpdateVertex(size_t index, const AZ::Vector3& vertex) override;
|
||||
size_t Size() const override { return m_config.m_vertices.size(); }
|
||||
void UpdatePortalObject() override;
|
||||
|
||||
// EntityDebugDisplayBus overrides ...
|
||||
void DisplayEntityViewport(
|
||||
const AzFramework::ViewportInfo& viewportInfo,
|
||||
AzFramework::DebugDisplayRequests& debugDisplay) override;
|
||||
|
||||
// BoundsRequestBus overrides ...
|
||||
AZ::Aabb GetWorldBounds() override;
|
||||
AZ::Aabb GetLocalBounds() override;
|
||||
|
||||
private:
|
||||
enum class VertTranslation
|
||||
{
|
||||
Keep,
|
||||
Remove
|
||||
};
|
||||
|
||||
PortalQuadVertices CalculatePortalQuadVertices(VertTranslation vertTranslation);
|
||||
|
||||
// Reflected members
|
||||
EditorPortalConfiguration m_config;
|
||||
|
||||
using ComponentModeDelegate = AzToolsFramework::ComponentModeFramework::ComponentModeDelegate;
|
||||
ComponentModeDelegate m_componentModeDelegate; ///< Responsible for detecting ComponentMode activation
|
||||
///< and creating a concrete ComponentMode.
|
||||
|
||||
AZ::Transform m_AZCachedWorldTransform;
|
||||
Matrix44 m_cryCachedWorldTransform;
|
||||
IVisArea* m_area = nullptr;
|
||||
};
|
||||
} // namespace Visibility
|
||||
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Visibility_precompiled.h"
|
||||
#include "EditorPortalComponentMode.h"
|
||||
|
||||
#include <AzToolsFramework/Manipulators/ManipulatorManager.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR_IMPL(EditorPortalComponentMode, AZ::SystemAllocator, 0)
|
||||
|
||||
EditorPortalComponentMode::EditorPortalComponentMode(
|
||||
const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType)
|
||||
: EditorBaseComponentMode(entityComponentIdPair, componentType)
|
||||
{
|
||||
CreateManipulators();
|
||||
|
||||
AZ::TransformNotificationBus::Handler::BusConnect(entityComponentIdPair.GetEntityId());
|
||||
EditorPortalNotificationBus::Handler::BusConnect(entityComponentIdPair.GetEntityId());
|
||||
}
|
||||
|
||||
EditorPortalComponentMode::~EditorPortalComponentMode()
|
||||
{
|
||||
EditorPortalNotificationBus::Handler::BusDisconnect();
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
m_vertexSelection.Destroy();
|
||||
}
|
||||
|
||||
void EditorPortalComponentMode::CreateManipulators()
|
||||
{
|
||||
using namespace AzToolsFramework;
|
||||
|
||||
m_vertexSelection.Create(
|
||||
AZ::EntityComponentIdPair(GetEntityId(), GetComponentId()), g_mainManipulatorManagerId,
|
||||
AZStd::make_unique<NullHoverSelection>(),
|
||||
TranslationManipulators::Dimensions::Three,
|
||||
ConfigureTranslationManipulatorAppearance3d);
|
||||
|
||||
m_vertexSelection.SetVertexPositionsUpdatedCallback([this]()
|
||||
{
|
||||
EditorPortalRequestBus::Event(
|
||||
GetEntityId(), &EditorPortalRequests::UpdatePortalObject);
|
||||
});
|
||||
}
|
||||
|
||||
void EditorPortalComponentMode::OnTransformChanged(
|
||||
const AZ::Transform& /*local*/, const AZ::Transform& world)
|
||||
{
|
||||
m_vertexSelection.RefreshSpace(world);
|
||||
}
|
||||
|
||||
void EditorPortalComponentMode::OnVerticesChangedInspector()
|
||||
{
|
||||
m_vertexSelection.RefreshLocal();
|
||||
}
|
||||
|
||||
void EditorPortalComponentMode::Refresh()
|
||||
{
|
||||
// destroy and recreate manipulators when container is modified (vertices are added or removed)
|
||||
m_vertexSelection.Destroy();
|
||||
CreateManipulators();
|
||||
}
|
||||
|
||||
AZStd::vector<AzToolsFramework::ActionOverride> EditorPortalComponentMode::PopulateActionsImpl()
|
||||
{
|
||||
return m_vertexSelection.ActionOverrides();
|
||||
}
|
||||
|
||||
bool EditorPortalComponentMode::HandleMouseInteraction(
|
||||
const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& mouseInteraction)
|
||||
{
|
||||
return m_vertexSelection.HandleMouse(mouseInteraction);
|
||||
}
|
||||
} // namespace Visibility
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorBaseComponentMode.h>
|
||||
#include <AzToolsFramework/Manipulators/EditorVertexSelection.h>
|
||||
|
||||
#include "EditorPortalComponentBus.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
class EditorPortalComponentMode
|
||||
: public AzToolsFramework::ComponentModeFramework::EditorBaseComponentMode
|
||||
, private AZ::TransformNotificationBus::Handler
|
||||
, private EditorPortalNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR_DECL
|
||||
|
||||
EditorPortalComponentMode(
|
||||
const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType);
|
||||
~EditorPortalComponentMode();
|
||||
|
||||
private:
|
||||
// EditorBaseComponentMode
|
||||
void Refresh() override;
|
||||
AZStd::vector<AzToolsFramework::ActionOverride> PopulateActionsImpl() override;
|
||||
bool HandleMouseInteraction(
|
||||
const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& mouseInteraction) override;
|
||||
|
||||
// Manipulator handling
|
||||
void CreateManipulators();
|
||||
|
||||
// TransformNotificationBus
|
||||
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
||||
|
||||
// EditorPortalNotificationBus
|
||||
void OnVerticesChangedInspector() override;
|
||||
|
||||
AzToolsFramework::EditorVertexSelectionFixed<AZ::Vector3> m_vertexSelection; ///< Handles all manipulator interactions with vertices.
|
||||
};
|
||||
} // namespace Visibility
|
||||
@ -1,629 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Visibility_precompiled.h"
|
||||
#include "EditorVisAreaComponent.h"
|
||||
#include "EditorVisAreaComponentMode.h"
|
||||
|
||||
#include <AzCore/Math/Crc.h>
|
||||
#include <AzCore/Math/IntersectSegment.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzToolsFramework/Viewport/VertexContainerDisplay.h>
|
||||
#include <Editor/Objects/BaseObject.h>
|
||||
|
||||
// Include files needed for writing DisplayEntity functions that access the DisplayContext directly.
|
||||
#include <EditorCoreAPI.h>
|
||||
|
||||
#include "MathConversion.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
/*static*/ AZ::Color EditorVisAreaComponent::s_visAreaColor = AZ::Color(1.0f, 0.5f, 0.0f, 1.0f);
|
||||
|
||||
void EditorVisAreaComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
{
|
||||
provided.push_back(AZ_CRC("EditorVisAreaService", 0x4507d2ae));
|
||||
provided.push_back(AZ_CRC("VisAreaService", 0x0c063fb9));
|
||||
provided.push_back(AZ_CRC("VariableVertexContainerService", 0x70c58740));
|
||||
provided.push_back(AZ_CRC("FixedVertexContainerService", 0x83f1bbf2));
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& requires)
|
||||
{
|
||||
requires.push_back(AZ_CRC("TransformService", 0x8ee22c50));
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(AZ_CRC("VariableVertexContainerService", 0x70c58740));
|
||||
incompatible.push_back(AZ_CRC("FixedVertexContainerService", 0x83f1bbf2));
|
||||
}
|
||||
|
||||
void EditorVisAreaConfiguration::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<EditorVisAreaConfiguration, VisAreaConfiguration>()
|
||||
->Version(1);
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<EditorVisAreaConfiguration>("VisArea Configuration", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true);
|
||||
|
||||
editContext->Class<VisAreaConfiguration>("VisArea Configuration", "")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &VisAreaConfiguration::m_height, "Height", "How tall the VisArea is.")
|
||||
->Attribute(AZ::Edit::Attributes::Max, 100.0f)
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &VisAreaConfiguration::ChangeHeight)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &VisAreaConfiguration::m_displayFilled, "DisplayFilled", "Display the VisArea as a filled volume.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &VisAreaConfiguration::ChangeDisplayFilled)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &VisAreaConfiguration::m_affectedBySun, "AffectedBySun", "Allows sunlight to affect objects inside the VisArea.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &VisAreaConfiguration::ChangeAffectedBySun)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &VisAreaConfiguration::m_viewDistRatio, "ViewDistRatio", "Specifies how far the VisArea is rendered.")
|
||||
->Attribute(AZ::Edit::Attributes::Max, 100.0f)
|
||||
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &VisAreaConfiguration::ChangeViewDistRatio)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &VisAreaConfiguration::m_oceanIsVisible, "OceanIsVisible", "Ocean will be visible when looking outside the VisArea.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &VisAreaConfiguration::ChangeOceanIsVisible)
|
||||
// note: This will not work as expected. See Activate where we set the callbacks on the vertex container directly
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &VisAreaConfiguration::m_vertexContainer, "Vertices", "Points that make up the floor of the VisArea.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, &VisAreaConfiguration::ChangeVertexContainer)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<EditorVisAreaComponent, AzToolsFramework::Components::EditorComponentBase>()
|
||||
->Version(2)
|
||||
->Field("m_config", &EditorVisAreaComponent::m_config)
|
||||
->Field("ComponentMode", &EditorVisAreaComponent::m_componentModeDelegate)
|
||||
;
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<EditorVisAreaComponent>("VisArea", "An area where only objects inside the area will be visible.")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Category, "Rendering")
|
||||
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Viewport/VisArea.png")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/VisArea.svg")
|
||||
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
|
||||
->Attribute(AZ::Edit::Attributes::HelpPageURL, "http://docs.aws.amazon.com/console/lumberyard/userguide/vis-area-component")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &EditorVisAreaComponent::m_config, "m_config", "No Description")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &EditorVisAreaComponent::m_componentModeDelegate, "Component Mode", "VisArea Component Mode")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<EditorVisAreaComponentRequestBus>("EditorVisAreaComponentRequestBus")
|
||||
->Event("SetHeight", &EditorVisAreaComponentRequestBus::Events::SetHeight)
|
||||
->Event("GetHeight", &EditorVisAreaComponentRequestBus::Events::GetHeight)
|
||||
->VirtualProperty("Height", "GetHeight", "SetHeight")
|
||||
|
||||
->Event("SetDisplayFilled", &EditorVisAreaComponentRequestBus::Events::SetDisplayFilled)
|
||||
->Event("GetDisplayFilled", &EditorVisAreaComponentRequestBus::Events::GetDisplayFilled)
|
||||
->VirtualProperty("DisplayFilled", "GetDisplayFilled", "SetDisplayFilled")
|
||||
|
||||
->Event("SetAffectedBySun", &EditorVisAreaComponentRequestBus::Events::SetAffectedBySun)
|
||||
->Event("GetAffectedBySun", &EditorVisAreaComponentRequestBus::Events::GetAffectedBySun)
|
||||
->VirtualProperty("AffectedBySun", "GetAffectedBySun", "SetAffectedBySun")
|
||||
|
||||
->Event("SetViewDistRatio", &EditorVisAreaComponentRequestBus::Events::SetViewDistRatio)
|
||||
->Event("GetViewDistRatio", &EditorVisAreaComponentRequestBus::Events::GetViewDistRatio)
|
||||
->VirtualProperty("ViewDistRatio", "GetViewDistRatio", "SetViewDistRatio")
|
||||
|
||||
->Event("SetOceanIsVisible", &EditorVisAreaComponentRequestBus::Events::SetOceanIsVisible)
|
||||
->Event("GetOceanIsVisible", &EditorVisAreaComponentRequestBus::Events::GetOceanIsVisible)
|
||||
->VirtualProperty("OceanIsVisible", "GetOceanIsVisible", "SetOceanIsVisible")
|
||||
;
|
||||
|
||||
behaviorContext->Class<EditorVisAreaComponent>()->RequestBus("EditorVisAreaComponentRequestBus");
|
||||
}
|
||||
|
||||
EditorVisAreaConfiguration::Reflect(context);
|
||||
}
|
||||
|
||||
void EditorVisAreaConfiguration::ChangeHeight()
|
||||
{
|
||||
EditorVisAreaComponentRequestBus::Event(
|
||||
m_entityId, &EditorVisAreaComponentRequests::UpdateVisAreaObject);
|
||||
}
|
||||
|
||||
void EditorVisAreaConfiguration::ChangeDisplayFilled()
|
||||
{
|
||||
EditorVisAreaComponentRequestBus::Event(
|
||||
m_entityId, &EditorVisAreaComponentRequests::UpdateVisAreaObject);
|
||||
}
|
||||
|
||||
void EditorVisAreaConfiguration::ChangeAffectedBySun()
|
||||
{
|
||||
EditorVisAreaComponentRequestBus::Event(
|
||||
m_entityId, &EditorVisAreaComponentRequests::UpdateVisAreaObject);
|
||||
}
|
||||
|
||||
void EditorVisAreaConfiguration::ChangeViewDistRatio()
|
||||
{
|
||||
EditorVisAreaComponentRequestBus::Event(
|
||||
m_entityId, &EditorVisAreaComponentRequests::UpdateVisAreaObject);
|
||||
}
|
||||
|
||||
void EditorVisAreaConfiguration::ChangeOceanIsVisible()
|
||||
{
|
||||
EditorVisAreaComponentRequestBus::Event(
|
||||
m_entityId, &EditorVisAreaComponentRequests::UpdateVisAreaObject);
|
||||
}
|
||||
|
||||
void EditorVisAreaConfiguration::ChangeVertexContainer()
|
||||
{
|
||||
EditorVisAreaComponentRequestBus::Event(
|
||||
m_entityId, &EditorVisAreaComponentRequests::UpdateVisAreaObject);
|
||||
}
|
||||
|
||||
void EditorVisAreaConfiguration::SetEntityId(const AZ::EntityId entityId)
|
||||
{
|
||||
m_entityId = entityId;
|
||||
}
|
||||
|
||||
EditorVisAreaComponent::~EditorVisAreaComponent()
|
||||
{
|
||||
if (m_area)
|
||||
{
|
||||
// Reset the listener vis area in the unlucky case that we are deleting the
|
||||
// vis area where the listener is currently in
|
||||
GetIEditor()->Get3DEngine()->DeleteVisArea(m_area);
|
||||
m_area = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::Activate()
|
||||
{
|
||||
Base::Activate();
|
||||
|
||||
const AZ::EntityId entityId = GetEntityId();
|
||||
|
||||
// NOTE: We create the vis-area here at activated, but destroy it in the destructor.
|
||||
// We have to do this, otherwise the vis-area is not saved into the level.
|
||||
// Unfortunately, at this time we cannot create the vis-areas at game runtime.
|
||||
// This means that dynamic slices cannot effectively contain vis areas until we fix the core rendering system to allow that.
|
||||
|
||||
const auto visGUID = AZ::u64(entityId);
|
||||
if(!m_area && GetIEditor())
|
||||
{
|
||||
m_area = GetIEditor()->Get3DEngine()->CreateVisArea(visGUID);
|
||||
}
|
||||
|
||||
m_componentModeDelegate.ConnectWithSingleComponentMode<
|
||||
EditorVisAreaComponent, EditorVisAreaComponentMode>(
|
||||
AZ::EntityComponentIdPair(entityId, GetId()), this);
|
||||
|
||||
// give default values to the vertices if needed
|
||||
if (m_config.m_vertexContainer.Size() == 0)
|
||||
{
|
||||
m_config.m_vertexContainer.AddVertex(AZ::Vector3(-1.0f, -1.0f, 0.0f));
|
||||
m_config.m_vertexContainer.AddVertex(AZ::Vector3(+1.0f, -1.0f, 0.0f));
|
||||
m_config.m_vertexContainer.AddVertex(AZ::Vector3(+1.0f, +1.0f, 0.0f));
|
||||
m_config.m_vertexContainer.AddVertex(AZ::Vector3(-1.0f, +1.0f, 0.0f));
|
||||
}
|
||||
|
||||
const auto vertexAdded = [this](size_t vertIndex)
|
||||
{
|
||||
EditorVisAreaComponentNotificationBus::Event(
|
||||
GetEntityId(), &EditorVisAreaComponentNotifications::OnVertexAdded, vertIndex);
|
||||
|
||||
UpdateVisAreaObject();
|
||||
};
|
||||
|
||||
const auto vertexRemoved = [this](size_t vertIndex)
|
||||
{
|
||||
EditorVisAreaComponentNotificationBus::Event(
|
||||
GetEntityId(), &EditorVisAreaComponentNotifications::OnVertexRemoved, vertIndex);
|
||||
|
||||
UpdateVisAreaObject();
|
||||
};
|
||||
|
||||
const auto vertexChanged = [this](size_t vertIndex)
|
||||
{
|
||||
EditorVisAreaComponentNotificationBus::Event(
|
||||
GetEntityId(), &EditorVisAreaComponentNotifications::OnVertexUpdated, vertIndex);
|
||||
|
||||
UpdateVisAreaObject();
|
||||
};
|
||||
|
||||
const auto verticesSet = [this]()
|
||||
{
|
||||
EditorVisAreaComponentNotificationBus::Event(
|
||||
GetEntityId(), &EditorVisAreaComponentNotifications::OnVerticesSet,
|
||||
m_config.m_vertexContainer.GetVertices());
|
||||
|
||||
UpdateVisAreaObject();
|
||||
};
|
||||
|
||||
const auto verticesCleared = [this]()
|
||||
{
|
||||
EditorVisAreaComponentNotificationBus::Event(
|
||||
GetEntityId(), &EditorVisAreaComponentNotifications::OnVerticesCleared);
|
||||
|
||||
UpdateVisAreaObject();
|
||||
};
|
||||
|
||||
m_config.m_vertexContainer.SetCallbacks(
|
||||
vertexAdded, vertexRemoved, vertexChanged,
|
||||
verticesSet, verticesCleared);
|
||||
|
||||
m_config.SetEntityId(entityId);
|
||||
|
||||
AZ::TransformBus::EventResult(
|
||||
m_currentWorldTransform, GetEntityId(), &AZ::TransformBus::Events::GetWorldTM);
|
||||
|
||||
// make the initial vis area with the data we just parsed
|
||||
UpdateVisAreaObject();
|
||||
|
||||
EditorVisAreaComponentRequestBus::Handler::BusConnect(entityId);
|
||||
AZ::VariableVerticesRequestBus<AZ::Vector3>::Handler::BusConnect(entityId);
|
||||
AZ::FixedVerticesRequestBus<AZ::Vector3>::Handler::BusConnect(entityId);
|
||||
AZ::TransformNotificationBus::Handler::BusConnect(entityId);
|
||||
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(entityId);
|
||||
AzToolsFramework::EditorEntityInfoNotificationBus::Handler::BusConnect();
|
||||
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusConnect(entityId);
|
||||
AzFramework::BoundsRequestBus::Handler::BusConnect(entityId);
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::Deactivate()
|
||||
{
|
||||
m_componentModeDelegate.Disconnect();
|
||||
|
||||
AzFramework::BoundsRequestBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::EditorComponentSelectionRequestsBus::Handler::BusDisconnect();
|
||||
AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::EditorEntityInfoNotificationBus::Handler::BusDisconnect();
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect();
|
||||
AZ::FixedVerticesRequestBus<AZ::Vector3>::Handler::BusDisconnect();
|
||||
AZ::VariableVerticesRequestBus<AZ::Vector3>::Handler::BusDisconnect();
|
||||
EditorVisAreaComponentRequestBus::Handler::BusDisconnect();
|
||||
|
||||
Base::Deactivate();
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world)
|
||||
{
|
||||
m_currentWorldTransform = world;
|
||||
UpdateVisAreaObject();
|
||||
}
|
||||
|
||||
/// Apply the component's settings to the underlying vis area
|
||||
void EditorVisAreaComponent::UpdateVisAreaObject()
|
||||
{
|
||||
if (m_area)
|
||||
{
|
||||
std::vector<Vec3> points;
|
||||
|
||||
const AZStd::vector<AZ::Vector3>& vertices = m_config.m_vertexContainer.GetVertices();
|
||||
const size_t vertexCount = vertices.size();
|
||||
|
||||
if (vertexCount > 3)
|
||||
{
|
||||
const Matrix34& wtm = AZTransformToLYTransform(GetWorldTM());
|
||||
points.resize(vertexCount);
|
||||
for (size_t i = 0; i < vertexCount; i++)
|
||||
{
|
||||
points[i] = wtm.TransformPoint(AZVec3ToLYVec3(vertices[i]));
|
||||
}
|
||||
|
||||
SVisAreaInfo info;
|
||||
info.fHeight = GetHeight();
|
||||
info.bAffectedByOutLights = m_config.m_affectedBySun;
|
||||
info.fViewDistRatio = m_config.m_viewDistRatio;
|
||||
info.bOceanIsVisible = m_config.m_oceanIsVisible;
|
||||
|
||||
//Unconfigurable; these values are used by other area types
|
||||
//We set them just so that debugging later it's clear that these
|
||||
//aren't being used because this is a VisArea.
|
||||
info.fPortalBlending = -1;
|
||||
info.bDoubleSide = true;
|
||||
info.bUseDeepness = false;
|
||||
info.bUseInIndoors = false;
|
||||
|
||||
const AZStd::string name = AZStd::string("vis-area_") + GetEntity()->GetName();
|
||||
|
||||
GetIEditor()->Get3DEngine()->UpdateVisArea(m_area, &points[0], points.size(), name.c_str(), info, true);
|
||||
|
||||
AzFramework::EntityBoundsUnionRequestBus::Broadcast(
|
||||
&AzFramework::EntityBoundsUnionRequestBus::Events::RefreshEntityLocalBoundsUnion, GetEntityId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::SetHeight(const float value)
|
||||
{
|
||||
m_config.m_height = value;
|
||||
UpdateVisAreaObject();
|
||||
}
|
||||
|
||||
float EditorVisAreaComponent::GetHeight()
|
||||
{
|
||||
return m_config.m_height;
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::SetDisplayFilled(const bool value)
|
||||
{
|
||||
m_config.m_displayFilled = value;
|
||||
UpdateVisAreaObject();
|
||||
}
|
||||
|
||||
bool EditorVisAreaComponent::GetDisplayFilled()
|
||||
{
|
||||
return m_config.m_displayFilled;
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::SetAffectedBySun(const bool value)
|
||||
{
|
||||
m_config.m_affectedBySun = value;
|
||||
UpdateVisAreaObject();
|
||||
}
|
||||
|
||||
bool EditorVisAreaComponent::GetAffectedBySun()
|
||||
{
|
||||
return m_config.m_affectedBySun;
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::SetViewDistRatio(const float value)
|
||||
{
|
||||
m_config.m_viewDistRatio = value;
|
||||
UpdateVisAreaObject();
|
||||
}
|
||||
|
||||
float EditorVisAreaComponent::GetViewDistRatio()
|
||||
{
|
||||
return m_config.m_viewDistRatio;
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::SetOceanIsVisible(const bool value)
|
||||
{
|
||||
m_config.m_oceanIsVisible = value;
|
||||
UpdateVisAreaObject();
|
||||
}
|
||||
|
||||
bool EditorVisAreaComponent::GetOceanIsVisible()
|
||||
{
|
||||
return m_config.m_oceanIsVisible;
|
||||
}
|
||||
|
||||
bool EditorVisAreaComponent::GetVertex(size_t index, AZ::Vector3& vertex) const
|
||||
{
|
||||
return m_config.m_vertexContainer.GetVertex(index, vertex);
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::AddVertex(const AZ::Vector3& vertex)
|
||||
{
|
||||
m_config.m_vertexContainer.AddVertex(vertex);
|
||||
UpdateVisAreaObject();
|
||||
}
|
||||
|
||||
bool EditorVisAreaComponent::UpdateVertex(size_t index, const AZ::Vector3& vertex)
|
||||
{
|
||||
if (m_config.m_vertexContainer.UpdateVertex(index, vertex))
|
||||
{
|
||||
UpdateVisAreaObject();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditorVisAreaComponent::InsertVertex(size_t index, const AZ::Vector3& vertex)
|
||||
{
|
||||
if (m_config.m_vertexContainer.InsertVertex(index, vertex))
|
||||
{
|
||||
UpdateVisAreaObject();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EditorVisAreaComponent::RemoveVertex(size_t index)
|
||||
{
|
||||
if (m_config.m_vertexContainer.RemoveVertex(index))
|
||||
{
|
||||
UpdateVisAreaObject();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::SetVertices(const AZStd::vector<AZ::Vector3>& vertices)
|
||||
{
|
||||
m_config.m_vertexContainer.SetVertices(vertices);
|
||||
UpdateVisAreaObject();
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::ClearVertices()
|
||||
{
|
||||
m_config.m_vertexContainer.Clear();
|
||||
UpdateVisAreaObject();
|
||||
}
|
||||
|
||||
size_t EditorVisAreaComponent::Size() const
|
||||
{
|
||||
return m_config.m_vertexContainer.Size();
|
||||
}
|
||||
|
||||
bool EditorVisAreaComponent::Empty() const
|
||||
{
|
||||
return m_config.m_vertexContainer.Empty();
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::DisplayEntityViewport(
|
||||
[[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo,
|
||||
AzFramework::DebugDisplayRequests& debugDisplay)
|
||||
{
|
||||
/*
|
||||
The VisArea and Portal share a common strangeness with how they are displayed.
|
||||
The Legacy visualization is actually incorrect! It's important to know that
|
||||
the vis volumes essentially act as a points on an XY plane with a known Z
|
||||
position and a height. The volumes that actually affect rendition are planar
|
||||
quads with a height. The height is calculated by the largest height value on
|
||||
a local point + the given height value on the component.
|
||||
|
||||
Also note that this visualization does not display the floors or ceilings of the vis area
|
||||
volumes. There is currently no way with the display context to easily draw a filled polygon.
|
||||
We could try to draw some triangles but it would take up a great deal of rendering
|
||||
time and could potentially slow down the editor more than we want if there are a lot
|
||||
of volumes.
|
||||
*/
|
||||
|
||||
const AZStd::vector<AZ::Vector3>& vertices = m_config.m_vertexContainer.GetVertices();
|
||||
const size_t vertexCount = vertices.size();
|
||||
|
||||
//We do not want to push a transform with scale or rotation as the
|
||||
//vis area is always snapped to the XY plane with a height.
|
||||
//Scale will be applied during flattening
|
||||
AZ::Transform translation = AZ::Transform::CreateIdentity();
|
||||
translation.SetTranslation(m_currentWorldTransform.GetTranslation());
|
||||
|
||||
debugDisplay.PushMatrix(translation);
|
||||
debugDisplay.SetColor(s_visAreaColor.GetAsVector4());
|
||||
|
||||
AZStd::vector<AZ::Vector3> transformedPoints;
|
||||
transformedPoints.resize(vertexCount);
|
||||
|
||||
//Min and max Z value (in local space)
|
||||
float minZ = FLT_MAX;
|
||||
float maxZ = FLT_MIN;
|
||||
|
||||
//Apply rotation and scale before removing translation.
|
||||
//We want translation to apply with the matrix to make things easier
|
||||
//but we need to calculate a difference in Z after rotation and scaling.
|
||||
//During the next loop we'll flatten all these points down to a common XY plane
|
||||
for (size_t i = 0; i < vertexCount; ++i)
|
||||
{
|
||||
AZ::Vector3 transformedPoint = m_currentWorldTransform.TransformPoint(vertices[i]);
|
||||
|
||||
//Back into local space
|
||||
transformedPoints[i] = transformedPoint - m_currentWorldTransform.GetTranslation();
|
||||
|
||||
const float transformedZ = transformedPoints[i].GetZ();
|
||||
|
||||
minZ = AZ::GetMin(transformedZ, minZ);
|
||||
maxZ = AZ::GetMax(transformedZ, maxZ);
|
||||
}
|
||||
|
||||
//The height of the vis area + the max local height
|
||||
const float actualHeight = m_config.m_height + maxZ;
|
||||
|
||||
//Draw walls for every line segment
|
||||
size_t transformedPointCount = transformedPoints.size();
|
||||
for (size_t i = 0; i < transformedPointCount; ++i)
|
||||
{
|
||||
AZ::Vector3 lowerLeft = AZ::Vector3();
|
||||
AZ::Vector3 lowerRight = AZ::Vector3();
|
||||
AZ::Vector3 upperRight = AZ::Vector3();
|
||||
AZ::Vector3 upperLeft = AZ::Vector3();
|
||||
|
||||
lowerLeft = transformedPoints[i];
|
||||
lowerRight = transformedPoints[(i + 1) % transformedPointCount];
|
||||
//The mod with transformedPointCount ensures that for the last vert it will connect back with vert 0
|
||||
//If vert count is 10, the last vert will be i = 9 and we want that to create a surface with vert 0
|
||||
|
||||
//Make all lower points planar
|
||||
lowerLeft.SetZ(minZ);
|
||||
lowerRight.SetZ(minZ);
|
||||
|
||||
upperRight = AZ::Vector3(lowerRight.GetX(), lowerRight.GetY(), actualHeight);
|
||||
upperLeft = AZ::Vector3(lowerLeft.GetX(), lowerLeft.GetY(), actualHeight);
|
||||
|
||||
if (m_config.m_displayFilled)
|
||||
{
|
||||
debugDisplay.SetAlpha(0.3f);
|
||||
//Draw filled quad with two winding orders to make it double sided
|
||||
debugDisplay.DrawQuad(lowerLeft, lowerRight, upperRight, upperLeft);
|
||||
debugDisplay.DrawQuad(lowerLeft, upperLeft, upperRight, lowerRight);
|
||||
}
|
||||
|
||||
debugDisplay.SetAlpha(1.0f);
|
||||
debugDisplay.DrawLine(lowerLeft, lowerRight);
|
||||
debugDisplay.DrawLine(lowerRight, upperRight);
|
||||
debugDisplay.DrawLine(upperRight, upperLeft);
|
||||
debugDisplay.DrawLine(upperLeft, lowerLeft);
|
||||
}
|
||||
|
||||
if (m_componentModeDelegate.AddedToComponentMode())
|
||||
{
|
||||
AzToolsFramework::VertexContainerDisplay::DisplayVertexContainerIndices(
|
||||
debugDisplay, AzToolsFramework::VariableVerticesVertexContainer<AZ::Vector3>(m_config.m_vertexContainer),
|
||||
GetWorldTM(), AZ::Vector3::CreateOne(), IsSelected());
|
||||
}
|
||||
|
||||
debugDisplay.PopMatrix();
|
||||
}
|
||||
|
||||
void EditorVisAreaComponent::BuildGameEntity(AZ::Entity* gameEntity)
|
||||
{
|
||||
gameEntity->CreateComponent<VisAreaComponent>(m_config);
|
||||
}
|
||||
|
||||
AZ::Aabb EditorVisAreaComponent::GetEditorSelectionBoundsViewport(
|
||||
const AzFramework::ViewportInfo& /*viewportInfo*/)
|
||||
{
|
||||
return GetWorldBounds();
|
||||
}
|
||||
|
||||
bool EditorVisAreaComponent::EditorSelectionIntersectRayViewport(
|
||||
const AzFramework::ViewportInfo& viewportInfo, const AZ::Vector3& src,
|
||||
const AZ::Vector3& dir, float& distance)
|
||||
{
|
||||
AZ::Aabb bbox = GetEditorSelectionBoundsViewport(viewportInfo);
|
||||
float end;
|
||||
float t;
|
||||
|
||||
const bool intersection = AZ::Intersect::IntersectRayAABB2(
|
||||
src, dir.GetReciprocal(),
|
||||
bbox, t, end) > 0;
|
||||
|
||||
if (intersection)
|
||||
{
|
||||
distance = t;
|
||||
}
|
||||
|
||||
return intersection;
|
||||
}
|
||||
|
||||
AZ::Aabb EditorVisAreaComponent::GetWorldBounds()
|
||||
{
|
||||
return GetLocalBounds().GetTransformedAabb(GetWorldTM());
|
||||
}
|
||||
|
||||
AZ::Aabb EditorVisAreaComponent::GetLocalBounds()
|
||||
{
|
||||
AZ::Aabb bbox = AZ::Aabb::CreateNull();
|
||||
for (const auto& vertex : m_config.m_vertexContainer.GetVertices())
|
||||
{
|
||||
bbox.AddPoint(vertex);
|
||||
}
|
||||
bbox.AddPoint(bbox.GetMax() + AZ::Vector3::CreateAxisZ(m_config.m_height));
|
||||
return bbox;
|
||||
}
|
||||
} //namespace Visibility
|
||||
@ -1,144 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Color.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzFramework/Visibility/BoundsBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/ComponentMode/ComponentModeDelegate.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
||||
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
|
||||
#include <AzToolsFramework/Manipulators/EditorVertexSelection.h>
|
||||
#include <AzFramework/Entity/EntityDebugDisplayBus.h>
|
||||
|
||||
#include "EditorVisAreaComponentBus.h"
|
||||
#include "VisAreaComponent.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
class EditorVisAreaComponent;
|
||||
|
||||
class EditorVisAreaConfiguration
|
||||
: public VisAreaConfiguration
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO_LEGACY(EditorVisAreaConfiguration, "{C329E65C-1F34-5C80-9A7A-4B568105256B}", VisAreaConfiguration);
|
||||
AZ_CLASS_ALLOCATOR(EditorVisAreaConfiguration, AZ::SystemAllocator,0);
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
void ChangeHeight() override;
|
||||
void ChangeDisplayFilled() override;
|
||||
void ChangeAffectedBySun() override;
|
||||
void ChangeViewDistRatio() override;
|
||||
void ChangeOceanIsVisible() override;
|
||||
void ChangeVertexContainer() override;
|
||||
|
||||
void SetEntityId(AZ::EntityId entityId);
|
||||
|
||||
private:
|
||||
AZ::EntityId m_entityId;
|
||||
};
|
||||
|
||||
class EditorVisAreaComponent
|
||||
: public AzToolsFramework::Components::EditorComponentBase
|
||||
, private EditorVisAreaComponentRequestBus::Handler
|
||||
, private AZ::FixedVerticesRequestBus<AZ::Vector3>::Handler
|
||||
, private AZ::VariableVerticesRequestBus<AZ::Vector3>::Handler
|
||||
, private AzFramework::EntityDebugDisplayEventBus::Handler
|
||||
, private AzToolsFramework::EditorEntityInfoNotificationBus::Handler
|
||||
, private AzToolsFramework::EditorComponentSelectionRequestsBus::Handler
|
||||
, private AZ::TransformNotificationBus::Handler
|
||||
, public AzFramework::BoundsRequestBus::Handler
|
||||
{
|
||||
friend class EditorVisAreaConfiguration; //So that the config can set m_vertices when the vertex container changes
|
||||
|
||||
using Base = AzToolsFramework::Components::EditorComponentBase;
|
||||
|
||||
public:
|
||||
AZ_COMPONENT(EditorVisAreaComponent, "{F4EC32D8-D4DD-54F7-97A8-D195497D5F2C}", AzToolsFramework::Components::EditorComponentBase);
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provides);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& requires);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
EditorVisAreaComponent() = default;
|
||||
EditorVisAreaComponent(const EditorVisAreaComponent&) = delete;
|
||||
EditorVisAreaComponent& operator=(const EditorVisAreaComponent&) = delete;
|
||||
virtual ~EditorVisAreaComponent();
|
||||
|
||||
// AZ::Component overrides ...
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
void BuildGameEntity(AZ::Entity* gameEntity) override;
|
||||
|
||||
// TransformNotificationBus overrides ...
|
||||
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
||||
|
||||
// EditorComponentSelectionRequestsBus overrides ...
|
||||
AZ::Aabb GetEditorSelectionBoundsViewport(
|
||||
const AzFramework::ViewportInfo& viewportInfo) override;
|
||||
bool EditorSelectionIntersectRayViewport(
|
||||
const AzFramework::ViewportInfo& viewportInfo, const AZ::Vector3& src,
|
||||
const AZ::Vector3& dir, float& distance) override;
|
||||
bool SupportsEditorRayIntersect() override { return true; }
|
||||
|
||||
// VisAreaComponentRequestBus overrides ...
|
||||
void SetHeight(float height) override;
|
||||
float GetHeight() override;
|
||||
void SetDisplayFilled(bool filled) override;
|
||||
bool GetDisplayFilled() override;
|
||||
void SetAffectedBySun(bool affectedBySun) override;
|
||||
bool GetAffectedBySun() override;
|
||||
void SetViewDistRatio(float viewDistRatio) override;
|
||||
float GetViewDistRatio() override;
|
||||
void SetOceanIsVisible(bool oceanVisible) override;
|
||||
bool GetOceanIsVisible() override;
|
||||
bool GetVertex(size_t index, AZ::Vector3& vertex) const override;
|
||||
void AddVertex(const AZ::Vector3& vertex) override;
|
||||
bool UpdateVertex(size_t index, const AZ::Vector3& vertex) override;
|
||||
bool InsertVertex(size_t index, const AZ::Vector3& vertex) override;
|
||||
bool RemoveVertex(size_t index) override;
|
||||
void SetVertices(const AZStd::vector<AZ::Vector3>& vertices) override;
|
||||
void ClearVertices() override;
|
||||
size_t Size() const override;
|
||||
bool Empty() const override;
|
||||
void UpdateVisAreaObject() override;
|
||||
|
||||
// AzFramework::EntityDebugDisplayEventBus overrides ...
|
||||
void DisplayEntityViewport(
|
||||
const AzFramework::ViewportInfo& viewportInfo,
|
||||
AzFramework::DebugDisplayRequests& debugDisplay) override;
|
||||
|
||||
// BoundsRequestBus overrides ...
|
||||
AZ::Aabb GetWorldBounds() override;
|
||||
AZ::Aabb GetLocalBounds() override;
|
||||
|
||||
private:
|
||||
// Reflected members
|
||||
EditorVisAreaConfiguration m_config;
|
||||
|
||||
using ComponentModeDelegate = AzToolsFramework::ComponentModeFramework::ComponentModeDelegate;
|
||||
ComponentModeDelegate m_componentModeDelegate; ///< Responsible for detecting ComponentMode activation
|
||||
///< and creating a concrete ComponentMode.
|
||||
|
||||
// Unreflected members
|
||||
AZ::Transform m_currentWorldTransform;
|
||||
IVisArea* m_area = nullptr;
|
||||
|
||||
static AZ::Color s_visAreaColor; ///< The orange color that all vis-areas draw with.
|
||||
};
|
||||
} // namespace Visibility
|
||||
@ -1,120 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Visibility_precompiled.h"
|
||||
#include "EditorVisAreaComponentMode.h"
|
||||
|
||||
#include <AzToolsFramework/Manipulators/ManipulatorManager.h>
|
||||
#include <AzToolsFramework/Manipulators/LineHoverSelection.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR_IMPL(EditorVisAreaComponentMode, AZ::SystemAllocator, 0)
|
||||
|
||||
EditorVisAreaComponentMode::EditorVisAreaComponentMode(
|
||||
const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType)
|
||||
: EditorBaseComponentMode(entityComponentIdPair, componentType)
|
||||
{
|
||||
CreateManipulators();
|
||||
|
||||
AZ::TransformNotificationBus::Handler::BusConnect(entityComponentIdPair.GetEntityId());
|
||||
EditorVisAreaComponentNotificationBus::Handler::BusConnect(entityComponentIdPair.GetEntityId());
|
||||
}
|
||||
|
||||
EditorVisAreaComponentMode::~EditorVisAreaComponentMode()
|
||||
{
|
||||
EditorVisAreaComponentNotificationBus::Handler::BusDisconnect();
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
m_vertexSelection.Destroy();
|
||||
}
|
||||
|
||||
void EditorVisAreaComponentMode::CreateManipulators()
|
||||
{
|
||||
using namespace AzToolsFramework;
|
||||
|
||||
m_vertexSelection.Create(
|
||||
GetEntityComponentIdPair(), g_mainManipulatorManagerId,
|
||||
AZStd::make_unique<LineSegmentHoverSelection<AZ::Vector3>>(GetEntityComponentIdPair(), g_mainManipulatorManagerId),
|
||||
TranslationManipulators::Dimensions::Three,
|
||||
ConfigureTranslationManipulatorAppearance3d);
|
||||
|
||||
m_vertexSelection.SetVertexPositionsUpdatedCallback([this]()
|
||||
{
|
||||
EditorVisAreaComponentRequestBus::Event(
|
||||
GetEntityId(), &EditorVisAreaComponentRequests::UpdateVisAreaObject);
|
||||
});
|
||||
}
|
||||
|
||||
void EditorVisAreaComponentMode::OnTransformChanged(
|
||||
const AZ::Transform& /*local*/, const AZ::Transform& world)
|
||||
{
|
||||
m_vertexSelection.RefreshSpace(world);
|
||||
}
|
||||
|
||||
void EditorVisAreaComponentMode::OnVertexAdded(size_t index)
|
||||
{
|
||||
Refresh();
|
||||
|
||||
AZ::Vector3 vertex;
|
||||
bool found = false;
|
||||
AZ::FixedVerticesRequestBus<AZ::Vector3>::EventResult(
|
||||
found, GetEntityId(), &AZ::FixedVerticesRequestBus<AZ::Vector3>::Handler::GetVertex,
|
||||
index, vertex);
|
||||
|
||||
if (found)
|
||||
{
|
||||
m_vertexSelection.CreateTranslationManipulator(
|
||||
GetEntityComponentIdPair(), AzToolsFramework::g_mainManipulatorManagerId,
|
||||
vertex, index);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorVisAreaComponentMode::OnVertexRemoved(size_t /*index*/)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void EditorVisAreaComponentMode::OnVerticesSet(const AZStd::vector<AZ::Vector3>& /*vertices*/)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void EditorVisAreaComponentMode::OnVerticesCleared()
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void EditorVisAreaComponentMode::Refresh()
|
||||
{
|
||||
// destroy and recreate manipulators when container is modified (vertices are added or removed)
|
||||
m_vertexSelection.Destroy();
|
||||
CreateManipulators();
|
||||
}
|
||||
|
||||
AZStd::vector<AzToolsFramework::ActionOverride> EditorVisAreaComponentMode::PopulateActionsImpl()
|
||||
{
|
||||
return m_vertexSelection.ActionOverrides();
|
||||
}
|
||||
|
||||
bool EditorVisAreaComponentMode::HandleMouseInteraction(
|
||||
const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& mouseInteraction)
|
||||
{
|
||||
return m_vertexSelection.HandleMouse(mouseInteraction);
|
||||
}
|
||||
|
||||
AZStd::string EditorVisAreaComponentMode::GetComponentModeName() const
|
||||
{
|
||||
return "Vis Area Edit Mode";
|
||||
}
|
||||
|
||||
} // namespace Visibility
|
||||
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorBaseComponentMode.h>
|
||||
#include <AzToolsFramework/Manipulators/EditorVertexSelection.h>
|
||||
|
||||
#include "EditorVisAreaComponentBus.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
/// The ComponentMode for editing the Vis Area Component.
|
||||
class EditorVisAreaComponentMode
|
||||
: public AzToolsFramework::ComponentModeFramework::EditorBaseComponentMode
|
||||
, private AZ::TransformNotificationBus::Handler
|
||||
, private EditorVisAreaComponentNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR_DECL
|
||||
|
||||
EditorVisAreaComponentMode(
|
||||
const AZ::EntityComponentIdPair& entityComponentIdPair, AZ::Uuid componentType);
|
||||
~EditorVisAreaComponentMode();
|
||||
|
||||
private:
|
||||
// EditorBaseComponentMode
|
||||
void Refresh() override;
|
||||
AZStd::vector<AzToolsFramework::ActionOverride> PopulateActionsImpl() override;
|
||||
bool HandleMouseInteraction(
|
||||
const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& mouseInteraction) override;
|
||||
AZStd::string GetComponentModeName() const override;
|
||||
|
||||
// Manipulator handling
|
||||
void CreateManipulators();
|
||||
|
||||
// TransformNotificationBus
|
||||
void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
|
||||
|
||||
// EditorVisAreaComponentNotificationBus
|
||||
void OnVertexAdded(size_t index) override;
|
||||
void OnVertexRemoved(size_t index) override;
|
||||
void OnVerticesSet(const AZStd::vector<AZ::Vector3>& vertices) override;
|
||||
void OnVerticesCleared() override;
|
||||
|
||||
AzToolsFramework::EditorVertexSelectionVariable<AZ::Vector3> m_vertexSelection; ///< Handles all manipulator interactions with vertices (inserting and translating).
|
||||
};
|
||||
} // namespace Visibility
|
||||
@ -1,115 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Visibility_precompiled.h"
|
||||
#include "OccluderAreaComponent.h"
|
||||
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <MathConversion.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
void OccluderAreaComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provides)
|
||||
{
|
||||
provides.push_back(AZ_CRC("OccluderAreaService"));
|
||||
}
|
||||
void OccluderAreaComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& requires)
|
||||
{
|
||||
requires.push_back(AZ_CRC("TransformService"));
|
||||
}
|
||||
|
||||
void OccluderAreaConfiguration::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<OccluderAreaConfiguration>()
|
||||
->Version(1)
|
||||
->Field("DisplayFilled", &OccluderAreaConfiguration::m_displayFilled)
|
||||
->Field("CullDistRatio", &OccluderAreaConfiguration::m_cullDistRatio)
|
||||
->Field("UseInIndoors", &OccluderAreaConfiguration::m_useInIndoors)
|
||||
->Field("DoubleSide", &OccluderAreaConfiguration::m_doubleSide)
|
||||
->Field("vertices", &OccluderAreaConfiguration::m_vertices)
|
||||
;
|
||||
}
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<OccluderAreaRequestBus>("OccluderAreaRequestBus")
|
||||
->Event("GetDisplayFilled", &OccluderAreaRequestBus::Events::GetDisplayFilled)
|
||||
->VirtualProperty("DisplayFilled", "GetDisplayFilled", nullptr)
|
||||
|
||||
->Event("GetCullDistRatio", &OccluderAreaRequestBus::Events::GetCullDistRatio)
|
||||
->VirtualProperty("CullDistRatio", "GetCullDistRatio", nullptr)
|
||||
|
||||
->Event("GetUseInIndoors", &OccluderAreaRequestBus::Events::GetUseInIndoors)
|
||||
->VirtualProperty("UseInIndoors", "GetUseInIndoors", nullptr)
|
||||
|
||||
->Event("GetDoubleSide", &OccluderAreaRequestBus::Events::GetDoubleSide)
|
||||
->VirtualProperty("DoubleSide", "GetDoubleSide", nullptr)
|
||||
;
|
||||
|
||||
behaviorContext->Class<OccluderAreaComponent>()->RequestBus("OccluderAreaRequestBus");
|
||||
}
|
||||
}
|
||||
|
||||
void OccluderAreaComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<OccluderAreaComponent, AZ::Component>()
|
||||
->Version(1)
|
||||
->Field("m_config", &OccluderAreaComponent::m_config)
|
||||
;
|
||||
}
|
||||
|
||||
OccluderAreaConfiguration::Reflect(context);
|
||||
}
|
||||
|
||||
OccluderAreaComponent::OccluderAreaComponent(const OccluderAreaConfiguration& params)
|
||||
: m_config(params)
|
||||
{
|
||||
}
|
||||
|
||||
void OccluderAreaComponent::Activate()
|
||||
{
|
||||
OccluderAreaRequestBus::Handler::BusConnect(GetEntityId());
|
||||
AZ::TransformNotificationBus::Handler::BusConnect(GetEntityId());
|
||||
}
|
||||
|
||||
void OccluderAreaComponent::Deactivate()
|
||||
{
|
||||
AZ::TransformNotificationBus::Handler::BusDisconnect(GetEntityId());
|
||||
OccluderAreaRequestBus::Handler::BusDisconnect(GetEntityId());
|
||||
}
|
||||
|
||||
bool OccluderAreaComponent::GetDisplayFilled()
|
||||
{
|
||||
return m_config.m_displayFilled;
|
||||
}
|
||||
|
||||
float OccluderAreaComponent::GetCullDistRatio()
|
||||
{
|
||||
return m_config.m_cullDistRatio;
|
||||
}
|
||||
|
||||
bool OccluderAreaComponent::GetUseInIndoors()
|
||||
{
|
||||
return m_config.m_useInIndoors;
|
||||
}
|
||||
|
||||
bool OccluderAreaComponent::GetDoubleSide()
|
||||
{
|
||||
return m_config.m_doubleSide;
|
||||
}
|
||||
|
||||
} //namespace Visibility
|
||||
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
|
||||
#include "OccluderAreaComponentBus.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
class OccluderAreaConfiguration
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(OccluderAreaConfiguration, "{F024EC7E-717F-576C-8C22-09CAFEFEAF29}");
|
||||
AZ_CLASS_ALLOCATOR(OccluderAreaConfiguration, AZ::SystemAllocator, 0);
|
||||
|
||||
virtual ~OccluderAreaConfiguration() = default;
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
bool m_displayFilled = true;
|
||||
float m_cullDistRatio = 100.0f;
|
||||
bool m_useInIndoors = false;
|
||||
bool m_doubleSide = true;
|
||||
|
||||
AZStd::array<AZ::Vector3, 4> m_vertices =
|
||||
AZStd::array<AZ::Vector3, 4> { {
|
||||
AZ::Vector3(-1.0f, -1.0f, 0.0f),
|
||||
AZ::Vector3( 1.0f, -1.0f, 0.0f),
|
||||
AZ::Vector3( 1.0f, 1.0f, 0.0f),
|
||||
AZ::Vector3(-1.0f, 1.0f, 0.0f)
|
||||
} };
|
||||
|
||||
virtual void OnChange() {}
|
||||
virtual void OnVerticesChange() {}
|
||||
};
|
||||
|
||||
class OccluderAreaComponent
|
||||
: public AZ::Component
|
||||
, private OccluderAreaRequestBus::Handler
|
||||
, public AZ::TransformNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(OccluderAreaComponent, "{B3C90C5F-0F9B-5D4F-ABAE-6D16CB45CB5A}", AZ::Component);
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provides);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& requires);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
OccluderAreaComponent() = default;
|
||||
explicit OccluderAreaComponent(const OccluderAreaConfiguration& params);
|
||||
|
||||
// AZ::Component
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
// OccluderAreaRequestBus
|
||||
bool GetDisplayFilled() override;
|
||||
float GetCullDistRatio() override;
|
||||
bool GetUseInIndoors() override;
|
||||
bool GetDoubleSide() override;
|
||||
|
||||
protected:
|
||||
// Reflected Data
|
||||
OccluderAreaConfiguration m_config;
|
||||
};
|
||||
} // namespace Visibility
|
||||
@ -1,182 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Visibility_precompiled.h"
|
||||
#include "PortalComponent.h"
|
||||
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <MathConversion.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
void PortalComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provides)
|
||||
{
|
||||
provides.push_back(AZ::Crc32("PortalService"));
|
||||
}
|
||||
|
||||
void PortalComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& requires)
|
||||
{
|
||||
requires.push_back(AZ::Crc32("TransformService"));
|
||||
}
|
||||
|
||||
void PortalConfiguration::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<PortalConfiguration>()
|
||||
->Version(1)
|
||||
->Field("Height", &PortalConfiguration::m_height)
|
||||
->Field("DisplayFilled", &PortalConfiguration::m_displayFilled)
|
||||
->Field("AffectedBySun", &PortalConfiguration::m_affectedBySun)
|
||||
->Field("ViewDistRatio", &PortalConfiguration::m_viewDistRatio)
|
||||
->Field("SkyOnly", &PortalConfiguration::m_skyOnly)
|
||||
->Field("OceanIsVisible", &PortalConfiguration::m_oceanIsVisible)
|
||||
->Field("UseDeepness", &PortalConfiguration::m_useDeepness)
|
||||
->Field("DoubleSide", &PortalConfiguration::m_doubleSide)
|
||||
->Field("LightBlending", &PortalConfiguration::m_lightBlending)
|
||||
->Field("LightBlendValue", &PortalConfiguration::m_lightBlendValue)
|
||||
->Field("vertices", &PortalConfiguration::m_vertices)
|
||||
;
|
||||
}
|
||||
|
||||
if (auto* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<PortalRequestBus>("PortalRequestBus")
|
||||
->Event("GetHeight", &PortalRequestBus::Events::GetHeight)
|
||||
->VirtualProperty("Height", "GetHeight", nullptr)
|
||||
|
||||
->Event("GetDisplayFilled", &PortalRequestBus::Events::GetDisplayFilled)
|
||||
->VirtualProperty("DisplayFilled", "GetDisplayFilled", nullptr)
|
||||
|
||||
->Event("GetAffectedBySun", &PortalRequestBus::Events::GetAffectedBySun)
|
||||
->VirtualProperty("AffectedBySun", "GetAffectedBySun", nullptr)
|
||||
|
||||
->Event("GetViewDistRatio", &PortalRequestBus::Events::GetViewDistRatio)
|
||||
->VirtualProperty("ViewDistRatio", "GetViewDistRatio", nullptr)
|
||||
|
||||
->Event("GetSkyOnly", &PortalRequestBus::Events::GetSkyOnly)
|
||||
->VirtualProperty("SkyOnly", "GetSkyOnly", nullptr)
|
||||
|
||||
->Event("GetOceanIsVisible", &PortalRequestBus::Events::GetOceanIsVisible)
|
||||
->VirtualProperty("OceanIsVisible", "GetOceanIsVisible", nullptr)
|
||||
|
||||
->Event("GetUseDeepness", &PortalRequestBus::Events::GetUseDeepness)
|
||||
->VirtualProperty("UseDeepness", "GetUseDeepness", nullptr)
|
||||
|
||||
->Event("GetDoubleSide", &PortalRequestBus::Events::GetDoubleSide)
|
||||
->VirtualProperty("DoubleSide", "GetDoubleSide", nullptr)
|
||||
|
||||
->Event("GetLightBlending", &PortalRequestBus::Events::GetLightBlending)
|
||||
->VirtualProperty("LightBlending", "GetLightBlending", nullptr)
|
||||
|
||||
->Event("GetLightBlendValue", &PortalRequestBus::Events::GetLightBlendValue)
|
||||
->VirtualProperty("LightBlendValue", "GetLightBlendValue", nullptr)
|
||||
;
|
||||
|
||||
behaviorContext->Class<PortalComponent>()->RequestBus("PortalRequestBus");
|
||||
}
|
||||
}
|
||||
|
||||
bool PortalConfiguration::VersionConverter(
|
||||
[[maybe_unused]] AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement)
|
||||
{
|
||||
// conversion from version 1:
|
||||
// - Remove IgnoreSkyColor
|
||||
// - Remove IgnoreGI
|
||||
if (classElement.GetVersion() <= 1)
|
||||
{
|
||||
classElement.RemoveElementByName(AZ_CRC("IgnoreSkyColor"));
|
||||
classElement.RemoveElementByName(AZ_CRC("IgnoreGI"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PortalComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<PortalComponent, AZ::Component>()
|
||||
->Version(1)
|
||||
->Field("m_config", &PortalComponent::m_config)
|
||||
;
|
||||
}
|
||||
|
||||
PortalConfiguration::Reflect(context);
|
||||
}
|
||||
|
||||
PortalComponent::PortalComponent(const PortalConfiguration& params)
|
||||
: m_config(params)
|
||||
{
|
||||
}
|
||||
|
||||
void PortalComponent::Activate()
|
||||
{
|
||||
PortalRequestBus::Handler::BusConnect(GetEntityId());
|
||||
}
|
||||
|
||||
void PortalComponent::Deactivate()
|
||||
{
|
||||
PortalRequestBus::Handler::BusDisconnect(GetEntityId());
|
||||
}
|
||||
|
||||
float PortalComponent::GetHeight()
|
||||
{
|
||||
return m_config.m_height;
|
||||
}
|
||||
|
||||
bool PortalComponent::GetDisplayFilled()
|
||||
{
|
||||
return m_config.m_displayFilled;
|
||||
}
|
||||
|
||||
bool PortalComponent::GetAffectedBySun()
|
||||
{
|
||||
return m_config.m_affectedBySun;
|
||||
}
|
||||
|
||||
float PortalComponent::GetViewDistRatio()
|
||||
{
|
||||
return m_config.m_viewDistRatio;
|
||||
}
|
||||
|
||||
bool PortalComponent::GetSkyOnly()
|
||||
{
|
||||
return m_config.m_skyOnly;
|
||||
}
|
||||
|
||||
bool PortalComponent::GetOceanIsVisible()
|
||||
{
|
||||
return m_config.m_oceanIsVisible;
|
||||
}
|
||||
|
||||
bool PortalComponent::GetUseDeepness()
|
||||
{
|
||||
return m_config.m_useDeepness;
|
||||
}
|
||||
|
||||
bool PortalComponent::GetDoubleSide()
|
||||
{
|
||||
return m_config.m_doubleSide;
|
||||
}
|
||||
|
||||
bool PortalComponent::GetLightBlending()
|
||||
{
|
||||
return m_config.m_lightBlending;
|
||||
}
|
||||
|
||||
float PortalComponent::GetLightBlendValue()
|
||||
{
|
||||
return m_config.m_lightBlendValue;
|
||||
}
|
||||
|
||||
} //namespace Visibility
|
||||
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
#include "PortalComponentBus.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
class PortalConfiguration
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(PortalConfiguration, "{B9BDF017-DF8B-5DBE-8A92-5F62B7AECC1C}");
|
||||
AZ_CLASS_ALLOCATOR(PortalConfiguration, AZ::SystemAllocator,0);
|
||||
|
||||
virtual ~PortalConfiguration() = default;
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
static bool VersionConverter(
|
||||
AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement);
|
||||
|
||||
float m_height = 1.0f;
|
||||
bool m_displayFilled = false;
|
||||
bool m_affectedBySun = false;
|
||||
float m_viewDistRatio = 100.0f;
|
||||
bool m_skyOnly = false;
|
||||
bool m_oceanIsVisible = false;
|
||||
bool m_useDeepness = true;
|
||||
bool m_doubleSide = true;
|
||||
bool m_lightBlending = true;
|
||||
float m_lightBlendValue = 0.5f;
|
||||
|
||||
AZStd::array<AZ::Vector3, 4> m_vertices =
|
||||
AZStd::array<AZ::Vector3, 4> { {
|
||||
AZ::Vector3(-1.0f, -1.0f, 0.0f),
|
||||
AZ::Vector3( 1.0f, -1.0f, 0.0f),
|
||||
AZ::Vector3( 1.0f, 1.0f, 0.0f),
|
||||
AZ::Vector3(-1.0f, 1.0f, 0.0f)
|
||||
} };
|
||||
|
||||
virtual void OnChange() {}
|
||||
virtual void OnVerticesChange() {}
|
||||
};
|
||||
|
||||
class PortalComponent
|
||||
: public AZ::Component
|
||||
, private PortalRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(PortalComponent, "{89F1DD88-4445-5A9D-9223-6D4D8D44E6AC}", AZ::Component);
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provides);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& requires);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
PortalComponent() = default;
|
||||
explicit PortalComponent(const PortalConfiguration& params);
|
||||
|
||||
// AZ::Component
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
// PortalRequestBus
|
||||
float GetHeight() override;
|
||||
bool GetDisplayFilled() override;
|
||||
bool GetAffectedBySun() override;
|
||||
float GetViewDistRatio() override;
|
||||
bool GetSkyOnly() override;
|
||||
bool GetOceanIsVisible() override;
|
||||
bool GetUseDeepness() override;
|
||||
bool GetDoubleSide() override;
|
||||
bool GetLightBlending() override;
|
||||
float GetLightBlendValue() override;
|
||||
|
||||
protected:
|
||||
// Reflected Data
|
||||
PortalConfiguration m_config;
|
||||
};
|
||||
} // namespace Visibility
|
||||
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Visibility_precompiled.h"
|
||||
#include "VisAreaComponent.h"
|
||||
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <MathConversion.h>
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
void VisAreaComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provides)
|
||||
{
|
||||
provides.push_back(AZ::Crc32("VisAreaService"));
|
||||
}
|
||||
|
||||
void VisAreaComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& requires)
|
||||
{
|
||||
requires.push_back(AZ::Crc32("TransformService"));
|
||||
}
|
||||
|
||||
void VisAreaConfiguration::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<VisAreaConfiguration>()
|
||||
->Version(2, &VersionConverter)
|
||||
->Field("m_Height", &VisAreaConfiguration::m_height)
|
||||
->Field("m_DisplayFilled", &VisAreaConfiguration::m_displayFilled)
|
||||
->Field("m_AffectedBySun", &VisAreaConfiguration::m_affectedBySun)
|
||||
->Field("m_ViewDistRatio", &VisAreaConfiguration::m_viewDistRatio)
|
||||
->Field("m_OceanIsVisible", &VisAreaConfiguration::m_oceanIsVisible)
|
||||
->Field("m_vertexContainer", &VisAreaConfiguration::m_vertexContainer)
|
||||
;
|
||||
}
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<VisAreaComponentRequestBus>("VisAreaComponentRequestBus")
|
||||
->Event("GetHeight", &VisAreaComponentRequestBus::Events::GetHeight)
|
||||
->VirtualProperty("Height", "GetHeight", nullptr)
|
||||
|
||||
->Event("GetDisplayFilled", &VisAreaComponentRequestBus::Events::GetDisplayFilled)
|
||||
->VirtualProperty("DisplayFilled", "GetDisplayFilled", nullptr)
|
||||
|
||||
->Event("GetAffectedBySun", &VisAreaComponentRequestBus::Events::GetAffectedBySun)
|
||||
->VirtualProperty("AffectedBySun", "GetAffectedBySun", nullptr)
|
||||
|
||||
->Event("GetViewDistRatio", &VisAreaComponentRequestBus::Events::GetViewDistRatio)
|
||||
->VirtualProperty("ViewDistRatio", "GetViewDistRatio", nullptr)
|
||||
|
||||
->Event("GetOceanIsVisible", &VisAreaComponentRequestBus::Events::GetOceanIsVisible)
|
||||
->VirtualProperty("OceanIsVisible", "GetOceanIsVisible", nullptr)
|
||||
;
|
||||
|
||||
behaviorContext->Class<VisAreaComponent>()->RequestBus("VisAreaComponentRequestBus");
|
||||
}
|
||||
}
|
||||
|
||||
bool VisAreaConfiguration::VersionConverter([[maybe_unused]] AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement)
|
||||
{
|
||||
// conversion from version 1:
|
||||
// - Remove IgnoreSkyColor
|
||||
// - Remove IgnoreGI
|
||||
// - Remove SkyOnly
|
||||
if (classElement.GetVersion() <= 1)
|
||||
{
|
||||
classElement.RemoveElementByName(AZ_CRC("IgnoreSkyColor"));
|
||||
classElement.RemoveElementByName(AZ_CRC("IgnoreGI"));
|
||||
classElement.RemoveElementByName(AZ_CRC("SkyOnly"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void VisAreaComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<VisAreaComponent, AZ::Component>()
|
||||
->Version(1)
|
||||
->Field("m_config", &VisAreaComponent::m_config)
|
||||
;
|
||||
}
|
||||
|
||||
VisAreaConfiguration::Reflect(context);
|
||||
}
|
||||
|
||||
VisAreaComponent::VisAreaComponent(const VisAreaConfiguration& params)
|
||||
: m_config(params)
|
||||
{
|
||||
}
|
||||
|
||||
void VisAreaComponent::Activate()
|
||||
{
|
||||
VisAreaComponentRequestBus::Handler::BusConnect(GetEntityId());
|
||||
}
|
||||
|
||||
void VisAreaComponent::Deactivate()
|
||||
{
|
||||
VisAreaComponentRequestBus::Handler::BusDisconnect(GetEntityId());
|
||||
}
|
||||
|
||||
float VisAreaComponent::GetHeight()
|
||||
{
|
||||
return m_config.m_height;
|
||||
}
|
||||
|
||||
bool VisAreaComponent::GetDisplayFilled()
|
||||
{
|
||||
return m_config.m_displayFilled;
|
||||
}
|
||||
|
||||
bool VisAreaComponent::GetAffectedBySun()
|
||||
{
|
||||
return m_config.m_affectedBySun;
|
||||
}
|
||||
|
||||
float VisAreaComponent::GetViewDistRatio()
|
||||
{
|
||||
return m_config.m_viewDistRatio;
|
||||
}
|
||||
|
||||
bool VisAreaComponent::GetOceanIsVisible()
|
||||
{
|
||||
return m_config.m_oceanIsVisible;
|
||||
}
|
||||
} //namespace Visibility
|
||||
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <AzCore/Math/VertexContainer.h>
|
||||
|
||||
#include "VisAreaComponentBus.h"
|
||||
|
||||
namespace Visibility
|
||||
{
|
||||
class VisAreaConfiguration
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(VisAreaConfiguration, "{160D9FC2-936F-59BB-827C-DEF89671E4DC}");
|
||||
AZ_CLASS_ALLOCATOR(VisAreaConfiguration, AZ::SystemAllocator,0);
|
||||
|
||||
virtual ~VisAreaConfiguration() = default;
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
static bool VersionConverter(
|
||||
AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement);
|
||||
|
||||
float m_height = 5.0f;
|
||||
bool m_displayFilled = false;
|
||||
bool m_affectedBySun = false;
|
||||
float m_viewDistRatio = 100.0f;
|
||||
bool m_oceanIsVisible = false;
|
||||
AZ::VertexContainer<AZ::Vector3> m_vertexContainer;
|
||||
|
||||
virtual void ChangeHeight() {}
|
||||
virtual void ChangeDisplayFilled() {}
|
||||
virtual void ChangeAffectedBySun() {}
|
||||
virtual void ChangeViewDistRatio() {}
|
||||
virtual void ChangeOceanIsVisible() {}
|
||||
virtual void ChangeVertexContainer() {}
|
||||
};
|
||||
|
||||
class VisAreaComponent
|
||||
: public AZ::Component
|
||||
, private VisAreaComponentRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(VisAreaComponent, "{ACAB60F8-100E-5EAF-BE2B-D60F79312404}", AZ::Component);
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provides);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& requires);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
VisAreaComponent() = default;
|
||||
explicit VisAreaComponent(const VisAreaConfiguration& params);
|
||||
|
||||
// AZ::Component
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
// VisAreaComponentRequestBus
|
||||
float GetHeight() override;
|
||||
bool GetDisplayFilled() override;
|
||||
bool GetAffectedBySun() override;
|
||||
float GetViewDistRatio() override;
|
||||
bool GetOceanIsVisible() override;
|
||||
|
||||
private:
|
||||
VisAreaConfiguration m_config; ///< Reflected configuration.
|
||||
};
|
||||
} // namespace Visibility
|
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "Visibility_precompiled.h"
|
||||
|
||||
#include "VisibilityGem.h"
|
||||
|
||||
#include "OccluderAreaComponent.h"
|
||||
#include "PortalComponent.h"
|
||||
#include "VisAreaComponent.h"
|
||||
|
||||
#ifdef VISIBILITY_EDITOR
|
||||
#include "EditorOccluderAreaComponent.h"
|
||||
#include "EditorPortalComponent.h"
|
||||
#include "EditorVisAreaComponent.h"
|
||||
#endif //VISIBILITY_EDITOR
|
||||
|
||||
VisibilityGem::VisibilityGem()
|
||||
{
|
||||
m_descriptors.push_back(Visibility::OccluderAreaComponent::CreateDescriptor());
|
||||
m_descriptors.push_back(Visibility::PortalComponent::CreateDescriptor());
|
||||
m_descriptors.push_back(Visibility::VisAreaComponent::CreateDescriptor());
|
||||
|
||||
#ifdef VISIBILITY_EDITOR
|
||||
m_descriptors.push_back(Visibility::EditorOccluderAreaComponent::CreateDescriptor());
|
||||
m_descriptors.push_back(Visibility::EditorPortalComponent::CreateDescriptor());
|
||||
m_descriptors.push_back(Visibility::EditorVisAreaComponent::CreateDescriptor());
|
||||
#endif //VISIBILITY_EDITOR
|
||||
}
|
||||
|
||||
AZ_DECLARE_MODULE_CLASS(Gem_Visibility, VisibilityGem)
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IGem.h>
|
||||
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
|
||||
|
||||
class VisibilityGem
|
||||
: public AZ::Module
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(VisibilityGem, "{5138F2B6-EDFB-490E-AB3E-B82E43263A20}");
|
||||
|
||||
VisibilityGem();
|
||||
};
|
||||
@ -1,12 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "Visibility_precompiled.h"
|
||||
@ -1,19 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <platform.h>
|
||||
#include <CryName.h>
|
||||
#include <I3DEngine.h>
|
||||
#include <ISerialize.h>
|
||||
#include <IGem.h>
|
||||
@ -1,184 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#include "Visibility_precompiled.h"
|
||||
|
||||
#include <AzTest/AzTest.h>
|
||||
#include <Mocks/ITimerMock.h>
|
||||
#include <Mocks/ICryPakMock.h>
|
||||
#include <Mocks/IConsoleMock.h>
|
||||
#include <Mocks/ISystemMock.h>
|
||||
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Math/Random.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/Script/ScriptContext.h>
|
||||
#include <AzCore/std/chrono/clocks.h>
|
||||
|
||||
#include <AzFramework/Components/TransformComponent.h>
|
||||
|
||||
#include <VisibilityGem.h>
|
||||
#include <OccluderAreaComponent.h>
|
||||
#include <PortalComponent.h>
|
||||
#include <VisAreaComponent.h>
|
||||
|
||||
class VisibilityTest
|
||||
: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
AZ::ComponentApplication::Descriptor appDesc;
|
||||
appDesc.m_memoryBlocksByteSize = 10 * 1024 * 1024;
|
||||
appDesc.m_recordingMode = AZ::Debug::AllocationRecords::RECORD_FULL;
|
||||
|
||||
AZ::ComponentApplication::StartupParameters appStartup;
|
||||
appStartup.m_createStaticModulesCallback =
|
||||
[](AZStd::vector<AZ::Module*>& modules)
|
||||
{
|
||||
modules.emplace_back(new VisibilityGem);
|
||||
};
|
||||
|
||||
m_systemEntity = m_application.Create(appDesc, appStartup);
|
||||
m_systemEntity->Init();
|
||||
m_systemEntity->Activate();
|
||||
|
||||
m_application.RegisterComponentDescriptor(AzFramework::TransformComponent::CreateDescriptor());
|
||||
m_application.RegisterComponentDescriptor(Visibility::OccluderAreaComponent::CreateDescriptor());
|
||||
m_application.RegisterComponentDescriptor(Visibility::PortalComponent::CreateDescriptor());
|
||||
m_application.RegisterComponentDescriptor(Visibility::VisAreaComponent::CreateDescriptor());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_application.Destroy();
|
||||
}
|
||||
|
||||
AZ::ComponentApplication m_application;
|
||||
AZ::Entity* m_systemEntity;
|
||||
};
|
||||
|
||||
#include <EditorOccluderAreaComponent.h>
|
||||
#include <EditorPortalComponent.h>
|
||||
#include <EditorVisAreaComponent.h>
|
||||
|
||||
TEST_F(VisibilityTest, Occluder_TestIntersect)
|
||||
{
|
||||
AZ::Entity* testEntity = aznew AZ::Entity();
|
||||
ASSERT_TRUE(testEntity != nullptr);
|
||||
|
||||
testEntity->CreateComponent<AzFramework::TransformComponent>();
|
||||
testEntity->CreateComponent<Visibility::EditorOccluderAreaComponent>();
|
||||
|
||||
Visibility::EditorOccluderAreaComponent* oaComp = testEntity->FindComponent<Visibility::EditorOccluderAreaComponent>();
|
||||
ASSERT_TRUE(oaComp != nullptr);
|
||||
testEntity->Init();
|
||||
testEntity->Activate();
|
||||
|
||||
// Test CCW tri intersection test
|
||||
const AZ::Vector3 src(0, 0, 10);
|
||||
const AZ::Vector3 dir(0, 0, -1);
|
||||
float distance;
|
||||
|
||||
// Visibility Components do not make use of the ViewportInfo to determine
|
||||
// camera position etc.
|
||||
AzFramework::ViewportInfo viewportInfo{};
|
||||
|
||||
bool didHit = oaComp->EditorSelectionIntersectRayViewport(viewportInfo, src, dir, distance);
|
||||
ASSERT_TRUE(didHit);
|
||||
ASSERT_NEAR(distance, 10, 0.1f); // Occluder is a flat plane
|
||||
|
||||
// Test CW tri intersection test
|
||||
const AZ::Vector3 srcNeg(0, 0, -10);
|
||||
const AZ::Vector3 dirNeg(0, 0, 1);
|
||||
|
||||
didHit = oaComp->EditorSelectionIntersectRayViewport(viewportInfo, srcNeg, dirNeg, distance);
|
||||
ASSERT_TRUE(didHit);
|
||||
ASSERT_NEAR(distance, 10, 0.1f); // Occluder is a flat plane
|
||||
|
||||
// Test intersect failure
|
||||
const AZ::Vector3 badDir(100, 100, -1);
|
||||
didHit = oaComp->EditorSelectionIntersectRayViewport(viewportInfo, src, badDir, distance);
|
||||
ASSERT_FALSE(didHit);
|
||||
}
|
||||
|
||||
TEST_F(VisibilityTest, Portal_TestIntersect)
|
||||
{
|
||||
AZ::Entity* testEntity = aznew AZ::Entity();
|
||||
ASSERT_TRUE(testEntity != nullptr);
|
||||
|
||||
testEntity->CreateComponent<AzFramework::TransformComponent>();
|
||||
testEntity->CreateComponent<Visibility::EditorPortalComponent>();
|
||||
|
||||
Visibility::EditorPortalComponent* pComp = testEntity->FindComponent<Visibility::EditorPortalComponent>();
|
||||
ASSERT_TRUE(pComp != nullptr);
|
||||
testEntity->Init();
|
||||
testEntity->Activate();
|
||||
|
||||
const AZ::Vector3 src(0, 0, 10);
|
||||
const AZ::Vector3 dir(0, 0, -1);
|
||||
float distance;
|
||||
|
||||
// Visibility Components do not make use of the ViewportInfo to determine
|
||||
// camera position etc.
|
||||
AzFramework::ViewportInfo viewportInfo{};
|
||||
|
||||
// Test intersect
|
||||
bool didHit = pComp->EditorSelectionIntersectRayViewport(viewportInfo, src, dir, distance);
|
||||
ASSERT_TRUE(didHit);
|
||||
ASSERT_NEAR(distance, 9, 0.1f); // Portal has a default height of 1
|
||||
|
||||
// Test casting a ray from inside the geom
|
||||
const AZ::Vector3 internalSrc(0, 0, 0.5f);
|
||||
didHit = pComp->EditorSelectionIntersectRayViewport(viewportInfo, internalSrc, dir, distance);
|
||||
ASSERT_FALSE(didHit);
|
||||
|
||||
// Test intersect failure
|
||||
const AZ::Vector3 badDir(100, 100, -1);
|
||||
didHit = pComp->EditorSelectionIntersectRayViewport(viewportInfo, src, badDir, distance);
|
||||
ASSERT_FALSE(didHit);
|
||||
}
|
||||
|
||||
TEST_F(VisibilityTest, VisArea_TestIntersect)
|
||||
{
|
||||
AZ::Entity* testEntity = aznew AZ::Entity();
|
||||
ASSERT_TRUE(testEntity != nullptr);
|
||||
|
||||
testEntity->CreateComponent<AzFramework::TransformComponent>();
|
||||
testEntity->CreateComponent<Visibility::EditorVisAreaComponent>();
|
||||
testEntity->Init();
|
||||
testEntity->Activate();
|
||||
|
||||
Visibility::EditorVisAreaComponent* vaComp = testEntity->FindComponent<Visibility::EditorVisAreaComponent>();
|
||||
ASSERT_TRUE(vaComp != nullptr);
|
||||
|
||||
const AZ::Vector3 src(0, 0, 10);
|
||||
const AZ::Vector3 dir(0, 0, -1);
|
||||
float distance;
|
||||
|
||||
// Visibility Components do not make use of the ViewportInfo to determine
|
||||
// camera position etc.
|
||||
AzFramework::ViewportInfo viewportInfo{};
|
||||
|
||||
bool didHit = vaComp->EditorSelectionIntersectRayViewport(viewportInfo, src, dir, distance);
|
||||
ASSERT_TRUE(didHit);
|
||||
ASSERT_NEAR(distance, 5, 0.1f); // VisArea has a default height of 5
|
||||
|
||||
const AZ::Vector3 badDir(100, 100, -1);
|
||||
didHit = vaComp->EditorSelectionIntersectRayViewport(viewportInfo, src, badDir, distance);
|
||||
ASSERT_FALSE(didHit);
|
||||
}
|
||||
|
||||
AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV);
|
||||
@ -1,22 +0,0 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Include/EditorOccluderAreaComponentBus.h
|
||||
Include/EditorPortalComponentBus.h
|
||||
Include/EditorVisAreaComponentBus.h
|
||||
Source/EditorOccluderAreaComponentMode.h
|
||||
Source/EditorOccluderAreaComponentMode.cpp
|
||||
Source/EditorPortalComponentMode.h
|
||||
Source/EditorPortalComponentMode.cpp
|
||||
Source/EditorVisAreaComponentMode.h
|
||||
Source/EditorVisAreaComponentMode.cpp
|
||||
)
|
||||
@ -1,21 +0,0 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Source/VisibilityGem.h
|
||||
Source/VisibilityGem.cpp
|
||||
Source/EditorOccluderAreaComponent.h
|
||||
Source/EditorOccluderAreaComponent.cpp
|
||||
Source/EditorPortalComponent.h
|
||||
Source/EditorPortalComponent.cpp
|
||||
Source/EditorVisAreaComponent.h
|
||||
Source/EditorVisAreaComponent.cpp
|
||||
)
|
||||
@ -1,22 +0,0 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Tests/VisibilityTest.cpp
|
||||
Source/VisibilityGem.h
|
||||
Source/VisibilityGem.cpp
|
||||
Source/EditorOccluderAreaComponent.h
|
||||
Source/EditorOccluderAreaComponent.cpp
|
||||
Source/EditorPortalComponent.h
|
||||
Source/EditorPortalComponent.cpp
|
||||
Source/EditorVisAreaComponent.h
|
||||
Source/EditorVisAreaComponent.cpp
|
||||
)
|
||||
@ -1,24 +0,0 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Source/Visibility_precompiled.cpp
|
||||
Source/Visibility_precompiled.h
|
||||
Include/OccluderAreaComponentBus.h
|
||||
Include/PortalComponentBus.h
|
||||
Include/VisAreaComponentBus.h
|
||||
Source/OccluderAreaComponent.h
|
||||
Source/OccluderAreaComponent.cpp
|
||||
Source/PortalComponent.h
|
||||
Source/PortalComponent.cpp
|
||||
Source/VisAreaComponent.h
|
||||
Source/VisAreaComponent.cpp
|
||||
)
|
||||
@ -1,15 +0,0 @@
|
||||
#
|
||||
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
# its licensors.
|
||||
#
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this
|
||||
# distribution (the "License"). All use of this software is governed by the License,
|
||||
# or, if provided, by the license below or the license accompanying this file. Do not
|
||||
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Source/VisibilityGem.h
|
||||
Source/VisibilityGem.cpp
|
||||
)
|
||||
@ -1,13 +0,0 @@
|
||||
{
|
||||
"gem_name": "Visibility",
|
||||
"GemFormatVersion": 3,
|
||||
"Uuid": "3b4ab3f54c2749328934c5b864355a61",
|
||||
"Name": "Visibility",
|
||||
"DisplayName": "Visibility",
|
||||
"Version": "0.1.0",
|
||||
"LinkType": "Dynamic",
|
||||
"Summary": "Provides components for defining visible regions of a scene",
|
||||
"Tags": ["Untagged"],
|
||||
"IconPath": "preview.png",
|
||||
"EditorModule": true
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8f1a3e838ba075704ee974a1289487d4007e7b7385eb855b8b2a09534b6cecd1
|
||||
size 1949
|
||||
Loading…
Reference in New Issue