Merge branch 'development' of https://github.com/o3de/o3de into jckand/PhysXVegTestFix
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# AWS Gem Automation Tests
|
||||
|
||||
## Prerequisites
|
||||
1. Build the O3DE Editor and AutomatedTesting.GameLauncher in Profile.
|
||||
2. AWS CLI is installed and configured following [Configuration and Credential File Settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html).
|
||||
3. [AWS Cloud Development Kit (CDK)](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html#getting_started_install) is installed.
|
||||
|
||||
## Deploy CDK Applications
|
||||
1. Go to the AWS IAM console and create an IAM role called o3de-automation-tests which adds your own account as as a trusted entity and uses the "AdministratorAccess" permissions policy.
|
||||
2. Copy {engine_root}\scripts\build\Platform\Windows\deploy_cdk_applications.cmd to your engine root folder.
|
||||
3. Open a Command Prompt window at the engine root and set the following environment variables:
|
||||
Set O3DE_AWS_PROJECT_NAME=AWSAUTO
|
||||
Set O3DE_AWS_DEPLOY_REGION=us-east-1
|
||||
Set ASSUME_ROLE_ARN="arn:aws:iam::{your_aws_account_id}:role/o3de-automation-tests"
|
||||
Set COMMIT_ID=HEAD
|
||||
4. Deploy the CDK applications for AWS gems by running deploy_cdk_applications.cmd in the same Command Prompt window.
|
||||
5. Edit AWS\common\constants.py to replace the assume role ARN with your own:
|
||||
arn:aws:iam::{your_aws_account_id}:role/o3de-automation-tests
|
||||
|
||||
## Run Automation Tests
|
||||
### CLI
|
||||
Open a Command Prompt window at the engine root and run the following CLI command:
|
||||
python\python.cmd -m pytest {path_to_the_test_file} --build-directory {directory_to_the_profile_build}
|
||||
|
||||
### Pycharm
|
||||
You can also run any specific automation test directly from Pycharm by providing the "--build-directory" argument in the Run Configuration.
|
||||
+61
-45
@@ -9,18 +9,18 @@ import logging
|
||||
import os
|
||||
import pytest
|
||||
import typing
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
import ly_test_tools.log.log_monitor
|
||||
|
||||
from AWS.common import constants
|
||||
from .aws_metrics_custom_thread import AWSMetricsThread
|
||||
|
||||
# fixture imports
|
||||
from assetpipeline.ap_fixtures.asset_processor_fixture import asset_processor
|
||||
from .aws_metrics_utils import aws_metrics_utils
|
||||
from .aws_metrics_custom_thread import AWSMetricsThread
|
||||
|
||||
AWS_METRICS_FEATURE_NAME = 'AWSMetrics'
|
||||
GAME_LOG_NAME = 'Game.log'
|
||||
CONTEXT_VARIABLE = ['-c', 'batch_processing=true']
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -36,7 +36,7 @@ def setup(launcher: pytest.fixture,
|
||||
asset_processor.start()
|
||||
asset_processor.wait_for_idle()
|
||||
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), GAME_LOG_NAME)
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), constants.GAME_LOG_NAME)
|
||||
|
||||
# Initialize the log monitor.
|
||||
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=launcher, log_file_path=file_to_monitor)
|
||||
@@ -73,23 +73,26 @@ def monitor_metrics_submission(log_monitor: pytest.fixture) -> None:
|
||||
f'unexpected_lines values: {unexpected_lines}')
|
||||
|
||||
|
||||
def query_metrics_from_s3(aws_metrics_utils: pytest.fixture, stack_name: str) -> None:
|
||||
def query_metrics_from_s3(aws_metrics_utils: pytest.fixture, resource_mappings: pytest.fixture, stack_name: str) -> None:
|
||||
"""
|
||||
Verify that the metrics events are delivered to the S3 bucket and can be queried.
|
||||
aws_metrics_utils: aws_metrics_utils fixture.
|
||||
stack_name: name of the CloudFormation stack.
|
||||
:param aws_metrics_utils: aws_metrics_utils fixture.
|
||||
:param resource_mappings: resource_mappings fixture.
|
||||
:param stack_name: name of the CloudFormation stack.
|
||||
"""
|
||||
analytics_bucket_name = aws_metrics_utils.get_analytics_bucket_name(stack_name)
|
||||
aws_metrics_utils.verify_s3_delivery(analytics_bucket_name)
|
||||
aws_metrics_utils.verify_s3_delivery(
|
||||
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsBucketName')
|
||||
)
|
||||
logger.info('Metrics are sent to S3.')
|
||||
|
||||
aws_metrics_utils.run_glue_crawler(f'{stack_name}-EventsCrawler')
|
||||
aws_metrics_utils.run_glue_crawler(
|
||||
resource_mappings.get_resource_name_id('AWSMetrics.EventsCrawlerName'))
|
||||
|
||||
# Remove the events_json table if exists so that the sample query can create a table with the same name.
|
||||
aws_metrics_utils.delete_table(f'{stack_name}-eventsdatabase', 'events_json')
|
||||
aws_metrics_utils.run_named_queries(f'{stack_name}-AthenaWorkGroup')
|
||||
logger.info('Query metrics from S3 successfully.')
|
||||
|
||||
# Empty the S3 bucket. S3 buckets can only be deleted successfully when it doesn't contain any object.
|
||||
aws_metrics_utils.empty_batch_analytics_bucket(analytics_bucket_name)
|
||||
|
||||
|
||||
def verify_operational_metrics(aws_metrics_utils: pytest.fixture, stack_name: str, start_time: datetime) -> None:
|
||||
"""
|
||||
@@ -102,7 +105,7 @@ def verify_operational_metrics(aws_metrics_utils: pytest.fixture, stack_name: st
|
||||
'AWS/Lambda',
|
||||
'Invocations',
|
||||
[{'Name': 'FunctionName',
|
||||
'Value': f'{stack_name}-AnalyticsProcessingLambdaName'}],
|
||||
'Value': f'{stack_name}-AnalyticsProcessingLambda'}],
|
||||
start_time)
|
||||
logger.info('AnalyticsProcessingLambda metrics are sent to CloudWatch.')
|
||||
|
||||
@@ -115,50 +118,59 @@ def verify_operational_metrics(aws_metrics_utils: pytest.fixture, stack_name: st
|
||||
logger.info('EventsProcessingLambda metrics are sent to CloudWatch.')
|
||||
|
||||
|
||||
def start_kinesis_analytics_application(aws_metrics_utils: pytest.fixture, stack_name: str) -> None:
|
||||
def update_kinesis_analytics_application_status(aws_metrics_utils: pytest.fixture,
|
||||
resource_mappings: pytest.fixture, start_application: bool) -> None:
|
||||
"""
|
||||
Start the Kinesis analytics application for real-time analytics.
|
||||
aws_metrics_utils: aws_metrics_utils fixture.
|
||||
stack_name: name of the CloudFormation stack.
|
||||
Update the Kinesis analytics application to start or stop it.
|
||||
:param aws_metrics_utils: aws_metrics_utils fixture.
|
||||
:param resource_mappings: resource_mappings fixture.
|
||||
:param start_application: whether to start or stop the application.
|
||||
"""
|
||||
analytics_application_name = f'{stack_name}-AnalyticsApplication'
|
||||
aws_metrics_utils.start_kinesis_data_analytics_application(analytics_application_name)
|
||||
if start_application:
|
||||
aws_metrics_utils.start_kinesis_data_analytics_application(
|
||||
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsApplicationName'))
|
||||
else:
|
||||
aws_metrics_utils.stop_kinesis_data_analytics_application(
|
||||
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsApplicationName'))
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.usefixtures('automatic_process_killer')
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['AWS/Metrics'])
|
||||
@pytest.mark.parametrize('feature_name', [AWS_METRICS_FEATURE_NAME])
|
||||
@pytest.mark.usefixtures('resource_mappings')
|
||||
@pytest.mark.parametrize('resource_mappings_filename', ['default_aws_resource_mappings.json'])
|
||||
@pytest.mark.usefixtures('aws_credentials')
|
||||
@pytest.mark.usefixtures('resource_mappings')
|
||||
@pytest.mark.parametrize('assume_role_arn', [constants.ASSUME_ROLE_ARN])
|
||||
@pytest.mark.parametrize('feature_name', [AWS_METRICS_FEATURE_NAME])
|
||||
@pytest.mark.parametrize('level', ['AWS/Metrics'])
|
||||
@pytest.mark.parametrize('profile_name', ['AWSAutomationTest'])
|
||||
@pytest.mark.parametrize('region_name', ['us-west-2'])
|
||||
@pytest.mark.parametrize('assume_role_arn', ['arn:aws:iam::645075835648:role/o3de-automation-tests'])
|
||||
@pytest.mark.usefixtures('cdk')
|
||||
@pytest.mark.parametrize('session_name', ['o3de-Automation-session'])
|
||||
@pytest.mark.parametrize('deployment_params', [CONTEXT_VARIABLE])
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('region_name', [constants.AWS_REGION])
|
||||
@pytest.mark.parametrize('resource_mappings_filename', [constants.AWS_RESOURCE_MAPPING_FILE_NAME])
|
||||
@pytest.mark.parametrize('session_name', [constants.SESSION_NAME])
|
||||
@pytest.mark.parametrize('stacks', [[f'{constants.AWS_PROJECT_NAME}-{AWS_METRICS_FEATURE_NAME}-{constants.AWS_REGION}']])
|
||||
class TestAWSMetricsWindows(object):
|
||||
"""
|
||||
Test class to verify the real-time and batch analytics for metrics.
|
||||
"""
|
||||
|
||||
@pytest.mark.parametrize('destroy_stacks_on_teardown', [False])
|
||||
def test_realtime_and_batch_analytics(self,
|
||||
level: str,
|
||||
launcher: pytest.fixture,
|
||||
asset_processor: pytest.fixture,
|
||||
workspace: pytest.fixture,
|
||||
aws_utils: pytest.fixture,
|
||||
cdk: pytest.fixture,
|
||||
resource_mappings: pytest.fixture,
|
||||
stacks: typing.List,
|
||||
aws_metrics_utils: pytest.fixture):
|
||||
"""
|
||||
Verify that the metrics events are sent to CloudWatch and S3 for analytics.
|
||||
"""
|
||||
# Start Kinesis analytics application on a separate thread to avoid blocking the test.
|
||||
kinesis_analytics_application_thread = AWSMetricsThread(target=start_kinesis_analytics_application,
|
||||
args=(aws_metrics_utils, cdk.stacks[0]))
|
||||
kinesis_analytics_application_thread = AWSMetricsThread(target=update_kinesis_analytics_application_status,
|
||||
args=(aws_metrics_utils, resource_mappings, True))
|
||||
kinesis_analytics_application_thread.start()
|
||||
|
||||
# Clear the analytics bucket objects before sending new metrics.
|
||||
aws_metrics_utils.empty_bucket(
|
||||
resource_mappings.get_resource_name_id('AWSMetrics.AnalyticsBucketName'))
|
||||
|
||||
log_monitor = setup(launcher, asset_processor)
|
||||
|
||||
# Kinesis analytics application needs to be in the running state before we start the game launcher.
|
||||
@@ -177,18 +189,22 @@ class TestAWSMetricsWindows(object):
|
||||
start_time)
|
||||
logger.info('Real-time metrics are sent to CloudWatch.')
|
||||
|
||||
# Run time-consuming verifications on separate threads to avoid blocking the test.
|
||||
verification_threads = list()
|
||||
verification_threads.append(
|
||||
AWSMetricsThread(target=query_metrics_from_s3, args=(aws_metrics_utils, cdk.stacks[0])))
|
||||
verification_threads.append(
|
||||
AWSMetricsThread(target=verify_operational_metrics, args=(aws_metrics_utils, cdk.stacks[0], start_time)))
|
||||
for thread in verification_threads:
|
||||
# Run time-consuming operations on separate threads to avoid blocking the test.
|
||||
operational_threads = list()
|
||||
operational_threads.append(
|
||||
AWSMetricsThread(target=query_metrics_from_s3,
|
||||
args=(aws_metrics_utils, resource_mappings, stacks[0])))
|
||||
operational_threads.append(
|
||||
AWSMetricsThread(target=verify_operational_metrics,
|
||||
args=(aws_metrics_utils, stacks[0], start_time)))
|
||||
operational_threads.append(
|
||||
AWSMetricsThread(target=update_kinesis_analytics_application_status,
|
||||
args=(aws_metrics_utils, resource_mappings, False)))
|
||||
for thread in operational_threads:
|
||||
thread.start()
|
||||
for thread in verification_threads:
|
||||
for thread in operational_threads:
|
||||
thread.join()
|
||||
|
||||
@pytest.mark.parametrize('destroy_stacks_on_teardown', [True])
|
||||
def test_unauthorized_user_request_rejected(self,
|
||||
level: str,
|
||||
launcher: pytest.fixture,
|
||||
|
||||
@@ -198,7 +198,7 @@ class AWSMetricsUtils:
|
||||
|
||||
assert state == 'SUCCEEDED', f'Failed to run the named query {named_query.get("Name", {})}'
|
||||
|
||||
def empty_batch_analytics_bucket(self, bucket_name: str) -> None:
|
||||
def empty_bucket(self, bucket_name: str) -> None:
|
||||
"""
|
||||
Empty the S3 bucket following:
|
||||
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/migrations3.html
|
||||
@@ -211,25 +211,18 @@ class AWSMetricsUtils:
|
||||
for key in bucket.objects.all():
|
||||
key.delete()
|
||||
|
||||
def get_analytics_bucket_name(self, stack_name: str) -> str:
|
||||
def delete_table(self, database_name: str, table_name: str) -> None:
|
||||
"""
|
||||
Get the name of the deployed S3 bucket.
|
||||
:param stack_name: Name of the CloudFormation stack.
|
||||
:return: Name of the deployed S3 bucket.
|
||||
Delete an existing Glue table.
|
||||
|
||||
:param database_name: Name of the Glue database.
|
||||
:param table_name: Name of the table to delete.
|
||||
"""
|
||||
|
||||
client = self._aws_util.client('cloudformation')
|
||||
|
||||
response = client.describe_stack_resources(
|
||||
StackName=stack_name
|
||||
client = self._aws_util.client('glue')
|
||||
client.delete_table(
|
||||
DatabaseName=database_name,
|
||||
Name=table_name
|
||||
)
|
||||
resources = response.get('StackResources', [])
|
||||
|
||||
for resource in resources:
|
||||
if resource.get('ResourceType') == 'AWS::S3::Bucket':
|
||||
return resource.get('PhysicalResourceId', '')
|
||||
|
||||
return ''
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
|
||||
@@ -45,7 +45,8 @@ class KinesisAnalyticsApplicationUpdatedWaiter(CustomWaiter):
|
||||
class GlueCrawlerReadyWaiter(CustomWaiter):
|
||||
"""
|
||||
Subclass of the base custom waiter class.
|
||||
Wait for the Glue crawler to finish its processing.
|
||||
Wait for the Glue crawler to finish its processing. Return when the crawler is in the "Stopping" status
|
||||
to avoid wasting too much time in the automation tests on its shutdown process.
|
||||
"""
|
||||
def __init__(self, client: botocore.client):
|
||||
"""
|
||||
@@ -57,7 +58,7 @@ class GlueCrawlerReadyWaiter(CustomWaiter):
|
||||
'GlueCrawlerReady',
|
||||
'GetCrawler',
|
||||
'Crawler.State',
|
||||
{'READY': WaitState.SUCCESS},
|
||||
{'STOPPING': WaitState.SUCCESS},
|
||||
client)
|
||||
|
||||
def wait(self, crawler_name):
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import boto3
|
||||
import uuid
|
||||
import logging
|
||||
import subprocess
|
||||
import botocore
|
||||
|
||||
import ly_test_tools.environment.process_utils as process_utils
|
||||
from typing import List
|
||||
|
||||
BOOTSTRAP_STACK_NAME = 'CDKToolkit'
|
||||
BOOTSTRAP_STAGING_BUCKET_LOGIC_ID = 'StagingBucket'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Cdk:
|
||||
"""
|
||||
Cdk class that provides methods to run cdk application commands.
|
||||
Expects system to have NodeJS, AWS CLI and CDK installed globally and have their paths setup as env variables.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._cdk_env = ''
|
||||
self._stacks = []
|
||||
self._cdk_path = os.path.dirname(os.path.realpath(__file__))
|
||||
self._session = ''
|
||||
|
||||
cdk_npm_latest_version_cmd = ['npm', 'view', 'aws-cdk', 'version']
|
||||
|
||||
output = process_utils.check_output(
|
||||
cdk_npm_latest_version_cmd,
|
||||
cwd=self._cdk_path,
|
||||
shell=True)
|
||||
cdk_npm_latest_version = output.split()[0]
|
||||
|
||||
cdk_version_cmd = ['cdk', 'version']
|
||||
output = process_utils.check_output(
|
||||
cdk_version_cmd,
|
||||
cwd=self._cdk_path,
|
||||
shell=True)
|
||||
cdk_version = output.split()[0]
|
||||
logger.info(f'Current CDK version {cdk_version}')
|
||||
|
||||
if cdk_version != cdk_npm_latest_version:
|
||||
try:
|
||||
logger.info(f'Updating CDK to latest')
|
||||
# uninstall and reinstall cdk in case npm has been updated.
|
||||
output = process_utils.check_output(
|
||||
'npm uninstall -g aws-cdk',
|
||||
cwd=self._cdk_path,
|
||||
shell=True)
|
||||
|
||||
logger.info(f'Uninstall CDK output: {output}')
|
||||
|
||||
output = process_utils.check_output(
|
||||
'npm install -g aws-cdk@latest',
|
||||
cwd=self._cdk_path,
|
||||
shell=True)
|
||||
|
||||
logger.info(f'Install CDK output: {output}')
|
||||
except subprocess.CalledProcessError as error:
|
||||
logger.warning(f'Failed reinstalling latest CDK on npm'
|
||||
f'\nError:{error.stderr}')
|
||||
|
||||
def setup(self, cdk_path: str, project: str, account_id: str,
|
||||
workspace: pytest.fixture, session: boto3.session.Session):
|
||||
"""
|
||||
:param cdk_path: Path where cdk app.py is stored.
|
||||
:param project: Project name used for cdk project name env variable.
|
||||
:param account_id: AWS account id to use with cdk application.
|
||||
:param workspace: ly_test_tools workspace fixture.
|
||||
:param session: Current boto3 session, provides credentials and region.
|
||||
"""
|
||||
self._cdk_env = os.environ.copy()
|
||||
unique_id = uuid.uuid4().hex[-4:]
|
||||
self._cdk_env['O3DE_AWS_PROJECT_NAME'] = project[:4] + unique_id if len(project) > 4 else project + unique_id
|
||||
self._cdk_env['O3DE_AWS_DEPLOY_REGION'] = session.region_name
|
||||
self._cdk_env['O3DE_AWS_DEPLOY_ACCOUNT'] = account_id
|
||||
self._cdk_env['PATH'] = f'{workspace.paths.engine_root()}\\python;' + self._cdk_env['PATH']
|
||||
|
||||
credentials = session.get_credentials().get_frozen_credentials()
|
||||
self._cdk_env['AWS_ACCESS_KEY_ID'] = credentials.access_key
|
||||
self._cdk_env['AWS_SECRET_ACCESS_KEY'] = credentials.secret_key
|
||||
self._cdk_env['AWS_SESSION_TOKEN'] = credentials.token
|
||||
self._cdk_path = cdk_path
|
||||
|
||||
self._session = session
|
||||
|
||||
output = process_utils.check_output(
|
||||
'python -m pip install -r requirements.txt',
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
|
||||
logger.info(f'Installing cdk python dependencies: {output}')
|
||||
|
||||
self.bootstrap()
|
||||
|
||||
def bootstrap(self) -> None:
|
||||
"""
|
||||
Deploy the bootstrap stack.
|
||||
"""
|
||||
try:
|
||||
bootstrap_cmd = ['cdk', 'bootstrap',
|
||||
f'aws://{self._cdk_env["O3DE_AWS_DEPLOY_ACCOUNT"]}/{self._cdk_env["O3DE_AWS_DEPLOY_REGION"]}']
|
||||
|
||||
process_utils.check_call(
|
||||
bootstrap_cmd,
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
except botocore.exceptions.ClientError as clientError:
|
||||
logger.warning(f'Failed creating Bootstrap stack {BOOTSTRAP_STACK_NAME} not found. '
|
||||
f'\nError:{clientError["Error"]["Message"]}')
|
||||
|
||||
def list(self, deployment_params: List[str] = None) -> List[str]:
|
||||
"""
|
||||
lists cdk stack names.
|
||||
:param deployment_params: Deployment parameters like --all can be passed in this way.
|
||||
:return List of cdk stack names.
|
||||
"""
|
||||
if not self._cdk_path:
|
||||
return []
|
||||
|
||||
list_cdk_application_cmd = ['cdk', 'list']
|
||||
if deployment_params:
|
||||
list_cdk_application_cmd.extend(deployment_params)
|
||||
|
||||
output = process_utils.check_output(
|
||||
list_cdk_application_cmd,
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
|
||||
return output.splitlines()
|
||||
|
||||
def synthesize(self, deployment_params: List[str] = None) -> None:
|
||||
"""
|
||||
Synthesizes all cdk stacks.
|
||||
:param deployment_params: Deployment parameters like --all can be passed in this way.
|
||||
"""
|
||||
if not self._cdk_path:
|
||||
return
|
||||
|
||||
synth_cdk_application_cmd = ['cdk', 'synth']
|
||||
if deployment_params:
|
||||
synth_cdk_application_cmd.extend(deployment_params)
|
||||
|
||||
process_utils.check_output(
|
||||
synth_cdk_application_cmd,
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
|
||||
def deploy(self, deployment_params: List[str] = None) -> List[str]:
|
||||
"""
|
||||
Deploys all the CDK stacks.
|
||||
:param deployment_params: Deployment parameters like --all can be passed in this way.
|
||||
:return List of deployed stack arns.
|
||||
"""
|
||||
if not self._cdk_path:
|
||||
return []
|
||||
|
||||
deploy_cdk_application_cmd = ['cdk', 'deploy', '--require-approval', 'never']
|
||||
if deployment_params:
|
||||
deploy_cdk_application_cmd.extend(deployment_params)
|
||||
|
||||
output = process_utils.check_output(
|
||||
deploy_cdk_application_cmd,
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
|
||||
for line in output.splitlines():
|
||||
line_sections = line.split('/')
|
||||
assert len(line_sections), 3
|
||||
self._stacks.append(line.split('/')[-2])
|
||||
|
||||
return self._stacks
|
||||
|
||||
def destroy(self, deployment_params: List[str] = None) -> None:
|
||||
"""
|
||||
Destroys the cdk application.
|
||||
:param deployment_params: Deployment parameters like --all can be passed in this way.
|
||||
"""
|
||||
|
||||
logger.info(f'CDK Path {self._cdk_path}')
|
||||
destroy_cdk_application_cmd = ['cdk', 'destroy', '-f']
|
||||
if deployment_params:
|
||||
destroy_cdk_application_cmd.extend(deployment_params)
|
||||
|
||||
try:
|
||||
process_utils.check_output(
|
||||
destroy_cdk_application_cmd,
|
||||
cwd=self._cdk_path,
|
||||
env=self._cdk_env,
|
||||
shell=True)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(e.output)
|
||||
raise e
|
||||
|
||||
self._stacks = []
|
||||
|
||||
def remove_bootstrap_stack(self) -> None:
|
||||
"""
|
||||
Remove the CDK bootstrap stack.
|
||||
:param aws_utils: aws_utils fixture.
|
||||
"""
|
||||
# Check if the bootstrap stack exists.
|
||||
response = self._session.client('cloudformation').describe_stacks(
|
||||
StackName=BOOTSTRAP_STACK_NAME
|
||||
)
|
||||
stacks = response.get('Stacks', [])
|
||||
if not stacks or len(stacks) is 0:
|
||||
return
|
||||
|
||||
# Clear the bootstrap staging bucket before deleting the bootstrap stack.
|
||||
response = self._session.client('cloudformation').describe_stack_resource(
|
||||
StackName=BOOTSTRAP_STACK_NAME,
|
||||
LogicalResourceId=BOOTSTRAP_STAGING_BUCKET_LOGIC_ID
|
||||
)
|
||||
|
||||
staging_bucket_name = response.get('StackResourceDetail', {}).get('PhysicalResourceId', '')
|
||||
if staging_bucket_name:
|
||||
s3 = self._session.resource('s3')
|
||||
bucket = s3.Bucket(staging_bucket_name)
|
||||
for key in bucket.objects.all():
|
||||
key.delete()
|
||||
|
||||
# Delete the bootstrap stack.
|
||||
# Should not need to delete the stack if S3 bucket can be cleaned.
|
||||
# self._session.client('cloudformation').delete_stack(
|
||||
# StackName=BOOTSTRAP_STACK_NAME
|
||||
# )
|
||||
|
||||
@property
|
||||
def stacks(self):
|
||||
return self._stacks
|
||||
+33
-28
@@ -4,45 +4,42 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
import pytest
|
||||
import os
|
||||
|
||||
import logging
|
||||
import os
|
||||
import pytest
|
||||
|
||||
import ly_test_tools.log.log_monitor
|
||||
|
||||
from AWS.common import constants
|
||||
|
||||
# fixture imports
|
||||
from assetpipeline.ap_fixtures.asset_processor_fixture import asset_processor
|
||||
|
||||
AWS_PROJECT_NAME = 'AWS-AutomationTest'
|
||||
AWS_CLIENT_AUTH_FEATURE_NAME = 'AWSClientAuth'
|
||||
AWS_CLIENT_AUTH_DEFAULT_PROFILE_NAME = 'default'
|
||||
|
||||
GAME_LOG_NAME = 'Game.log'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.usefixtures('automatic_process_killer')
|
||||
@pytest.mark.usefixtures('asset_processor')
|
||||
@pytest.mark.usefixtures('workspace')
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.usefixtures('cdk')
|
||||
@pytest.mark.parametrize('feature_name', [AWS_CLIENT_AUTH_FEATURE_NAME])
|
||||
@pytest.mark.usefixtures('resource_mappings')
|
||||
@pytest.mark.parametrize('resource_mappings_filename', ['default_aws_resource_mappings.json'])
|
||||
@pytest.mark.usefixtures('automatic_process_killer')
|
||||
@pytest.mark.usefixtures('aws_utils')
|
||||
@pytest.mark.parametrize('region_name', ['us-west-2'])
|
||||
@pytest.mark.parametrize('assume_role_arn', ['arn:aws:iam::645075835648:role/o3de-automation-tests'])
|
||||
@pytest.mark.parametrize('session_name', ['o3de-Automation-session'])
|
||||
@pytest.mark.usefixtures('cdk')
|
||||
@pytest.mark.parametrize('deployment_params', [[]])
|
||||
@pytest.mark.usefixtures('workspace')
|
||||
@pytest.mark.parametrize('assume_role_arn', [constants.ASSUME_ROLE_ARN])
|
||||
@pytest.mark.parametrize('feature_name', [AWS_CLIENT_AUTH_FEATURE_NAME])
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.usefixtures('resource_mappings')
|
||||
@pytest.mark.parametrize('resource_mappings_filename', [constants.AWS_RESOURCE_MAPPING_FILE_NAME])
|
||||
@pytest.mark.parametrize('region_name', [constants.AWS_REGION])
|
||||
@pytest.mark.parametrize('session_name', [constants.SESSION_NAME])
|
||||
@pytest.mark.parametrize('stacks', [[f'{constants.AWS_PROJECT_NAME}-{AWS_CLIENT_AUTH_FEATURE_NAME}-Stack-{constants.AWS_REGION}']])
|
||||
class TestAWSClientAuthWindows(object):
|
||||
"""
|
||||
Test class to verify AWS Client Auth gem features on Windows.
|
||||
"""
|
||||
|
||||
@pytest.mark.parametrize('level', ['AWS/ClientAuth'])
|
||||
@pytest.mark.parametrize('destroy_stacks_on_teardown', [False])
|
||||
def test_anonymous_credentials(self,
|
||||
level: str,
|
||||
launcher: pytest.fixture,
|
||||
@@ -53,14 +50,14 @@ class TestAWSClientAuthWindows(object):
|
||||
"""
|
||||
Test to verify AWS Cognito Identity pool anonymous authorization.
|
||||
|
||||
Setup: Deploys cdk and updates resource mapping file.
|
||||
Setup: Updates resource mapping file using existing CloudFormation stacks.
|
||||
Tests: Getting credentials when no credentials are configured
|
||||
Verification: Log monitor looks for success credentials log.
|
||||
"""
|
||||
asset_processor.start()
|
||||
asset_processor.wait_for_idle()
|
||||
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), GAME_LOG_NAME)
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), constants.GAME_LOG_NAME)
|
||||
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=launcher, log_file_path=file_to_monitor)
|
||||
|
||||
launcher.args = ['+LoadLevel', level]
|
||||
@@ -74,10 +71,8 @@ class TestAWSClientAuthWindows(object):
|
||||
)
|
||||
assert result, 'Anonymous credentials fetched successfully.'
|
||||
|
||||
@pytest.mark.parametrize('destroy_stacks_on_teardown', [True])
|
||||
def test_password_signin_credentials(self,
|
||||
launcher: pytest.fixture,
|
||||
cdk: pytest.fixture,
|
||||
resource_mappings: pytest.fixture,
|
||||
workspace: pytest.fixture,
|
||||
asset_processor: pytest.fixture,
|
||||
@@ -86,16 +81,29 @@ class TestAWSClientAuthWindows(object):
|
||||
"""
|
||||
Test to verify AWS Cognito IDP Password sign in and Cognito Identity pool authenticated authorization.
|
||||
|
||||
Setup: Deploys cdk and updates resource mapping file.
|
||||
Setup: Updates resource mapping file using existing CloudFormation stacks.
|
||||
Tests: Sign up new test user, admin confirm the user, sign in and get aws credentials.
|
||||
Verification: Log monitor looks for success credentials log.
|
||||
"""
|
||||
asset_processor.start()
|
||||
asset_processor.wait_for_idle()
|
||||
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), GAME_LOG_NAME)
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), constants.GAME_LOG_NAME)
|
||||
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=launcher, log_file_path=file_to_monitor)
|
||||
|
||||
cognito_idp = aws_utils.client('cognito-idp')
|
||||
user_pool_id = resource_mappings.get_resource_name_id(f'{AWS_CLIENT_AUTH_FEATURE_NAME}.CognitoUserPoolId')
|
||||
logger.info(f'UserPoolId:{user_pool_id}')
|
||||
|
||||
# Remove the user if already exists
|
||||
try:
|
||||
cognito_idp.admin_delete_user(
|
||||
UserPoolId=user_pool_id,
|
||||
Username='test1'
|
||||
)
|
||||
except cognito_idp.exceptions.UserNotFoundException:
|
||||
pass
|
||||
|
||||
launcher.args = ['+LoadLevel', 'AWS/ClientAuthPasswordSignUp']
|
||||
launcher.args.extend(['-rhi=null'])
|
||||
|
||||
@@ -109,9 +117,6 @@ class TestAWSClientAuthWindows(object):
|
||||
|
||||
launcher.stop()
|
||||
|
||||
cognito_idp = aws_utils.client('cognito-idp')
|
||||
user_pool_id = resource_mappings.get_resource_name_id(f'{AWS_CLIENT_AUTH_FEATURE_NAME}.CognitoUserPoolId')
|
||||
print(f'UserPoolId:{user_pool_id}')
|
||||
cognito_idp.admin_confirm_sign_up(
|
||||
UserPoolId=user_pool_id,
|
||||
Username='test1'
|
||||
|
||||
+15
-17
@@ -5,10 +5,11 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import logging
|
||||
import typing
|
||||
import os
|
||||
import shutil
|
||||
import typing
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
import pytest
|
||||
import ly_test_tools
|
||||
@@ -16,16 +17,15 @@ import ly_test_tools.log.log_monitor
|
||||
import ly_test_tools.environment.process_utils as process_utils
|
||||
import ly_test_tools.o3de.asset_processor_utils as asset_processor_utils
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from AWS.common import constants
|
||||
|
||||
# fixture imports
|
||||
from assetpipeline.ap_fixtures.asset_processor_fixture import asset_processor
|
||||
|
||||
AWS_CORE_FEATURE_NAME = 'AWSCore'
|
||||
AWS_RESOURCE_MAPPING_FILE_NAME = 'default_aws_resource_mappings.json'
|
||||
|
||||
process_utils.kill_processes_named("o3de", ignore_extensions=True) # Kill ProjectManager windows
|
||||
|
||||
GAME_LOG_NAME = 'Game.log'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ def setup(launcher: pytest.fixture, asset_processor: pytest.fixture) -> typing.T
|
||||
asset_processor.start()
|
||||
asset_processor.wait_for_idle()
|
||||
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), GAME_LOG_NAME)
|
||||
file_to_monitor = os.path.join(launcher.workspace.paths.project_log(), constants.GAME_LOG_NAME)
|
||||
log_monitor = ly_test_tools.log.log_monitor.LogMonitor(launcher=launcher, log_file_path=file_to_monitor)
|
||||
|
||||
return log_monitor, s3_download_dir
|
||||
@@ -58,7 +58,7 @@ def write_test_data_to_dynamodb_table(resource_mappings: pytest.fixture, aws_uti
|
||||
:param resource_mappings: resource_mappings fixture.
|
||||
:param aws_utils: aws_utils fixture.
|
||||
"""
|
||||
table_name = resource_mappings.get_resource_name_id("AWSCore.ExampleDynamoTableOutput")
|
||||
table_name = resource_mappings.get_resource_name_id(f'{AWS_CORE_FEATURE_NAME}.ExampleDynamoTableOutput')
|
||||
try:
|
||||
aws_utils.client('dynamodb').put_item(
|
||||
TableName=table_name,
|
||||
@@ -77,21 +77,19 @@ def write_test_data_to_dynamodb_table(resource_mappings: pytest.fixture, aws_uti
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.usefixtures('automatic_process_killer')
|
||||
@pytest.mark.usefixtures('asset_processor')
|
||||
@pytest.mark.usefixtures('cdk')
|
||||
@pytest.mark.parametrize('feature_name', [AWS_CORE_FEATURE_NAME])
|
||||
@pytest.mark.parametrize('region_name', ['us-west-2'])
|
||||
@pytest.mark.parametrize('assume_role_arn', ['arn:aws:iam::645075835648:role/o3de-automation-tests'])
|
||||
@pytest.mark.parametrize('session_name', ['o3de-Automation-session'])
|
||||
@pytest.mark.parametrize('region_name', [constants.AWS_REGION])
|
||||
@pytest.mark.parametrize('assume_role_arn', [constants.ASSUME_ROLE_ARN])
|
||||
@pytest.mark.parametrize('session_name', [constants.SESSION_NAME])
|
||||
@pytest.mark.usefixtures('workspace')
|
||||
@pytest.mark.parametrize('project', ['AutomatedTesting'])
|
||||
@pytest.mark.parametrize('level', ['AWS/Core'])
|
||||
@pytest.mark.usefixtures('resource_mappings')
|
||||
@pytest.mark.parametrize('resource_mappings_filename', [AWS_RESOURCE_MAPPING_FILE_NAME])
|
||||
@pytest.mark.parametrize('resource_mappings_filename', [constants.AWS_RESOURCE_MAPPING_FILE_NAME])
|
||||
@pytest.mark.parametrize('stacks', [[f'{constants.AWS_PROJECT_NAME}-{AWS_CORE_FEATURE_NAME}',
|
||||
f'{constants.AWS_PROJECT_NAME}-{AWS_CORE_FEATURE_NAME}-Example-{constants.AWS_REGION}']])
|
||||
@pytest.mark.usefixtures('aws_credentials')
|
||||
@pytest.mark.parametrize('profile_name', ['AWSAutomationTest'])
|
||||
@pytest.mark.usefixtures('cdk')
|
||||
@pytest.mark.parametrize('deployment_params', [['--all']])
|
||||
@pytest.mark.parametrize('destroy_stacks_on_teardown', [True])
|
||||
class TestAWSCoreAWSResourceInteraction(object):
|
||||
"""
|
||||
Test class to verify the scripting behavior for the AWSCore gem.
|
||||
@@ -119,7 +117,7 @@ class TestAWSCoreAWSResourceInteraction(object):
|
||||
expected_lines: typing.List[str],
|
||||
unexpected_lines: typing.List[str]):
|
||||
"""
|
||||
Setup: Deploys cdk and updates resource mapping file.
|
||||
Setup: Updates resource mapping file using existing CloudFormation stacks.
|
||||
Tests: Interact with AWS S3, DynamoDB and Lambda services.
|
||||
Verification: Script canvas nodes can communicate with AWS services successfully.
|
||||
"""
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
@@ -0,0 +1,19 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
# ARN of the IAM role to assume for retrieving temporary AWS credentials
|
||||
ASSUME_ROLE_ARN = 'arn:aws:iam::645075835648:role/o3de-automation-tests'
|
||||
# Name of the AWS project deployed by the CDK applications
|
||||
AWS_PROJECT_NAME = 'AWSAUTO'
|
||||
# Region for the existing CloudFormation stacks used by the automation tests
|
||||
AWS_REGION = 'us-east-1'
|
||||
# Name of the default resource mapping config file used by the automation tests
|
||||
AWS_RESOURCE_MAPPING_FILE_NAME = 'default_aws_resource_mappings.json'
|
||||
# Name of the game launcher log
|
||||
GAME_LOG_NAME = 'Game.log'
|
||||
# Name of the IAM role session for retrieving temporary AWS credentials
|
||||
SESSION_NAME = 'o3de-Automation-session'
|
||||
+5
-9
@@ -6,9 +6,9 @@ SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import json
|
||||
import logging
|
||||
from AWS.common import constants
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -22,18 +22,14 @@ class ResourceMappings:
|
||||
ResourceMappings class that handles writing Cloud formation outputs to resource mappings json file in a project.
|
||||
"""
|
||||
|
||||
def __init__(self, file_path: str, region: str, feature_name: str, account_id: str, workspace: pytest.fixture,
|
||||
cloud_formation_client):
|
||||
def __init__(self, file_path: str, region: str, feature_name: str, account_id: str, cloud_formation_client):
|
||||
"""
|
||||
:param file_path: Path for the resource mapping file.
|
||||
:param region: Region value for the resource mapping file.
|
||||
:param feature_name: Feature gem name to use to append name to mappings key.
|
||||
:param account_id: AWS account id value for the resource mapping file.
|
||||
:param workspace: ly_test_tools workspace fixture.
|
||||
:param cloud_formation_client: AWS cloud formation client.
|
||||
"""
|
||||
self._cdk_env = os.environ.copy()
|
||||
self._cdk_env['PATH'] = f'{workspace.paths.engine_root()}\\python;' + self._cdk_env['PATH']
|
||||
self._resource_mapping_file_path = file_path
|
||||
self._region = region
|
||||
self._feature_name = feature_name
|
||||
@@ -44,7 +40,7 @@ class ResourceMappings:
|
||||
f'Invalid resource mapping file path {self._resource_mapping_file_path}'
|
||||
self._client = cloud_formation_client
|
||||
|
||||
def populate_output_keys(self, stacks=[]) -> None:
|
||||
def populate_output_keys(self, stacks=None) -> None:
|
||||
"""
|
||||
Calls describe stacks on cloud formation service and persists outputs to resource mappings file.
|
||||
:param stacks List of stack arns to describe and populate resource mappings with.
|
||||
@@ -58,7 +54,7 @@ class ResourceMappings:
|
||||
|
||||
self._write_resource_mappings(stacks[0].get('Outputs', []))
|
||||
|
||||
def _write_resource_mappings(self, outputs, append_feature_name = True) -> None:
|
||||
def _write_resource_mappings(self, outputs, append_feature_name=True) -> None:
|
||||
with open(self._resource_mapping_file_path) as file_content:
|
||||
resource_mappings = json.load(file_content)
|
||||
|
||||
@@ -91,7 +87,7 @@ class ResourceMappings:
|
||||
resource_mappings = json.load(file_content)
|
||||
|
||||
resource_mappings[AWS_RESOURCE_MAPPINGS_ACCOUNT_ID_KEY] = ''
|
||||
resource_mappings[AWS_RESOURCE_MAPPINGS_REGION_KEY] = 'us-west-2'
|
||||
resource_mappings[AWS_RESOURCE_MAPPINGS_REGION_KEY] = constants.AWS_REGION
|
||||
|
||||
# Append new mappings.
|
||||
resource_mappings[AWS_RESOURCE_MAPPINGS_KEY] = resource_mappings.get(AWS_RESOURCE_MAPPINGS_KEY, {})
|
||||
@@ -11,8 +11,7 @@ import typing
|
||||
|
||||
from AWS.common.aws_utils import AwsUtils
|
||||
from AWS.common.aws_credentials import AwsCredentials
|
||||
from AWS.Windows.cdk.cdk_utils import Cdk
|
||||
from AWS.Windows.resource_mappings.resource_mappings import ResourceMappings
|
||||
from AWS.common.resource_mappings import ResourceMappings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -52,6 +51,7 @@ def resource_mappings(
|
||||
project: str,
|
||||
feature_name: str,
|
||||
resource_mappings_filename: str,
|
||||
stacks: typing.List,
|
||||
workspace: pytest.fixture,
|
||||
aws_utils: pytest.fixture) -> ResourceMappings:
|
||||
"""
|
||||
@@ -61,6 +61,7 @@ def resource_mappings(
|
||||
:param project: Project to find resource mapping file.
|
||||
:param feature_name: AWS Gem name that is prepended to resource mapping keys.
|
||||
:param resource_mappings_filename: Name of resource mapping file.
|
||||
:param stacks: List of stack names to describe and populate resource mappings with.
|
||||
:param workspace: ly_test_tools workspace fixture.
|
||||
:param aws_utils: AWS utils fixture.
|
||||
:return: ResourceMappings class object.
|
||||
@@ -70,8 +71,8 @@ def resource_mappings(
|
||||
logger.info(f'Resource mapping path : {path}')
|
||||
logger.info(f'Resource mapping resolved path : {abspath(path)}')
|
||||
resource_mappings_obj = ResourceMappings(abspath(path), aws_utils.assume_session().region_name, feature_name,
|
||||
aws_utils.assume_account_id(), workspace,
|
||||
aws_utils.client('cloudformation'))
|
||||
aws_utils.assume_account_id(), aws_utils.client('cloudformation'))
|
||||
resource_mappings_obj.populate_output_keys(stacks)
|
||||
|
||||
def teardown():
|
||||
resource_mappings_obj.clear_output_keys()
|
||||
@@ -81,56 +82,6 @@ def resource_mappings(
|
||||
return resource_mappings_obj
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def cdk(
|
||||
request: pytest.fixture,
|
||||
project: str,
|
||||
feature_name: str,
|
||||
workspace: pytest.fixture,
|
||||
aws_utils: pytest.fixture,
|
||||
resource_mappings: pytest.fixture,
|
||||
deployment_params: typing.List[str],
|
||||
destroy_stacks_on_teardown: bool) -> Cdk:
|
||||
"""
|
||||
Fixture for setting up a Cdk
|
||||
:param request: _pytest.fixtures.SubRequest class that handles getting
|
||||
a pytest fixture from a pytest function/fixture.
|
||||
:param project: Project name used for cdk project name env variable.
|
||||
:param feature_name: Feature gem name to expect cdk folder in.
|
||||
:param workspace: ly_test_tools workspace fixture.
|
||||
:param aws_utils: aws_utils fixture.
|
||||
:param resource_mappings: resource_mappings fixture.
|
||||
:param deployment_params: Parameters for the CDK application deployment.
|
||||
:param destroy_stacks_on_teardown: option to control calling destroy ot the end of test.
|
||||
:return Cdk class object.
|
||||
"""
|
||||
|
||||
cdk_path = f'{workspace.paths.engine_root()}/Gems/{feature_name}/cdk'
|
||||
logger.info(f'CDK Path {cdk_path}')
|
||||
|
||||
if pytest.cdk_obj is None:
|
||||
pytest.cdk_obj = Cdk()
|
||||
pytest.cdk_obj.setup(cdk_path, project, aws_utils.assume_account_id(), workspace, aws_utils.assume_session())
|
||||
|
||||
stacks = pytest.cdk_obj.deploy(deployment_params=deployment_params)
|
||||
|
||||
logger.info(f'Cdk stack names:\n{stacks}')
|
||||
resource_mappings.populate_output_keys(stacks)
|
||||
|
||||
def teardown():
|
||||
if destroy_stacks_on_teardown:
|
||||
pytest.cdk_obj.destroy(deployment_params=deployment_params)
|
||||
# Enable after https://github.com/aws/aws-cdk/issues/986 is fixed.
|
||||
# Until then clean the bootstrap bucket manually.
|
||||
# pytest.cdk_obj.remove_bootstrap_stack()
|
||||
|
||||
pytest.cdk_obj = None
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
return pytest.cdk_obj
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def aws_credentials(request: pytest.fixture, aws_utils: pytest.fixture, profile_name: str):
|
||||
"""
|
||||
|
||||
@@ -130,8 +130,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
NAME AutomatedTesting::LandscapeCanvasTests_Main
|
||||
TEST_SERIAL
|
||||
TEST_SUITE main
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/landscape_canvas
|
||||
PYTEST_MARKS "not SUITE_sandbox and not SUITE_periodic and not SUITE_benchmark"
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/landscape_canvas/test_LandscapeCanvas_Main.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -144,8 +143,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
NAME AutomatedTesting::LandscapeCanvasTests_Periodic
|
||||
TEST_SERIAL
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/landscape_canvas
|
||||
PYTEST_MARKS "SUITE_periodic"
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/landscape_canvas/test_LandscapeCanvas_Periodic.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
@@ -159,7 +157,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_
|
||||
NAME AutomatedTesting::GradientSignalTests_Periodic
|
||||
TEST_SERIAL
|
||||
TEST_SUITE periodic
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/gradient_signal
|
||||
PATH ${CMAKE_CURRENT_LIST_DIR}/gradient_signal/test_GradientSignal_Periodic.py
|
||||
RUNTIME_DEPENDENCIES
|
||||
AZ::AssetProcessor
|
||||
Legacy::Editor
|
||||
|
||||
+96
-102
@@ -4,124 +4,118 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestGradientGeneratorIncompatibilities(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientGeneratorIncompatibilities", args=["level"])
|
||||
def GradientGenerators_Incompatibilities():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that components are disabled when conflicting components are present on the same entity.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that components are disabled when conflicting components are present on the same entity.
|
||||
Expected Behavior:
|
||||
Gradient Generator components are incompatible with Vegetation area components.
|
||||
|
||||
Expected Behavior:
|
||||
Gradient Generator components are incompatible with Vegetation area components.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Generator component to an entity, and add a Vegetation Area component to the same entity
|
||||
4) Verify that components are only enabled when entity is free of a conflicting component
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Generator component to an entity, and add a Vegetation Area component to the same entity
|
||||
4) Verify that components are only enabled when entity is free of a conflicting component
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
gradient_generators = [
|
||||
'Altitude Gradient',
|
||||
'Constant Gradient',
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient',
|
||||
'Shape Falloff Gradient',
|
||||
'Slope Gradient',
|
||||
'Surface Mask Gradient'
|
||||
]
|
||||
require_transform_modifiers = [
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient'
|
||||
]
|
||||
vegetation_areas = [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Layer Blender',
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Layer Blocker (Mesh)'
|
||||
]
|
||||
area_dependencies = {
|
||||
'Vegetation Layer Spawner': 'Vegetation Asset List',
|
||||
'Vegetation Layer Blocker (Mesh)': 'Mesh'
|
||||
}
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
gradient_generators = [
|
||||
'Altitude Gradient',
|
||||
'Constant Gradient',
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient',
|
||||
'Shape Falloff Gradient',
|
||||
'Slope Gradient',
|
||||
'Surface Mask Gradient'
|
||||
]
|
||||
require_transform_modifiers = [
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient'
|
||||
]
|
||||
vegetation_areas = [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Layer Blender',
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Layer Blocker (Mesh)'
|
||||
]
|
||||
area_dependencies = {
|
||||
'Vegetation Layer Spawner': 'Vegetation Asset List',
|
||||
'Vegetation Layer Blocker (Mesh)': 'Mesh'
|
||||
}
|
||||
|
||||
# For every gradient generator component, verify that they are incompatible
|
||||
# which each vegetation area component
|
||||
for component_name in gradient_generators:
|
||||
for vegetation_area_name in vegetation_areas:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
# For every gradient generator component, verify that they are incompatible
|
||||
# which each vegetation area component
|
||||
for component_name in gradient_generators:
|
||||
for vegetation_area_name in vegetation_areas:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add the specific vegetation area dependencies (if necessary)
|
||||
if vegetation_area_name in area_dependencies:
|
||||
hydra.add_component(area_dependencies[vegetation_area_name], entity_id)
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Add the vegetation area component we are validating against, then add the
|
||||
# gradient generator afterwards, so that the gradient generator will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the vegetation area)
|
||||
area_component = hydra.add_component(vegetation_area_name, entity_id)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
# Add the specific vegetation area dependencies (if necessary)
|
||||
if vegetation_area_name in area_dependencies:
|
||||
hydra.add_component(area_dependencies[vegetation_area_name], entity_id)
|
||||
|
||||
# Verify the gradient generator component is disabled since the vegetation area is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and not active
|
||||
if not active:
|
||||
self.log(f"{component_name} is disabled before removing {vegetation_area_name} component")
|
||||
# Add the vegetation area component we are validating against, then add the
|
||||
# gradient generator afterwards, so that the gradient generator will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the vegetation area)
|
||||
area_component = hydra.add_component(vegetation_area_name, entity_id)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
|
||||
# Remove the vegetation area component
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
|
||||
# Verify the gradient generator component is disabled since the vegetation area is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_disabled = (
|
||||
f"{component_name} is disabled before removing {vegetation_area_name} component",
|
||||
f"{component_name} is unexpectedly enabled before removing {vegetation_area_name} component"
|
||||
)
|
||||
Report.result(component_is_disabled, not active)
|
||||
|
||||
# Add required dependencies for our gradient generators after the vegetation
|
||||
# area has been removed, because the transform modifier is also incompatible
|
||||
# with the vegetation areas
|
||||
if component_name in require_transform_modifiers:
|
||||
hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
# Remove the vegetation area component
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
|
||||
|
||||
# Verify the gradient generator component is enabled now that the vegetation area is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and active
|
||||
if active:
|
||||
self.log(f"{component_name} is enabled after removing {vegetation_area_name} component")
|
||||
# Add required dependencies for our gradient generators after the vegetation
|
||||
# area has been removed, because the transform modifier is also incompatible
|
||||
# with the vegetation areas
|
||||
if component_name in require_transform_modifiers:
|
||||
hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
|
||||
# Verify the gradient generator component is enabled now that the vegetation area is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_enabled = (
|
||||
f"{component_name} is enabled after removing {vegetation_area_name} component",
|
||||
f"{component_name} is unexpectedly disabled after removing {vegetation_area_name} component"
|
||||
)
|
||||
Report.result(component_is_enabled, active)
|
||||
|
||||
|
||||
test = TestGradientGeneratorIncompatibilities()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientGenerators_Incompatibilities)
|
||||
|
||||
+133
-135
@@ -4,164 +4,162 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestGradientModifiersIncompatibilities(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientModifiersIncompatibilities", args=["level"])
|
||||
def GradientModifiers_Incompatibilities():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that components are disabled when conflicting components are present on the same entity.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that components are disabled when conflicting components are present on the same entity.
|
||||
Expected Behavior:
|
||||
Gradient Modifier components are incompatible with Vegetation area components.
|
||||
|
||||
Expected Behavior:
|
||||
Gradient Modifier components are incompatible with Vegetation area components.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Modifier component to an entity, and add a Vegetation Area component to the same entity
|
||||
4) Verify that components are only enabled when entity is free of a conflicting component
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Modifier component to an entity, and add a Vegetation Area component to the same entity
|
||||
4) Verify that components are only enabled when entity is free of a conflicting component
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
gradient_generators = [
|
||||
'Altitude Gradient',
|
||||
'Constant Gradient',
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient',
|
||||
'Shape Falloff Gradient',
|
||||
'Slope Gradient',
|
||||
'Surface Mask Gradient'
|
||||
]
|
||||
require_transform_modifiers = [
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient'
|
||||
]
|
||||
gradient_modifiers = [
|
||||
'Dither Gradient Modifier',
|
||||
'Gradient Mixer',
|
||||
'Invert Gradient Modifier',
|
||||
'Levels Gradient Modifier',
|
||||
'Posterize Gradient Modifier',
|
||||
'Smooth-Step Gradient Modifier',
|
||||
'Threshold Gradient Modifier'
|
||||
]
|
||||
vegetation_areas = [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Layer Blender',
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Layer Blocker (Mesh)'
|
||||
]
|
||||
area_dependencies = {
|
||||
'Vegetation Layer Spawner': 'Vegetation Asset List',
|
||||
'Vegetation Layer Blocker (Mesh)': 'Mesh'
|
||||
}
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
gradient_generators = [
|
||||
'Altitude Gradient',
|
||||
'Constant Gradient',
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient',
|
||||
'Shape Falloff Gradient',
|
||||
'Slope Gradient',
|
||||
'Surface Mask Gradient'
|
||||
]
|
||||
require_transform_modifiers = [
|
||||
'FastNoise Gradient',
|
||||
'Image Gradient',
|
||||
'Perlin Noise Gradient',
|
||||
'Random Noise Gradient'
|
||||
]
|
||||
gradient_modifiers = [
|
||||
'Dither Gradient Modifier',
|
||||
'Gradient Mixer',
|
||||
'Invert Gradient Modifier',
|
||||
'Levels Gradient Modifier',
|
||||
'Posterize Gradient Modifier',
|
||||
'Smooth-Step Gradient Modifier',
|
||||
'Threshold Gradient Modifier'
|
||||
]
|
||||
vegetation_areas = [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Layer Blender',
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Layer Blocker (Mesh)'
|
||||
]
|
||||
area_dependencies = {
|
||||
'Vegetation Layer Spawner': 'Vegetation Asset List',
|
||||
'Vegetation Layer Blocker (Mesh)': 'Mesh'
|
||||
}
|
||||
|
||||
# For every gradient modifier component, verify that they are incompatible
|
||||
# which each vegetation area and gradient generator/modifier component
|
||||
all_gradients = gradient_modifiers + gradient_generators
|
||||
for component_name in gradient_modifiers:
|
||||
for vegetation_area_name in vegetation_areas:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
# For every gradient modifier component, verify that they are incompatible
|
||||
# which each vegetation area and gradient generator/modifier component
|
||||
all_gradients = gradient_modifiers + gradient_generators
|
||||
for component_name in gradient_modifiers:
|
||||
for vegetation_area_name in vegetation_areas:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add the specific vegetation area dependencies (if necessary)
|
||||
if vegetation_area_name in area_dependencies:
|
||||
hydra.add_component(area_dependencies[vegetation_area_name], entity_id)
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Add the vegetation area component we are validating against, then add the
|
||||
# gradient modifier afterwards, so that the gradient modifier will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the vegetation area)
|
||||
area_component = hydra.add_component(vegetation_area_name, entity_id)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
# Add the specific vegetation area dependencies (if necessary)
|
||||
if vegetation_area_name in area_dependencies:
|
||||
hydra.add_component(area_dependencies[vegetation_area_name], entity_id)
|
||||
|
||||
# Verify the gradient modifier component is disabled since the vegetation area is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and not active
|
||||
if not active:
|
||||
self.log("{gradient} is disabled before removing {vegetation_area} component".format(gradient=component_name, vegetation_area=vegetation_area_name))
|
||||
# Add the vegetation area component we are validating against, then add the
|
||||
# gradient modifier afterwards, so that the gradient modifier will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the vegetation area)
|
||||
area_component = hydra.add_component(vegetation_area_name, entity_id)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
|
||||
# Remove the vegetation area component
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
|
||||
# Verify the gradient modifier component is disabled since the vegetation area is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_disabled = (
|
||||
f"{component_name} is disabled before removing {vegetation_area_name} component",
|
||||
f"{component_name} is unexpectedly enabled before removing {vegetation_area_name} component"
|
||||
)
|
||||
Report.result(component_is_disabled, not active)
|
||||
|
||||
# Verify the gradient modifier component is enabled now that the vegetation area is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and active
|
||||
if active:
|
||||
self.log("{gradient} is enabled after removing {vegetation_area} component".format(gradient=component_name, vegetation_area=vegetation_area_name))
|
||||
# Remove the vegetation area component
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [area_component])
|
||||
|
||||
for gradient_name in all_gradients:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
# Verify the gradient modifier component is enabled now that the vegetation area is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_enabled = (
|
||||
f"{component_name} is enabled after removing {vegetation_area_name} component",
|
||||
f"{component_name} is unexpectedly disabled after removing {vegetation_area_name} component"
|
||||
)
|
||||
Report.result(component_is_enabled, active)
|
||||
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
for gradient_name in all_gradients:
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add the specific gradient generator dependencies (if necessary)
|
||||
conflicting_components = []
|
||||
if gradient_name in require_transform_modifiers:
|
||||
component = hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
conflicting_components.append(component)
|
||||
# Most of these need a shape, so use a Box Shape
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Add the gradient component we are validating against, then add the
|
||||
# gradient modifier afterwards, so that the gradient modifier will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the other gradient)
|
||||
component = hydra.add_component(gradient_name, entity_id)
|
||||
# Add the specific gradient generator dependencies (if necessary)
|
||||
conflicting_components = []
|
||||
if gradient_name in require_transform_modifiers:
|
||||
component = hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
conflicting_components.append(component)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
|
||||
# Verify the gradient modifier component is disabled since the other gradient is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and not active
|
||||
if not active:
|
||||
self.log("{gradient} is disabled before removing {conflicting_gradient} component".format(gradient=component_name, conflicting_gradient=gradient_name))
|
||||
# Add the gradient component we are validating against, then add the
|
||||
# gradient modifier afterwards, so that the gradient modifier will actually
|
||||
# be disabled (if it was present before, it would only get deactivated instead of disabled
|
||||
# by the other gradient)
|
||||
component = hydra.add_component(gradient_name, entity_id)
|
||||
conflicting_components.append(component)
|
||||
gradient_component = hydra.add_component(component_name, entity_id)
|
||||
|
||||
# Remove the conflicting gradient component (and transform modifier if it was added)
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', conflicting_components)
|
||||
# Verify the gradient modifier component is disabled since the other gradient is incompatible
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_disabled = (
|
||||
f"{component_name} is disabled before removing {gradient_name} component",
|
||||
f"{component_name} is unexpectedly enabled before removing {gradient_name} component"
|
||||
)
|
||||
Report.result(component_is_disabled, not active)
|
||||
|
||||
# Verify the gradient modifier component is enabled now that the other gradient is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
self.test_success = self.test_success and active
|
||||
if active:
|
||||
self.log("{gradient} is enabled after removing {conflicting_gradient} component".format(gradient=component_name, conflicting_gradient=gradient_name))
|
||||
# Remove the conflicting gradient component (and transform modifier if it was added)
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', conflicting_components)
|
||||
|
||||
# Verify the gradient modifier component is enabled now that the other gradient is gone
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_component)
|
||||
component_is_enabled = (
|
||||
f"{component_name} is enabled after removing {gradient_name} component",
|
||||
f"{component_name} is unexpectedly disabled after removing {gradient_name} component"
|
||||
)
|
||||
Report.result(component_is_enabled, active)
|
||||
|
||||
|
||||
test = TestGradientModifiersIncompatibilities()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientModifiers_Incompatibilities)
|
||||
|
||||
+98
-102
@@ -5,129 +5,125 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.entity as EntityId
|
||||
def GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin():
|
||||
"""
|
||||
Summary:
|
||||
A temporary level is created. An entity for each test case is created and added with the corresponding
|
||||
components to verify if the gradient transform is set to the world origin.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
1) Preview image updates to reflect change in transform of the gradient sampler.
|
||||
2) New Preview Position property is exposed, and set to 0,0,0 (world origin).
|
||||
3) Preview Size is set to 1,1,1 by default.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
|
||||
3) Create entity with Levels Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
4) Create entity with Posterize Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
5) Create entity with Smooth-Step Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
6) Create entity with Threshold Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
7) Create entity with FastNoise Gradient and verify gradient position after clearing pinned entity
|
||||
8) Create entity with Dither Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
9) Create entity with Invert Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
10) Create entity with Perlin Noise Gradient and verify gradient position after clearing pinned entity
|
||||
|
||||
class TestGradientPreviewSettings(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientPreviewSettings_ClearPinnedEntity", args=["level"])
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
A temporary level is created. An entity for each test case is created and added with the corresponding
|
||||
components to verify if the gradient transform is set to the world origin.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Expected Behavior:
|
||||
1) Preview image updates to reflect change in transform of the gradient sampler.
|
||||
2) New Preview Position property is exposed, and set to 0,0,0 (world origin).
|
||||
3) Preview Size is set to 1,1,1 by default.
|
||||
import sys
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
|
||||
3) Create entity with Levels Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
4) Create entity with Posterize Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
5) Create entity with Smooth-Step Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
6) Create entity with Threshold Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
7) Create entity with FastNoise Gradient and verify gradient position after clearing pinned entity
|
||||
8) Create entity with Dither Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
9) Create entity with Invert Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
10) Create entity with Perlin Noise Gradient and verify gradient position after clearing pinned entity
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
:return: None
|
||||
"""
|
||||
WORLD_ORIGIN = math.Vector3(0.0, 0.0, 0.0)
|
||||
EXPECTED_SIZE = math.Vector3(1.0, 1.0, 1.0)
|
||||
CLOSE_THRESHOLD = sys.float_info.min
|
||||
|
||||
WORLD_ORIGIN = math.Vector3(0.0, 0.0, 0.0)
|
||||
EXPECTED_SIZE = math.Vector3(1.0, 1.0, 1.0)
|
||||
CLOSE_THRESHOLD = sys.float_info.min
|
||||
def create_entity(entity_name, components_to_add):
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
entity = hydra.Entity(entity_name, entity_id)
|
||||
if entity_id.IsValid():
|
||||
print(f"{entity_name} entity Created")
|
||||
entity.components = []
|
||||
for component in components_to_add:
|
||||
entity.components.append(hydra.add_component(component, entity_id))
|
||||
return entity
|
||||
|
||||
def create_entity(enity_name, components_to_add):
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
def clear_entityid_check_position(entity_name, components_to_add, check_preview_size=False):
|
||||
entity = create_entity(entity_name, components_to_add)
|
||||
hydra.get_set_test(entity, 0, "Preview Settings|Pin Preview to Shape", EntityId.EntityId())
|
||||
preview_position = hydra.get_component_property_value(
|
||||
entity.components[0], "Preview Settings|Preview Position"
|
||||
)
|
||||
preview_set_to_origin = (
|
||||
f"{entity_name}: Preview Position set to world origin",
|
||||
f"{entity_name}: Preview Position set to unexpected coords"
|
||||
)
|
||||
Report.result(preview_set_to_origin, preview_position.IsClose(WORLD_ORIGIN, CLOSE_THRESHOLD))
|
||||
if check_preview_size:
|
||||
preview_size = hydra.get_component_property_value(entity.components[0], "Preview Settings|Preview Size")
|
||||
preview_size_default_set = (
|
||||
f"{entity_name}: Preview Size set as expected",
|
||||
f"{entity_name}: Preview Size set to unexpected value. Expected {EXPECTED_SIZE}, Found {preview_size}"
|
||||
)
|
||||
entity = hydra.Entity(enity_name, entity_id)
|
||||
if entity_id.IsValid():
|
||||
print(f"{enity_name} entity Created")
|
||||
entity.components = []
|
||||
for component in components_to_add:
|
||||
entity.components.append(hydra.add_component(component, entity_id))
|
||||
return entity
|
||||
Report.result(preview_size_default_set, preview_size.IsClose(EXPECTED_SIZE, CLOSE_THRESHOLD))
|
||||
return entity
|
||||
|
||||
def clear_entityid_check_position(entity_name, components_to_add, check_preview_size=False):
|
||||
entity = create_entity(entity_name, components_to_add)
|
||||
hydra.get_set_test(entity, 0, "Preview Settings|Pin Preview to Shape", EntityId.EntityId())
|
||||
preview_position = hydra.get_component_property_value(
|
||||
entity.components[0], "Preview Settings|Preview Position"
|
||||
)
|
||||
if preview_position.IsClose(WORLD_ORIGIN, CLOSE_THRESHOLD):
|
||||
print(f"{entity_name} --- Preview Position set to world origin")
|
||||
if check_preview_size:
|
||||
preview_size = hydra.get_component_property_value(entity.components[0], "Preview Settings|Preview Size")
|
||||
if preview_size.IsClose(EXPECTED_SIZE, CLOSE_THRESHOLD):
|
||||
print(f"{entity_name} --- Preview Size set to (1, 1, 1)")
|
||||
return entity
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
# 2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"Random Noise Gradient", ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
|
||||
# 2) Create entity with Random Noise gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"Random Noise Gradient", ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
# 3) Create entity with Levels Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Levels Gradient Modifier", ["Levels Gradient Modifier"])
|
||||
|
||||
# 3) Create entity with Levels Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Levels Gradient Modifier", ["Levels Gradient Modifier"])
|
||||
# 4) Create entity with Posterize Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Posterize Gradient Modifier", ["Posterize Gradient Modifier"])
|
||||
|
||||
# 4) Create entity with Posterize Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Posterize Gradient Modifier", ["Posterize Gradient Modifier"])
|
||||
# 5) Create entity with Smooth-Step Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Smooth-Step Gradient Modifier", ["Smooth-Step Gradient Modifier"])
|
||||
|
||||
# 5) Create entity with Smooth-Step Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Smooth-Step Gradient Modifier", ["Smooth-Step Gradient Modifier"])
|
||||
# 6) Create entity with Threshold Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Threshold Gradient Modifier", ["Threshold Gradient Modifier"])
|
||||
|
||||
# 6) Create entity with Threshold Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Threshold Gradient Modifier", ["Threshold Gradient Modifier"])
|
||||
# 7) Create entity with FastNoise Gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"FastNoise Gradient", ["FastNoise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
|
||||
# 7) Create entity with FastNoise Gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"FastNoise Gradient", ["FastNoise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
# 8) Create entity with Dither Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Dither Gradient Modifier", ["Dither Gradient Modifier"], True)
|
||||
|
||||
# 8) Create entity with Dither Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Dither Gradient Modifier", ["Dither Gradient Modifier"], True)
|
||||
# 9) Create entity with Invert Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Invert Gradient Modifier", ["Invert Gradient Modifier"])
|
||||
|
||||
# 9) Create entity with Invert Gradient Modifier and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position("Invert Gradient Modifier", ["Invert Gradient Modifier"])
|
||||
|
||||
# 10) Create entity with Perlin Noise Gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"Perlin Noise Gradient", ["Perlin Noise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
# 10) Create entity with Perlin Noise Gradient and verify gradient position after clearing pinned entity
|
||||
clear_entityid_check_position(
|
||||
"Perlin Noise Gradient", ["Perlin Noise Gradient", "Gradient Transform Modifier", "Box Shape"], True
|
||||
)
|
||||
|
||||
|
||||
test = TestGradientPreviewSettings()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin)
|
||||
|
||||
+70
-79
@@ -5,18 +5,6 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class Scoped:
|
||||
def __init__(self, constructor, destructor, *args):
|
||||
@@ -33,81 +21,84 @@ class TestParams:
|
||||
self.accessed_component = accessed_component
|
||||
|
||||
|
||||
class TestGradientPreviewSettings(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientPreviewSettings_DefaultPinnedEntity", args=["level"])
|
||||
def GradientPreviewSettings_DefaultPinnedEntityIsSelf():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies default values for the pinned entity for Gradient Preview settings.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies default values for the pinned entity for Gradient Preview settings.
|
||||
Expected Behavior:
|
||||
Pinned entity is self for all gradient generator/modifiers.
|
||||
|
||||
Expected Behavior:
|
||||
Pinned entity is self for all gradient generator/modifiers.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Generator component to an entity, and verify the Pin Preview to Shape property is set to
|
||||
self
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Create a new entity in the level
|
||||
3) Add each Gradient Generator component to an entity, and verify the Pin Preview to Shape property is set to
|
||||
self
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
def execute_test(test_id, function, *args):
|
||||
if function(*args):
|
||||
self.log(test_id + ' has Preview pinned to own Entity result: SUCCESS')
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def create_entity():
|
||||
return editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
def delete_entity(entity_id):
|
||||
editor.ToolsApplicationRequestBus(bus.Broadcast, 'DeleteEntityAndAllDescendants', entity_id)
|
||||
|
||||
def attach_components(component_list, entity_id):
|
||||
components = []
|
||||
for i in component_list:
|
||||
components.append(hydra.add_component(i, entity_id))
|
||||
return components
|
||||
|
||||
def validate_id_is_current(param):
|
||||
entity_ptr = Scoped(create_entity, delete_entity)
|
||||
added_components = attach_components(param.required_components, entity_ptr.data)
|
||||
value = hydra.get_component_property_value(added_components[param.accessed_component],
|
||||
'Preview Settings|Pin Preview to Shape')
|
||||
self.test_success = self.test_success and entity_ptr.data.Equal(value)
|
||||
return entity_ptr.data.Equal(value)
|
||||
|
||||
param_list = [
|
||||
TestParams(['Gradient Transform Modifier', 'Box Shape', 'Perlin Noise Gradient'], 2),
|
||||
TestParams(['Random Noise Gradient', 'Gradient Transform Modifier', 'Box Shape'], 0),
|
||||
TestParams(['FastNoise Gradient', 'Gradient Transform Modifier', 'Box Shape'], 0),
|
||||
TestParams(['Dither Gradient Modifier'], 0),
|
||||
TestParams(['Invert Gradient Modifier'], 0),
|
||||
TestParams(['Levels Gradient Modifier'], 0),
|
||||
TestParams(['Posterize Gradient Modifier'], 0),
|
||||
TestParams(['Smooth-Step Gradient Modifier'], 0),
|
||||
TestParams(['Threshold Gradient Modifier'], 0)
|
||||
]
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
def execute_test(test_id, function, *args):
|
||||
pinned_to_self = (
|
||||
f"{test_id} has Preview pinned to self",
|
||||
f"{test_id} has Preview pinned to a different entity"
|
||||
)
|
||||
Report.result(pinned_to_self, function(*args))
|
||||
|
||||
for param in param_list:
|
||||
execute_test(param.required_components[param.accessed_component],
|
||||
validate_id_is_current, param)
|
||||
def create_entity():
|
||||
return editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
def delete_entity(entity_id):
|
||||
editor.ToolsApplicationRequestBus(bus.Broadcast, 'DeleteEntityAndAllDescendants', entity_id)
|
||||
|
||||
def attach_components(component_list, entity_id):
|
||||
components = []
|
||||
for i in component_list:
|
||||
components.append(hydra.add_component(i, entity_id))
|
||||
return components
|
||||
|
||||
def validate_id_is_current(param):
|
||||
entity_ptr = Scoped(create_entity, delete_entity)
|
||||
added_components = attach_components(param.required_components, entity_ptr.data)
|
||||
value = hydra.get_component_property_value(added_components[param.accessed_component],
|
||||
'Preview Settings|Pin Preview to Shape')
|
||||
return entity_ptr.data.Equal(value)
|
||||
|
||||
param_list = [
|
||||
TestParams(['Gradient Transform Modifier', 'Box Shape', 'Perlin Noise Gradient'], 2),
|
||||
TestParams(['Random Noise Gradient', 'Gradient Transform Modifier', 'Box Shape'], 0),
|
||||
TestParams(['FastNoise Gradient', 'Gradient Transform Modifier', 'Box Shape'], 0),
|
||||
TestParams(['Dither Gradient Modifier'], 0),
|
||||
TestParams(['Invert Gradient Modifier'], 0),
|
||||
TestParams(['Levels Gradient Modifier'], 0),
|
||||
TestParams(['Posterize Gradient Modifier'], 0),
|
||||
TestParams(['Smooth-Step Gradient Modifier'], 0),
|
||||
TestParams(['Threshold Gradient Modifier'], 0)
|
||||
]
|
||||
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
for param in param_list:
|
||||
execute_test(param.required_components[param.accessed_component],
|
||||
validate_id_is_current, param)
|
||||
|
||||
|
||||
test = TestGradientPreviewSettings()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientPreviewSettings_DefaultPinnedEntityIsSelf)
|
||||
|
||||
+67
-77
@@ -5,92 +5,82 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.entity as EntityId
|
||||
def GradientSampling_GradientReferencesAddRemoveSuccessfully():
|
||||
"""
|
||||
Summary:
|
||||
An existing gradient generator can be pinned and cleared to/from the Gradient Entity Id field
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
Gradient generator is assigned to the Gradient Entity Id field.
|
||||
Gradient generator is removed from the field.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape"
|
||||
3) Create a new entity with Gradient Modifier's, pin and clear the random noise entity id to the Gradient Id
|
||||
field in Gradient Modifier
|
||||
|
||||
class TestGradientSampling(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientSampling_GradientReferences", args=["level"])
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
An existing gradient generator can be pinned and cleared to/from the Gradient Entity Id field
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Expected Behavior:
|
||||
Gradient generator is assigned to the Gradient Entity Id field.
|
||||
Gradient generator is removed from the field.
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape"
|
||||
3) Create a new entity with Gradient Modifier's, pin and clear the random noise entity id to the Gradient Id
|
||||
field in Gradient Modifier
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
def modifier_pin_clear_to_gradiententityid(modifier):
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
component_to_add = [modifier]
|
||||
gradient_modifier = hydra.Entity(modifier)
|
||||
gradient_modifier.create_entity(entity_position, component_to_add)
|
||||
gradient_modifier.get_set_test(0, "Configuration|Gradient|Gradient Entity Id", random_noise.id)
|
||||
entity = hydra.get_component_property_value(
|
||||
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
|
||||
)
|
||||
if entity.Equal(random_noise.id):
|
||||
print(f"Gradient Generator is pinned to the {modifier} successfully")
|
||||
else:
|
||||
print(f"Failed to pin Gradient Generator to the {modifier}")
|
||||
hydra.get_set_test(gradient_modifier, 0, "Configuration|Gradient|Gradient Entity Id", EntityId.EntityId())
|
||||
entity = hydra.get_component_property_value(
|
||||
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
|
||||
)
|
||||
if entity.Equal(EntityId.EntityId()):
|
||||
print(f"Gradient Generator is cleared from the {modifier} successfully")
|
||||
else:
|
||||
print(f"Failed to clear Gradient Generator from the {modifier}")
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# 2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape"
|
||||
def modifier_pin_clear_to_gradiententityid(modifier):
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
random_noise = hydra.Entity("Random_Noise")
|
||||
random_noise.create_entity(entity_position, components_to_add)
|
||||
component_to_add = [modifier]
|
||||
gradient_modifier = hydra.Entity(modifier)
|
||||
gradient_modifier.create_entity(entity_position, component_to_add)
|
||||
gradient_modifier.get_set_test(0, "Configuration|Gradient|Gradient Entity Id", random_noise.id)
|
||||
entity = hydra.get_component_property_value(
|
||||
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
|
||||
)
|
||||
gradient_pinned_to_modifier = (
|
||||
f"Gradient Generator is pinned to the {modifier} successfully",
|
||||
f"Failed to pin Gradient Generator to the {modifier}"
|
||||
)
|
||||
Report.result(gradient_pinned_to_modifier, entity.Equal(random_noise.id))
|
||||
hydra.get_set_test(gradient_modifier, 0, "Configuration|Gradient|Gradient Entity Id", EntityId.EntityId())
|
||||
entity = hydra.get_component_property_value(
|
||||
gradient_modifier.components[0], "Configuration|Gradient|Gradient Entity Id"
|
||||
)
|
||||
gradient_cleared_from_modifier = (
|
||||
f"Gradient Generator is cleared from the {modifier} successfully",
|
||||
f"Failed to clear Gradient Generator from the {modifier}"
|
||||
)
|
||||
Report.result(gradient_cleared_from_modifier, entity.Equal(EntityId.EntityId()))
|
||||
|
||||
# 3) Create a new entity with Gradient Modifier's, pin and clear the random noise entity id to the Gradient Id
|
||||
# field in Gradient Modifier
|
||||
modifier_pin_clear_to_gradiententityid("Dither Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Invert Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Levels Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Posterize Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Smooth-Step Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Threshold Gradient Modifier")
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 2) Create a new entity with components "Random Noise Gradient", "Gradient Transform Modifier" and "Box Shape"
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
random_noise = hydra.Entity("Random_Noise")
|
||||
random_noise.create_entity(entity_position, components_to_add)
|
||||
|
||||
# 3) Create a new entity with Gradient Modifier's, pin and clear the random noise entity id to the Gradient Id
|
||||
# field in Gradient Modifier
|
||||
modifier_pin_clear_to_gradiententityid("Dither Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Invert Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Levels Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Posterize Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Smooth-Step Gradient Modifier")
|
||||
modifier_pin_clear_to_gradiententityid("Threshold Gradient Modifier")
|
||||
|
||||
|
||||
test = TestGradientSampling()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientSampling_GradientReferencesAddRemoveSuccessfully)
|
||||
|
||||
+95
-105
@@ -5,114 +5,104 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import azlmbr.math as math
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
import azlmbr.editor as editor
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestGradientSurfaceTagEmitterDependencies(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(
|
||||
self, log_prefix="GradientSurfaceTagEmitter_ComponentDependencies", args=["level"]
|
||||
def GradientSurfaceTagEmitter_ComponentDependencies():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Gradient Surface Tag Emitter component is dependent on a gradient component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Surface Tag Emitter component is disabled until a Gradient Generator, Modifier or Gradient Reference
|
||||
component (and any sub-dependencies) is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Gradient Surface Tag Emitter component
|
||||
3) Verify the component is disabled until a dependent component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.math as math
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.editor as editor
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Create an entity with Gradient Surface Tag Emitter component
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
gradient = hydra.Entity("gradient")
|
||||
gradient.create_entity(position, ["Gradient Surface Tag Emitter"])
|
||||
|
||||
# Make sure Gradient Surface Tag Emitter is disabled
|
||||
gradient_surface_tag_disabled = (
|
||||
"Gradient Surface Tag Emitter is Disabled",
|
||||
"Gradient Surface Tag Emitter is Enabled, but should be Disabled without dependencies met"
|
||||
)
|
||||
Report.result(gradient_surface_tag_disabled, not is_enabled(gradient.components[0]))
|
||||
|
||||
# Verify Gradient Surface Tag Emitter component is enabled after adding Gradient, Generator, Modifier
|
||||
# or Reference component
|
||||
new_components_to_add = [
|
||||
"Dither Gradient Modifier",
|
||||
"Gradient Mixer",
|
||||
"Invert Gradient Modifier",
|
||||
"Levels Gradient Modifier",
|
||||
"Posterize Gradient Modifier",
|
||||
"Smooth-Step Gradient Modifier",
|
||||
"Threshold Gradient Modifier",
|
||||
"Altitude Gradient",
|
||||
"Constant Gradient",
|
||||
"FastNoise Gradient",
|
||||
"Image Gradient",
|
||||
"Perlin Noise Gradient",
|
||||
"Random Noise Gradient",
|
||||
"Reference Gradient",
|
||||
"Shape Falloff Gradient",
|
||||
"Slope Gradient",
|
||||
"Surface Mask Gradient",
|
||||
]
|
||||
for component in new_components_to_add:
|
||||
component_list = ["FastNoise Gradient", "Image Gradient", "Perlin Noise Gradient", "Random Noise Gradient"]
|
||||
if component in component_list:
|
||||
for Component in ["Gradient Transform Modifier", "Box Shape"]:
|
||||
hydra.add_component(Component, gradient.id)
|
||||
typeIdsList = editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeIdsByEntityType', [component],
|
||||
entity.EntityType().Game)
|
||||
ComponentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', gradient.id, [typeIdsList[0]])
|
||||
Components = ComponentOutcome.GetValue()
|
||||
ComponentIdPair = Components[0]
|
||||
gradient_enabled = is_enabled(gradient.components[0])
|
||||
new_components_enabled = is_enabled(ComponentIdPair)
|
||||
dependencies_met = (
|
||||
f"{component} and Gradient Surface Tag Emitter are enabled",
|
||||
f"{component} and Gradient Surface Tag Emitter are disabled"
|
||||
)
|
||||
Report.result(dependencies_met, new_components_enabled and gradient_enabled)
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Gradient Surface Tag Emitter component is dependent on a gradient component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Surface Tag Emitter component is disabled until a Gradient Generator, Modifier or Gradient Reference
|
||||
component (and any sub-dependencies) is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Gradient Surface Tag Emitter component
|
||||
3) Verify the component is disabled until a dependent component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
|
||||
# Create empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# Create an entity with Gradient Surface Tag Emitter component
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
gradient = hydra.Entity("gradient")
|
||||
gradient.create_entity(position, ["Gradient Surface Tag Emitter"])
|
||||
|
||||
# Make sure Gradient Surface Tag Emitter is disabled
|
||||
is_enable = is_enabled(gradient.components[0])
|
||||
if not is_enable:
|
||||
self.log("Gradient Surface Tag Emitter is Disabled")
|
||||
elif not is_enable:
|
||||
self.log("Gradient Surface Tag Emitter is Enabled, but should be Disabled without dependencies met")
|
||||
|
||||
# Verify Gradient Surface Tag Emitter component is enabled after adding Gradient, Generator, Modifier
|
||||
# or Reference component
|
||||
new_components_to_add = [
|
||||
"Dither Gradient Modifier",
|
||||
"Gradient Mixer",
|
||||
"Invert Gradient Modifier",
|
||||
"Levels Gradient Modifier",
|
||||
"Posterize Gradient Modifier",
|
||||
"Smooth-Step Gradient Modifier",
|
||||
"Threshold Gradient Modifier",
|
||||
"Altitude Gradient",
|
||||
"Constant Gradient",
|
||||
"FastNoise Gradient",
|
||||
"Image Gradient",
|
||||
"Perlin Noise Gradient",
|
||||
"Random Noise Gradient",
|
||||
"Reference Gradient",
|
||||
"Shape Falloff Gradient",
|
||||
"Slope Gradient",
|
||||
"Surface Mask Gradient",
|
||||
]
|
||||
for component in new_components_to_add:
|
||||
component_list = ["FastNoise Gradient", "Image Gradient", "Perlin Noise Gradient", "Random Noise Gradient"]
|
||||
if component in component_list:
|
||||
for Component in ["Gradient Transform Modifier", "Box Shape"]:
|
||||
hydra.add_component(Component, gradient.id)
|
||||
typeIdsList = editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeIdsByEntityType', [component],
|
||||
entity.EntityType().Game)
|
||||
ComponentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', gradient.id, [typeIdsList[0]])
|
||||
Components = ComponentOutcome.GetValue()
|
||||
ComponentIdPair = Components[0]
|
||||
gradient_enabled = new_components_enabled = False
|
||||
gradient_enabled = is_enabled(gradient.components[0])
|
||||
new_components_enabled = is_enabled(ComponentIdPair)
|
||||
if new_components_enabled and gradient_enabled:
|
||||
self.log(f"{component} and Gradient Surface Tag Emitter are enabled")
|
||||
else:
|
||||
self.log(f"{component} and Gradient Surface Tag Emitter are disabled")
|
||||
if component in component_list:
|
||||
hydra.remove_component("Gradient Transform Modifier", gradient.id)
|
||||
hydra.remove_component("Box Shape", gradient.id)
|
||||
hydra.remove_component(component, gradient.id)
|
||||
if component in component_list:
|
||||
hydra.remove_component("Gradient Transform Modifier", gradient.id)
|
||||
hydra.remove_component("Box Shape", gradient.id)
|
||||
hydra.remove_component(component, gradient.id)
|
||||
|
||||
|
||||
test = TestGradientSurfaceTagEmitterDependencies()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientSurfaceTagEmitter_ComponentDependencies)
|
||||
|
||||
+60
-66
@@ -5,75 +5,69 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.surface_data as surface_data
|
||||
def GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully():
|
||||
"""
|
||||
Summary:
|
||||
Entity with Gradient Surface Tag Emitter and Reference Gradient components is created.
|
||||
And new surface tag has been added and removed.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
A new Surface Tag can be added and removed from the component
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
|
||||
3) Add/ remove Surface Tags
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.math as math
|
||||
import azlmbr.surface_data as surface_data
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Surface Tag Emitter", "Reference Gradient"]
|
||||
entity = hydra.Entity("entity")
|
||||
entity.create_entity(entity_position, components_to_add)
|
||||
|
||||
# 3) Add/ remove Surface Tags
|
||||
tag = surface_data.SurfaceTag()
|
||||
tag.SetTag("water")
|
||||
pte = hydra.get_property_tree(entity.components[0])
|
||||
path = "Configuration|Extended Tags"
|
||||
pte.add_container_item(path, 0, tag)
|
||||
success = helper.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 1, 1.0)
|
||||
tag_added_to_container = (
|
||||
"Successfully added surface tag",
|
||||
"Failed to add surface tag"
|
||||
)
|
||||
Report.result(tag_added_to_container, success)
|
||||
pte.remove_container_item(path, 0)
|
||||
success = helper.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 0, 1.0)
|
||||
tag_removed_from_container = (
|
||||
"Successfully removed surface tag",
|
||||
"Failed to remove surface tag"
|
||||
)
|
||||
Report.result(tag_removed_from_container, success)
|
||||
|
||||
|
||||
class TestGradientSurfaceTagEmitter(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSucessfully",
|
||||
args=["level"])
|
||||
if __name__ == "__main__":
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
Entity with Gradient Surface Tag Emitter and Reference Gradient components is created.
|
||||
And new surface tag has been added and removed.
|
||||
|
||||
Expected Behavior:
|
||||
A new Surface Tag can be added and removed from the component
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully)
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
|
||||
3) Add/ remove Surface Tags
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# 2) Create an entity with Gradient Surface Tag Emitter and Reference Gradient components.
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Surface Tag Emitter", "Reference Gradient"]
|
||||
entity = hydra.Entity("entity")
|
||||
entity.create_entity(entity_position, components_to_add)
|
||||
|
||||
# 3) Add/ remove Surface Tags
|
||||
tag = surface_data.SurfaceTag()
|
||||
tag.SetTag("water")
|
||||
pte = hydra.get_property_tree(entity.components[0])
|
||||
path = "Configuration|Extended Tags"
|
||||
pte.add_container_item(path, 0, tag)
|
||||
success = self.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 1)
|
||||
self.test_success = self.test_success and success
|
||||
print(f"Added SurfaceTag: container count is {pte.get_container_count(path).GetValue()}")
|
||||
pte.remove_container_item(path, 0)
|
||||
success = self.wait_for_condition(lambda: pte.get_container_count(path).GetValue() == 0)
|
||||
self.test_success = self.test_success and success
|
||||
print(f"Removed SurfaceTag: container count is {pte.get_container_count(path).GetValue()}")
|
||||
|
||||
|
||||
test = TestGradientSurfaceTagEmitter()
|
||||
test.run()
|
||||
|
||||
+81
-97
@@ -5,118 +5,102 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
def GradientTransform_ComponentIncompatibleWithExpectedGradients():
|
||||
"""
|
||||
Summary:
|
||||
A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape.
|
||||
Adding components Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
All added components are disabled and inform the user that they are incompatible with the Gradient Transform
|
||||
Modifier
|
||||
|
||||
Test Steps:
|
||||
1) Create level
|
||||
2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
3) Make sure all components are enabled in Entity
|
||||
4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity
|
||||
5) Make sure all newly added components are disabled
|
||||
|
||||
class TestGradientTransform_ComponentIncompatibleWithExpectedGradients(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientTransform_ComponentIncompatibleWithExpectedGradients",
|
||||
args=["level"])
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape.
|
||||
Adding components Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Expected Behavior:
|
||||
All added components are disabled and inform the user that they are incompatible with the Gradient Transform
|
||||
Modifier
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
Test Steps:
|
||||
1) Create level
|
||||
2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
3) Make sure all components are enabled in Entity
|
||||
4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity
|
||||
5) Make sure all newly added components are disabled
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Transform Modifier", "Box Shape"]
|
||||
gradient_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
gradient = hydra.Entity("gradient", gradient_id)
|
||||
|
||||
# 1) Create level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
gradient.components = []
|
||||
|
||||
for component in components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
entity_created = (
|
||||
"Entity created successfully",
|
||||
"Failed to create entity"
|
||||
)
|
||||
Report.critical_result(entity_created, gradient_id.isValid())
|
||||
|
||||
# 3) Make sure all components are enabled in Entity
|
||||
index = 0
|
||||
for component in components_to_add:
|
||||
components_enabled = (
|
||||
f"{component} is enabled",
|
||||
f"{component} is unexpectedly disabled"
|
||||
)
|
||||
Report.critical_result(components_enabled, is_enabled(gradient.components[index]))
|
||||
index += 1
|
||||
|
||||
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Transform Modifier", "Box Shape"]
|
||||
gradient_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
# 4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
# Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity
|
||||
new_components_to_add = [
|
||||
"Constant Gradient",
|
||||
"Altitude Gradient",
|
||||
"Gradient Mixer",
|
||||
"Reference Gradient",
|
||||
"Shape Falloff Gradient",
|
||||
"Slope Gradient",
|
||||
"Surface Mask Gradient",
|
||||
]
|
||||
new_components_enabled = False
|
||||
for component in new_components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
gradient_components_disabled = (
|
||||
f"{component} is disabled",
|
||||
f"{component} is enabled, but should be disabled"
|
||||
)
|
||||
gradient = hydra.Entity("gradient", gradient_id)
|
||||
|
||||
gradient.components = []
|
||||
|
||||
for component in components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
if gradient_id.isValid():
|
||||
self.log("New Entity Created")
|
||||
|
||||
# 3) Make sure all components are enabled in Entity
|
||||
index = 0
|
||||
for component in components_to_add:
|
||||
is_enable = is_enabled(gradient.components[index])
|
||||
if is_enable:
|
||||
self.log(f"{component} is Enabled")
|
||||
self.test_success = self.test_success and is_enable
|
||||
elif not is_enable:
|
||||
self.log(f"{component} is disabled, but it should be enabled")
|
||||
self.test_success = self.test_success and is_enable
|
||||
break
|
||||
index += 1
|
||||
|
||||
# 4) Add Constant Gradient, Altitude Gradient, Gradient Mixer, Reference Gradient, Shape
|
||||
# Falloff Gradient, Slope Gradient and Surface Mask Gradient to the same entity
|
||||
new_components_to_add = [
|
||||
"Constant Gradient",
|
||||
"Altitude Gradient",
|
||||
"Gradient Mixer",
|
||||
"Reference Gradient",
|
||||
"Shape Falloff Gradient",
|
||||
"Slope Gradient",
|
||||
"Surface Mask Gradient",
|
||||
]
|
||||
index = 2
|
||||
new_components_enabled = False
|
||||
for component in new_components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
new_components_enabled = is_enabled(gradient.components[index])
|
||||
if new_components_enabled:
|
||||
self.log(f"{component} is enabled, but should be disabled")
|
||||
break
|
||||
Report.result(gradient_components_disabled, not is_enabled(gradient.components[2]))
|
||||
if not is_enabled(gradient.components[2]):
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, "RemoveComponents", component)
|
||||
|
||||
# 5) Make sure all newly added components are disabled
|
||||
if not new_components_enabled:
|
||||
self.log("All newly added components are incompatible and disabled")
|
||||
self.test_success = self.test_success and not new_components_enabled
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
test = TestGradientTransform_ComponentIncompatibleWithExpectedGradients()
|
||||
test.run()
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientTransform_ComponentIncompatibleWithExpectedGradients)
|
||||
|
||||
+69
-85
@@ -5,104 +5,88 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
def GradientTransform_ComponentIncompatibleWithSpawners():
|
||||
"""
|
||||
Summary:
|
||||
A simple level is opened. A New entity is created with components Gradient Transform Modifier and Box Shape.
|
||||
Adding a component Vegetation Layer Spawner to the same entity.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
The Vegetation Layer Spawner is deactivated and it is communicated that it is incompatible with Gradient
|
||||
Transform Modifier
|
||||
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
3) Make sure all components are enabled in Entity
|
||||
4) Add Vegetation Layer Spawner to the same entity
|
||||
5) Make sure newly added component is disabled
|
||||
|
||||
class TestGradientTransform_ComponentIncompatibleWithSpawners(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientTransform_ComponentIncompatibleWithSpawners",
|
||||
args=["level"])
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
A New level is created. A New entity is created with components Gradient Transform Modifier and Box Shape.
|
||||
Adding a component Vegetation Layer Spawner to the same entity.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Expected Behavior:
|
||||
The Vegetation Layer Spawner is deactivated and it is communicated that it is incompatible with Gradient
|
||||
Transform Modifier
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
Test Steps:
|
||||
1) Create level
|
||||
2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
3) Make sure all components are enabled in Entity
|
||||
4) Add Vegetation Layer Spawner to the same entity
|
||||
5) Make sure newly added component is disabled
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
def is_enabled(EntityComponentIdPair):
|
||||
return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", EntityComponentIdPair)
|
||||
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Transform Modifier", "Box Shape"]
|
||||
gradient_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
gradient = hydra.Entity("gradient", gradient_id)
|
||||
|
||||
# 1) Create level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
gradient.components = []
|
||||
|
||||
for component in components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
entity_created = (
|
||||
"Entity created successfully",
|
||||
"Failed to create entity"
|
||||
)
|
||||
Report.critical_result(entity_created, gradient_id.isValid())
|
||||
|
||||
# 3) Make sure all components are enabled in Entity
|
||||
index = 0
|
||||
for component in components_to_add:
|
||||
components_enabled = (
|
||||
f"{component} is enabled",
|
||||
f"{component} is unexpectedly disabled"
|
||||
)
|
||||
Report.critical_result(components_enabled, is_enabled(gradient.components[index]))
|
||||
index += 1
|
||||
|
||||
# 2) Create a new entity with components Gradient Transform Modifier and Box Shape
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
components_to_add = ["Gradient Transform Modifier", "Box Shape"]
|
||||
gradient_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
gradient = hydra.Entity("gradient", gradient_id)
|
||||
# 4) Add Vegetation Layer Spawner to the same entity
|
||||
gradient.components.append(hydra.add_component("Vegetation Layer Spawner", gradient_id))
|
||||
|
||||
gradient.components = []
|
||||
|
||||
for component in components_to_add:
|
||||
gradient.components.append(hydra.add_component(component, gradient_id))
|
||||
if gradient_id.isValid():
|
||||
self.log("New Entity Created")
|
||||
|
||||
# 3) Make sure all components are enabled in Entity
|
||||
index = 0
|
||||
for component in components_to_add:
|
||||
is_enable = is_enabled(gradient.components[index])
|
||||
if is_enable:
|
||||
self.log(f"{component} is Enabled")
|
||||
self.test_success = self.test_success and is_enable
|
||||
elif not is_enable:
|
||||
self.log(f"{component} is Disabled. But It should be Enabled in an Entity")
|
||||
self.test_success = self.test_success and is_enable
|
||||
break
|
||||
index += 1
|
||||
|
||||
# 4) Add Vegetation Layer Spawner to the same entity
|
||||
new_component_to_add = "Vegetation Layer Spawner"
|
||||
index = 2
|
||||
gradient.components.append(hydra.add_component(new_component_to_add, gradient_id))
|
||||
new_component_enabled = is_enabled(gradient.components[index])
|
||||
|
||||
# 5) Make sure newly added component is disabled
|
||||
if not new_component_enabled:
|
||||
self.log(f"{new_component_to_add} is incompatible and disabled")
|
||||
self.test_success = self.test_success and not new_component_enabled
|
||||
elif new_component_enabled:
|
||||
self.log(f"{new_component_to_add} is compatible and enabled. But It should be Incompatible and disabled")
|
||||
self.test_success = self.test_success and new_component_enabled
|
||||
# 5) Make sure newly added component is disabled
|
||||
spawner_component_disabled = (
|
||||
"Spawner component is disabled",
|
||||
"Spawner component is unexpectedly enabled"
|
||||
)
|
||||
Report.result(spawner_component_disabled, not is_enabled(gradient.components[2]))
|
||||
|
||||
|
||||
test = TestGradientTransform_ComponentIncompatibleWithSpawners()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientTransform_ComponentIncompatibleWithSpawners)
|
||||
|
||||
+64
-69
@@ -5,87 +5,82 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
"""
|
||||
C3430292: Frequency Zoom can manually be set higher than 8.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
class Tests:
|
||||
entity_created = (
|
||||
"Entity created successfully",
|
||||
"Failed to create entity"
|
||||
)
|
||||
components_added = (
|
||||
"All expected components added to entity",
|
||||
"Failed to add expected components to entity"
|
||||
)
|
||||
higher_zoom_value_set = (
|
||||
"Frequency Zoom is equal to expected value",
|
||||
"Frequency Zoom is not equal to expected value"
|
||||
)
|
||||
|
||||
|
||||
class TestGradientTransformFrequencyZoom(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientTransform_FrequencyZoomBeyondSliders", args=["level"])
|
||||
def GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange():
|
||||
"""
|
||||
Summary:
|
||||
Frequency Zoom can manually be set higher than 8 in a random noise gradient
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
Frequency Zoom can manually be set higher than 8 in a random noise gradient
|
||||
Expected Behavior:
|
||||
The value properly changes, despite the value being outside of the slider limit
|
||||
|
||||
Expected Behavior:
|
||||
The value properly changes, despite the value being outside of the slider limit
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create entity
|
||||
3) Add components to the entity
|
||||
4) Set the frequency value of the component
|
||||
5) Verify if the frequency value is set to higher value
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create entity
|
||||
3) Add components to the entity
|
||||
4) Set the frequency value of the component
|
||||
5) Verify if the frequency value is set to higher value
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.entity as EntityId
|
||||
|
||||
# 1) Open level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# 2) Create entity
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
if entity_id.IsValid():
|
||||
print("Entity Created")
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# 3) Add components to the entity
|
||||
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
entity = hydra.Entity("entity", entity_id)
|
||||
entity.components = []
|
||||
for component in components_to_add:
|
||||
entity.components.append(hydra.add_component(component, entity_id))
|
||||
print("Components added to the entity")
|
||||
# 2) Create entity
|
||||
entity_position = math.Vector3(125.0, 136.0, 32.0)
|
||||
entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
Report.critical_result(Tests.entity_created, entity_id.IsValid())
|
||||
|
||||
# 4) Set the frequency value of the component
|
||||
hydra.get_set_test(entity, 1, "Configuration|Frequency Zoom", 10)
|
||||
# 3) Add components to the entity
|
||||
components_to_add = ["Random Noise Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
entity = hydra.Entity("entity", entity_id)
|
||||
entity.components = []
|
||||
for component in components_to_add:
|
||||
entity.components.append(hydra.add_component(component, entity_id))
|
||||
Report.critical_result(Tests.components_added, len(entity.components) == 3)
|
||||
|
||||
# 5) Verify if the frequency value is set to higher value
|
||||
curr_value = hydra.get_component_property_value(entity.components[1], "Configuration|Frequency Zoom")
|
||||
if curr_value == 10.0:
|
||||
print("Frequency Zoom is equal to expected value")
|
||||
else:
|
||||
print("Frequency Zoom is not equal to expected value")
|
||||
# 4) Set the frequency value of the component
|
||||
hydra.get_set_test(entity, 1, "Configuration|Frequency Zoom", 10)
|
||||
|
||||
# 5) Verify if the frequency value is set to higher value
|
||||
curr_value = hydra.get_component_property_value(entity.components[1], "Configuration|Frequency Zoom")
|
||||
Report.result(Tests.higher_zoom_value_set, curr_value == 10.0)
|
||||
|
||||
|
||||
test = TestGradientTransformFrequencyZoom()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange)
|
||||
|
||||
+64
-66
@@ -4,73 +4,71 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestGradientTransformRequiresShape(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientTransformRequiresShape", args=["level"])
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Gradient Transform Modifier component is dependent on a shape component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Transform Modifier component is disabled until a shape component is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Gradient Transform Modifier component
|
||||
3) Verify the component is disabled until a shape component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add a Gradient Transform Component (that will be disabled since there is no shape on the Entity)
|
||||
gradient_transform_component = hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
|
||||
# Verify the Gradient Transform Component is not active before adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
|
||||
self.test_success = self.test_success and not active
|
||||
if not active:
|
||||
self.log("Gradient Transform component is not active without a Shape component on the Entity")
|
||||
|
||||
# Add a Shape component to the same Entity
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Check if the Gradient Transform Component is active now after adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
|
||||
self.test_success = self.test_success and active
|
||||
if active:
|
||||
self.log("Gradient Transform Modifier component is active now that the Entity has a Shape")
|
||||
class Tests:
|
||||
disabled_without_shape = (
|
||||
"Gradient Transform Modifier component is disabled without a Shape component on the Entity",
|
||||
"Gradient Transform Modifier component is unexpectedly enabled without a Shape component on the Entity",
|
||||
)
|
||||
enabled_with_shape = (
|
||||
"Gradient Transform Modifier component is enabled now that the Entity has a Shape",
|
||||
"Gradient Transform Modifier component is still disabled alongside a Shape component",
|
||||
)
|
||||
|
||||
|
||||
test = TestGradientTransformRequiresShape()
|
||||
test.run()
|
||||
def GradientTransform_RequiresShape():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Gradient Transform Modifier component is dependent on a shape component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Transform Modifier component is disabled until a shape component is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Gradient Transform Modifier component
|
||||
3) Verify the component is disabled until a shape component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add a Gradient Transform Component (that will be disabled since there is no shape on the Entity)
|
||||
gradient_transform_component = hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
|
||||
# Verify the Gradient Transform Component is not active before adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
|
||||
Report.result(Tests.disabled_without_shape, not active)
|
||||
|
||||
# Add a Shape component to the same Entity
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Check if the Gradient Transform Component is active now after adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', gradient_transform_component)
|
||||
Report.result(Tests.enabled_with_shape, active)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientTransform_RequiresShape)
|
||||
|
||||
+73
-71
@@ -5,89 +5,91 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.entity as EntityId
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
class Tests:
|
||||
image_gradient_entity_created = (
|
||||
"Image Gradient entity created",
|
||||
"Failed to create Image Gradient entity",
|
||||
)
|
||||
image_gradient_asset_found = (
|
||||
"image_grad_test_gsi.png was found in the workspace",
|
||||
"image_grad_test_gsi.png was not found in the workspace"
|
||||
)
|
||||
image_gradient_assigned = (
|
||||
"Successfully assigned image gradient asset",
|
||||
"Failed to assign image gradient asset"
|
||||
)
|
||||
|
||||
|
||||
class TestImageGradient(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="ImageGradient_ProcessedImageAssignedSucessfully",
|
||||
args=["level"])
|
||||
def ImageGradient_ProcessedImageAssignedSuccessfully():
|
||||
"""
|
||||
Summary:
|
||||
Level created with Entity having Image Gradient and Gradient Transform Modifier components.
|
||||
Save any new image to your workspace with the suffix "_gsi" and assign as image asset.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
Level created with Entity having Image Gradient and Gradient Transform Modifier components.
|
||||
Save any new image to your workspace with the suffix "_gsi" and assign as image asset.
|
||||
|
||||
Expected Behavior:
|
||||
Image can be assigned as the Image Asset for the Image as Gradient component.
|
||||
Expected Behavior:
|
||||
Image can be assigned as the Image Asset for the Image as Gradient component.
|
||||
|
||||
Test Steps:
|
||||
1) Create level
|
||||
2) Create an entity with Image Gradient and Gradient Transform Modifier components.
|
||||
3) Assign the newly processed gradient image as Image asset.
|
||||
Test Steps:
|
||||
1) Open a level
|
||||
2) Create an entity with Image Gradient and Gradient Transform Modifier components.
|
||||
3) Assign the newly processed gradient image as Image asset.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# 1) Create level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
import os
|
||||
|
||||
# 2) Create an entity with Image Gradient and Gradient Transform Modifier components
|
||||
components_to_add = ["Image Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
entity_position = math.Vector3(512.0, 512.0, 32.0)
|
||||
new_entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
if new_entity_id.IsValid():
|
||||
print("Image Gradient Entity created")
|
||||
image_gradient_entity = hydra.Entity("Image Gradient Entity", new_entity_id)
|
||||
image_gradient_entity.components = []
|
||||
for component in components_to_add:
|
||||
image_gradient_entity.add_component(component)
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.entity as EntityId
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.math as math
|
||||
|
||||
# 3) Assign the processed gradient signal image as the Image Gradient's image asset and verify success
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# First, check for the base image in the workspace
|
||||
base_image = "image_grad_test_gsi.png"
|
||||
base_image_path = os.path.join("AutomatedTesting", "Assets", "ImageGradients", base_image)
|
||||
if os.path.isfile(base_image_path):
|
||||
print(f"{base_image} was found in the workspace")
|
||||
# 1) Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Next, assign the processed image to the Image Gradient's Image Asset property
|
||||
processed_image_path = os.path.join("Assets", "ImageGradients", "image_grad_test_gsi.gradimage")
|
||||
asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", processed_image_path, math.Uuid(),
|
||||
False)
|
||||
hydra.get_set_test(image_gradient_entity, 0, "Configuration|Image Asset", asset_id)
|
||||
# 2) Create an entity with Image Gradient and Gradient Transform Modifier components
|
||||
components_to_add = ["Image Gradient", "Gradient Transform Modifier", "Box Shape"]
|
||||
entity_position = math.Vector3(512.0, 512.0, 32.0)
|
||||
new_entity_id = editor.ToolsApplicationRequestBus(
|
||||
bus.Broadcast, "CreateNewEntityAtPosition", entity_position, EntityId.EntityId()
|
||||
)
|
||||
Report.critical_result(Tests.image_gradient_entity_created, new_entity_id.IsValid())
|
||||
image_gradient_entity = hydra.Entity("Image Gradient Entity", new_entity_id)
|
||||
image_gradient_entity.components = []
|
||||
for component in components_to_add:
|
||||
image_gradient_entity.add_component(component)
|
||||
|
||||
# Finally, verify if the gradient image is assigned as the Image Asset
|
||||
success = hydra.get_component_property_value(image_gradient_entity.components[0], "Configuration|Image Asset") == asset_id
|
||||
self.test_success = self.test_success and success
|
||||
# 3) Assign the processed gradient signal image as the Image Gradient's image asset and verify success
|
||||
|
||||
# First, check for the base image in the workspace
|
||||
base_image = "image_grad_test_gsi.png"
|
||||
base_image_path = os.path.join("AutomatedTesting", "Assets", "ImageGradients", base_image)
|
||||
Report.critical_result(Tests.image_gradient_asset_found, os.path.isfile(base_image_path))
|
||||
|
||||
# Next, assign the processed image to the Image Gradient's Image Asset property
|
||||
processed_image_path = os.path.join("Assets", "ImageGradients", "image_grad_test_gsi.gradimage")
|
||||
asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", processed_image_path, math.Uuid(),
|
||||
False)
|
||||
hydra.get_set_test(image_gradient_entity, 0, "Configuration|Image Asset", asset_id)
|
||||
|
||||
# Finally, verify if the gradient image is assigned as the Image Asset
|
||||
success = hydra.get_component_property_value(image_gradient_entity.components[0], "Configuration|Image Asset") == asset_id
|
||||
Report.result(Tests.image_gradient_assigned, success)
|
||||
|
||||
|
||||
test = TestImageGradient()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(ImageGradient_ProcessedImageAssignedSuccessfully)
|
||||
|
||||
+65
-67
@@ -4,74 +4,72 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestImageGradientRequiresShape(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="ImageGradientRequiresShape", args=["level"])
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Image Gradient component is dependent on a shape component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Transform Modifier component is disabled until a shape component is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Image Gradient component
|
||||
3) Verify the component is disabled until a shape component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add an Image Gradient and Gradient Transform Component (should be disabled until a Shape exists on the Entity)
|
||||
image_gradient_component = hydra.add_component('Image Gradient', entity_id)
|
||||
hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
|
||||
# Verify the Image Gradient Component is not active before adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
|
||||
self.test_success = self.test_success and not active
|
||||
if not active:
|
||||
self.log("Image Gradient component is not active without a Shape component on the Entity")
|
||||
|
||||
# Add a Shape component to the same Entity
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Check if the Image Gradient Component is active now after adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
|
||||
self.test_success = self.test_success and active
|
||||
if active:
|
||||
self.log("Image Gradient component is active now that the Entity has a Shape")
|
||||
class Tests:
|
||||
disabled_without_shape = (
|
||||
"Image Gradient component is disabled without a Shape component on the Entity",
|
||||
"Image Gradient component is unexpectedly enabled without a Shape component on the Entity",
|
||||
)
|
||||
enabled_with_shape = (
|
||||
"Image Gradient component is enabled now that the Entity has a Shape",
|
||||
"Image Gradient component is still disabled alongside a Shape component",
|
||||
)
|
||||
|
||||
|
||||
test = TestImageGradientRequiresShape()
|
||||
test.run()
|
||||
def ImageGradient_RequiresShape():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Image Gradient component is dependent on a shape component.
|
||||
|
||||
Expected Result:
|
||||
Gradient Transform Modifier component is disabled until a shape component is added to the entity.
|
||||
|
||||
Test Steps:
|
||||
1) Open level
|
||||
2) Create a new entity with a Image Gradient component
|
||||
3) Verify the component is disabled until a shape component is also added to the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Create a new Entity in the level
|
||||
entity_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Add an Image Gradient and Gradient Transform Component (should be disabled until a Shape exists on the Entity)
|
||||
image_gradient_component = hydra.add_component('Image Gradient', entity_id)
|
||||
hydra.add_component('Gradient Transform Modifier', entity_id)
|
||||
|
||||
# Verify the Image Gradient Component is not active before adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
|
||||
Report.result(Tests.disabled_without_shape, not active)
|
||||
|
||||
# Add a Shape component to the same Entity
|
||||
hydra.add_component('Box Shape', entity_id)
|
||||
|
||||
# Check if the Image Gradient Component is active now after adding the Shape
|
||||
active = editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled', image_gradient_component)
|
||||
Report.result(Tests.enabled_with_shape, active)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(ImageGradient_RequiresShape)
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../../automatedtesting_shared')
|
||||
from base import TestAutomationBase
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(TestAutomationBase):
|
||||
|
||||
def test_GradientGenerators_Incompatibilities(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientGenerators_Incompatibilities as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientModifiers_Incompatibilities(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientModifiers_Incompatibilities as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientPreviewSettings_DefaultPinnedEntityIsSelf(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientPreviewSettings_DefaultPinnedEntityIsSelf as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientSampling_GradientReferencesAddRemoveSuccessfully(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientSampling_GradientReferencesAddRemoveSuccessfully as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientSurfaceTagEmitter_ComponentDependencies(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientSurfaceTagEmitter_ComponentDependencies as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientTransform_RequiresShape(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientTransform_RequiresShape as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientTransform_ComponentIncompatibleWithSpawners(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientTransform_ComponentIncompatibleWithSpawners as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_GradientTransform_ComponentIncompatibleWithExpectedGradients(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientTransform_ComponentIncompatibleWithExpectedGradients as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_ImageGradient_RequiresShape(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import ImageGradient_RequiresShape as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_ImageGradient_ProcessedImageAssignedSuccessfully(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import ImageGradient_ProcessedImageAssignedSuccessfully as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from ly_test_tools.o3de.editor_test import EditorSingleTest, EditorSharedTest, EditorParallelTest, EditorTestSuite
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(EditorTestSuite):
|
||||
|
||||
class test_GradientGenerators_Incompatibilities(EditorSharedTest):
|
||||
from .EditorScripts import GradientGenerators_Incompatibilities as test_module
|
||||
|
||||
class test_GradientModifiers_Incompatibilities(EditorSharedTest):
|
||||
from .EditorScripts import GradientModifiers_Incompatibilities as test_module
|
||||
|
||||
class test_GradientPreviewSettings_DefaultPinnedEntityIsSelf(EditorSharedTest):
|
||||
from .EditorScripts import GradientPreviewSettings_DefaultPinnedEntityIsSelf as test_module
|
||||
|
||||
class test_GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin(EditorSharedTest):
|
||||
from .EditorScripts import GradientPreviewSettings_ClearingPinnedEntitySetsPreviewToOrigin as test_module
|
||||
|
||||
class test_GradientSampling_GradientReferencesAddRemoveSuccessfully(EditorSharedTest):
|
||||
from .EditorScripts import GradientSampling_GradientReferencesAddRemoveSuccessfully as test_module
|
||||
|
||||
class test_GradientSurfaceTagEmitter_ComponentDependencies(EditorSharedTest):
|
||||
from .EditorScripts import GradientSurfaceTagEmitter_ComponentDependencies as test_module
|
||||
|
||||
class test_GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully(EditorSharedTest):
|
||||
from .EditorScripts import GradientSurfaceTagEmitter_SurfaceTagsAddRemoveSuccessfully as test_module
|
||||
|
||||
class test_GradientTransform_RequiresShape(EditorSharedTest):
|
||||
from .EditorScripts import GradientTransform_RequiresShape as test_module
|
||||
|
||||
class test_GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange(EditorSharedTest):
|
||||
from .EditorScripts import GradientTransform_FrequencyZoomCanBeSetBeyondSliderRange as test_module
|
||||
|
||||
class test_GradientTransform_ComponentIncompatibleWithSpawners(EditorSharedTest):
|
||||
from .EditorScripts import GradientTransform_ComponentIncompatibleWithSpawners as test_module
|
||||
|
||||
class test_GradientTransform_ComponentIncompatibleWithExpectedGradients(EditorSharedTest):
|
||||
from .EditorScripts import GradientTransform_ComponentIncompatibleWithExpectedGradients as test_module
|
||||
|
||||
class test_ImageGradient_RequiresShape(EditorSharedTest):
|
||||
from .EditorScripts import ImageGradient_RequiresShape as test_module
|
||||
|
||||
class test_ImageGradient_ProcessedImageAssignedSuccessfully(EditorSharedTest):
|
||||
from .EditorScripts import ImageGradient_ProcessedImageAssignedSuccessfully as test_module
|
||||
+119
-116
@@ -5,144 +5,147 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
dependencies_added = (
|
||||
"Node created new Entity with all required components",
|
||||
"Failed to create node with all required components"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestAreaNodeComponentDependency(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="AreaNodeComponentDependency", args=["level"])
|
||||
def AreaNodes_DependentComponentsAdded():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities with
|
||||
proper dependent components.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities with
|
||||
proper dependent components.
|
||||
Expected Behavior:
|
||||
All expected component dependencies are met when adding an area node to a graph.
|
||||
|
||||
Expected Behavior:
|
||||
All expected component dependencies are met when adding an area node to a graph.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the area nodes to the graph area, and ensure the proper dependent components are added
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the area nodes to the graph area, and ensure the proper dependent components are added
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding these vegetation area nodes has the main target Vegetation Layer Component
|
||||
# as well as automatically adding all required dependency components
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Vegetation area mapping with the key being the node name and the value is the
|
||||
# expected Components that should be added to the Entity created for the node
|
||||
areas = {
|
||||
'SpawnerAreaNode': [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Asset List',
|
||||
'Vegetation Reference Shape'
|
||||
],
|
||||
'MeshBlockerAreaNode': [
|
||||
'Vegetation Layer Blocker (Mesh)',
|
||||
'Mesh'
|
||||
],
|
||||
'BlockerAreaNode': [
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Reference Shape'
|
||||
]
|
||||
}
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in areas:
|
||||
componentNames.extend(areas[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding these vegetation area nodes has the main target Vegetation Layer Component
|
||||
# as well as automatically adding all required dependency components
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
# Create nodes for the vegetation areas that have additional required dependencies and check if
|
||||
# the Entity created by adding the node has the appropriate component and required
|
||||
# additional components added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in areas:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
# Vegetation area mapping with the key being the node name and the value is the
|
||||
# expected Components that should be added to the Entity created for the node
|
||||
areas = {
|
||||
'SpawnerAreaNode': [
|
||||
'Vegetation Layer Spawner',
|
||||
'Vegetation Asset List',
|
||||
'Vegetation Reference Shape'
|
||||
],
|
||||
'MeshBlockerAreaNode': [
|
||||
'Vegetation Layer Blocker (Mesh)',
|
||||
'Mesh'
|
||||
],
|
||||
'BlockerAreaNode': [
|
||||
'Vegetation Layer Blocker',
|
||||
'Vegetation Reference Shape'
|
||||
]
|
||||
}
|
||||
|
||||
components = areas[nodeName]
|
||||
success = False
|
||||
for component in components:
|
||||
componentTypeId = componentTypeIds[component]
|
||||
success = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId,
|
||||
componentTypeId)
|
||||
if not success:
|
||||
break
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("{node} created new Entity with all required components".format(node=nodeName))
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in areas:
|
||||
componentNames.extend(areas[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
# Create nodes for the vegetation areas that have additional required dependencies and check if
|
||||
# the Entity created by adding the node has the appropriate component and required
|
||||
# additional components added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in areas:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
components = areas[nodeName]
|
||||
success = False
|
||||
for component in components:
|
||||
componentTypeId = componentTypeIds[component]
|
||||
success = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId,
|
||||
componentTypeId)
|
||||
if not success:
|
||||
break
|
||||
Report.info(nodeName)
|
||||
Report.result(Tests.dependencies_added, success)
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestAreaNodeComponentDependency()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AreaNodes_DependentComponentsAdded)
|
||||
|
||||
+102
-98
@@ -5,125 +5,129 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
component_added = (
|
||||
"New entity created with the expected component",
|
||||
"Expected component was not found on entity"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestGradientNodeEntityCreate(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="AreaNodeEntityCreate", args=["level"])
|
||||
def AreaNodes_EntityCreatedOnNodeAdd():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities.
|
||||
Expected Behavior:
|
||||
New entities are created when dragging area nodes to graph area.
|
||||
|
||||
Expected Behavior:
|
||||
New entities are created when dragging area nodes to graph area.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the area nodes to the graph area, and ensure a new entity is created
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the area nodes to the graph area, and ensure a new entity is created
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding vegetation area nodes has the appropriate Vegetation Layer Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Vegetation Area mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
areas = {
|
||||
'AreaBlenderNode': 'Vegetation Layer Blender',
|
||||
'BlockerAreaNode': 'Vegetation Layer Blocker',
|
||||
'MeshBlockerAreaNode': 'Vegetation Layer Blocker (Mesh)',
|
||||
'SpawnerAreaNode': 'Vegetation Layer Spawner'
|
||||
}
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in areas:
|
||||
componentNames.append(areas[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Create nodes for all the vegetation areas we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in areas:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding vegetation area nodes has the appropriate Vegetation Layer Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
areaComponent = areas[nodeName]
|
||||
componentTypeId = componentTypeIds[areaComponent]
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId, componentTypeId)
|
||||
self.test_success = self.test_success and hasComponent
|
||||
if hasComponent:
|
||||
self.log("{node} created new Entity with {component} Component".format(node=nodeName, component=areaComponent))
|
||||
# Vegetation Area mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
areas = {
|
||||
'AreaBlenderNode': 'Vegetation Layer Blender',
|
||||
'BlockerAreaNode': 'Vegetation Layer Blocker',
|
||||
'MeshBlockerAreaNode': 'Vegetation Layer Blocker (Mesh)',
|
||||
'SpawnerAreaNode': 'Vegetation Layer Spawner'
|
||||
}
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in areas:
|
||||
componentNames.append(areas[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
# Create nodes for all the vegetation areas we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in areas:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
areaComponent = areas[nodeName]
|
||||
componentTypeId = componentTypeIds[areaComponent]
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId, componentTypeId)
|
||||
Report.info(f"Node: {nodeName} | Component: {areaComponent}")
|
||||
Report.result(Tests.component_added, hasComponent)
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestGradientNodeEntityCreate()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AreaNodes_EntityCreatedOnNodeAdd)
|
||||
|
||||
+99
-94
@@ -5,123 +5,128 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
entity_deleted = (
|
||||
"Entity was deleted when node was removed",
|
||||
"Entity was not deleted as expected when node was removed"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
createdEntityId = None
|
||||
deletedEntityId = None
|
||||
|
||||
|
||||
class TestAreaNodeEntityDelete(EditorTestHelper):
|
||||
def AreaNodes_EntityRemovedOnNodeDelete():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas node deletion properly cleans up entities in the Editor.
|
||||
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="AreaNodeEntityDelete", args=["level"])
|
||||
Expected Behavior:
|
||||
Entities are removed when area nodes are deleted from a graph.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas node deletion properly cleans up entities in the Editor.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the area nodes to the graph area, and ensure a new entity is created
|
||||
4) Delete the nodes, and ensure the newly created entities are removed
|
||||
|
||||
Expected Behavior:
|
||||
Entities are removed when area nodes are deleted from a graph.
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the area nodes to the graph area, and ensure a new entity is created
|
||||
4) Delete the nodes, and ensure the newly created entities are removed
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
:return: None
|
||||
"""
|
||||
def onEntityCreated(parameters):
|
||||
global createdEntityId
|
||||
createdEntityId = parameters[0]
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def onEntityDeleted(parameters):
|
||||
global deletedEntityId
|
||||
deletedEntityId = parameters[0]
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
def onEntityCreated(parameters):
|
||||
global createdEntityId
|
||||
createdEntityId = parameters[0]
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
def onEntityDeleted(parameters):
|
||||
global deletedEntityId
|
||||
deletedEntityId = parameters[0]
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding gradient nodes has the appropriate Gradient Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
handler.add_callback('OnEditorEntityDeleted', onEntityDeleted)
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Vegetation Area mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
areas = [
|
||||
'AreaBlenderNode',
|
||||
'BlockerAreaNode',
|
||||
'MeshBlockerAreaNode',
|
||||
'SpawnerAreaNode',
|
||||
]
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Create nodes for all the gradients we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in areas:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding gradient nodes has the appropriate Gradient Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
handler.add_callback('OnEditorEntityDeleted', onEntityDeleted)
|
||||
|
||||
removed = graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', newGraphId, node)
|
||||
# Vegetation Area mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
areas = [
|
||||
'AreaBlenderNode',
|
||||
'BlockerAreaNode',
|
||||
'MeshBlockerAreaNode',
|
||||
'SpawnerAreaNode',
|
||||
]
|
||||
|
||||
# Verify that the created Entity for this node matches the Entity that gets
|
||||
# deleted when the node is removed
|
||||
self.test_success = self.test_success and removed and createdEntityId.invoke("Equal", deletedEntityId)
|
||||
if removed and createdEntityId.invoke("Equal", deletedEntityId):
|
||||
self.log("{node} corresponding Entity was deleted when node is removed".format(node=nodeName))
|
||||
# Create nodes for all the gradients we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in areas:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph,
|
||||
nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
removed = graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', newGraphId, node)
|
||||
|
||||
# Verify that the created Entity for this node matches the Entity that gets
|
||||
# deleted when the node is removed
|
||||
Report.info(f"Node: {nodeName}")
|
||||
Report.result(Tests.entity_deleted, removed and createdEntityId.invoke("Equal", deletedEntityId))
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestAreaNodeEntityDelete()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(AreaNodes_EntityRemovedOnNodeDelete)
|
||||
|
||||
+179
-167
@@ -5,197 +5,209 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.math as math
|
||||
import azlmbr.slice as slice
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
class Tests:
|
||||
slice_instantiated = (
|
||||
"Slice instantiated successfully",
|
||||
"Failed to instantiate slice"
|
||||
)
|
||||
lc_entity_found = (
|
||||
"LandscapeCanvas entity found",
|
||||
"Failed to find LandscapeCanvas entity"
|
||||
)
|
||||
spawner_entity_found = (
|
||||
"BushSpawner entity found",
|
||||
"Failed to find BushSpawner entity"
|
||||
)
|
||||
dist_filter_component_found = (
|
||||
"Vegetation Distribution Filter component on BushSpawner entity found",
|
||||
"Failed to find Distribution Filter component on BushSpawner entity"
|
||||
)
|
||||
existing_graph_opened = (
|
||||
"Opened existing graph from slice",
|
||||
"Failed to open existing graph"
|
||||
)
|
||||
dist_filter_node_found = (
|
||||
"Vegetation Distribution Filter node found on graph",
|
||||
"Failed to find Distribution Filter node on graph"
|
||||
)
|
||||
alt_filter_component_found = (
|
||||
"Vegetation Altitude Filter component on BushSpawner entity found",
|
||||
"Failed to find Altitude Filter component on BushSpawner entity"
|
||||
)
|
||||
alt_filter_node_found = (
|
||||
"Vegetation Altitude Filter node found on graph",
|
||||
"Failed to find Altitude Filter node on graph"
|
||||
)
|
||||
dist_filter_component_removed = (
|
||||
"Vegetation Distribution Filter component removed from BushSpawner entity",
|
||||
"Failed to remove Distribution Filter component from BushSpawner entity"
|
||||
)
|
||||
dist_filter_node_removed = (
|
||||
"Vegetation Distribution Filter node removed from graph",
|
||||
"Failed to remove Distribution Filter node from graph"
|
||||
)
|
||||
child_entity_added = (
|
||||
"New entity successfully added as a child of the BushSpawner entity",
|
||||
"New entity added with an unexpected parent"
|
||||
)
|
||||
box_shape_component_found = (
|
||||
"Box Shape component on Box entity found",
|
||||
"Failed to find Box Shape component on Box entity"
|
||||
)
|
||||
box_shape_node_found = (
|
||||
"Box Shape node found on graph",
|
||||
"Failed to find Box Shape node on graph"
|
||||
)
|
||||
|
||||
|
||||
class TestComponentUpdatesUpdateGraph(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="ComponentUpdatesUpdateGraph", args=["level"])
|
||||
def ComponentUpdates_UpdateGraph():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas graphs update properly when components are added/removed outside of
|
||||
Landscape Canvas.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas graphs update properly when components are added/removed outside of
|
||||
Landscape Canvas.
|
||||
Expected Behavior:
|
||||
Graphs properly reflect component changes made to entities outside of Landscape Canvas.
|
||||
|
||||
Expected Behavior:
|
||||
Graphs properly reflect component changes made to entities outside of Landscape Canvas.
|
||||
Test Steps:
|
||||
1. Open Level
|
||||
2. Find LandscapeCanvas named entity
|
||||
3. Ensure Vegetation Distribution Component is present on the BushSpawner entity
|
||||
4. Open graph and ensure Distribution Filter wrapped node is present
|
||||
5. Delete the Vegetation Distribution Filter component from the BushSpawner entity via Entity Inspector
|
||||
6. Ensure the Vegetation Distribution Filter component was deleted from the BushSpawner entity and node is
|
||||
no longer present in the graph
|
||||
7. Add Vegetation Altitude Filter to the BushSpawner entity through Entity Inspector
|
||||
8. Ensure Altitude Filter was added to the BushSpawner node in the open graph
|
||||
9. Add a new entity with unique name as a child of the Landscape Canvas entity
|
||||
10. Add a Box Shape component to the new child entity
|
||||
11. Ensure Box Shape node is present on the open graph
|
||||
|
||||
Test Steps:
|
||||
1. Open Level
|
||||
2. Find LandscapeCanvas named entity
|
||||
3. Ensure Vegetation Distribution Component is present on the BushSpawner entity
|
||||
4. Open graph and ensure Distribution Filter wrapped node is present
|
||||
5. Delete the Vegetation Distribution Filter component from the BushSpawner entity via Entity Inspector
|
||||
6. Ensure the Vegetation Distribution Filter component was deleted from the BushSpawner entity and node is
|
||||
no longer present in the graph
|
||||
7. Add Vegetation Altitude Filter to the BushSpawner entity through Entity Inspector
|
||||
8. Ensure Altitude Filter was added to the BushSpawner node in the open graph
|
||||
9. Add a new entity with unique name as a child of the Landscape Canvas entity
|
||||
10. Add a Box Shape component to the new child entity
|
||||
11. Ensure Box Shape node is present on the open graph
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import os
|
||||
|
||||
# Create a new empty level and instantiate LC_BushFlowerBlender.slice
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
transform = math.Transform_CreateIdentity()
|
||||
position = math.Vector3(64.0, 64.0, 32.0)
|
||||
transform.invoke('SetPosition', position)
|
||||
test_slice_path = os.path.join("Slices", "LC_BushFlowerBlender.slice")
|
||||
test_slice_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", test_slice_path, math.Uuid(),
|
||||
False)
|
||||
test_slice = slice.SliceRequestBus(bus.Broadcast, 'InstantiateSliceFromAssetId', test_slice_id, transform)
|
||||
self.test_success = self.test_success and test_slice.IsValid()
|
||||
if test_slice.IsValid():
|
||||
self.log("Slice spawned!")
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.math as math
|
||||
import azlmbr.slice as slice
|
||||
|
||||
# Find root entity in the loaded level
|
||||
search_filter = entity.SearchFilter()
|
||||
search_filter.names = ["LandscapeCanvas"]
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Allow a few seconds for matching entity to be found
|
||||
self.wait_for_condition(lambda: len(entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)) > 0, 5.0)
|
||||
lc_matching_entities = entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)
|
||||
slice_root_id = lc_matching_entities[0] #Entity with Landscape Canvas component
|
||||
self.test_success = self.test_success and slice_root_id.IsValid()
|
||||
if slice_root_id.IsValid():
|
||||
self.log("LandscapeCanvas entity found")
|
||||
# Open a simple level and instantiate LC_BushFlowerBlender.slice
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
transform = math.Transform_CreateIdentity()
|
||||
position = math.Vector3(64.0, 64.0, 32.0)
|
||||
transform.invoke('SetPosition', position)
|
||||
test_slice_path = os.path.join("Slices", "LC_BushFlowerBlender.slice")
|
||||
test_slice_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", test_slice_path, math.Uuid(),
|
||||
False)
|
||||
test_slice = slice.SliceRequestBus(bus.Broadcast, 'InstantiateSliceFromAssetId', test_slice_id, transform)
|
||||
Report.critical_result(Tests.slice_instantiated, test_slice.IsValid())
|
||||
|
||||
# Find the BushSpawner entity
|
||||
search_filter.names = ["BushSpawner"]
|
||||
spawner_matching_entities = entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)
|
||||
spawner_id = spawner_matching_entities[0] #Entity with Vegetation Layer Spawner component
|
||||
self.test_success = self.test_success and spawner_id.IsValid()
|
||||
if spawner_id.IsValid():
|
||||
self.log("BushSpawner entity found")
|
||||
# Find root entity in the loaded level
|
||||
search_filter = entity.SearchFilter()
|
||||
search_filter.names = ["LandscapeCanvas"]
|
||||
|
||||
# Get needed component type ids
|
||||
distribution_filter_type_id = hydra.get_component_type_id("Vegetation Distribution Filter")
|
||||
altitude_filter_type_id = hydra.get_component_type_id("Vegetation Altitude Filter")
|
||||
box_shape_type_id = hydra.get_component_type_id("Box Shape")
|
||||
# Allow a few seconds for matching entity to be found
|
||||
helper.wait_for_condition(lambda: len(entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)) > 0, 5.0)
|
||||
lc_matching_entities = entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)
|
||||
slice_root_id = lc_matching_entities[0] #Entity with Landscape Canvas component
|
||||
Report.critical_result(Tests.lc_entity_found, slice_root_id.IsValid())
|
||||
|
||||
# Verify the BushSpawner entity has a Distribution Filter
|
||||
has_distribution_filter = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', spawner_id,
|
||||
distribution_filter_type_id)
|
||||
self.test_success = self.test_success and has_distribution_filter
|
||||
if has_distribution_filter:
|
||||
self.log("Vegetation Distribution Filter on BushSpawner entity found")
|
||||
# Find the BushSpawner entity
|
||||
search_filter.names = ["BushSpawner"]
|
||||
spawner_matching_entities = entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)
|
||||
spawner_id = spawner_matching_entities[0] #Entity with Vegetation Layer Spawner component
|
||||
Report.critical_result(Tests.spawner_entity_found, spawner_id.IsValid())
|
||||
|
||||
# Open Landscape Canvas and the existing graph
|
||||
general.open_pane('Landscape Canvas')
|
||||
open_graph = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'OnGraphEntity', slice_root_id)
|
||||
self.test_success = self.test_success and open_graph.IsValid()
|
||||
if open_graph.IsValid():
|
||||
self.log("Graph opened")
|
||||
# Get needed component type ids
|
||||
distribution_filter_type_id = hydra.get_component_type_id("Vegetation Distribution Filter")
|
||||
altitude_filter_type_id = hydra.get_component_type_id("Vegetation Altitude Filter")
|
||||
box_shape_type_id = hydra.get_component_type_id("Box Shape")
|
||||
|
||||
# Verify that Distribution Filter node is present on the graph
|
||||
spawner_distribution_filter_component = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', spawner_id,
|
||||
distribution_filter_type_id)
|
||||
spawner_distribution_filter_component_id = spawner_distribution_filter_component.GetValue()
|
||||
distribution_filter_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast,
|
||||
'GetNodeMatchingEntityComponentInGraph',
|
||||
open_graph,
|
||||
spawner_distribution_filter_component_id)
|
||||
self.test_success = self.test_success and distribution_filter_node is not None
|
||||
if distribution_filter_node is not None:
|
||||
self.log("Distribution Filter node found on graph")
|
||||
else:
|
||||
self.log("Distribution Filter node not found on graph")
|
||||
# Verify the BushSpawner entity has a Distribution Filter
|
||||
has_distribution_filter = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', spawner_id,
|
||||
distribution_filter_type_id)
|
||||
Report.critical_result(Tests.dist_filter_component_found, has_distribution_filter)
|
||||
|
||||
# Add a Vegetation Altitude Filter component to the BushSpawner entity, and verify the node is added to the graph
|
||||
spawner_altitude_filter_component = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', spawner_id,
|
||||
altitude_filter_type_id)
|
||||
spawner_altitude_filter_component_id = spawner_altitude_filter_component.GetValue()
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentOfType', spawner_id, altitude_filter_type_id)
|
||||
has_altitude_filter = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', spawner_id,
|
||||
altitude_filter_type_id)
|
||||
altitude_filter_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'GetNodeMatchingEntityComponentInGraph',
|
||||
open_graph, spawner_altitude_filter_component_id)
|
||||
self.test_success = self.test_success and has_altitude_filter and altitude_filter_node is not None
|
||||
if has_altitude_filter:
|
||||
self.log("Vegetation Altitude Filter on BushSpawner entity found")
|
||||
# Open Landscape Canvas and the existing graph
|
||||
general.open_pane('Landscape Canvas')
|
||||
open_graph = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'OnGraphEntity', slice_root_id)
|
||||
Report.critical_result(Tests.existing_graph_opened, open_graph.IsValid())
|
||||
|
||||
if altitude_filter_node is not None:
|
||||
self.log("Altitude Filter node found on graph")
|
||||
else:
|
||||
self.log("Altitude Filter node not found on graph")
|
||||
# Verify that Distribution Filter node is present on the graph
|
||||
spawner_distribution_filter_component = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', spawner_id,
|
||||
distribution_filter_type_id)
|
||||
spawner_distribution_filter_component_id = spawner_distribution_filter_component.GetValue()
|
||||
distribution_filter_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast,
|
||||
'GetNodeMatchingEntityComponentInGraph',
|
||||
open_graph,
|
||||
spawner_distribution_filter_component_id)
|
||||
Report.critical_result(Tests.dist_filter_node_found, distribution_filter_node is not None)
|
||||
|
||||
# Remove the Distribution Filter
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [spawner_distribution_filter_component_id])
|
||||
general.idle_wait(1.0)
|
||||
# Add a Vegetation Altitude Filter component to the BushSpawner entity, and verify the node is added to the graph
|
||||
spawner_altitude_filter_component = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', spawner_id,
|
||||
altitude_filter_type_id)
|
||||
spawner_altitude_filter_component_id = spawner_altitude_filter_component.GetValue()
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentOfType', spawner_id, altitude_filter_type_id)
|
||||
has_altitude_filter = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', spawner_id,
|
||||
altitude_filter_type_id)
|
||||
altitude_filter_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'GetNodeMatchingEntityComponentInGraph',
|
||||
open_graph, spawner_altitude_filter_component_id)
|
||||
Report.result(Tests.dist_filter_component_found, has_altitude_filter)
|
||||
Report.result(Tests.dist_filter_node_found, altitude_filter_node is not None)
|
||||
|
||||
# Verify the Distribution Filter was successfully removed from entity and the node was likewise removed
|
||||
has_distribution_filter = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', spawner_id,
|
||||
distribution_filter_type_id)
|
||||
self.test_success = self.test_success and not has_distribution_filter
|
||||
if not has_distribution_filter:
|
||||
self.log("Vegetation Distribution Filter removed from BushSpawner entity")
|
||||
# Remove the Distribution Filter
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [spawner_distribution_filter_component_id])
|
||||
general.idle_wait(1.0)
|
||||
|
||||
distribution_filter_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast,
|
||||
'GetAllNodesMatchingEntityComponent',
|
||||
spawner_distribution_filter_component_id)
|
||||
self.test_success = self.test_success and not distribution_filter_node
|
||||
if distribution_filter_node:
|
||||
self.log("Distribution Filter node is still present on the graph")
|
||||
else:
|
||||
self.log("Distribution Filter node was removed from the graph")
|
||||
# Verify the Distribution Filter was successfully removed from entity and the node was likewise removed
|
||||
has_distribution_filter = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', spawner_id,
|
||||
distribution_filter_type_id)
|
||||
Report.result(Tests.dist_filter_component_removed, not has_distribution_filter)
|
||||
|
||||
# Add a new child entity of BushSpawner entity
|
||||
box_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', spawner_id)
|
||||
if editor.EditorEntityInfoRequestBus(bus.Event, 'GetParent', box_id) == spawner_id:
|
||||
self.log("New entity successfully added as a child of the BushSpawner entity")
|
||||
else:
|
||||
self.log("New entity added with an unexpected parent")
|
||||
distribution_filter_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast,
|
||||
'GetAllNodesMatchingEntityComponent',
|
||||
spawner_distribution_filter_component_id)
|
||||
Report.result(Tests.dist_filter_node_removed, not distribution_filter_node)
|
||||
|
||||
# Add a Box Shape component to the new entity and verify it was properly added
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentOfType', box_id, box_shape_type_id)
|
||||
has_box_shape = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', box_id,
|
||||
box_shape_type_id)
|
||||
self.test_success = self.test_success and has_box_shape
|
||||
if has_box_shape:
|
||||
self.log("Box Shape on Box entity found")
|
||||
# Add a new child entity of BushSpawner entity
|
||||
box_id = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', spawner_id)
|
||||
Report.result(Tests.child_entity_added, editor.EditorEntityInfoRequestBus(bus.Event, 'GetParent', box_id) ==
|
||||
spawner_id)
|
||||
|
||||
# Verify the Box Shape node appear on the graph
|
||||
box_shape_component = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', box_id,
|
||||
box_shape_type_id)
|
||||
# Add a Box Shape component to the new entity and verify it was properly added
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentOfType', box_id, box_shape_type_id)
|
||||
has_box_shape = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', box_id,
|
||||
box_shape_type_id)
|
||||
Report.result(Tests.box_shape_component_found, has_box_shape)
|
||||
|
||||
box_shape_component_id = box_shape_component.GetValue()
|
||||
box_shape_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'GetAllNodesMatchingEntityComponent',
|
||||
box_shape_component_id)
|
||||
self.test_success = self.test_success and box_shape_node is not None
|
||||
if box_shape_node is not None:
|
||||
self.log("Box Shape node found on graph")
|
||||
else:
|
||||
self.log("Box Shape node not found on graph")
|
||||
# Verify the Box Shape node appears on the graph
|
||||
box_shape_component = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', box_id,
|
||||
box_shape_type_id)
|
||||
|
||||
box_shape_component_id = box_shape_component.GetValue()
|
||||
box_shape_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'GetAllNodesMatchingEntityComponent',
|
||||
box_shape_component_id)
|
||||
Report.result(Tests.box_shape_node_found, box_shape_node is not None)
|
||||
|
||||
|
||||
test = TestComponentUpdatesUpdateGraph()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(ComponentUpdates_UpdateGraph)
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
|
||||
class Tests:
|
||||
lc_component_added = (
|
||||
"Landscape Canvas component successfully added to entity",
|
||||
"Failed to add Landscape Canvas component to entity"
|
||||
)
|
||||
lc_component_removed = (
|
||||
"Landscape Canvas component successfully removed from entity",
|
||||
"Failed to remove Landscape Canvas component from entity"
|
||||
)
|
||||
|
||||
|
||||
def Component_AddedRemoved():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas component can be added to/removed from an entity.
|
||||
|
||||
Expected Behavior:
|
||||
Closing a tabbed graph only closes the appropriate graph.
|
||||
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Create a new entity
|
||||
3) Add a Landscape Canvas component to the entity
|
||||
4) Remove the Landscape Canvas component from the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Create an Entity at the root of the level
|
||||
newEntityId = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Find the component TypeId for our Landscape Canvas component
|
||||
landscape_canvas_type_id = hydra.get_component_type_id("Landscape Canvas")
|
||||
|
||||
# Add the Landscape Canvas Component to our Entity
|
||||
componentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', newEntityId, [landscape_canvas_type_id])
|
||||
components = componentOutcome.GetValue()
|
||||
landscapeCanvasComponent = components[0]
|
||||
|
||||
# Validate the Landscape Canvas Component exists
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId, landscape_canvas_type_id)
|
||||
Report.result(Tests.lc_component_added, hasComponent)
|
||||
|
||||
# Remove the Landscape Canvas Component
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [landscapeCanvasComponent])
|
||||
|
||||
# Validate the Landscape Canvas Component is no longer on our Entity
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId, landscape_canvas_type_id)
|
||||
Report.result(Tests.lc_component_removed, not hasComponent)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(Component_AddedRemoved)
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
new_root_entity_id = None
|
||||
|
||||
|
||||
class TestCreateNewGraph(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="CreateNewGraph", args=["level"])
|
||||
|
||||
def on_entity_created(self, parameters):
|
||||
global new_root_entity_id
|
||||
new_root_entity_id = parameters[0]
|
||||
|
||||
print("New root entity created")
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that new graphs can be created in Landscape Canvas.
|
||||
|
||||
Expected Behavior:
|
||||
New graphs can be created, and proper entity is created to hold graph data with a Landscape Canvas component.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Ensures the root entity created contains a Landscape Canvas component
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane("Landscape Canvas")
|
||||
self.test_success = self.test_success and general.is_pane_visible("Landscape Canvas")
|
||||
if general.is_pane_visible("Landscape Canvas"):
|
||||
self.log("Landscape Canvas pane is open")
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# with the new graph has our Landscape Canvas component automatically added
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback("OnEditorEntityCreated", self.on_entity_created)
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, "CreateNewGraph", editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, "ContainsGraph", editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
|
||||
# Check if the entity created when we create a new graph has the
|
||||
# Landscape Canvas component already added to it
|
||||
landscape_canvas_type_id = hydra.get_component_type_id("Landscape Canvas")
|
||||
success = editor.EditorComponentAPIBus(bus.Broadcast, "HasComponentOfType", new_root_entity_id,
|
||||
landscape_canvas_type_id)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Root entity has Landscape Canvas component")
|
||||
|
||||
# Close Landscape Canvas tool and verify
|
||||
general.close_pane("Landscape Canvas")
|
||||
self.test_success = self.test_success and not general.is_pane_visible("Landscape Canvas")
|
||||
if not general.is_pane_visible("Landscape Canvas"):
|
||||
self.log("Landscape Canvas pane is closed")
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestCreateNewGraph()
|
||||
test.run()
|
||||
+104
-103
@@ -5,131 +5,132 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestDisabledNodeDuplication(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="DisabledNodeDuplication", args=["level"])
|
||||
def Edit_DisabledNodeDuplication():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies Editor stability after duplicating disabled Landscape Canvas nodes.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies Editor stability after duplicating disabled Landscape Canvas nodes.
|
||||
Expected Behavior:
|
||||
Editor remains stable and free of crashes.
|
||||
|
||||
Expected Behavior:
|
||||
Editor remains stable and free of crashes.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Create several new nodes, disable the nodes via disabling/deleting components, and duplicate the nodes
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Create several new nodes, disable the nodes via disabling/deleting components, and duplicate the nodes
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Listen for entity creation notifications so when we add a new node
|
||||
# we can access the corresponding Entity that was created so that we
|
||||
# can disable/remove components on that Entity
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Mapping of our Landscape Canvas nodes with corresponding dependent components
|
||||
# that we can disable/remove to reproduce the crash
|
||||
nodes = {
|
||||
'SpawnerAreaNode': 'Vegetation Asset List',
|
||||
'MeshBlockerAreaNode': 'Mesh',
|
||||
'BlockerAreaNode': 'Vegetation Reference Shape',
|
||||
'FastNoiseGradientNode': 'Gradient Transform Modifier',
|
||||
'ImageGradientNode': 'Gradient Transform Modifier',
|
||||
'PerlinNoiseGradientNode': 'Gradient Transform Modifier',
|
||||
'RandomNoiseGradientNode': 'Gradient Transform Modifier'
|
||||
}
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = list(set(nodes.values())) # Convert to set then back to list to remove any duplicates
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Iterate through creating our nodes and then disabling/deleting required components
|
||||
# and then duplicating the node to reproduce the crash
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in nodes:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
# Listen for entity creation notifications so when we add a new node
|
||||
# we can access the corresponding Entity that was created so that we
|
||||
# can disable/remove components on that Entity
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
dependentComponentName = nodes[nodeName]
|
||||
componentTypeId = componentTypeIds[dependentComponentName]
|
||||
componentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', newEntityId, componentTypeId)
|
||||
component = componentOutcome.GetValue()
|
||||
# Mapping of our Landscape Canvas nodes with corresponding dependent components
|
||||
# that we can disable/remove to reproduce the crash
|
||||
nodes = {
|
||||
'SpawnerAreaNode': 'Vegetation Asset List',
|
||||
'MeshBlockerAreaNode': 'Mesh',
|
||||
'BlockerAreaNode': 'Vegetation Reference Shape',
|
||||
'FastNoiseGradientNode': 'Gradient Transform Modifier',
|
||||
'ImageGradientNode': 'Gradient Transform Modifier',
|
||||
'PerlinNoiseGradientNode': 'Gradient Transform Modifier',
|
||||
'RandomNoiseGradientNode': 'Gradient Transform Modifier'
|
||||
}
|
||||
|
||||
# First make sure we can duplicate a node with a dependent component that is disabled
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'DisableComponents', [component])
|
||||
general.idle_wait(1.0)
|
||||
graph.SceneRequestBus(bus.Event, 'DuplicateSelection', newGraphId) # This duplication would cause a crash without the fix
|
||||
self.log("{node} duplicated with disabled component".format(node=nodeName))
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = list(set(nodes.values())) # Convert to set then back to list to remove any duplicates
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
|
||||
# Then, make sure we can duplicate the node with a dependent component that is deleted
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [component])
|
||||
general.idle_wait(1.0)
|
||||
graph.SceneRequestBus(bus.Event, 'DuplicateSelection', newGraphId) # This duplication would cause a crash without the fix
|
||||
self.log("{node} duplicated with deleted component".format(node=nodeName))
|
||||
# Iterate through creating our nodes and then disabling/deleting required components
|
||||
# and then duplicating the node to reproduce the crash
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in nodes:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
dependentComponentName = nodes[nodeName]
|
||||
componentTypeId = componentTypeIds[dependentComponentName]
|
||||
componentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', newEntityId, componentTypeId)
|
||||
component = componentOutcome.GetValue()
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
# First make sure we can duplicate a node with a dependent component that is disabled
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'DisableComponents', [component])
|
||||
helper.wait_for_condition(lambda: not editor.EditorComponentAPIBus(bus.Broadcast, 'IsComponentEnabled',
|
||||
[component]), 1.0)
|
||||
graph.SceneRequestBus(bus.Event, 'DuplicateSelection', newGraphId) # This duplication would cause a crash without the fix
|
||||
Report.info("{node} duplicated with disabled component".format(node=nodeName))
|
||||
|
||||
# Then, make sure we can duplicate the node with a dependent component that is deleted
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [component])
|
||||
helper.wait_for_condition(lambda: not editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType',
|
||||
componentTypeIds[dependentComponentName]), 1.0)
|
||||
graph.SceneRequestBus(bus.Event, 'DuplicateSelection', newGraphId) # This duplication would cause a crash without the fix
|
||||
Report.info("{node} duplicated with deleted component".format(node=nodeName))
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestDisabledNodeDuplication()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(Edit_DisabledNodeDuplication)
|
||||
|
||||
+125
-124
@@ -5,133 +5,134 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.math as math
|
||||
import azlmbr.slice as slice
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
slice_spawned = (
|
||||
"Slice instantiated successfully",
|
||||
"Failed to instantiate slice"
|
||||
)
|
||||
lc_entity_found = (
|
||||
"Landscape Canvas entity found",
|
||||
"Failed to find Landscape Canvas entity"
|
||||
)
|
||||
spawner_entity_found = (
|
||||
"Spawner entity found",
|
||||
"Failed to find Spawner entity"
|
||||
)
|
||||
graph_opened = (
|
||||
"Graph successfully opened",
|
||||
"Graph failed to open"
|
||||
)
|
||||
spawner_node_found = (
|
||||
"Vegetation Layer Spawner node found on graph",
|
||||
"Failed to find Vegetation Layer Spawner node on graph"
|
||||
)
|
||||
spawner_node_removed = (
|
||||
"Vegetation Layer Spawner node was successfully removed",
|
||||
"Failed to remove Vegetation Layer Spawner node"
|
||||
)
|
||||
def Edit_UndoNodeDelete_SliceEntity():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies Editor stability after undoing the deletion of nodes on a slice entity.
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
Expected Behavior:
|
||||
Editor remains stable and free of crashes.
|
||||
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Instantiate a slice with a Landscape Canvas setup
|
||||
3) Find a specific node on the graph, and delete it
|
||||
4) Restore the node with Undo
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.math as math
|
||||
import azlmbr.slice as slice
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Instantiate slice
|
||||
transform = math.Transform_CreateIdentity()
|
||||
position = math.Vector3(64.0, 64.0, 32.0)
|
||||
transform.invoke('SetPosition', position)
|
||||
test_slice_path = os.path.join("Slices", "LC_BushFlowerBlender.slice")
|
||||
test_slice_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", test_slice_path, math.Uuid(),
|
||||
False)
|
||||
test_slice = slice.SliceRequestBus(bus.Broadcast, 'InstantiateSliceFromAssetId', test_slice_id, transform)
|
||||
Report.result(Tests.slice_spawned, test_slice.IsValid())
|
||||
|
||||
# Find root entity in the loaded level
|
||||
search_filter = entity.SearchFilter()
|
||||
search_filter.names = ["LandscapeCanvas"]
|
||||
|
||||
# Allow a few seconds for matching entity to be found
|
||||
helper.wait_for_condition(lambda: len(entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)) > 0, 5.0)
|
||||
lc_matching_entities = entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)
|
||||
slice_root_id = lc_matching_entities[0] # Entity with Landscape Canvas component
|
||||
Report.result(Tests.lc_entity_found, slice_root_id.IsValid())
|
||||
|
||||
# Find the BushSpawner entity
|
||||
search_filter.names = ["BushSpawner"]
|
||||
spawner_matching_entities = entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)
|
||||
spawner_id = spawner_matching_entities[0] # Entity with Vegetation Layer Spawner component
|
||||
Report.result(Tests.spawner_entity_found, spawner_id.IsValid())
|
||||
|
||||
# Open Landscape Canvas and the existing graph
|
||||
general.open_pane('Landscape Canvas')
|
||||
open_graph = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'OnGraphEntity', slice_root_id)
|
||||
Report.result(Tests.graph_opened, open_graph.IsValid())
|
||||
|
||||
# Get needed component type ids
|
||||
layer_spawner_type_id = hydra.get_component_type_id("Vegetation Layer Spawner")
|
||||
|
||||
# Find the Vegetation Layer Spawner node on the BushSpawner entity
|
||||
layer_spawner_component = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', spawner_id,
|
||||
layer_spawner_type_id)
|
||||
layer_spawner_component_component_id = layer_spawner_component.GetValue()
|
||||
layer_spawner_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'GetAllNodesMatchingEntityComponent',
|
||||
layer_spawner_component_component_id)
|
||||
Report.result(Tests.spawner_node_found, layer_spawner_node is not None)
|
||||
|
||||
# Remove the Layer Spawner node
|
||||
graph.GraphControllerRequestBus(bus.Event, "RemoveNode", open_graph, layer_spawner_node[0])
|
||||
|
||||
# Verify node was removed
|
||||
layer_spawner_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'GetAllNodesMatchingEntityComponent',
|
||||
layer_spawner_component_component_id)
|
||||
Report.result(Tests.spawner_node_removed, not layer_spawner_node)
|
||||
|
||||
# Undo the Node deletion. This is required to be executed twice to hit the node removal.
|
||||
general.undo()
|
||||
general.undo()
|
||||
|
||||
# self.log a line to the Console to verify the Editor is still active
|
||||
Report.info("Editor is still responsive")
|
||||
|
||||
|
||||
class TestUndoNodeDeleteSlice(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="UndoNodeDeleteSlice", args=["level"])
|
||||
if __name__ == "__main__":
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies Editor stability after undoing the deletion of nodes on a slice entity.
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(Edit_UndoNodeDelete_SliceEntity)
|
||||
|
||||
Expected Behavior:
|
||||
Editor remains stable and free of crashes.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Instantiate a slice with a Landscape Canvas setup
|
||||
3) Find a specific node on the graph, and delete it
|
||||
4) Restore the node with Undo
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Create a new empty level and instantiate LC_BushFlowerBlender.slice
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
transform = math.Transform_CreateIdentity()
|
||||
position = math.Vector3(64.0, 64.0, 32.0)
|
||||
transform.invoke('SetPosition', position)
|
||||
test_slice_path = os.path.join("Slices", "LC_BushFlowerBlender.slice")
|
||||
test_slice_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", test_slice_path, math.Uuid(),
|
||||
False)
|
||||
test_slice = slice.SliceRequestBus(bus.Broadcast, 'InstantiateSliceFromAssetId', test_slice_id, transform)
|
||||
self.test_success = self.test_success and test_slice.IsValid()
|
||||
if test_slice.IsValid():
|
||||
self.log("Slice spawned!")
|
||||
|
||||
# Find root entity in the loaded level
|
||||
search_filter = entity.SearchFilter()
|
||||
search_filter.names = ["LandscapeCanvas"]
|
||||
|
||||
# Allow a few seconds for matching entity to be found
|
||||
self.wait_for_condition(lambda: len(entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)) > 0,
|
||||
5.0)
|
||||
lc_matching_entities = entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)
|
||||
slice_root_id = lc_matching_entities[0] # Entity with Landscape Canvas component
|
||||
self.test_success = self.test_success and slice_root_id.IsValid()
|
||||
if slice_root_id.IsValid():
|
||||
self.log("LandscapeCanvas entity found")
|
||||
|
||||
# Find the BushSpawner entity
|
||||
search_filter.names = ["BushSpawner"]
|
||||
spawner_matching_entities = entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)
|
||||
spawner_id = spawner_matching_entities[0] # Entity with Vegetation Layer Spawner component
|
||||
self.test_success = self.test_success and spawner_id.IsValid()
|
||||
if spawner_id.IsValid():
|
||||
self.log("BushSpawner entity found")
|
||||
|
||||
# Open Landscape Canvas and the existing graph
|
||||
general.open_pane('Landscape Canvas')
|
||||
open_graph = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'OnGraphEntity', slice_root_id)
|
||||
self.test_success = self.test_success and open_graph.IsValid()
|
||||
if open_graph.IsValid():
|
||||
self.log("Graph opened")
|
||||
|
||||
# Get needed component type ids
|
||||
layer_spawner_type_id = hydra.get_component_type_id("Vegetation Layer Spawner")
|
||||
|
||||
# Find the Vegetation Layer Spawner node on the BushSpawner entity
|
||||
layer_spawner_component = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', spawner_id,
|
||||
layer_spawner_type_id)
|
||||
layer_spawner_component_component_id = layer_spawner_component.GetValue()
|
||||
layer_spawner_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'GetAllNodesMatchingEntityComponent',
|
||||
layer_spawner_component_component_id)
|
||||
|
||||
self.test_success = self.test_success and layer_spawner_node
|
||||
if layer_spawner_node:
|
||||
self.log("Vegetation Layer Spawner node found on graph")
|
||||
else:
|
||||
self.log("Vegetation Layer Spawner node not found")
|
||||
|
||||
# Remove the Layer Spawner node
|
||||
graph.GraphControllerRequestBus(bus.Event, "RemoveNode", open_graph, layer_spawner_node[0])
|
||||
|
||||
# Verify node was removed
|
||||
layer_spawner_node = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'GetAllNodesMatchingEntityComponent',
|
||||
layer_spawner_component_component_id)
|
||||
|
||||
self.test_success = self.test_success and not layer_spawner_node
|
||||
if not layer_spawner_node:
|
||||
self.log("Vegetation Layer Spawner node was removed")
|
||||
else:
|
||||
self.log("Vegetation Layer Spawner node was not removed")
|
||||
|
||||
# Undo the Node deletion. This is required to be executed twice to hit the node removal.
|
||||
general.undo()
|
||||
general.undo()
|
||||
|
||||
# self.log a line to the Console to verify the Editor is still active
|
||||
self.log("Editor is still responsive")
|
||||
|
||||
|
||||
test = TestUndoNodeDeleteSlice()
|
||||
test.run()
|
||||
|
||||
+167
-152
@@ -5,190 +5,205 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
preview_entity_set = (
|
||||
"Perlin Noise Gradient component Preview Entity property set to Box Shape EntityId",
|
||||
"Unexpected entity set in Perlin Noise Gradient Preview Entity property"
|
||||
)
|
||||
mixer_inbound_gradient_set_a = (
|
||||
"Gradient Mixer component Inbound Gradient extendable property set to Perlin Noise Gradient EntityId",
|
||||
"Unexpected entity set in Gradient Mixer's Inbound Gradient property"
|
||||
)
|
||||
mixer_inbound_gradient_set_b = (
|
||||
"Gradient Mixer component Inbound Gradient extendable property set to FastNoise Gradient EntityId",
|
||||
"Unexpected entity set in Gradient Mixer's Inbound Gradient property"
|
||||
)
|
||||
mixer_operation_a = (
|
||||
"Layer 1 Operation is set to Initialize",
|
||||
"Layer 1 Operation is not set to Initialize as expected"
|
||||
)
|
||||
mixer_operation_b = (
|
||||
"Layer 2 Operation is set to Average",
|
||||
"Layer 2 Operation is not set to Average as expected"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestGradientMixerNodeConstruction(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientMixerNodeConstruction", args=["level"])
|
||||
def GradientMixer_NodeConstruction():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies a Gradient Mixer vegetation setup can be constructed through Landscape Canvas.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies a Gradient Mixer vegetation setup can be constructed through Landscape Canvas.
|
||||
Expected Behavior:
|
||||
Entities contain all required components and component references after creating nodes and setting connections
|
||||
on a Landscape Canvas graph.
|
||||
|
||||
Expected Behavior:
|
||||
Entities contain all required components and component references after creating nodes and setting connections
|
||||
on a Landscape Canvas graph.
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Add all necessary nodes to the graph and set connections to form a Gradient Mixer setup
|
||||
4) Verify all components and component references were properly set during graph construction
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Add all necessary nodes to the graph and set connections to form a Gradient Mixer setup
|
||||
4) Verify all components and component references were properly set during graph construction
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Listen for entity creation notifications so we can verify the component EntityId
|
||||
# references are set correctly when connecting slots on the nodes
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
positionX = 10.0
|
||||
positionY = 10.0
|
||||
offsetX = 340.0
|
||||
offsetY = 100.0
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Add a Box Shape node to the graph
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
boxShapeNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph,
|
||||
'BoxShapeNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, boxShapeNode, math.Vector2(positionX, positionY))
|
||||
boxShapeEntityId = newEntityId
|
||||
# Listen for entity creation notifications so we can verify the component EntityId
|
||||
# references are set correctly when connecting slots on the nodes
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
positionX = 10.0
|
||||
positionY = 10.0
|
||||
offsetX = 340.0
|
||||
offsetY = 100.0
|
||||
|
||||
# Add a Random Noise Gradient node to the graph
|
||||
perlinNoiseNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph,
|
||||
'PerlinNoiseGradientNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, perlinNoiseNode, math.Vector2(positionX, positionY))
|
||||
perlinNoiseEntityId = newEntityId
|
||||
# Add a Box Shape node to the graph
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
boxShapeNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph,
|
||||
'BoxShapeNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, boxShapeNode, math.Vector2(positionX, positionY))
|
||||
boxShapeEntityId = newEntityId
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Add a FastNoise Gradient node to the graph
|
||||
fastNoiseNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph,
|
||||
'FastNoiseGradientNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, fastNoiseNode, math.Vector2(positionX, positionY))
|
||||
fastNoiseEntityId = newEntityId
|
||||
# Add a Random Noise Gradient node to the graph
|
||||
perlinNoiseNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph,
|
||||
'PerlinNoiseGradientNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, perlinNoiseNode, math.Vector2(positionX, positionY))
|
||||
perlinNoiseEntityId = newEntityId
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Add a Gradient Mixer node to the graph
|
||||
gradientMixerNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph,
|
||||
'GradientMixerNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, gradientMixerNode, math.Vector2(positionX, positionY))
|
||||
gradientMixerEntityId = newEntityId
|
||||
# Add a FastNoise Gradient node to the graph
|
||||
fastNoiseNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph,
|
||||
'FastNoiseGradientNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, fastNoiseNode, math.Vector2(positionX, positionY))
|
||||
fastNoiseEntityId = newEntityId
|
||||
|
||||
boundsSlotId = graph.GraphModelSlotId('Bounds')
|
||||
previewBoundsSlotId = graph.GraphModelSlotId('PreviewBounds')
|
||||
inboundGradientSlotId = graph.GraphModelSlotId('InboundGradient')
|
||||
outboundGradientSlotId = graph.GraphModelSlotId('OutboundGradient')
|
||||
inboundGradientSlotId2 = graph.GraphControllerRequestBus(bus.Event, 'ExtendSlot', newGraphId, gradientMixerNode,
|
||||
'InboundGradient')
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Connect slots on our nodes to construct a Gradient Mixer hierarchy
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, boxShapeNode, boundsSlotId,
|
||||
perlinNoiseNode, previewBoundsSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, boxShapeNode, boundsSlotId,
|
||||
fastNoiseNode, previewBoundsSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, boxShapeNode, boundsSlotId,
|
||||
gradientMixerNode, previewBoundsSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, perlinNoiseNode, outboundGradientSlotId,
|
||||
gradientMixerNode, inboundGradientSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, fastNoiseNode, outboundGradientSlotId,
|
||||
gradientMixerNode, inboundGradientSlotId2)
|
||||
# Add a Gradient Mixer node to the graph
|
||||
gradientMixerNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph,
|
||||
'GradientMixerNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, gradientMixerNode, math.Vector2(positionX, positionY))
|
||||
gradientMixerEntityId = newEntityId
|
||||
|
||||
# Delay to allow all the underlying component properties to be updated after the slot connections are made
|
||||
general.idle_wait(1.0)
|
||||
boundsSlotId = graph.GraphModelSlotId('Bounds')
|
||||
previewBoundsSlotId = graph.GraphModelSlotId('PreviewBounds')
|
||||
inboundGradientSlotId = graph.GraphModelSlotId('InboundGradient')
|
||||
outboundGradientSlotId = graph.GraphModelSlotId('OutboundGradient')
|
||||
inboundGradientSlotId2 = graph.GraphControllerRequestBus(bus.Event, 'ExtendSlot', newGraphId, gradientMixerNode,
|
||||
'InboundGradient')
|
||||
|
||||
# Get component info
|
||||
gradientMixerTypeId = hydra.get_component_type_id("Gradient Mixer")
|
||||
perlinNoiseTypeId = hydra.get_component_type_id("Perlin Noise Gradient")
|
||||
gradientMixerOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', gradientMixerEntityId,
|
||||
gradientMixerTypeId)
|
||||
gradientMixerComponent = gradientMixerOutcome.GetValue()
|
||||
perlinNoiseOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', perlinNoiseEntityId,
|
||||
perlinNoiseTypeId)
|
||||
perlinNoiseComponent = perlinNoiseOutcome.GetValue()
|
||||
# Connect slots on our nodes to construct a Gradient Mixer hierarchy
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, boxShapeNode, boundsSlotId,
|
||||
perlinNoiseNode, previewBoundsSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, boxShapeNode, boundsSlotId,
|
||||
fastNoiseNode, previewBoundsSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, boxShapeNode, boundsSlotId,
|
||||
gradientMixerNode, previewBoundsSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, perlinNoiseNode, outboundGradientSlotId,
|
||||
gradientMixerNode, inboundGradientSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, fastNoiseNode, outboundGradientSlotId,
|
||||
gradientMixerNode, inboundGradientSlotId2)
|
||||
|
||||
# Verify the Preview EntityId property on our Perlin Noise Gradient component has been set to our Box Shape's EntityId
|
||||
previewEntityId = hydra.get_component_property_value(perlinNoiseComponent, 'Preview Settings|Pin Preview to Shape')
|
||||
self.test_success = self.test_success and previewEntityId and boxShapeEntityId.invoke("Equal", previewEntityId)
|
||||
if previewEntityId and boxShapeEntityId.invoke("Equal", previewEntityId):
|
||||
self.log("Perlin Noise Gradient component Preview Entity property set to Box Shape EntityId")
|
||||
# Delay to allow all the underlying component properties to be updated after the slot connections are made
|
||||
general.idle_wait(1.0)
|
||||
|
||||
# Verify the 1st Inbound Gradient EntityId property on our Gradient Mixer component has been set to our Perlin Noise
|
||||
# Gradient's EntityId
|
||||
inboundGradientEntityId = hydra.get_component_property_value(gradientMixerComponent,
|
||||
'Configuration|Layers|[0]|Gradient|Gradient Entity Id')
|
||||
self.test_success = self.test_success and inboundGradientEntityId and perlinNoiseEntityId.invoke("Equal", inboundGradientEntityId)
|
||||
if inboundGradientEntityId and perlinNoiseEntityId.invoke("Equal", inboundGradientEntityId):
|
||||
self.log("Gradient Mixer component Inbound Gradient extendable property set to Perlin Noise Gradient EntityId")
|
||||
# Get component info
|
||||
gradientMixerTypeId = hydra.get_component_type_id("Gradient Mixer")
|
||||
perlinNoiseTypeId = hydra.get_component_type_id("Perlin Noise Gradient")
|
||||
gradientMixerOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', gradientMixerEntityId,
|
||||
gradientMixerTypeId)
|
||||
gradientMixerComponent = gradientMixerOutcome.GetValue()
|
||||
perlinNoiseOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', perlinNoiseEntityId,
|
||||
perlinNoiseTypeId)
|
||||
perlinNoiseComponent = perlinNoiseOutcome.GetValue()
|
||||
|
||||
# Verify the 2nd Inbound Gradient EntityId property on our Gradient Mixer component has been set to our FastNoise
|
||||
# Gradient Modifier's EntityId
|
||||
inboundGradientEntityId2 = hydra.get_component_property_value(gradientMixerComponent,
|
||||
'Configuration|Layers|[1]|Gradient|Gradient Entity Id')
|
||||
self.test_success = self.test_success and inboundGradientEntityId2 and fastNoiseEntityId.invoke("Equal", inboundGradientEntityId2)
|
||||
if inboundGradientEntityId2 and fastNoiseEntityId.invoke("Equal", inboundGradientEntityId2):
|
||||
self.log("Gradient Mixer component Inbound Gradient extendable property set to FastNoise Gradient EntityId")
|
||||
# Verify the Preview EntityId property on our Perlin Noise Gradient component has been set to our Box Shape's EntityId
|
||||
previewEntityId = hydra.get_component_property_value(perlinNoiseComponent, 'Preview Settings|Pin Preview to Shape')
|
||||
Report.result(Tests.preview_entity_set, previewEntityId and boxShapeEntityId.invoke("Equal", previewEntityId))
|
||||
|
||||
# Verify that Gradient Mixer Layer Operations are properly set
|
||||
hydra.get_component_property_value(gradientMixerComponent, 'Configuration|Layers|[0]|Operation')
|
||||
hydra.get_component_property_value(gradientMixerComponent, 'Configuration|Layers|[1]|Operation')
|
||||
# Verify the 1st Inbound Gradient EntityId property on our Gradient Mixer component has been set to our Perlin Noise
|
||||
# Gradient's EntityId
|
||||
inboundGradientEntityId = hydra.get_component_property_value(gradientMixerComponent,
|
||||
'Configuration|Layers|[0]|Gradient|Gradient Entity Id')
|
||||
Report.result(Tests.mixer_inbound_gradient_set_a, inboundGradientEntityId and perlinNoiseEntityId.invoke("Equal", inboundGradientEntityId))
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
# Verify the 2nd Inbound Gradient EntityId property on our Gradient Mixer component has been set to our FastNoise
|
||||
# Gradient Modifier's EntityId
|
||||
inboundGradientEntityId2 = hydra.get_component_property_value(gradientMixerComponent,
|
||||
'Configuration|Layers|[1]|Gradient|Gradient Entity Id')
|
||||
Report.result(Tests.mixer_inbound_gradient_set_b, inboundGradientEntityId2 and fastNoiseEntityId.invoke("Equal", inboundGradientEntityId2))
|
||||
|
||||
# Verify that Gradient Mixer Layer Operations are properly set
|
||||
mixer_operation_a = hydra.get_component_property_value(gradientMixerComponent, 'Configuration|Layers|[0]|Operation')
|
||||
mixer_operation_b = hydra.get_component_property_value(gradientMixerComponent, 'Configuration|Layers|[1]|Operation')
|
||||
Report.result(Tests.mixer_operation_a, mixer_operation_a == 0)
|
||||
Report.result(Tests.mixer_operation_b, mixer_operation_b == 6)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestGradientMixerNodeConstruction()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientMixer_NodeConstruction)
|
||||
|
||||
+106
-104
@@ -5,132 +5,134 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
component_added = (
|
||||
"New entity created with the expected component",
|
||||
"Expected component was not found on entity"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestGradientModifierNodeEntityCreate(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientModifierNodeEntityCreate", args=["level"])
|
||||
def GradientModifierNodes_EntityCreatedOnNodeAdd():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities.
|
||||
Expected Behavior:
|
||||
New entities are created when dragging Gradient Modifier nodes to graph area.
|
||||
|
||||
Expected Behavior:
|
||||
New entities are created when dragging Gradient Modifier nodes to graph area.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the Gradient Modifier nodes to the graph area, and ensure a new entity is created
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the Gradient Modifier nodes to the graph area, and ensure a new entity is created
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding gradient modifier nodes has the appropriate Gradient Modifier Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Gradient modifier mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
gradientModifiers = {
|
||||
'DitherGradientModifierNode': 'Dither Gradient Modifier',
|
||||
'GradientMixerNode': 'Gradient Mixer',
|
||||
'InvertGradientModifierNode': 'Invert Gradient Modifier',
|
||||
'LevelsGradientModifierNode': 'Levels Gradient Modifier',
|
||||
'PosterizeGradientModifierNode': 'Posterize Gradient Modifier',
|
||||
'SmoothStepGradientModifierNode': 'Smooth-Step Gradient Modifier',
|
||||
'ThresholdGradientModifierNode': 'Threshold Gradient Modifier'
|
||||
}
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in gradientModifiers:
|
||||
componentNames.append(gradientModifiers[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding gradient modifier nodes has the appropriate Gradient Modifier Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
# Create nodes for all the gradients modifiers we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in gradientModifiers:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
# Gradient modifier mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
gradientModifiers = {
|
||||
'DitherGradientModifierNode': 'Dither Gradient Modifier',
|
||||
'GradientMixerNode': 'Gradient Mixer',
|
||||
'InvertGradientModifierNode': 'Invert Gradient Modifier',
|
||||
'LevelsGradientModifierNode': 'Levels Gradient Modifier',
|
||||
'PosterizeGradientModifierNode': 'Posterize Gradient Modifier',
|
||||
'SmoothStepGradientModifierNode': 'Smooth-Step Gradient Modifier',
|
||||
'ThresholdGradientModifierNode': 'Threshold Gradient Modifier'
|
||||
}
|
||||
|
||||
gradientComponent = gradientModifiers[nodeName]
|
||||
componentTypeId = componentTypeIds[gradientComponent]
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId,
|
||||
componentTypeId)
|
||||
self.test_success = self.test_success and hasComponent
|
||||
if hasComponent:
|
||||
self.log("{node} created new Entity with {component} Component".format(node=nodeName,
|
||||
component=gradientComponent))
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in gradientModifiers:
|
||||
componentNames.append(gradientModifiers[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
# Create nodes for all the gradients modifiers we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in gradientModifiers:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
gradientComponent = gradientModifiers[nodeName]
|
||||
componentTypeId = componentTypeIds[gradientComponent]
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId,
|
||||
componentTypeId)
|
||||
Report.info(f"Node: {nodeName} | Component: {gradientComponent}")
|
||||
Report.result(Tests.component_added, hasComponent)
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestGradientModifierNodeEntityCreate()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientModifierNodes_EntityCreatedOnNodeAdd)
|
||||
|
||||
+100
-97
@@ -5,126 +5,129 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
entity_deleted = (
|
||||
"Entity was deleted when node was removed",
|
||||
"Entity was not deleted as expected when node was removed"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
createdEntityId = None
|
||||
deletedEntityId = None
|
||||
|
||||
|
||||
class TestGradientModifierNodeEntityDelete(EditorTestHelper):
|
||||
def GradientModifierNodes_EntityRemovedOnNodeDelete():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas node deletion properly cleans up entities in the Editor.
|
||||
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientModifierNodeEntityDelete", args=["level"])
|
||||
Expected Behavior:
|
||||
Entities are removed when Gradient Modifier nodes are deleted from a graph.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas node deletion properly cleans up entities in the Editor.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the Gradient Modifier nodes to the graph area, and ensure a new entity is created
|
||||
4) Delete the nodes, and ensure the newly created entities are removed
|
||||
|
||||
Expected Behavior:
|
||||
Entities are removed when Gradient Modifier nodes are deleted from a graph.
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the Gradient Modifier nodes to the graph area, and ensure a new entity is created
|
||||
4) Delete the nodes, and ensure the newly created entities are removed
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
:return: None
|
||||
"""
|
||||
def onEntityCreated(parameters):
|
||||
global createdEntityId
|
||||
createdEntityId = parameters[0]
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def onEntityDeleted(parameters):
|
||||
global deletedEntityId
|
||||
deletedEntityId = parameters[0]
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
def onEntityCreated(parameters):
|
||||
global createdEntityId
|
||||
createdEntityId = parameters[0]
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
def onEntityDeleted(parameters):
|
||||
global deletedEntityId
|
||||
deletedEntityId = parameters[0]
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding gradient nodes has the appropriate Gradient Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
handler.add_callback('OnEditorEntityDeleted', onEntityDeleted)
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Vegetation Area mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
gradientModifiers = [
|
||||
'DitherGradientModifierNode',
|
||||
'GradientMixerNode',
|
||||
'InvertGradientModifierNode',
|
||||
'LevelsGradientModifierNode',
|
||||
'PosterizeGradientModifierNode',
|
||||
'SmoothStepGradientModifierNode',
|
||||
'ThresholdGradientModifierNode'
|
||||
]
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Create nodes for all the gradients we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in gradientModifiers:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding gradient nodes has the appropriate Gradient Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
handler.add_callback('OnEditorEntityDeleted', onEntityDeleted)
|
||||
|
||||
removed = graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', newGraphId, node)
|
||||
# Vegetation Area mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
gradientModifiers = [
|
||||
'DitherGradientModifierNode',
|
||||
'GradientMixerNode',
|
||||
'InvertGradientModifierNode',
|
||||
'LevelsGradientModifierNode',
|
||||
'PosterizeGradientModifierNode',
|
||||
'SmoothStepGradientModifierNode',
|
||||
'ThresholdGradientModifierNode'
|
||||
]
|
||||
|
||||
# Verify that the created Entity for this node matches the Entity that gets
|
||||
# deleted when the node is removed
|
||||
self.test_success = self.test_success and removed and createdEntityId.invoke("Equal", deletedEntityId)
|
||||
if removed and createdEntityId.invoke("Equal", deletedEntityId):
|
||||
self.log("{node} corresponding Entity was deleted when node is removed".format(node=nodeName))
|
||||
# Create nodes for all the gradients we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in gradientModifiers:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
removed = graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', newGraphId, node)
|
||||
|
||||
# Verify that the created Entity for this node matches the Entity that gets
|
||||
# deleted when the node is removed
|
||||
Report.info(f"Node: {nodeName}")
|
||||
Report.result(Tests.entity_deleted, removed and createdEntityId.invoke("Equal", deletedEntityId))
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestGradientModifierNodeEntityDelete()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientModifierNodes_EntityRemovedOnNodeDelete)
|
||||
|
||||
+114
-112
@@ -5,141 +5,143 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
dependencies_added = (
|
||||
"Node created new Entity with all required components",
|
||||
"Failed to create node with all required components"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestGradientNodeComponentDependency(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientNodeComponentDependency", args=["level"])
|
||||
def GradientNodes_DependentComponentsAdded():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities with
|
||||
proper dependent components.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities with
|
||||
proper dependent components.
|
||||
Expected Behavior:
|
||||
All expected component dependencies are met when adding a Gradient Modifier node to a graph.
|
||||
|
||||
Expected Behavior:
|
||||
All expected component dependencies are met when adding a Gradient Modifier node to a graph.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the Gradient Modifier nodes to the graph area, and ensure the proper dependent components are
|
||||
added
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the Gradient Modifier nodes to the graph area, and ensure the proper dependent components are
|
||||
added
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding these gradients nodes has the main target Gradient Component
|
||||
# as well as automatically adding all required dependency components
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Gradient mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
gradients = {
|
||||
'FastNoiseGradientNode': 'FastNoise Gradient',
|
||||
'ImageGradientNode': 'Image Gradient',
|
||||
'PerlinNoiseGradientNode': 'Perlin Noise Gradient',
|
||||
'RandomNoiseGradientNode': 'Random Noise Gradient'
|
||||
}
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
commonComponents = [
|
||||
'Gradient Transform Modifier',
|
||||
'Vegetation Reference Shape'
|
||||
]
|
||||
componentNames = []
|
||||
for name in gradients:
|
||||
componentNames.append(gradients[name])
|
||||
componentNames.extend(commonComponents)
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding these gradients nodes has the main target Gradient Component
|
||||
# as well as automatically adding all required dependency components
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
# Create nodes for the gradients that have additional required dependencies and check if
|
||||
# the Entity created by adding the node has the appropriate Component and required
|
||||
# Gradient Transform Modifier and Vegetation Reference Shape components added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in gradients:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
# Gradient mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
gradients = {
|
||||
'FastNoiseGradientNode': 'FastNoise Gradient',
|
||||
'ImageGradientNode': 'Image Gradient',
|
||||
'PerlinNoiseGradientNode': 'Perlin Noise Gradient',
|
||||
'RandomNoiseGradientNode': 'Random Noise Gradient'
|
||||
}
|
||||
|
||||
gradientComponent = gradients[nodeName]
|
||||
components = [gradientComponent] + commonComponents
|
||||
success = False
|
||||
for component in components:
|
||||
componentTypeId = componentTypeIds[component]
|
||||
success = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId, componentTypeId)
|
||||
self.test_success = self.test_success and success
|
||||
if not success:
|
||||
break
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
commonComponents = [
|
||||
'Gradient Transform Modifier',
|
||||
'Vegetation Reference Shape'
|
||||
]
|
||||
componentNames = []
|
||||
for name in gradients:
|
||||
componentNames.append(gradients[name])
|
||||
componentNames.extend(commonComponents)
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
|
||||
if success:
|
||||
self.log("{node} created new Entity with all required components".format(node=nodeName))
|
||||
# Create nodes for the gradients that have additional required dependencies and check if
|
||||
# the Entity created by adding the node has the appropriate Component and required
|
||||
# Gradient Transform Modifier and Vegetation Reference Shape components added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in gradients:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
gradientComponent = gradients[nodeName]
|
||||
components = [gradientComponent] + commonComponents
|
||||
success = False
|
||||
for component in components:
|
||||
componentTypeId = componentTypeIds[component]
|
||||
success = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId, componentTypeId)
|
||||
if not success:
|
||||
break
|
||||
Report.info(nodeName)
|
||||
Report.result(Tests.dependencies_added, success)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestGradientNodeComponentDependency()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientNodes_DependentComponentsAdded)
|
||||
|
||||
+106
-102
@@ -5,130 +5,134 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os, sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
component_added = (
|
||||
"New entity created with the expected component",
|
||||
"Expected component was not found on entity"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestGradientNodeEntityCreate(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientNodeEntityCreate", args=["level"])
|
||||
def GradientNodes_EntityCreatedOnNodeAdd():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities.
|
||||
Expected Behavior:
|
||||
New entities are created when dragging Gradient nodes to graph area.
|
||||
|
||||
Expected Behavior:
|
||||
New entities are created when dragging Gradient nodes to graph area.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the Gradient nodes to the graph area, and ensure a new entity is created
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the Gradient nodes to the graph area, and ensure a new entity is created
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding gradient nodes has the appropriate Gradient Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Gradient mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
gradients = {
|
||||
'AltitudeGradientNode': 'Altitude Gradient',
|
||||
'ConstantGradientNode': 'Constant Gradient',
|
||||
'FastNoiseGradientNode': 'FastNoise Gradient',
|
||||
'ImageGradientNode': 'Image Gradient',
|
||||
'PerlinNoiseGradientNode': 'Perlin Noise Gradient',
|
||||
'RandomNoiseGradientNode': 'Random Noise Gradient',
|
||||
'ShapeAreaFalloffGradientNode': 'Shape Falloff Gradient',
|
||||
'SlopeGradientNode': 'Slope Gradient',
|
||||
'SurfaceMaskGradientNode': 'Surface Mask Gradient',
|
||||
}
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in gradients:
|
||||
componentNames.append(gradients[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding gradient nodes has the appropriate Gradient Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
# Create nodes for all the gradients we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in gradients:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
# Gradient mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
gradients = {
|
||||
'AltitudeGradientNode': 'Altitude Gradient',
|
||||
'ConstantGradientNode': 'Constant Gradient',
|
||||
'FastNoiseGradientNode': 'FastNoise Gradient',
|
||||
'ImageGradientNode': 'Image Gradient',
|
||||
'PerlinNoiseGradientNode': 'Perlin Noise Gradient',
|
||||
'RandomNoiseGradientNode': 'Random Noise Gradient',
|
||||
'ShapeAreaFalloffGradientNode': 'Shape Falloff Gradient',
|
||||
'SlopeGradientNode': 'Slope Gradient',
|
||||
'SurfaceMaskGradientNode': 'Surface Mask Gradient',
|
||||
}
|
||||
|
||||
gradientComponent = gradients[nodeName]
|
||||
componentTypeId = componentTypeIds[gradientComponent]
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId, componentTypeId)
|
||||
self.test_success = self.test_success and hasComponent
|
||||
if hasComponent:
|
||||
self.log("{node} created new Entity with {component} Component".format(node=nodeName, component=gradientComponent))
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in gradients:
|
||||
componentNames.append(gradients[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
# Create nodes for all the gradients we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in gradients:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
gradientComponent = gradients[nodeName]
|
||||
componentTypeId = componentTypeIds[gradientComponent]
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId, componentTypeId)
|
||||
Report.info(f"Node: {nodeName} | Component: {gradientComponent}")
|
||||
Report.result(Tests.component_added, hasComponent)
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestGradientNodeEntityCreate()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientNodes_EntityCreatedOnNodeAdd)
|
||||
|
||||
+101
-99
@@ -5,129 +5,131 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
entity_deleted = (
|
||||
"Entity was deleted when node was removed",
|
||||
"Entity was not deleted as expected when node was removed"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
createdEntityId = None
|
||||
deletedEntityId = None
|
||||
|
||||
|
||||
class TestGradientNodeEntityDelete(EditorTestHelper):
|
||||
def GradientNodes_EntityRemovedOnNodeDelete():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas node deletion properly cleans up entities in the Editor.
|
||||
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GradientNodeEntityDelete", args=["level"])
|
||||
Expected Behavior:
|
||||
Entities are removed when Gradient nodes are deleted from a graph.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas node deletion properly cleans up entities in the Editor.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the Gradient nodes to the graph area, and ensure a new entity is created
|
||||
4) Delete the nodes, and ensure the newly created entities are removed
|
||||
|
||||
Expected Behavior:
|
||||
Entities are removed when Gradient nodes are deleted from a graph.
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the Gradient nodes to the graph area, and ensure a new entity is created
|
||||
4) Delete the nodes, and ensure the newly created entities are removed
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
:return: None
|
||||
"""
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global createdEntityId
|
||||
createdEntityId = parameters[0]
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
def onEntityDeleted(parameters):
|
||||
global deletedEntityId
|
||||
deletedEntityId = parameters[0]
|
||||
def onEntityCreated(parameters):
|
||||
global createdEntityId
|
||||
createdEntityId = parameters[0]
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
def onEntityDeleted(parameters):
|
||||
global deletedEntityId
|
||||
deletedEntityId = parameters[0]
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding gradient nodes has the appropriate Gradient Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
handler.add_callback('OnEditorEntityDeleted', onEntityDeleted)
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Gradient mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
gradients = [
|
||||
'AltitudeGradientNode',
|
||||
'ConstantGradientNode',
|
||||
'FastNoiseGradientNode',
|
||||
'ImageGradientNode',
|
||||
'PerlinNoiseGradientNode',
|
||||
'RandomNoiseGradientNode',
|
||||
'ShapeAreaFalloffGradientNode',
|
||||
'SlopeGradientNode',
|
||||
'SurfaceMaskGradientNode',
|
||||
]
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding gradient nodes has the appropriate Gradient Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
handler.add_callback('OnEditorEntityDeleted', onEntityDeleted)
|
||||
|
||||
# Create nodes for all the gradients we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in gradients:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
# Gradient mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
gradients = [
|
||||
'AltitudeGradientNode',
|
||||
'ConstantGradientNode',
|
||||
'FastNoiseGradientNode',
|
||||
'ImageGradientNode',
|
||||
'PerlinNoiseGradientNode',
|
||||
'RandomNoiseGradientNode',
|
||||
'ShapeAreaFalloffGradientNode',
|
||||
'SlopeGradientNode',
|
||||
'SurfaceMaskGradientNode',
|
||||
]
|
||||
|
||||
removed = graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', newGraphId, node)
|
||||
# Create nodes for all the gradients we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in gradients:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
# Verify that the created Entity for this node matches the Entity that gets
|
||||
# deleted when the node is removed
|
||||
self.test_success = self.test_success and removed and createdEntityId.invoke("Equal", deletedEntityId)
|
||||
if removed and createdEntityId.invoke("Equal", deletedEntityId):
|
||||
self.log("{node} corresponding Entity was deleted when node is removed".format(node=nodeName))
|
||||
removed = graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', newGraphId, node)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
# Verify that the created Entity for this node matches the Entity that gets
|
||||
# deleted when the node is removed
|
||||
Report.info(f"Node: {nodeName}")
|
||||
Report.result(Tests.entity_deleted, removed and createdEntityId.invoke("Equal", deletedEntityId))
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestGradientNodeEntityDelete()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GradientNodes_EntityRemovedOnNodeDelete)
|
||||
|
||||
+73
-74
@@ -5,100 +5,99 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
graph_closed = (
|
||||
"Graph closed on entity delete",
|
||||
"Graph is still open after entity delete"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newRootEntityId = None
|
||||
|
||||
|
||||
class TestGraphClosedOnEntityDelete(EditorTestHelper):
|
||||
def GraphClosed_OnEntityDelete():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that Landscape Canvas graphs are auto-closed when the corresponding entity is deleted.
|
||||
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GraphClosedOnEntityDelete", args=["level"])
|
||||
Expected Behavior:
|
||||
When a Landscape Canvas root entity is deleted, the corresponding graph automatically closes.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that Landscape Canvas graphs are auto-closed when the corresponding entity is deleted.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Delete the automatically created entity
|
||||
4) Verify the open graph is closed
|
||||
|
||||
Expected Behavior:
|
||||
When a Landscape Canvas root entity is deleted, the corresponding graph automatically closes.
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Delete the automatically created entity
|
||||
4) Verify the open graph is closed
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
:return: None
|
||||
"""
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newRootEntityId
|
||||
newRootEntityId = parameters[0]
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
def onEntityCreated(parameters):
|
||||
global newRootEntityId
|
||||
newRootEntityId = parameters[0]
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Listen for entity creation notifications so we can store the top-level Entity created
|
||||
# when a new graph is created, and then delete it to test if the graph is closed
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Create a new graph in Landscape Canvas and verify
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
graphIsOpen = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and graphIsOpen
|
||||
if graphIsOpen:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Listen for entity creation notifications so we can store the top-level Entity created
|
||||
# when a new graph is created, and then delete it to test if the graph is closed
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
# Delete the top-level Entity created by the new graph
|
||||
editor.ToolsApplicationRequestBus(bus.Broadcast, 'DeleteEntityById', newRootEntityId)
|
||||
# Create a new graph in Landscape Canvas and verify
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
graphIsOpen = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graphIsOpen)
|
||||
|
||||
# We need to delay here because the closing of the graph due to Entity deletion
|
||||
# is actually queued in order to workaround an undo/redo issue
|
||||
# Alternatively, we could add a notifications bus for AssetEditorRequests
|
||||
# that could trigger when graphs are opened/closed and then do the check there
|
||||
general.idle_enable(True)
|
||||
general.idle_wait(1.0)
|
||||
# Delete the top-level Entity created by the new graph
|
||||
editor.ToolsApplicationRequestBus(bus.Broadcast, 'DeleteEntityById', newRootEntityId)
|
||||
|
||||
# Verify that the corresponding graph is no longer open
|
||||
graphIsClosed = not graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and graphIsClosed
|
||||
if graphIsClosed:
|
||||
self.log("The graph is no longer open after deleting the Entity")
|
||||
# We need to delay here because the closing of the graph due to Entity deletion
|
||||
# is actually queued in order to workaround an undo/redo issue
|
||||
# Alternatively, we could add a notifications bus for AssetEditorRequests
|
||||
# that could trigger when graphs are opened/closed and then do the check there
|
||||
general.idle_enable(True)
|
||||
general.idle_wait(1.0)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
# Verify that the corresponding graph is no longer open
|
||||
graphIsClosed = not graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_closed, graphIsClosed)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestGraphClosedOnEntityDelete()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GraphClosed_OnEntityDelete)
|
||||
|
||||
+63
-63
@@ -5,82 +5,82 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
graph_closed = (
|
||||
"Graph closed on level change",
|
||||
"Graph is still open after level change"
|
||||
)
|
||||
|
||||
|
||||
class TestGraphClosedOnLevelChange(EditorTestHelper):
|
||||
def GraphClosed_OnLevelChange():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that Landscape Canvas graphs are auto-closed when the currently open level changes.
|
||||
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GraphClosedOnLevelChange", args=["level"])
|
||||
Expected Behavior:
|
||||
When a new level is loaded in the Editor, open Landscape Canvas graphs are automatically closed.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that Landscape Canvas graphs are auto-closed when the currently open level changes.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Open a different level
|
||||
4) Verify the open graph is closed
|
||||
|
||||
Expected Behavior:
|
||||
When a new level is loaded in the Editor, open Landscape Canvas graphs are automatically closed.
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Open a different level
|
||||
4) Verify the open graph is closed
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graphIsOpen = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and graphIsOpen
|
||||
if graphIsOpen:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Open a different level, which should close any open Landscape Canvas graphs
|
||||
general.open_level_no_prompt('WhiteBox/EmptyLevel')
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Make sure the graph we created is now closed
|
||||
graphIsOpen = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and not graphIsOpen
|
||||
if not graphIsOpen:
|
||||
self.log("Graph is no longer open in Landscape Canvas")
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Open a different level, which should close any open Landscape Canvas graphs
|
||||
general.open_level_no_prompt('WhiteBox/EmptyLevel')
|
||||
|
||||
# Make sure the graph we created is now closed
|
||||
graphIsOpen = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_closed, not graphIsOpen)
|
||||
|
||||
|
||||
test = TestGraphClosedOnLevelChange()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GraphClosed_OnLevelChange)
|
||||
|
||||
+72
-74
@@ -5,95 +5,93 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_open = (
|
||||
"Graph is open in Landscape Canvas",
|
||||
"Graph is not open in Landscape Canvas"
|
||||
)
|
||||
tabbed_graph_closed = (
|
||||
"Tabbed graph closed independently",
|
||||
"Closing tabbed graph resulted in unexpected graphs closing"
|
||||
)
|
||||
|
||||
|
||||
class TestGraphClosedTabbedGraph(EditorTestHelper):
|
||||
def GraphClosed_TabbedGraphClosesIndependently():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that Landscape Canvas tabbed graphs can be independently closed.
|
||||
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GraphClosedTabbedGraph", args=["level"])
|
||||
Expected Behavior:
|
||||
Closing a tabbed graph only closes the appropriate graph.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that Landscape Canvas tabbed graphs can be independently closed.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create several new graphs
|
||||
3) Close one of the open graphs
|
||||
4) Ensure the graph properly closed, and other open graphs remain open
|
||||
|
||||
Expected Behavior:
|
||||
Closing a tabbed graph only closes the appropriate graph.
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create several new graphs
|
||||
3) Close one of the open graphs
|
||||
4) Ensure the graph properly closed, and other open graphs remain open
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
:return: None
|
||||
"""
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
editor_id = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
def create_new_graph():
|
||||
new_graph_id = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editor_id)
|
||||
return new_graph_id
|
||||
|
||||
# Create 3 new graphs in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
def is_graph_open(graph_id):
|
||||
graph_open = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editor_id, graph_id)
|
||||
return graph_open
|
||||
|
||||
newGraphId2 = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId2
|
||||
if newGraphId2:
|
||||
self.log("2nd new graph created")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
newGraphId3 = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId3
|
||||
if newGraphId3:
|
||||
self.log("3rd new graph created")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Make sure the graphs we created are open in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
success2 = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId2)
|
||||
success3 = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId3)
|
||||
self.test_success = self.test_success and success and success2 and success3
|
||||
if success and success2 and success3:
|
||||
self.log("Graphs registered with Landscape Canvas")
|
||||
# Create 3 new graphs in Landscape Canvas and make sure the graphs we created are open in Landscape Canvas
|
||||
graph1 = create_new_graph()
|
||||
Report.result(Tests.new_graph_created, graph1 is not None)
|
||||
Report.result(Tests.graph_open, is_graph_open(graph1))
|
||||
|
||||
# Close a single graph and verify it was properly closed and other graphs remain open
|
||||
success4 = graph.AssetEditorRequestBus(bus.Event, 'CloseGraph', editorId, newGraphId2)
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
success2 = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId2)
|
||||
success3 = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId3)
|
||||
self.test_success = self.test_success and success and success3 and success4 and not success2
|
||||
if success and success3 and success4 and not success2:
|
||||
self.log("Graph 2 was successfully closed")
|
||||
graph2 = create_new_graph()
|
||||
Report.result(Tests.new_graph_created, graph2 is not None)
|
||||
Report.result(Tests.graph_open, is_graph_open(graph2))
|
||||
|
||||
graph3 = create_new_graph()
|
||||
Report.result(Tests.new_graph_created, graph3 is not None)
|
||||
Report.result(Tests.graph_open, is_graph_open(graph3))
|
||||
|
||||
# Close a single graph and verify it was properly closed and other graphs remain open
|
||||
graph.AssetEditorRequestBus(bus.Event, 'CloseGraph', editor_id, graph2)
|
||||
Report.result(Tests.tabbed_graph_closed, not is_graph_open(graph2) and is_graph_open(graph1) and
|
||||
is_graph_open(graph3))
|
||||
|
||||
|
||||
test = TestGraphClosedTabbedGraph()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GraphClosed_TabbedGraphClosesIndependently)
|
||||
|
||||
+125
-129
@@ -5,155 +5,151 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.math as math
|
||||
import azlmbr.slice as slice
|
||||
import azlmbr.paths
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import automatedtesting_shared.landscape_canvas_utils as lc
|
||||
class Tests:
|
||||
slice_instantiated = (
|
||||
"Slice instantiated successfully",
|
||||
"Failed to instantiate slice"
|
||||
)
|
||||
existing_graph_opened = (
|
||||
"Opened existing graph from slice",
|
||||
"Failed to open existing graph"
|
||||
)
|
||||
node_removed = (
|
||||
"Rotation Modifier node was removed",
|
||||
"Failed to remove Rotation Modifier node"
|
||||
)
|
||||
component_removed = (
|
||||
"Rotation Modifier component was removed from entity",
|
||||
"Rotation Modifier component is still present on entity"
|
||||
)
|
||||
entity_deleted = (
|
||||
"BushSpawner entity was deleted",
|
||||
"Failed to delete BushSpawner entity"
|
||||
)
|
||||
entity_reference_updated = (
|
||||
"Gradient Entity Id reference was properly updated",
|
||||
"Gradient Entity Id reference was not updated properly"
|
||||
)
|
||||
|
||||
|
||||
class TestGraphUpdatesUpdateComponents(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="GraphUpdatesUpdateComponents", args=["level"])
|
||||
def GraphUpdates_UpdateComponent():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that components are properly updated as nodes are added/removed/updated.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that components are properly updated as nodes are added/removed/updated.
|
||||
Expected Behavior:
|
||||
Landscape Canvas node CRUD properly updates component entities.
|
||||
|
||||
Expected Behavior:
|
||||
Landscape Canvas node CRUD properly updates component entities.
|
||||
Test Steps:
|
||||
1. Open Level.
|
||||
2. Open the graph on LC_BushFlowerBlender.slice
|
||||
3. Find the Rotation Modifier node on the BushSpawner entity
|
||||
4. Delete the Rotation Modifier node
|
||||
5. Ensure the Vegetation Rotation Modifier component is removed from the BushSpawner entity
|
||||
6. Delete the Vegetation Layer Spawner node from the graph
|
||||
7. Ensure BushSpawner entity is deleted
|
||||
8. Change connection from second Rotation Modifier node to a different Gradient
|
||||
9. Ensure Gradient reference on component is updated
|
||||
|
||||
Test Steps:
|
||||
1. Open Level.
|
||||
2. Open the graph on LC_BushFlowerBlender.slice
|
||||
3. Find the Rotation Modifier node on the BushSpawner entity
|
||||
4. Delete the Rotation Modifier node
|
||||
5. Ensure the Vegetation Rotation Modifier component is removed from the BushSpawner entity
|
||||
6. Delete the Vegetation Layer Spawner node from the graph
|
||||
7. Ensure BushSpawner entity is deleted
|
||||
8. Change connection from second Rotation Modifier node to a different Gradient
|
||||
9. Ensure Gradient reference on component is updated
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Create a new empty level and instantiate LC_BushFlowerBlender.slice
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
transform = math.Transform_CreateIdentity()
|
||||
position = math.Vector3(64.0, 64.0, 32.0)
|
||||
transform.invoke('SetPosition', position)
|
||||
test_slice_path = os.path.join("Slices", "LC_BushFlowerBlender.slice")
|
||||
test_slice_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", test_slice_path, math.Uuid(),
|
||||
False)
|
||||
test_slice = slice.SliceRequestBus(bus.Broadcast, 'InstantiateSliceFromAssetId', test_slice_id, transform)
|
||||
self.test_success = self.test_success and test_slice.IsValid()
|
||||
if test_slice.IsValid():
|
||||
self.log("Slice spawned!")
|
||||
import os
|
||||
|
||||
# Search for root entity to ensure slice is loaded
|
||||
search_filter = entity.SearchFilter()
|
||||
search_filter.names = ["LandscapeCanvas"]
|
||||
self.wait_for_condition(lambda: len(entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)) > 0, 5.0)
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.math as math
|
||||
import azlmbr.slice as slice
|
||||
|
||||
# Find needed entities in the loaded level
|
||||
slice_root_id = hydra.find_entity_by_name('LandscapeCanvas')
|
||||
bush_spawner_id = hydra.find_entity_by_name('BushSpawner')
|
||||
flower_spawner_id = hydra.find_entity_by_name('FlowerSpawner')
|
||||
inverted_perlin_noise_id = hydra.find_entity_by_name('Invert')
|
||||
import automatedtesting_shared.landscape_canvas_utils as lc
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Open Landscape Canvas and the existing graph
|
||||
general.open_pane('Landscape Canvas')
|
||||
open_graph_id = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'OnGraphEntity', slice_root_id)
|
||||
self.test_success = self.test_success and open_graph_id.IsValid()
|
||||
if open_graph_id.IsValid():
|
||||
self.log('Graph opened')
|
||||
# Open a simple level and instantiate LC_BushFlowerBlender.slice
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
transform = math.Transform_CreateIdentity()
|
||||
position = math.Vector3(64.0, 64.0, 32.0)
|
||||
transform.invoke('SetPosition', position)
|
||||
test_slice_path = os.path.join("Slices", "LC_BushFlowerBlender.slice")
|
||||
test_slice_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", test_slice_path, math.Uuid(),
|
||||
False)
|
||||
test_slice = slice.SliceRequestBus(bus.Broadcast, 'InstantiateSliceFromAssetId', test_slice_id, transform)
|
||||
Report.critical_result(Tests.slice_instantiated, test_slice.IsValid())
|
||||
|
||||
# Find the Rotation Modifier node on the BushSpawner entity
|
||||
rotation_modifier_node = lc.find_nodes_matching_entity_component('Vegetation Rotation Modifier', bush_spawner_id)
|
||||
# Search for root entity to ensure slice is loaded
|
||||
search_filter = entity.SearchFilter()
|
||||
search_filter.names = ["LandscapeCanvas"]
|
||||
helper.wait_for_condition(lambda: len(entity.SearchBus(bus.Broadcast, 'SearchEntities', search_filter)) > 0, 5.0)
|
||||
|
||||
# Remove the Rotation Modifier node
|
||||
graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', open_graph_id, rotation_modifier_node[0])
|
||||
# Find needed entities in the loaded level
|
||||
slice_root_id = hydra.find_entity_by_name('LandscapeCanvas')
|
||||
bush_spawner_id = hydra.find_entity_by_name('BushSpawner')
|
||||
flower_spawner_id = hydra.find_entity_by_name('FlowerSpawner')
|
||||
inverted_perlin_noise_id = hydra.find_entity_by_name('Invert')
|
||||
|
||||
# Verify node was removed
|
||||
rotation_modifier_node = lc.find_nodes_matching_entity_component('Vegetation Rotation Modifier', bush_spawner_id)
|
||||
self.test_success = self.test_success and not rotation_modifier_node
|
||||
if not rotation_modifier_node:
|
||||
self.log('Rotation Modifier node was removed')
|
||||
else:
|
||||
self.log('Rotation Modifier node was not removed')
|
||||
# Open Landscape Canvas and the existing graph
|
||||
general.open_pane('Landscape Canvas')
|
||||
open_graph_id = landscapecanvas.LandscapeCanvasRequestBus(bus.Broadcast, 'OnGraphEntity', slice_root_id)
|
||||
Report.critical_result(Tests.existing_graph_opened, open_graph_id.IsValid())
|
||||
|
||||
# Verify the component was removed from the BushSpawner entity
|
||||
has_rotation_modifier = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', bush_spawner_id,
|
||||
hydra.get_component_type_id('Vegetation Rotation Modifier'))
|
||||
self.test_success = self.test_success and not has_rotation_modifier
|
||||
if not has_rotation_modifier:
|
||||
self.log('Rotation Modifier component was removed from entity')
|
||||
else:
|
||||
self.log('Rotation Modifier component is still present on entity')
|
||||
# Find the Rotation Modifier node on the BushSpawner entity
|
||||
rotation_modifier_node = lc.find_nodes_matching_entity_component('Vegetation Rotation Modifier', bush_spawner_id)
|
||||
|
||||
# Find the Vegetation Layer Spawner node on the BushSpawner entity
|
||||
layer_spawner_node = lc.find_nodes_matching_entity_component('Vegetation Layer Spawner', bush_spawner_id)
|
||||
# Remove the Rotation Modifier node
|
||||
graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', open_graph_id, rotation_modifier_node[0])
|
||||
|
||||
# Remove the Vegetation Layer Spawner node and verify the corresponding entity is deleted
|
||||
graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', open_graph_id, layer_spawner_node[0])
|
||||
bush_spawner_id = hydra.find_entity_by_name('BushSpawner')
|
||||
self.test_success = self.test_success and not bush_spawner_id
|
||||
if not bush_spawner_id:
|
||||
self.log('BushSpawner entity was deleted')
|
||||
else:
|
||||
self.log('Failed to delete BushSpawner entity')
|
||||
# Verify node was removed
|
||||
rotation_modifier_node = lc.find_nodes_matching_entity_component('Vegetation Rotation Modifier', bush_spawner_id)
|
||||
Report.result(Tests.node_removed, not rotation_modifier_node)
|
||||
|
||||
# Connect the FlowerSpawner's Rotation Modifier node to the Invert Gradient Modifier node
|
||||
rotation_modifier_node = lc.find_nodes_matching_entity_component('Vegetation Rotation Modifier', flower_spawner_id)
|
||||
invert_node = lc.find_nodes_matching_entity_component('Invert Gradient Modifier', inverted_perlin_noise_id)
|
||||
# Verify the component was removed from the BushSpawner entity
|
||||
has_rotation_modifier = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', bush_spawner_id,
|
||||
hydra.get_component_type_id('Vegetation Rotation Modifier'))
|
||||
Report.result(Tests.component_removed, not has_rotation_modifier)
|
||||
|
||||
inbound_gradient_z_slot = graph.GraphModelSlotId('InboundGradientZ')
|
||||
outbound_gradient_slot = graph.GraphModelSlotId('OutboundGradient')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', open_graph_id, invert_node[0],
|
||||
outbound_gradient_slot, rotation_modifier_node[0], inbound_gradient_z_slot)
|
||||
# Find the Vegetation Layer Spawner node on the BushSpawner entity
|
||||
layer_spawner_node = lc.find_nodes_matching_entity_component('Vegetation Layer Spawner', bush_spawner_id)
|
||||
|
||||
general.idle_wait(1.0) # Add a small wait to ensure component property has time to update
|
||||
# Remove the Vegetation Layer Spawner node and verify the corresponding entity is deleted
|
||||
graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', open_graph_id, layer_spawner_node[0])
|
||||
bush_spawner_id = hydra.find_entity_by_name('BushSpawner')
|
||||
Report.result(Tests.entity_deleted, not bush_spawner_id)
|
||||
|
||||
# Verify the Gradient Entity Id reference on the Rotation Modifier component was properly set
|
||||
rotation_type_id = hydra.get_component_type_id('Vegetation Rotation Modifier')
|
||||
rotation_outcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', flower_spawner_id,
|
||||
rotation_type_id)
|
||||
rotation_component = rotation_outcome.GetValue()
|
||||
gradient_reference = hydra.get_component_property_value(rotation_component,
|
||||
'Configuration|Rotation Z|Gradient|Gradient Entity Id')
|
||||
gradient_reference_success = gradient_reference == inverted_perlin_noise_id
|
||||
self.test_success = self.test_success and gradient_reference_success
|
||||
if gradient_reference_success:
|
||||
self.log('Gradient Entity Id reference was properly updated')
|
||||
else:
|
||||
self.log(f'Gradient Entity Id was not updated properly: Expected {inverted_perlin_noise_id.ToString()} -- Got '
|
||||
f'{gradient_reference.ToString()}.')
|
||||
# Connect the FlowerSpawner's Rotation Modifier node to the Invert Gradient Modifier node
|
||||
rotation_modifier_node = lc.find_nodes_matching_entity_component('Vegetation Rotation Modifier', flower_spawner_id)
|
||||
invert_node = lc.find_nodes_matching_entity_component('Invert Gradient Modifier', inverted_perlin_noise_id)
|
||||
|
||||
inbound_gradient_z_slot = graph.GraphModelSlotId('InboundGradientZ')
|
||||
outbound_gradient_slot = graph.GraphModelSlotId('OutboundGradient')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', open_graph_id, invert_node[0],
|
||||
outbound_gradient_slot, rotation_modifier_node[0], inbound_gradient_z_slot)
|
||||
|
||||
general.idle_wait(1.0) # Add a small wait to ensure component property has time to update
|
||||
|
||||
# Verify the Gradient Entity Id reference on the Rotation Modifier component was properly set
|
||||
rotation_type_id = hydra.get_component_type_id('Vegetation Rotation Modifier')
|
||||
rotation_outcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', flower_spawner_id,
|
||||
rotation_type_id)
|
||||
rotation_component = rotation_outcome.GetValue()
|
||||
gradient_reference = hydra.get_component_property_value(rotation_component,
|
||||
'Configuration|Rotation Z|Gradient|Gradient Entity Id')
|
||||
Report.result(Tests.entity_reference_updated, gradient_reference == inverted_perlin_noise_id)
|
||||
|
||||
|
||||
test = TestGraphUpdatesUpdateComponents()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(GraphUpdates_UpdateComponent)
|
||||
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.paths
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
|
||||
class TestLandscapeCanvasComponentAddedRemoved(EditorTestHelper):
|
||||
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="LandscapeCanvasComponentAddedRemoved", args=["level"])
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas component can be added to/removed from an entity.
|
||||
|
||||
Expected Behavior:
|
||||
Closing a tabbed graph only closes the appropriate graph.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Create a new entity
|
||||
3) Add a Landscape Canvas component to the entity
|
||||
4) Remove the Landscape Canvas component from the entity
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# Create an Entity at the root of the level
|
||||
newEntityId = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', entity.EntityId())
|
||||
|
||||
# Find the component TypeId for our Landscape Canvas component
|
||||
landscape_canvas_type_id = hydra.get_component_type_id("Landscape Canvas")
|
||||
|
||||
# Add the Landscape Canvas Component to our Entity
|
||||
componentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'AddComponentsOfType', newEntityId, [landscape_canvas_type_id])
|
||||
components = componentOutcome.GetValue()
|
||||
landscapeCanvasComponent = components[0]
|
||||
|
||||
# Validate the Landscape Canvas Component exists
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId, landscape_canvas_type_id)
|
||||
self.test_success = self.test_success and hasComponent
|
||||
if hasComponent:
|
||||
self.log("Landscape Canvas Component added to Entity")
|
||||
|
||||
# Remove the Landscape Canvas Component
|
||||
editor.EditorComponentAPIBus(bus.Broadcast, 'RemoveComponents', [landscapeCanvasComponent])
|
||||
|
||||
# Validate the Landscape Canvas Component is no longer on our Entity
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId, landscape_canvas_type_id)
|
||||
self.test_success = self.test_success and not hasComponent
|
||||
if not hasComponent:
|
||||
self.log("Landscape Canvas Component removed from Entity")
|
||||
|
||||
|
||||
test = TestLandscapeCanvasComponentAddedRemoved()
|
||||
test.run()
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.slice as slice
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests"))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
|
||||
class TestLandscapeCanvasSliceCreateInstantiate(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="LandscapeCanvas_SliceCreateInstantiate", args=["level"])
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
A slice containing the LandscapeCanvas component can be created/instantiated.
|
||||
|
||||
Expected Result:
|
||||
Slice is created/processed/instantiated successfully and free of errors/warnings.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Create a new entity with a Landscape Canvas component
|
||||
3) Create a slice of the new entity
|
||||
4) Instantiate a new copy of the slice
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
def path_is_valid_asset(asset_path):
|
||||
asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", asset_path, math.Uuid(), False)
|
||||
return asset_id.invoke("IsValid")
|
||||
|
||||
# Create empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# Create entity with LandScape Canvas component
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
landscape_canvas = hydra.Entity("landscape_canvas_entity")
|
||||
landscape_canvas.create_entity(position, ["Landscape Canvas"])
|
||||
|
||||
# Create slice from the created entity
|
||||
slice_path = os.path.join("slices", "TestSlice.slice")
|
||||
slice.SliceRequestBus(bus.Broadcast, "CreateNewSlice", landscape_canvas.id, slice_path)
|
||||
|
||||
# Verify if slice is created
|
||||
self.wait_for_condition(lambda: path_is_valid_asset(slice_path), 5.0)
|
||||
self.log(f"Slice has been created successfully: {path_is_valid_asset(slice_path)}")
|
||||
|
||||
# Instantiate slice
|
||||
transform = math.Transform_CreateIdentity()
|
||||
asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", slice_path, math.Uuid(), False)
|
||||
test_slice = slice.SliceRequestBus(bus.Broadcast, "InstantiateSliceFromAssetId", asset_id, transform)
|
||||
self.wait_for_condition(lambda: test_slice.IsValid(), 3.0)
|
||||
self.log(f"Slice instantiated: {test_slice.IsValid()}")
|
||||
|
||||
|
||||
test = TestLandscapeCanvasSliceCreateInstantiate()
|
||||
test.run()
|
||||
+124
-121
@@ -5,157 +5,160 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
blender_first_layer_set = (
|
||||
"Spawner entity set as the first layer of the Vegetation Layer Blender component",
|
||||
"Unexpected entity set as the first layer of the Vegetation Layer Blender component"
|
||||
)
|
||||
blender_second_layer_set = (
|
||||
"Blocker entity set as the second layer of the Vegetation Layer Blender component",
|
||||
"Unexpected entity set as the second layer of the Vegetation Layer Blender component"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestLayerBlenderNodeConstruction(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="LayerBlenderNodeConstruction", args=["level"])
|
||||
def LayerBlender_NodeConstruction():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies a Layer Blender vegetation setup can be constructed through Landscape Canvas.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies a Layer Blender vegetation setup can be constructed through Landscape Canvas.
|
||||
Expected Behavior:
|
||||
Entities contain all required components and component references after creating nodes and setting connections
|
||||
on a Landscape Canvas graph.
|
||||
|
||||
Expected Behavior:
|
||||
Entities contain all required components and component references after creating nodes and setting connections
|
||||
on a Landscape Canvas graph.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Add all necessary nodes to the graph and set connections to form a Layer Blender setup
|
||||
4) Verify all components and component references were properly set during graph construction
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Add all necessary nodes to the graph and set connections to form a Layer Blender setup
|
||||
4) Verify all components and component references were properly set during graph construction
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=1024,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=4096,
|
||||
use_terrain=False,
|
||||
)
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Listen for entity creation notifications so we can verify the component EntityId
|
||||
# references are set correctly when connecting slots on the nodes
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
positionX = 10.0
|
||||
positionY = 10.0
|
||||
offsetX = 340.0
|
||||
offsetY = 100.0
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Add a Vegetation Layer Spawner node to the graph
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
layerSpawnerNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'SpawnerAreaNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, layerSpawnerNode, math.Vector2(positionX, positionY))
|
||||
layerSpawnerEntityId = newEntityId
|
||||
# Listen for entity creation notifications so we can verify the component EntityId
|
||||
# references are set correctly when connecting slots on the nodes
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
positionX = 10.0
|
||||
positionY = 10.0
|
||||
offsetX = 340.0
|
||||
offsetY = 100.0
|
||||
|
||||
# Add a Vegetation Layer Blocker node to the graph
|
||||
layerBlockerNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'BlockerAreaNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, layerBlockerNode, math.Vector2(positionX, positionY))
|
||||
layerBlockerEntityId = newEntityId
|
||||
# Add a Vegetation Layer Spawner node to the graph
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
layerSpawnerNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'SpawnerAreaNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, layerSpawnerNode, math.Vector2(positionX, positionY))
|
||||
layerSpawnerEntityId = newEntityId
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Add a Vegetation Layer Blender node to the graph
|
||||
layerBlenderNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'AreaBlenderNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, layerBlenderNode, math.Vector2(positionX, positionY))
|
||||
layerBlenderNodeEntityId = newEntityId
|
||||
# Add a Vegetation Layer Blocker node to the graph
|
||||
layerBlockerNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'BlockerAreaNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, layerBlockerNode, math.Vector2(positionX, positionY))
|
||||
layerBlockerEntityId = newEntityId
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
outboundAreaSlotId = graph.GraphModelSlotId('OutboundArea')
|
||||
inboundAreaSlotId = graph.GraphModelSlotId('InboundArea')
|
||||
inboundAreaSlotId2 = graph.GraphControllerRequestBus(bus.Event, 'ExtendSlot', newGraphId, layerBlenderNode,
|
||||
'InboundArea')
|
||||
# Add a Vegetation Layer Blender node to the graph
|
||||
layerBlenderNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'AreaBlenderNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, layerBlenderNode, math.Vector2(positionX, positionY))
|
||||
layerBlenderNodeEntityId = newEntityId
|
||||
|
||||
# Connect slots on our nodes to construct a Vegetation Layer Blender hierarchy
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, layerSpawnerNode, outboundAreaSlotId,
|
||||
layerBlenderNode, inboundAreaSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, layerBlockerNode, outboundAreaSlotId,
|
||||
layerBlenderNode, inboundAreaSlotId2)
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Delay to allow all the underlying component properties to be updated after the slot connections are made
|
||||
general.idle_wait(1.0)
|
||||
outboundAreaSlotId = graph.GraphModelSlotId('OutboundArea')
|
||||
inboundAreaSlotId = graph.GraphModelSlotId('InboundArea')
|
||||
inboundAreaSlotId2 = graph.GraphControllerRequestBus(bus.Event, 'ExtendSlot', newGraphId, layerBlenderNode,
|
||||
'InboundArea')
|
||||
|
||||
# Get component info
|
||||
layerBlenderTypeId = hydra.get_component_type_id("Vegetation Layer Blender")
|
||||
vegetationLayerBlenderOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType',
|
||||
layerBlenderNodeEntityId, layerBlenderTypeId)
|
||||
layerBlenderComponent = vegetationLayerBlenderOutcome.GetValue()
|
||||
# Connect slots on our nodes to construct a Vegetation Layer Blender hierarchy
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, layerSpawnerNode, outboundAreaSlotId,
|
||||
layerBlenderNode, inboundAreaSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, layerBlockerNode, outboundAreaSlotId,
|
||||
layerBlenderNode, inboundAreaSlotId2)
|
||||
|
||||
# Verify the Vegetation Areas properties on our Vegetation Layer Blender component have been set to our area EntityIds
|
||||
area1EntityId = hydra.get_component_property_value(layerBlenderComponent, 'Configuration|Vegetation Areas|[0]')
|
||||
self.test_success = self.test_success and area1EntityId and layerSpawnerEntityId.invoke("Equal", area1EntityId)
|
||||
if area1EntityId and layerSpawnerEntityId.invoke("Equal", area1EntityId):
|
||||
self.log("Vegetation Layer Blender component Vegetation Areas[0] property set to Vegetation Layer Spawner EntityId")
|
||||
# Delay to allow all the underlying component properties to be updated after the slot connections are made
|
||||
general.idle_wait(1.0)
|
||||
|
||||
area2EntityId = hydra.get_component_property_value(layerBlenderComponent, 'Configuration|Vegetation Areas|[1]')
|
||||
self.test_success = self.test_success and area2EntityId and layerBlockerEntityId.invoke("Equal", area2EntityId)
|
||||
if area2EntityId and layerBlockerEntityId.invoke("Equal", area2EntityId):
|
||||
self.log("Vegetation Layer Blender component Vegetation Areas[1] property set to Vegetation Layer Blocker EntityId")
|
||||
# Get component info
|
||||
layerBlenderTypeId = hydra.get_component_type_id("Vegetation Layer Blender")
|
||||
vegetationLayerBlenderOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType',
|
||||
layerBlenderNodeEntityId, layerBlenderTypeId)
|
||||
layerBlenderComponent = vegetationLayerBlenderOutcome.GetValue()
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
# Verify the Vegetation Areas properties on our Vegetation Layer Blender component have been set to our area EntityIds
|
||||
area1EntityId = hydra.get_component_property_value(layerBlenderComponent, 'Configuration|Vegetation Areas|[0]')
|
||||
Report.result(Tests.blender_first_layer_set, area1EntityId and layerSpawnerEntityId.invoke("Equal", area1EntityId))
|
||||
|
||||
area2EntityId = hydra.get_component_property_value(layerBlenderComponent, 'Configuration|Vegetation Areas|[1]')
|
||||
Report.result(Tests.blender_second_layer_set, area2EntityId and layerBlockerEntityId.invoke("Equal", area2EntityId))
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestLayerBlenderNodeConstruction()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(LayerBlender_NodeConstruction)
|
||||
|
||||
+138
-132
@@ -5,164 +5,170 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
component_added = (
|
||||
"Expected component is present on entity",
|
||||
"Expected component was not found on entity"
|
||||
)
|
||||
component_removed = (
|
||||
"Expected component was removed from entity",
|
||||
"Component is unexpectedly still present on entity"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestLayerExtenderNodeComponentEntitySync(EditorTestHelper):
|
||||
def LayerExtenderNodes_ComponentEntitySync():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that all wrapped nodes can be successfully added to/removed from parent nodes.
|
||||
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="LayerExtenderNodeComponentEntitySync", args=["level"])
|
||||
Expected Behavior:
|
||||
All wrapped extender nodes can be added to/removed from appropriate parent nodes.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that all wrapped nodes can be successfully added to/removed from parent nodes.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Add Area Blender and Layer Spawner nodes to the graph, and add/remove each extender node to/from each
|
||||
|
||||
Expected Behavior:
|
||||
All wrapped extender nodes can be added to/removed from appropriate parent nodes.
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Add Area Blender and Layer Spawner nodes to the graph, and add/remove each extender node to/from each
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Listen for entity creation notifications so we can check if the
|
||||
# proper components are added when we add nodes
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Extender mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the layer Entity for that wrapped node
|
||||
extenders = {
|
||||
'AltitudeFilterNode': 'Vegetation Altitude Filter',
|
||||
'DistanceBetweenFilterNode': 'Vegetation Distance Between Filter',
|
||||
'DistributionFilterNode': 'Vegetation Distribution Filter',
|
||||
'ShapeIntersectionFilterNode': 'Vegetation Shape Intersection Filter',
|
||||
'SlopeFilterNode': 'Vegetation Slope Filter',
|
||||
'SurfaceMaskDepthFilterNode': 'Vegetation Surface Mask Depth Filter',
|
||||
'SurfaceMaskFilterNode': 'Vegetation Surface Mask Filter',
|
||||
'PositionModifierNode': 'Vegetation Position Modifier',
|
||||
'RotationModifierNode': 'Vegetation Rotation Modifier',
|
||||
'ScaleModifierNode': 'Vegetation Scale Modifier',
|
||||
'SlopeAlignmentModifierNode': 'Vegetation Slope Alignment Modifier',
|
||||
'AssetWeightSelectorNode': 'Vegetation Asset Weight Selector'
|
||||
}
|
||||
# Listen for entity creation notifications so we can check if the
|
||||
# proper components are added when we add nodes
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in extenders:
|
||||
componentNames.append(extenders[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
# Extender mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the layer Entity for that wrapped node
|
||||
extenders = {
|
||||
'AltitudeFilterNode': 'Vegetation Altitude Filter',
|
||||
'DistanceBetweenFilterNode': 'Vegetation Distance Between Filter',
|
||||
'DistributionFilterNode': 'Vegetation Distribution Filter',
|
||||
'ShapeIntersectionFilterNode': 'Vegetation Shape Intersection Filter',
|
||||
'SlopeFilterNode': 'Vegetation Slope Filter',
|
||||
'SurfaceMaskDepthFilterNode': 'Vegetation Surface Mask Depth Filter',
|
||||
'SurfaceMaskFilterNode': 'Vegetation Surface Mask Filter',
|
||||
'PositionModifierNode': 'Vegetation Position Modifier',
|
||||
'RotationModifierNode': 'Vegetation Rotation Modifier',
|
||||
'ScaleModifierNode': 'Vegetation Scale Modifier',
|
||||
'SlopeAlignmentModifierNode': 'Vegetation Slope Alignment Modifier',
|
||||
'AssetWeightSelectorNode': 'Vegetation Asset Weight Selector'
|
||||
}
|
||||
|
||||
areas = [
|
||||
'AreaBlenderNode',
|
||||
'SpawnerAreaNode'
|
||||
]
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in extenders:
|
||||
componentNames.append(extenders[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
|
||||
# Add/remove all our supported extender nodes to the Layer Areas and check if the appropriate
|
||||
# Components are added/removed to the wrapper node's Entity
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for areaName in areas:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
areaNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, areaName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, areaNode, nodePosition)
|
||||
areas = [
|
||||
'AreaBlenderNode',
|
||||
'SpawnerAreaNode'
|
||||
]
|
||||
|
||||
success = True
|
||||
for extenderName in extenders:
|
||||
# Add the wrapped node for the extender
|
||||
extenderNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast,
|
||||
'CreateNodeForTypeName', newGraph,
|
||||
extenderName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, extenderNode, nodePosition)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'WrapNode', newGraphId, areaNode, extenderNode)
|
||||
# Add/remove all our supported extender nodes to the Layer Areas and check if the appropriate
|
||||
# Components are added/removed to the wrapper node's Entity
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for areaName in areas:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
areaNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, areaName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, areaNode, nodePosition)
|
||||
|
||||
# Check that the appropriate Component was added when the extender node was added
|
||||
extenderComponent = extenders[extenderName]
|
||||
componentTypeId = componentTypeIds[extenderComponent]
|
||||
success = success and editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId,
|
||||
success = True
|
||||
for extenderName in extenders:
|
||||
# Add the wrapped node for the extender
|
||||
extenderNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast,
|
||||
'CreateNodeForTypeName', newGraph,
|
||||
extenderName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, extenderNode, nodePosition)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'WrapNode', newGraphId, areaNode, extenderNode)
|
||||
|
||||
# Check that the appropriate Component was added when the extender node was added
|
||||
extenderComponent = extenders[extenderName]
|
||||
componentTypeId = componentTypeIds[extenderComponent]
|
||||
success = success and editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId,
|
||||
componentTypeId)
|
||||
Report.info(f"Component: {extenderComponent}")
|
||||
Report.result(Tests.component_added, success)
|
||||
if not success:
|
||||
break
|
||||
|
||||
# Check that the appropriate Component was removed when the extender node was removed
|
||||
graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', newGraphId, extenderNode)
|
||||
success = success and not editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId,
|
||||
componentTypeId)
|
||||
self.test_success = self.test_success and success
|
||||
if not success:
|
||||
self.log("{node} failed to add {component} Component".format(node=areaName,
|
||||
component=extenderComponent))
|
||||
break
|
||||
Report.info(f"Component: {extenderComponent}")
|
||||
Report.result(Tests.component_removed, success)
|
||||
if not success:
|
||||
break
|
||||
|
||||
# Check that the appropriate Component was removed when the extender node was removed
|
||||
graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', newGraphId, extenderNode)
|
||||
success = success and not editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId,
|
||||
componentTypeId)
|
||||
self.test_success = self.test_success and success
|
||||
if not success:
|
||||
self.log("{node} failed to remove {component} Component".format(node=areaName,
|
||||
component=extenderComponent))
|
||||
break
|
||||
if success:
|
||||
Report.info(f"{areaName} successfully added and removed all filters/modifiers/selectors")
|
||||
|
||||
if success:
|
||||
self.log("{node} successfully added and removed all filters/modifiers/selectors".format(node=areaName))
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestLayerExtenderNodeComponentEntitySync()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(LayerExtenderNodes_ComponentEntitySync)
|
||||
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
lc_component_added = (
|
||||
"Root entity created with the Landscape Canvas component",
|
||||
"Landscape Canvas component was not found on the root entity"
|
||||
)
|
||||
lc_tool_closed = (
|
||||
"Landscape Canvas tool closed",
|
||||
"Failed to close Landscape Canvas tool"
|
||||
)
|
||||
|
||||
|
||||
new_root_entity_id = None
|
||||
|
||||
|
||||
def NewGraph_CreatedSuccessfully():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that new graphs can be created in Landscape Canvas.
|
||||
|
||||
Expected Behavior:
|
||||
New graphs can be created, and proper entity is created to hold graph data with a Landscape Canvas component.
|
||||
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Ensures the root entity created contains a Landscape Canvas component
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
def on_entity_created(parameters):
|
||||
global new_root_entity_id
|
||||
new_root_entity_id = parameters[0]
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# with the new graph has our Landscape Canvas component automatically added
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback("OnEditorEntityCreated", on_entity_created)
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
new_graph_id = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, new_graph_id is not None)
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, new_graph_id)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Check if the entity created when we create a new graph has the
|
||||
# Landscape Canvas component already added to it
|
||||
landscape_canvas_type_id = hydra.get_component_type_id("Landscape Canvas")
|
||||
success = editor.EditorComponentAPIBus(bus.Broadcast, "HasComponentOfType", new_root_entity_id,
|
||||
landscape_canvas_type_id)
|
||||
Report.result(Tests.lc_component_added, success)
|
||||
|
||||
# Close Landscape Canvas tool and verify
|
||||
general.close_pane("Landscape Canvas")
|
||||
Report.result(Tests.lc_tool_closed, not general.is_pane_visible("Landscape Canvas"))
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(NewGraph_CreatedSuccessfully)
|
||||
+108
-105
@@ -5,133 +5,136 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
component_added = (
|
||||
"New entity created with the expected component",
|
||||
"Expected component was not found on entity"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestShapeNodeEntityCreate(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="ShapeNodeEntityCreate", args=["level"])
|
||||
def ShapeNodes_EntityCreatedOnNodeAdd():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas nodes can be added to a graph, and correctly create entities.
|
||||
Expected Behavior:
|
||||
New entities are created when dragging shape nodes to graph area.
|
||||
|
||||
Expected Behavior:
|
||||
New entities are created when dragging shape nodes to graph area.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the shape nodes to the graph area, and ensure a new entity is created
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the shape nodes to the graph area, and ensure a new entity is created
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
# Open an existing simple level
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding shape nodes has the appropriate Shape Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Shape mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
shapes = {
|
||||
'BoxShapeNode': 'Box Shape',
|
||||
'CapsuleShapeNode': 'Capsule Shape',
|
||||
'CompoundShapeNode': 'Compound Shape',
|
||||
'CylinderShapeNode': 'Cylinder Shape',
|
||||
'PolygonPrismShapeNode': 'Polygon Prism Shape',
|
||||
'SphereShapeNode': 'Sphere Shape',
|
||||
'TubeShapeNode': 'Tube Shape',
|
||||
'DiskShapeNode': 'Disk Shape'
|
||||
}
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in shapes:
|
||||
componentNames.append(shapes[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Create nodes for all the shapes we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in shapes:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
# Listen for entity creation notifications so we can check if the entity created
|
||||
# from adding shape nodes has the appropriate Shape Component
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
shapeComponent = shapes[nodeName]
|
||||
componentTypeId = componentTypeIds[shapeComponent]
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId,
|
||||
componentTypeId)
|
||||
self.test_success = self.test_success and hasComponent
|
||||
if hasComponent:
|
||||
self.log("{node} created new Entity with {component} Component".format(node=nodeName,
|
||||
component=shapeComponent))
|
||||
# Shape mapping with the key being the node name and the value is the
|
||||
# expected Component that should be added to the Entity created for the node
|
||||
shapes = {
|
||||
'BoxShapeNode': 'Box Shape',
|
||||
'CapsuleShapeNode': 'Capsule Shape',
|
||||
'CompoundShapeNode': 'Compound Shape',
|
||||
'CylinderShapeNode': 'Cylinder Shape',
|
||||
'PolygonPrismShapeNode': 'Polygon Prism Shape',
|
||||
'SphereShapeNode': 'Sphere Shape',
|
||||
'TubeShapeNode': 'Tube Shape',
|
||||
'DiskShapeNode': 'Disk Shape'
|
||||
}
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
# Retrieve a mapping of the TypeIds for all the components
|
||||
# we will be checking for
|
||||
componentNames = []
|
||||
for name in shapes:
|
||||
componentNames.append(shapes[name])
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
# Create nodes for all the shapes we support and check if the Entity created by
|
||||
# adding the node has the appropriate Component added automatically to it
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in shapes:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
shapeComponent = shapes[nodeName]
|
||||
componentTypeId = componentTypeIds[shapeComponent]
|
||||
hasComponent = editor.EditorComponentAPIBus(bus.Broadcast, 'HasComponentOfType', newEntityId,
|
||||
componentTypeId)
|
||||
Report.info(f"Node: {nodeName} | Component: {shapeComponent}")
|
||||
Report.result(Tests.component_added, hasComponent)
|
||||
|
||||
x += 40.0
|
||||
y += 40.0
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestShapeNodeEntityCreate()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(ShapeNodes_EntityCreatedOnNodeAdd)
|
||||
|
||||
+109
-107
@@ -5,127 +5,129 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
entity_deleted = (
|
||||
"Entity was deleted when node was removed",
|
||||
"Entity was not deleted as expected when node was removed"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
createdEntityId = None
|
||||
deletedEntityId = None
|
||||
|
||||
|
||||
class TestShapeNodeEntityDelete(EditorTestHelper):
|
||||
def ShapeNodes_EntityRemovedOnNodeDelete():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas node deletion properly cleans up entities in the Editor.
|
||||
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="ShapeNodeEntityDelete", args=["level"])
|
||||
Expected Behavior:
|
||||
Entities are removed when shape nodes are deleted from a graph.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas node deletion properly cleans up entities in the Editor.
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the shape nodes to the graph area, and ensure a new entity is created
|
||||
4) Delete the nodes, and ensure the newly created entities are removed
|
||||
|
||||
Expected Behavior:
|
||||
Entities are removed when shape nodes are deleted from a graph.
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Drag each of the shape nodes to the graph area, and ensure a new entity is created
|
||||
4) Delete the nodes, and ensure the newly created entities are removed
|
||||
:return: None
|
||||
"""
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
|
||||
:return: None
|
||||
"""
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global createdEntityId
|
||||
createdEntityId = parameters[0]
|
||||
|
||||
def onEntityDeleted(parameters):
|
||||
global deletedEntityId
|
||||
deletedEntityId = parameters[0]
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
|
||||
# Listen for entity creation/deletion notifications so we can verify the
|
||||
# Entity created when adding a new also gets deleted when the node is deleted
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
handler.add_callback('OnEditorEntityDeleted', onEntityDeleted)
|
||||
|
||||
# All of the shape nodes that we support
|
||||
shapes = [
|
||||
'BoxShapeNode',
|
||||
'CapsuleShapeNode',
|
||||
'CompoundShapeNode',
|
||||
'CylinderShapeNode',
|
||||
'PolygonPrismShapeNode',
|
||||
'SphereShapeNode',
|
||||
'TubeShapeNode',
|
||||
'DiskShapeNode'
|
||||
]
|
||||
|
||||
# Create nodes for all the shapes we support and check if the Entity is created
|
||||
# and then deleted when the node is removed
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in shapes:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
removed = graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', newGraphId, node)
|
||||
|
||||
# Verify that the created Entity for this node matches the Entity that gets
|
||||
# deleted when the node is removed
|
||||
self.test_success = self.test_success and removed and createdEntityId.invoke("Equal", deletedEntityId)
|
||||
if removed and createdEntityId.invoke("Equal", deletedEntityId):
|
||||
self.log("{node} corresponding Entity was deleted when node is removed".format(node=nodeName))
|
||||
|
||||
# Stop listening for entity creation/deletion notifications
|
||||
handler.disconnect()
|
||||
def onEntityCreated(parameters):
|
||||
global createdEntityId
|
||||
createdEntityId = parameters[0]
|
||||
|
||||
def onEntityDeleted(parameters):
|
||||
global deletedEntityId
|
||||
deletedEntityId = parameters[0]
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Listen for entity creation/deletion notifications so we can verify the
|
||||
# Entity created when adding a new also gets deleted when the node is deleted
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
handler.add_callback('OnEditorEntityDeleted', onEntityDeleted)
|
||||
|
||||
# All of the shape nodes that we support
|
||||
shapes = [
|
||||
'BoxShapeNode',
|
||||
'CapsuleShapeNode',
|
||||
'CompoundShapeNode',
|
||||
'CylinderShapeNode',
|
||||
'PolygonPrismShapeNode',
|
||||
'SphereShapeNode',
|
||||
'TubeShapeNode',
|
||||
'DiskShapeNode'
|
||||
]
|
||||
|
||||
# Create nodes for all the shapes we support and check if the Entity is created
|
||||
# and then deleted when the node is removed
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
x = 10.0
|
||||
y = 10.0
|
||||
for nodeName in shapes:
|
||||
nodePosition = math.Vector2(x, y)
|
||||
node = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName', newGraph, nodeName)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, node, nodePosition)
|
||||
|
||||
removed = graph.GraphControllerRequestBus(bus.Event, 'RemoveNode', newGraphId, node)
|
||||
|
||||
# Verify that the created Entity for this node matches the Entity that gets
|
||||
# deleted when the node is removed
|
||||
Report.info(f"Node: {nodeName}")
|
||||
Report.result(Tests.entity_deleted, removed and createdEntityId.invoke("Equal", deletedEntityId))
|
||||
|
||||
# Stop listening for entity creation/deletion notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
test = TestShapeNodeEntityDelete()
|
||||
test.run()
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(ShapeNodes_EntityRemovedOnNodeDelete)
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
|
||||
class Tests:
|
||||
slice_created = (
|
||||
"Slice created successfully",
|
||||
"Failed to create slice"
|
||||
)
|
||||
slice_instantiated = (
|
||||
"Slice instantiated successfully",
|
||||
"Failed to instantiate slice"
|
||||
)
|
||||
|
||||
|
||||
def Slice_CreateInstantiate():
|
||||
"""
|
||||
Summary:
|
||||
A slice containing the LandscapeCanvas component can be created/instantiated.
|
||||
|
||||
Expected Result:
|
||||
Slice is created/processed/instantiated successfully and free of errors/warnings.
|
||||
|
||||
Test Steps:
|
||||
1) Open a simple level
|
||||
2) Create a new entity with a Landscape Canvas component
|
||||
3) Create a slice of the new entity
|
||||
4) Instantiate a new copy of the slice
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
import azlmbr.math as math
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.asset as asset
|
||||
import azlmbr.slice as slice
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
def path_is_valid_asset(asset_path):
|
||||
asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", asset_path, math.Uuid(), False)
|
||||
return asset_id.invoke("IsValid")
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Create entity with Landscape Canvas component
|
||||
position = math.Vector3(512.0, 512.0, 32.0)
|
||||
landscape_canvas = hydra.Entity("landscape_canvas_entity")
|
||||
landscape_canvas.create_entity(position, ["Landscape Canvas"])
|
||||
|
||||
# Create slice from the created entity
|
||||
slice_path = os.path.join("slices", "TestSlice.slice")
|
||||
slice.SliceRequestBus(bus.Broadcast, "CreateNewSlice", landscape_canvas.id, slice_path)
|
||||
|
||||
# Verify if slice is created
|
||||
helper.wait_for_condition(lambda: path_is_valid_asset(slice_path), 5.0)
|
||||
Report.result(Tests.slice_created, path_is_valid_asset(slice_path))
|
||||
|
||||
# Instantiate slice
|
||||
transform = math.Transform_CreateIdentity()
|
||||
asset_id = asset.AssetCatalogRequestBus(bus.Broadcast, "GetAssetIdByPath", slice_path, math.Uuid(), False)
|
||||
test_slice = slice.SliceRequestBus(bus.Broadcast, "InstantiateSliceFromAssetId", asset_id, transform)
|
||||
helper.wait_for_condition(lambda: test_slice.IsValid(), 5.0)
|
||||
Report.result(Tests.slice_instantiated, test_slice.IsValid())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(Slice_CreateInstantiate)
|
||||
+200
-193
@@ -5,210 +5,217 @@ For complete copyright and license terms please see the LICENSE at the root of t
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
class Tests:
|
||||
lc_tool_opened = (
|
||||
"Landscape Canvas tool opened",
|
||||
"Failed to open Landscape Canvas tool"
|
||||
)
|
||||
new_graph_created = (
|
||||
"Successfully created new graph",
|
||||
"Failed to create new graph"
|
||||
)
|
||||
graph_registered = (
|
||||
"Graph registered with Landscape Canvas",
|
||||
"Failed to register graph"
|
||||
)
|
||||
preview_entity_set = (
|
||||
"Random Noise Gradient component Preview Entity property set to Box Shape EntityId",
|
||||
"Unexpected entity set in Random Noise Gradient Preview Entity property"
|
||||
)
|
||||
dither_inbound_gradient_set = (
|
||||
"Dither Gradient Modifier component Inbound Gradient property set to Random Noise Gradient EntityId",
|
||||
"Unexpected entity set in Dither Gradient's Inbound Gradient property"
|
||||
)
|
||||
mixer_inbound_gradient_set = (
|
||||
"Gradient Mixer component Inbound Gradient extendable property set to Dither Gradient Modifier EntityId",
|
||||
"Unexpected entity set in Gradient Mixer's Inbound Gradient property"
|
||||
)
|
||||
|
||||
sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests'))
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.editor_test_helper import EditorTestHelper
|
||||
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
newEntityId = None
|
||||
|
||||
|
||||
class TestSlotConnectionsUpdateComponents(EditorTestHelper):
|
||||
def __init__(self):
|
||||
EditorTestHelper.__init__(self, log_prefix="SlotConnectionsUpdateComponents", args=["level"])
|
||||
def SlotConnections_UpdateComponentReferences():
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas slot connections properly update component references.
|
||||
|
||||
def run_test(self):
|
||||
"""
|
||||
Summary:
|
||||
This test verifies that the Landscape Canvas slot connections properly update component references.
|
||||
Expected Behavior:
|
||||
A reference created through slot connections in Landscape Canvas is reflected in the Entity Inspector.
|
||||
|
||||
Expected Behavior:
|
||||
A reference created through slot connections in Landscape Canvas is reflected in the Entity Inspector.
|
||||
Test Steps:
|
||||
1) Open an existing level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Several nodes are added to a graph, and connections are set between the nodes
|
||||
4) Component references are verified via Entity Inspector
|
||||
|
||||
Test Steps:
|
||||
1) Create a new level
|
||||
2) Open Landscape Canvas and create a new graph
|
||||
3) Several nodes are added to a graph, and connections are set between the nodes
|
||||
4) Component references are verified via Entity Inspector
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
:return: None
|
||||
"""
|
||||
import azlmbr.bus as bus
|
||||
import azlmbr.editor as editor
|
||||
import azlmbr.editor.graph as graph
|
||||
import azlmbr.landscapecanvas as landscapecanvas
|
||||
import azlmbr.legacy.general as general
|
||||
import azlmbr.math as math
|
||||
import azlmbr.paths
|
||||
|
||||
:return: None
|
||||
"""
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
# Retrieve the proper component TypeIds per component name
|
||||
componentNames = [
|
||||
'Random Noise Gradient',
|
||||
'Dither Gradient Modifier',
|
||||
'Gradient Mixer'
|
||||
]
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
|
||||
# Helper method for retrieving an EntityId from a specific property on a component
|
||||
def getEntityIdFromComponentProperty(targetEntityId, componentTypeName, propertyPath):
|
||||
componentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', targetEntityId,
|
||||
componentTypeIds[componentTypeName])
|
||||
if not componentOutcome.IsSuccess():
|
||||
return None
|
||||
|
||||
component = componentOutcome.GetValue()
|
||||
propertyOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentProperty', component,
|
||||
propertyPath)
|
||||
if not propertyOutcome.IsSuccess():
|
||||
return None
|
||||
|
||||
return propertyOutcome.GetValue()
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Create a new empty level
|
||||
self.test_success = self.create_level(
|
||||
self.args["level"],
|
||||
heightmap_resolution=128,
|
||||
heightmap_meters_per_pixel=1,
|
||||
terrain_texture_resolution=128,
|
||||
use_terrain=False,
|
||||
)
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
self.test_success = self.test_success and general.is_pane_visible('Landscape Canvas')
|
||||
if general.is_pane_visible('Landscape Canvas'):
|
||||
self.log('Landscape Canvas pane is open')
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
self.test_success = self.test_success and newGraphId
|
||||
if newGraphId:
|
||||
self.log("New graph created")
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
success = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
self.test_success = self.test_success and success
|
||||
if success:
|
||||
self.log("Graph registered with Landscape Canvas")
|
||||
|
||||
# Listen for entity creation notifications so we can verify the component EntityId
|
||||
# references are set correctly when connecting slots on the nodes
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
positionX = 10.0
|
||||
positionY = 10.0
|
||||
offsetX = 340.0
|
||||
offsetY = 100.0
|
||||
|
||||
# Add a box shape node to the graph
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
boxShapeNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'BoxShapeNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, boxShapeNode, math.Vector2(positionX,
|
||||
positionY))
|
||||
boxShapeEntityId = newEntityId
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Add a random noise gradient node to the graph
|
||||
randomNoiseNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'RandomNoiseGradientNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, randomNoiseNode, math.Vector2(positionX,
|
||||
positionY))
|
||||
randomNoiseEntityId = newEntityId
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Add a dither gradient modifier node to the graph
|
||||
ditherNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'DitherGradientModifierNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, ditherNode, math.Vector2(positionX,
|
||||
positionY))
|
||||
ditherEntityId = newEntityId
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Add a gradient mixer node to the graph
|
||||
gradientMixerNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'GradientMixerNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, gradientMixerNode, math.Vector2(positionX,
|
||||
positionY))
|
||||
gradientMixerEntityId = newEntityId
|
||||
|
||||
boundsSlotId = graph.GraphModelSlotId('Bounds')
|
||||
previewBoundsSlotId = graph.GraphModelSlotId('PreviewBounds')
|
||||
inboundGradientSlotId = graph.GraphModelSlotId('InboundGradient')
|
||||
outboundGradientSlotId = graph.GraphModelSlotId('OutboundGradient')
|
||||
|
||||
# Connect slots on our nodes to test all slot types like so:
|
||||
# Shape -> Gradient -> Gradient Modifier -> Gradient Mixer
|
||||
#
|
||||
# Which tests the following slot types:
|
||||
# * Shape -> Preview Bounds
|
||||
# * Gradient Output -> Gradient Modifier
|
||||
# * Gradient Output -> Gradient Mixer (extendable slots)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, boxShapeNode, boundsSlotId,
|
||||
randomNoiseNode, previewBoundsSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, randomNoiseNode,
|
||||
outboundGradientSlotId, ditherNode, inboundGradientSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, ditherNode,
|
||||
outboundGradientSlotId, gradientMixerNode, inboundGradientSlotId)
|
||||
|
||||
# Delay to allow all the underlying component properties to be updated after the slot connections are made
|
||||
general.idle_wait(1.0)
|
||||
|
||||
# Verify the Preview EntityId property on our Random Noise Gradient component has been set to our Box Shape's
|
||||
# EntityId
|
||||
previewEntityId = getEntityIdFromComponentProperty(randomNoiseEntityId, 'Random Noise Gradient',
|
||||
'Preview Settings|Pin Preview to Shape')
|
||||
random_gradient_success = previewEntityId and boxShapeEntityId.invoke("Equal", previewEntityId)
|
||||
self.test_success = self.test_success and random_gradient_success
|
||||
if random_gradient_success:
|
||||
self.log("Random Noise Gradient component Preview Entity property set to Box Shape EntityId")
|
||||
|
||||
# Verify the Inbound Gradient EntityId property on our Dither Gradient Modifier component has been set to our
|
||||
# Random Noise Gradient's EntityId
|
||||
inboundGradientEntityId = getEntityIdFromComponentProperty(ditherEntityId, 'Dither Gradient Modifier',
|
||||
'Configuration|Gradient|Gradient Entity Id')
|
||||
dither_gradient_success = inboundGradientEntityId and randomNoiseEntityId.invoke("Equal",
|
||||
inboundGradientEntityId)
|
||||
self.test_success = self.test_success and dither_gradient_success
|
||||
if dither_gradient_success:
|
||||
self.log("Dither Gradient Modifier component Inbound Gradient property set to Random Noise Gradient "
|
||||
"EntityId")
|
||||
|
||||
# Verify the Inbound Gradient Mixer EntityId property on our Gradient Mixer component has been set to our
|
||||
# Dither Gradient Modifier's EntityId
|
||||
inboundGradientMixerEntityId = getEntityIdFromComponentProperty(gradientMixerEntityId, 'Gradient Mixer',
|
||||
'Configuration|Layers|[0]|Gradient|Gradient Entity Id')
|
||||
gradient_mixer_success = inboundGradientMixerEntityId and ditherEntityId.invoke("Equal",
|
||||
inboundGradientMixerEntityId)
|
||||
self.test_success = self.test_success and gradient_mixer_success
|
||||
if gradient_mixer_success:
|
||||
self.log("Gradient Mixer component Inbound Gradient extendable property set to Dither Gradient Modifier "
|
||||
"EntityId")
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID
|
||||
|
||||
|
||||
test = TestSlotConnectionsUpdateComponents()
|
||||
test.run()
|
||||
# Retrieve the proper component TypeIds per component name
|
||||
componentNames = [
|
||||
'Random Noise Gradient',
|
||||
'Dither Gradient Modifier',
|
||||
'Gradient Mixer'
|
||||
]
|
||||
componentTypeIds = hydra.get_component_type_id_map(componentNames)
|
||||
|
||||
# Helper method for retrieving an EntityId from a specific property on a component
|
||||
def getEntityIdFromComponentProperty(targetEntityId, componentTypeName, propertyPath):
|
||||
componentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', targetEntityId,
|
||||
componentTypeIds[componentTypeName])
|
||||
|
||||
if not componentOutcome.IsSuccess():
|
||||
return None
|
||||
|
||||
component = componentOutcome.GetValue()
|
||||
propertyOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentProperty', component,
|
||||
propertyPath)
|
||||
if not propertyOutcome.IsSuccess():
|
||||
return None
|
||||
|
||||
return propertyOutcome.GetValue()
|
||||
|
||||
def onEntityCreated(parameters):
|
||||
global newEntityId
|
||||
newEntityId = parameters[0]
|
||||
|
||||
# Open an existing simple level
|
||||
helper.init_idle()
|
||||
helper.open_level("Physics", "Base")
|
||||
|
||||
# Open Landscape Canvas tool and verify
|
||||
general.open_pane('Landscape Canvas')
|
||||
Report.critical_result(Tests.lc_tool_opened, general.is_pane_visible('Landscape Canvas'))
|
||||
|
||||
# Create a new graph in Landscape Canvas
|
||||
newGraphId = graph.AssetEditorRequestBus(bus.Event, 'CreateNewGraph', editorId)
|
||||
Report.critical_result(Tests.new_graph_created, newGraphId is not None)
|
||||
|
||||
# Make sure the graph we created is in Landscape Canvas
|
||||
graph_registered = graph.AssetEditorRequestBus(bus.Event, 'ContainsGraph', editorId, newGraphId)
|
||||
Report.result(Tests.graph_registered, graph_registered)
|
||||
|
||||
# Listen for entity creation notifications so we can verify the component EntityId
|
||||
# references are set correctly when connecting slots on the nodes
|
||||
handler = editor.EditorEntityContextNotificationBusHandler()
|
||||
handler.connect()
|
||||
handler.add_callback('OnEditorEntityCreated', onEntityCreated)
|
||||
|
||||
positionX = 10.0
|
||||
positionY = 10.0
|
||||
offsetX = 340.0
|
||||
offsetY = 100.0
|
||||
|
||||
# Add a box shape node to the graph
|
||||
newGraph = graph.GraphManagerRequestBus(bus.Broadcast, 'GetGraph', newGraphId)
|
||||
boxShapeNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'BoxShapeNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, boxShapeNode, math.Vector2(positionX,
|
||||
positionY))
|
||||
boxShapeEntityId = newEntityId
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Add a random noise gradient node to the graph
|
||||
randomNoiseNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'RandomNoiseGradientNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, randomNoiseNode, math.Vector2(positionX,
|
||||
positionY))
|
||||
randomNoiseEntityId = newEntityId
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Add a dither gradient modifier node to the graph
|
||||
ditherNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'DitherGradientModifierNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, ditherNode, math.Vector2(positionX,
|
||||
positionY))
|
||||
ditherEntityId = newEntityId
|
||||
|
||||
positionX += offsetX
|
||||
positionY += offsetY
|
||||
|
||||
# Add a gradient mixer node to the graph
|
||||
gradientMixerNode = landscapecanvas.LandscapeCanvasNodeFactoryRequestBus(bus.Broadcast, 'CreateNodeForTypeName',
|
||||
newGraph, 'GradientMixerNode')
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddNode', newGraphId, gradientMixerNode, math.Vector2(positionX,
|
||||
positionY))
|
||||
gradientMixerEntityId = newEntityId
|
||||
|
||||
boundsSlotId = graph.GraphModelSlotId('Bounds')
|
||||
previewBoundsSlotId = graph.GraphModelSlotId('PreviewBounds')
|
||||
inboundGradientSlotId = graph.GraphModelSlotId('InboundGradient')
|
||||
outboundGradientSlotId = graph.GraphModelSlotId('OutboundGradient')
|
||||
|
||||
# Connect slots on our nodes to test all slot types like so:
|
||||
# Shape -> Gradient -> Gradient Modifier -> Gradient Mixer
|
||||
#
|
||||
# Which tests the following slot types:
|
||||
# * Shape -> Preview Bounds
|
||||
# * Gradient Output -> Gradient Modifier
|
||||
# * Gradient Output -> Gradient Mixer (extendable slots)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, boxShapeNode, boundsSlotId,
|
||||
randomNoiseNode, previewBoundsSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, randomNoiseNode,
|
||||
outboundGradientSlotId, ditherNode, inboundGradientSlotId)
|
||||
graph.GraphControllerRequestBus(bus.Event, 'AddConnectionBySlotId', newGraphId, ditherNode,
|
||||
outboundGradientSlotId, gradientMixerNode, inboundGradientSlotId)
|
||||
|
||||
# Delay to allow all the underlying component properties to be updated after the slot connections are made
|
||||
general.idle_wait(1.0)
|
||||
|
||||
|
||||
# Verify the Preview EntityId property on our Random Noise Gradient component has been set to our Box Shape's
|
||||
# EntityId
|
||||
previewEntityId = getEntityIdFromComponentProperty(randomNoiseEntityId, 'Random Noise Gradient',
|
||||
'Preview Settings|Pin Preview to Shape')
|
||||
random_gradient_success = previewEntityId and boxShapeEntityId.invoke("Equal", previewEntityId)
|
||||
Report.result(Tests.preview_entity_set, random_gradient_success)
|
||||
|
||||
# Verify the Inbound Gradient EntityId property on our Dither Gradient Modifier component has been set to our
|
||||
# Random Noise Gradient's EntityId
|
||||
inboundGradientEntityId = getEntityIdFromComponentProperty(ditherEntityId, 'Dither Gradient Modifier',
|
||||
'Configuration|Gradient|Gradient Entity Id')
|
||||
dither_gradient_success = inboundGradientEntityId and randomNoiseEntityId.invoke("Equal",
|
||||
inboundGradientEntityId)
|
||||
Report.result(Tests.dither_inbound_gradient_set, dither_gradient_success)
|
||||
|
||||
# Verify the Inbound Gradient Mixer EntityId property on our Gradient Mixer component has been set to our
|
||||
# Dither Gradient Modifier's EntityId
|
||||
inboundGradientMixerEntityId = getEntityIdFromComponentProperty(gradientMixerEntityId, 'Gradient Mixer',
|
||||
'Configuration|Layers|[0]|Gradient|Gradient Entity Id')
|
||||
gradient_mixer_success = inboundGradientMixerEntityId and ditherEntityId.invoke("Equal",
|
||||
inboundGradientMixerEntityId)
|
||||
Report.result(Tests.mixer_inbound_gradient_set, gradient_mixer_success)
|
||||
|
||||
# Stop listening for entity creation notifications
|
||||
handler.disconnect()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test(SlotConnections_UpdateComponentReferences)
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../../automatedtesting_shared')
|
||||
from base import TestAutomationBase
|
||||
|
||||
|
||||
@pytest.mark.SUITE_main
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(TestAutomationBase):
|
||||
|
||||
def test_LandscapeCanvas_SlotConnections_UpdateComponentReferences(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import SlotConnections_UpdateComponentReferences as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_GradientMixer_NodeConstruction(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientMixer_NodeConstruction as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from ly_test_tools.o3de.editor_test import EditorSingleTest, EditorSharedTest, EditorParallelTest, EditorTestSuite
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(EditorTestSuite):
|
||||
|
||||
class test_LandscapeCanvas_SlotConnections_UpdateComponentReferences(EditorSharedTest):
|
||||
from .EditorScripts import SlotConnections_UpdateComponentReferences as test_module
|
||||
|
||||
class test_LandscapeCanvas_GradientMixer_NodeConstruction(EditorSharedTest):
|
||||
from .EditorScripts import GradientMixer_NodeConstruction as test_module
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../../automatedtesting_shared')
|
||||
from base import TestAutomationBase
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def remove_test_slice(request, workspace, project):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "slices", "TestSlice.slice")], True, True)
|
||||
|
||||
def teardown():
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), project, "slices", "TestSlice.slice")], True,
|
||||
True)
|
||||
|
||||
request.addfinalizer(teardown)
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(TestAutomationBase):
|
||||
|
||||
def test_LandscapeCanvas_AreaNodes_DependentComponentsAdded(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import AreaNodes_DependentComponentsAdded as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_AreaNodes_EntityCreatedOnNodeAdd(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import AreaNodes_EntityCreatedOnNodeAdd as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_AreaNodes_EntityRemovedOnNodeDelete(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import AreaNodes_EntityRemovedOnNodeDelete as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_LayerExtenderNodes_ComponentEntitySync(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import LayerExtenderNodes_ComponentEntitySync as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_Edit_DisabledNodeDuplication(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import Edit_DisabledNodeDuplication as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_Edit_UndoNodeDelete_SliceEntity(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import Edit_UndoNodeDelete_SliceEntity as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_NewGraph_CreatedSuccessfully(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import NewGraph_CreatedSuccessfully as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_Component_AddedRemoved(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import Component_AddedRemoved as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_GraphClosed_OnLevelChange(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GraphClosed_OnLevelChange as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
@pytest.mark.xfail(reason="https://github.com/o3de/o3de/issues/2201")
|
||||
def test_LandscapeCanvas_GraphClosed_OnEntityDelete(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GraphClosed_OnEntityDelete as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_GraphClosed_TabbedGraphClosesIndependently(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GraphClosed_TabbedGraph as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_Slice_CreateInstantiate(self, request, workspace, editor, remove_test_slice, launcher_platform):
|
||||
from .EditorScripts import Slice_CreateInstantiate as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_GradientModifierNodes_EntityCreatedOnNodeAdd(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientModifierNodes_EntityCreatedOnNodeAdd as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_GradientModifierNodes_EntityRemovedOnNodeDelete(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientModifierNodes_EntityRemovedOnNodeDelete as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_GradientNodes_DependentComponentsAdded(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientNodes_DependentComponentsAdded as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_GradientNodes_EntityCreatedOnNodeAdd(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientNodes_EntityCreatedOnNodeAdd as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_GradientNodes_EntityRemovedOnNodeDelete(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GradientNodes_EntityRemovedOnNodeDelete as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_GraphUpdates_UpdateComponents(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import GraphUpdates_UpdateComponents as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_ComponentUpdates_UpdateGraph(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import ComponentUpdates_UpdateGraph as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_LayerBlender_NodeConstruction(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import LayerBlender_NodeConstruction as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_ShapeNodes_EntityCreatedOnNodeAdd(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import ShapeNodes_EntityCreatedOnNodeAdd as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
|
||||
def test_LandscapeCanvas_ShapeNodes_EntityRemovedOnNodeDelete(self, request, workspace, editor, launcher_platform):
|
||||
from .EditorScripts import ShapeNodes_EntityRemovedOnNodeDelete as test_module
|
||||
self._run_test(request, workspace, editor, test_module)
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
"""
|
||||
Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
import ly_test_tools.environment.file_system as file_system
|
||||
from ly_test_tools.o3de.editor_test import EditorSingleTest, EditorSharedTest, EditorParallelTest, EditorTestSuite
|
||||
|
||||
|
||||
@pytest.mark.SUITE_periodic
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(EditorTestSuite):
|
||||
|
||||
class test_LandscapeCanvas_AreaNodes_DependentComponentsAdded(EditorSharedTest):
|
||||
from .EditorScripts import AreaNodes_DependentComponentsAdded as test_module
|
||||
|
||||
class test_LandscapeCanvas_AreaNodes_EntityCreatedOnNodeAdd(EditorSharedTest):
|
||||
from .EditorScripts import AreaNodes_EntityCreatedOnNodeAdd as test_module
|
||||
|
||||
class test_LandscapeCanvas_AreaNodes_EntityRemovedOnNodeDelete(EditorSharedTest):
|
||||
from .EditorScripts import AreaNodes_EntityRemovedOnNodeDelete as test_module
|
||||
|
||||
class test_LandscapeCanvas_LayerExtenderNodes_ComponentEntitySync(EditorSharedTest):
|
||||
from .EditorScripts import LayerExtenderNodes_ComponentEntitySync as test_module
|
||||
|
||||
class test_LandscapeCanvas_Edit_DisabledNodeDuplication(EditorSharedTest):
|
||||
from .EditorScripts import Edit_DisabledNodeDuplication as test_module
|
||||
|
||||
class test_LandscapeCanvas_Edit_UndoNodeDelete_SliceEntity(EditorSharedTest):
|
||||
from .EditorScripts import Edit_UndoNodeDelete_SliceEntity as test_module
|
||||
|
||||
class test_LandscapeCanvas_NewGraph_CreatedSuccessfully(EditorSharedTest):
|
||||
from .EditorScripts import NewGraph_CreatedSuccessfully as test_module
|
||||
|
||||
class test_LandscapeCanvas_Component_AddedRemoved(EditorSharedTest):
|
||||
from .EditorScripts import Component_AddedRemoved as test_module
|
||||
|
||||
class test_LandscapeCanvas_GraphClosed_OnLevelChange(EditorSharedTest):
|
||||
from .EditorScripts import GraphClosed_OnLevelChange as test_module
|
||||
|
||||
@pytest.mark.xfail(reason="https://github.com/o3de/o3de/issues/2201")
|
||||
class test_LandscapeCanvas_GraphClosed_OnEntityDelete(EditorSharedTest):
|
||||
from .EditorScripts import GraphClosed_OnEntityDelete as test_module
|
||||
|
||||
class test_LandscapeCanvas_GraphClosed_TabbedGraphClosesIndependently(EditorSharedTest):
|
||||
from .EditorScripts import GraphClosed_TabbedGraph as test_module
|
||||
|
||||
class test_LandscapeCanvas_Slice_CreateInstantiate(EditorSingleTest):
|
||||
# Custom teardown to remove slice asset created during test
|
||||
def teardown(self, request, workspace, editor, editor_test_results, launcher_platform):
|
||||
file_system.delete([os.path.join(workspace.paths.engine_root(), "AutomatedTesting", "slices",
|
||||
"TestSlice.slice")], True, True)
|
||||
from .EditorScripts import Slice_CreateInstantiate as test_module
|
||||
|
||||
class test_LandscapeCanvas_GradientModifierNodes_EntityCreatedOnNodeAdd(EditorSharedTest):
|
||||
from .EditorScripts import GradientModifierNodes_EntityCreatedOnNodeAdd as test_module
|
||||
|
||||
class test_LandscapeCanvas_GradientModifierNodes_EntityRemovedOnNodeDelete(EditorSharedTest):
|
||||
from .EditorScripts import GradientModifierNodes_EntityRemovedOnNodeDelete as test_module
|
||||
|
||||
class test_LandscapeCanvas_GradientNodes_DependentComponentsAdded(EditorSharedTest):
|
||||
from .EditorScripts import GradientNodes_DependentComponentsAdded as test_module
|
||||
|
||||
class test_LandscapeCanvas_GradientNodes_EntityCreatedOnNodeAdd(EditorSharedTest):
|
||||
from .EditorScripts import GradientNodes_EntityCreatedOnNodeAdd as test_module
|
||||
|
||||
class test_LandscapeCanvas_GradientNodes_EntityRemovedOnNodeDelete(EditorSharedTest):
|
||||
from .EditorScripts import GradientNodes_EntityRemovedOnNodeDelete as test_module
|
||||
|
||||
class test_LandscapeCanvas_GraphUpdates_UpdateComponents(EditorSharedTest):
|
||||
from .EditorScripts import GraphUpdates_UpdateComponents as test_module
|
||||
|
||||
class test_LandscapeCanvas_ComponentUpdates_UpdateGraph(EditorSharedTest):
|
||||
from .EditorScripts import ComponentUpdates_UpdateGraph as test_module
|
||||
|
||||
class test_LandscapeCanvas_LayerBlender_NodeConstruction(EditorSharedTest):
|
||||
from .EditorScripts import LayerBlender_NodeConstruction as test_module
|
||||
|
||||
class test_LandscapeCanvas_ShapeNodes_EntityCreatedOnNodeAdd(EditorSharedTest):
|
||||
from .EditorScripts import ShapeNodes_EntityCreatedOnNodeAdd as test_module
|
||||
|
||||
class test_LandscapeCanvas_ShapeNodes_EntityRemovedOnNodeDelete(EditorSharedTest):
|
||||
from .EditorScripts import ShapeNodes_EntityRemovedOnNodeDelete as test_module
|
||||
+42
-38
@@ -70,9 +70,9 @@ static void OnMenuGrid()
|
||||
inline Vec3 SnapToSize(Vec3 v, double size)
|
||||
{
|
||||
Vec3 snapped;
|
||||
snapped.x = floor((v.x / size) + 0.5) * size;
|
||||
snapped.y = floor((v.y / size) + 0.5) * size;
|
||||
snapped.z = floor((v.z / size) + 0.5) * size;
|
||||
snapped.x = static_cast<f32>(floor((v.x / size) + 0.5) * size);
|
||||
snapped.y = static_cast<f32>(floor((v.y / size) + 0.5) * size);
|
||||
snapped.z = static_cast<f32>(floor((v.z / size) + 0.5) * size);
|
||||
return snapped;
|
||||
}
|
||||
|
||||
@@ -479,8 +479,8 @@ void Q2DViewport::SetZoom(float fZoomFactor, const QPoint& center)
|
||||
SetZoomFactor(fZoomFactor);
|
||||
|
||||
// Calculate new offset to center zoom on mouse.
|
||||
float x2 = center.x();
|
||||
float y2 = m_rcClient.height() - center.y();
|
||||
float x2 = static_cast<float>(center.x());
|
||||
float y2 = static_cast<float>(m_rcClient.height() - center.y());
|
||||
ofsx = -(x2 / s2 - x2 / s1 - ofsx);
|
||||
ofsy = -(y2 / s2 - y2 / s1 - ofsy);
|
||||
SetScrollOffset(ofsx, ofsy, true);
|
||||
@@ -544,21 +544,21 @@ void Q2DViewport::Update()
|
||||
QPoint Q2DViewport::WorldToView(const Vec3& wp) const
|
||||
{
|
||||
Vec3 sp = m_screenTM.TransformPoint(wp);
|
||||
QPoint p = QPoint(sp.x, sp.y);
|
||||
QPoint p = QPoint(static_cast<int>(sp.x), static_cast<int>(sp.y));
|
||||
return p;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
QPoint Q2DViewport::WorldToViewParticleEditor(const Vec3& wp, [[maybe_unused]] int width, [[maybe_unused]] int height) const //Eric@conffx implement for the children class of IDisplayViewport
|
||||
{
|
||||
Vec3 sp = m_screenTM.TransformPoint(wp);
|
||||
QPoint p = QPoint(sp.x, sp.y);
|
||||
QPoint p = QPoint(static_cast<int>(sp.x), static_cast<int>(sp.y));
|
||||
return p;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Vec3 Q2DViewport::ViewToWorld(const QPoint& vp, [[maybe_unused]] bool* collideWithTerrain, [[maybe_unused]] bool onlyTerrain, [[maybe_unused]] bool bSkipVegetation, [[maybe_unused]] bool bTestRenderMesh, [[maybe_unused]] bool* collideWithObject) const
|
||||
{
|
||||
Vec3 wp = m_screenTM_Inverted.TransformPoint(Vec3(vp.x(), vp.y(), 0));
|
||||
Vec3 wp = m_screenTM_Inverted.TransformPoint(Vec3(static_cast<f32>(vp.x()), static_cast<f32>(vp.y()), 0.0f));
|
||||
switch (m_axis)
|
||||
{
|
||||
case VPA_XY:
|
||||
@@ -694,10 +694,10 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
Matrix34 viewTM = GetViewTM().GetInverted() * m_screenTM_Inverted;
|
||||
Matrix34 viewTM_Inv = m_screenTM * GetViewTM();
|
||||
|
||||
Vec3 viewP0 = viewTM.TransformPoint(Vec3(0, 0, 0));
|
||||
Vec3 viewP1 = viewTM.TransformPoint(Vec3(m_rcClient.width(), m_rcClient.height(), 0));
|
||||
Vec3 viewP0 = viewTM.TransformPoint(Vec3(0.0f, 0.0f, 0.0f));
|
||||
Vec3 viewP1 = viewTM.TransformPoint(Vec3(static_cast<f32>(m_rcClient.width()), static_cast<f32>(m_rcClient.height()), 0.0f));
|
||||
|
||||
Vec3 viewP_Text = viewTM.TransformPoint(Vec3(0, m_rcClient.height(), 0));
|
||||
Vec3 viewP_Text = viewTM.TransformPoint(Vec3(0.0f, static_cast<f32>(m_rcClient.height()), 0.0f));
|
||||
|
||||
if (m_bShowMinorGridLines && (!m_bAutoAdjustGrids || pixelsPerGrid > 5))
|
||||
{
|
||||
@@ -806,8 +806,8 @@ void Q2DViewport::DrawGrid(DisplayContext& dc, bool bNoXNumbers)
|
||||
{
|
||||
Vec3 org = m_screenTM.TransformPoint(Vec3(0, 0, 0));
|
||||
dc.SetColor(AXIS_GRID_COLOR);
|
||||
dc.DrawLine(Vec3(org.x, 0, fZ), Vec3(org.x, height, fZ));
|
||||
dc.DrawLine(Vec3(0, org.y, fZ), Vec3(width, org.y, fZ));
|
||||
dc.DrawLine(Vec3(org.x, 0.0f, fZ), Vec3(org.x, static_cast<f32>(height), fZ));
|
||||
dc.DrawLine(Vec3(0.0f, org.y, fZ), Vec3(static_cast<f32>(width), org.y, fZ));
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
@@ -860,18 +860,18 @@ void Q2DViewport::DrawAxis(DisplayContext& dc)
|
||||
int height = m_rcClient.height();
|
||||
|
||||
int size = 25;
|
||||
Vec3 pos(30, height - 15, 1);
|
||||
Vec3 pos(30.0f, static_cast<f32>(height - 15), 1.0f);
|
||||
|
||||
dc.SetColor(colx.x, colx.y, colx.z, 1);
|
||||
dc.DrawLine(pos, pos + Vec3(size, 0, 0));
|
||||
dc.DrawLine(pos, pos + Vec3(static_cast<f32>(size), 0.0f, 0.0f));
|
||||
|
||||
dc.SetColor(coly.x, coly.y, coly.z, 1);
|
||||
dc.DrawLine(pos, pos - Vec3(0, size, 0));
|
||||
dc.SetColor(coly.x, coly.y, coly.z, 1.0f);
|
||||
dc.DrawLine(pos, pos - Vec3(0.0f, static_cast<f32>(size), 0.0f));
|
||||
|
||||
dc.SetColor(m_colorAxisText);
|
||||
pos.x -= 3;
|
||||
pos.y -= 4;
|
||||
pos.z = 2;
|
||||
pos.x -= 3.0f;
|
||||
pos.y -= 4.0f;
|
||||
pos.z = 2.0f;
|
||||
dc.Draw2dTextLabel(pos.x + size + 4, pos.y - 2, 1, xstr);
|
||||
dc.Draw2dTextLabel(pos.x + 3, pos.y - size, 1, ystr);
|
||||
dc.Draw2dTextLabel(pos.x - 5, pos.y + 5, 1, zstr);
|
||||
@@ -910,10 +910,14 @@ void Q2DViewport::DrawSelection(DisplayContext& dc)
|
||||
dc.SetColor(SELECTION_RECT_COLOR.x, SELECTION_RECT_COLOR.y, SELECTION_RECT_COLOR.z, 1);
|
||||
QPoint p1(m_selectedRect.left(), m_selectedRect.top());
|
||||
QPoint p2(m_selectedRect.right() + 1, m_selectedRect.bottom() +1);
|
||||
dc.DrawLine(Vec3(p1.x(), p1.y(), 0), Vec3(p2.x(), p1.y(), 0));
|
||||
dc.DrawLine(Vec3(p1.x(), p2.y(), 0), Vec3(p2.x(), p2.y(), 0));
|
||||
dc.DrawLine(Vec3(p1.x(), p1.y(), 0), Vec3(p1.x(), p2.y(), 0));
|
||||
dc.DrawLine(Vec3(p2.x(), p1.y(), 0), Vec3(p2.x(), p2.y(), 0));
|
||||
dc.DrawLine(
|
||||
Vec3(static_cast<f32>(p1.x()), static_cast<f32>(p1.y()), 0.0f), Vec3(static_cast<f32>(p2.x()), static_cast<f32>(p1.y()), 0.0f));
|
||||
dc.DrawLine(
|
||||
Vec3(static_cast<f32>(p1.x()), static_cast<f32>(p2.y()), 0.0f), Vec3(static_cast<f32>(p2.x()), static_cast<f32>(p2.y()), 0.0f));
|
||||
dc.DrawLine(
|
||||
Vec3(static_cast<f32>(p1.x()), static_cast<f32>(p1.y()), 0.0f), Vec3(static_cast<f32>(p1.x()), static_cast<f32>(p2.y()), 0.0f));
|
||||
dc.DrawLine(
|
||||
Vec3(static_cast<f32>(p2.x()), static_cast<f32>(p1.y()), 0.0f), Vec3(static_cast<f32>(p2.x()), static_cast<f32>(p2.y()), 0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1038,16 +1042,16 @@ AABB Q2DViewport::GetWorldBounds(const QPoint& pnt1, const QPoint& pnt2)
|
||||
{
|
||||
case VPA_XY:
|
||||
case VPA_YX:
|
||||
box.min.z = -maxSize;
|
||||
box.max.z = maxSize;
|
||||
box.min.z = static_cast<f32>(-maxSize);
|
||||
box.max.z = static_cast<f32>(maxSize);
|
||||
break;
|
||||
case VPA_XZ:
|
||||
box.min.y = -maxSize;
|
||||
box.max.y = maxSize;
|
||||
box.min.y = static_cast<f32>(-maxSize);
|
||||
box.max.y = static_cast<f32>(maxSize);
|
||||
break;
|
||||
case VPA_YZ:
|
||||
box.min.x = -maxSize;
|
||||
box.max.x = maxSize;
|
||||
box.min.x = static_cast<f32>(-maxSize);
|
||||
box.max.x = static_cast<f32>(maxSize);
|
||||
break;
|
||||
}
|
||||
return box;
|
||||
@@ -1076,32 +1080,32 @@ void Q2DViewport::OnDragSelectRectangle(const QRect &rect, [[maybe_unused]] bool
|
||||
switch (m_axis)
|
||||
{
|
||||
case VPA_XY:
|
||||
box.min.z = -maxSize;
|
||||
box.max.z = maxSize;
|
||||
box.min.z = static_cast<f32>(-maxSize);
|
||||
box.max.z = static_cast<f32>(maxSize);
|
||||
|
||||
w = box.max.x - box.min.x;
|
||||
h = box.max.y - box.min.y;
|
||||
sprintf_s(szNewStatusText, "X:%g Y:%g W:%g H:%g", org.x, org.y, w, h);
|
||||
break;
|
||||
case VPA_YX:
|
||||
box.min.z = -maxSize;
|
||||
box.max.z = maxSize;
|
||||
box.min.z = static_cast<f32>(-maxSize);
|
||||
box.max.z = static_cast<f32>(maxSize);
|
||||
|
||||
w = box.max.y - box.min.y;
|
||||
h = box.max.x - box.min.x;
|
||||
sprintf_s(szNewStatusText, "X:%g Y:%g W:%g H:%g", org.x, org.y, w, h);
|
||||
break;
|
||||
case VPA_XZ:
|
||||
box.min.y = -maxSize;
|
||||
box.max.y = maxSize;
|
||||
box.min.y = static_cast<f32>(-maxSize);
|
||||
box.max.y = static_cast<f32>(maxSize);
|
||||
|
||||
w = box.max.x - box.min.x;
|
||||
h = box.max.z - box.min.z;
|
||||
sprintf_s(szNewStatusText, "X:%g Z:%g W:%g H:%g", org.x, org.z, w, h);
|
||||
break;
|
||||
case VPA_YZ:
|
||||
box.min.x = -maxSize;
|
||||
box.max.x = maxSize;
|
||||
box.min.x = static_cast<f32>(-maxSize);
|
||||
box.max.x = static_cast<f32>(maxSize);
|
||||
|
||||
w = box.max.y - box.min.y;
|
||||
h = box.max.z - box.min.z;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
//evaluate size
|
||||
XmlString xmlStr = m_undoCtx.node->getXML();
|
||||
m_size = sizeof(CUndoBaseLibraryItem);
|
||||
m_size += xmlStr.GetAllocatedMemory();
|
||||
m_size += static_cast<int>(xmlStr.GetAllocatedMemory());
|
||||
m_size += m_itemPath.length();
|
||||
m_size += m_description.length();
|
||||
}
|
||||
@@ -87,7 +87,7 @@ protected:
|
||||
libItem->Serialize(m_redoCtx);
|
||||
|
||||
XmlString xmlStr = m_redoCtx.node->getXML();
|
||||
m_size += xmlStr.GetAllocatedMemory();
|
||||
m_size += static_cast<int>(xmlStr.GetAllocatedMemory());
|
||||
}
|
||||
|
||||
//load previous saved data
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
virtual IDataBaseLibrary* AddLibrary(const QString& library, bool bIsLevelLibrary = false, bool bIsLoading = true) override;
|
||||
virtual void DeleteLibrary(const QString& library, bool forceDeleteLevel = false) override;
|
||||
//! Get number of libraries.
|
||||
virtual int GetLibraryCount() const override { return m_libs.size(); };
|
||||
virtual int GetLibraryCount() const override { return static_cast<int>(m_libs.size()); };
|
||||
//! Get number of modified libraries.
|
||||
virtual int GetModifiedLibraryCount() const override;
|
||||
|
||||
|
||||
@@ -529,8 +529,8 @@ QString CEditorCommandManager::ExecuteAndLogReturn(CCommand* pCommand, const CCo
|
||||
void CEditorCommandManager::GetArgsFromString(const AZStd::string& argsTxt, CCommand::CArgs& argList)
|
||||
{
|
||||
const char quoteSymbol = '\'';
|
||||
int curPos = 0;
|
||||
int prevPos = 0;
|
||||
size_t curPos = 0;
|
||||
size_t prevPos = 0;
|
||||
AZStd::vector<AZStd::string> tokens;
|
||||
AZ::StringFunc::Tokenize(argsTxt, tokens, ' ');
|
||||
for(AZStd::string& arg : tokens)
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Config
|
||||
|
||||
uint32 CConfigGroup::GetVarCount()
|
||||
{
|
||||
return m_vars.size();
|
||||
return static_cast<uint32>(m_vars.size());
|
||||
}
|
||||
|
||||
IConfigVar* CConfigGroup::GetVar(const char* szName)
|
||||
|
||||
@@ -72,7 +72,7 @@ void CColorGradientCtrl::resizeEvent(QResizeEvent* event)
|
||||
m_grid.rect = m_rcGradient;
|
||||
if (m_bNoZoom)
|
||||
{
|
||||
m_grid.zoom.x = m_grid.rect.width();
|
||||
m_grid.zoom.x = static_cast<f32>(m_grid.rect.width());
|
||||
}
|
||||
|
||||
m_rcKeys = rc;
|
||||
@@ -106,11 +106,6 @@ QPoint CColorGradientCtrl::KeyToPoint(int nKey)
|
||||
QPoint CColorGradientCtrl::TimeToPoint(float time)
|
||||
{
|
||||
return QPoint(m_grid.WorldToClient(Vec2(time, 0)).x(), m_rcGradient.height() / 2);
|
||||
|
||||
QPoint point;
|
||||
point.rx() = (time - m_fMinTime) * (m_rcGradient.width() / (m_fMaxTime - m_fMinTime)) + m_rcGradient.left();
|
||||
point.ry() = m_rcGradient.height() / 2;
|
||||
return point;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -220,7 +220,7 @@ void ConsoleLineEdit::keyPressEvent(QKeyEvent* ev)
|
||||
}
|
||||
|
||||
// If a history command was reused directly via up arrow enter, do not reset history index
|
||||
if (m_history.size() > 0 && m_historyIndex < m_history.size() && m_history[m_historyIndex] == str)
|
||||
if (m_history.size() > 0 && m_historyIndex < static_cast<unsigned int>(m_history.size()) && m_history[m_historyIndex] == str)
|
||||
{
|
||||
m_bReusedHistory = true;
|
||||
}
|
||||
@@ -833,15 +833,15 @@ static void SetEditorRange(EditorType* editor, IVariable* var)
|
||||
// If this variable has custom limits set, then use that as the min/max
|
||||
// Otherwise, the min/max for the input box will be bounded by the type
|
||||
// limit, but the slider will be constricted to a smaller default range
|
||||
static const double defaultMin = -100.0f;
|
||||
static const double defaultMax = 100.0f;
|
||||
static const float defaultMin = -100.0f;
|
||||
static const float defaultMax = 100.0f;
|
||||
if (var->HasCustomLimits())
|
||||
{
|
||||
editor->setRange(min, max);
|
||||
editor->setRange(static_cast<typename EditorType::value_type>(min), static_cast<typename EditorType::value_type>(max));
|
||||
}
|
||||
else
|
||||
{
|
||||
editor->setSoftRange(defaultMin, defaultMax);
|
||||
editor->setSoftRange(static_cast<typename EditorType::value_type>(defaultMin), static_cast<typename EditorType::value_type>(defaultMax));
|
||||
}
|
||||
|
||||
// Set the step size. The default variable step is 0, so if it's
|
||||
@@ -850,7 +850,7 @@ static void SetEditorRange(EditorType* editor, IVariable* var)
|
||||
// use that for the int values
|
||||
if (step > 0)
|
||||
{
|
||||
editor->spinbox()->setSingleStep(step);
|
||||
editor->spinbox()->setSingleStep(static_cast<int>(step));
|
||||
}
|
||||
else if (auto doubleSpinBox = qobject_cast<AzQtComponents::DoubleSpinBox*>(editor->spinbox()))
|
||||
{
|
||||
|
||||
@@ -175,7 +175,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
penSpikes = penColor;
|
||||
painter.setPen(Qt::black);
|
||||
painter.setBrush(Qt::white);
|
||||
rcGraph = QRect(QPoint(m_graphMargin, m_graphMargin), QPoint(abs(rc.width() - m_graphMargin), abs(rc.height() * m_graphHeightPercent)));
|
||||
rcGraph = QRect(QPoint(m_graphMargin, m_graphMargin), QPoint(abs(rc.width() - m_graphMargin), static_cast<int>(abs(rc.height() * m_graphHeightPercent))));
|
||||
painter.drawRect(rcGraph);
|
||||
painter.setPen(penSpikes);
|
||||
|
||||
@@ -193,7 +193,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
{
|
||||
float scale = 0;
|
||||
|
||||
i = ((float)x / graphWidth) * (kNumColorLevels - 1);
|
||||
i = static_cast<int>(((float)x / graphWidth) * (kNumColorLevels - 1));
|
||||
i = CLAMP(i, 0, kNumColorLevels - 1);
|
||||
|
||||
switch (m_drawMode)
|
||||
@@ -244,8 +244,8 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
crtX = rcGraph.left() + x + 1;
|
||||
painter.drawLine(crtX, graphBottom, crtX, graphBottom - scale * graphHeight);
|
||||
crtX = static_cast<int>(rcGraph.left() + x + 1);
|
||||
painter.drawLine(crtX, graphBottom, crtX, static_cast<int>(graphBottom - scale * graphHeight));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -258,9 +258,9 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
|
||||
for (size_t x = 0, xCount = abs(rcGraph.width()); x < xCount; ++x)
|
||||
{
|
||||
i = ((float)x / graphWidth) * (kNumColorLevels - 1);
|
||||
i = static_cast<int>(((float)x / graphWidth) * (kNumColorLevels - 1));
|
||||
i = CLAMP(i, 0, kNumColorLevels - 1);
|
||||
crtX = rcGraph.left() + x + 1;
|
||||
crtX = static_cast<UINT>(rcGraph.left() + x + 1);
|
||||
scaleR = scaleG = scaleB = scaleA = 0;
|
||||
|
||||
if (m_maxCount[0])
|
||||
@@ -283,10 +283,10 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
scaleA = (float)m_count[3][i] / m_maxCount[3];
|
||||
}
|
||||
|
||||
heightR = graphBottom - scaleR * graphHeight;
|
||||
heightG = graphBottom - scaleG * graphHeight;
|
||||
heightB = graphBottom - scaleB * graphHeight;
|
||||
heightA = graphBottom - scaleA * graphHeight;
|
||||
heightR = static_cast<int>(graphBottom - scaleR * graphHeight);
|
||||
heightG = static_cast<int>(graphBottom - scaleG * graphHeight);
|
||||
heightB = static_cast<int>(graphBottom - scaleB * graphHeight);
|
||||
heightA = static_cast<int>(graphBottom - scaleA * graphHeight);
|
||||
|
||||
if (lastHeight[0] == INT_MAX)
|
||||
{
|
||||
@@ -350,7 +350,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
for (size_t x = 0, xCount = abs(rcGraph.width()); x < xCount; ++x)
|
||||
{
|
||||
pos = (float)x / graphWidth;
|
||||
i = (float)((int)(pos * kNumColorLevels) % aThirdOfNumColorLevels) / aThirdOfNumColorLevels * kNumColorLevels;
|
||||
i = static_cast<int>((float)((int)(pos * kNumColorLevels) % aThirdOfNumColorLevels) / aThirdOfNumColorLevels * kNumColorLevels);
|
||||
i = CLAMP(i, 0, kNumColorLevels - 1);
|
||||
scale = 0;
|
||||
|
||||
@@ -385,7 +385,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
}
|
||||
|
||||
painter.setPen(pPen);
|
||||
painter.drawLine(rcGraph.left() + x + 1, graphBottom, rcGraph.left() + x + 1, graphBottom - scale * graphHeight);
|
||||
painter.drawLine(rcGraph.left() + static_cast<int>(x) + 1, graphBottom, rcGraph.left() + static_cast<int>(x) + 1, static_cast<int>(graphBottom - scale * graphHeight));
|
||||
}
|
||||
|
||||
// then draw 3 lines so we separate the channels
|
||||
|
||||
@@ -422,7 +422,7 @@ void QBitmapPreviewDialogImp::paintEvent(QPaintEvent* e)
|
||||
|
||||
|
||||
curr_x = histogramRect.left() + x + 1;
|
||||
int i = ((float)x / (graphWidth - 1)) * (CImageHistogram::kNumColorLevels - 1);
|
||||
int i = static_cast<int>(((float)x / (graphWidth - 1)) * (CImageHistogram::kNumColorLevels - 1));
|
||||
if (m_histrogramMode == eHistogramMode_SplitRGB)
|
||||
{
|
||||
// Filter out to area which we are interested
|
||||
@@ -446,7 +446,7 @@ void QBitmapPreviewDialogImp::paintEvent(QPaintEvent* e)
|
||||
scale = (float)m_histogram.m_count[c][i] / m_histogram.m_maxCount[c];
|
||||
}
|
||||
|
||||
int height = graphBottom - graphHeight * scale;
|
||||
int height = static_cast<int>(graphBottom - graphHeight * scale);
|
||||
if (last_height == INT_MAX)
|
||||
{
|
||||
last_height = height;
|
||||
|
||||
@@ -56,8 +56,8 @@ CReflectedVarAnimation AnimationPropertyCtrl::value() const
|
||||
void AnimationPropertyCtrl::OnApplyClicked()
|
||||
{
|
||||
QStringList cSelectedAnimations;
|
||||
size_t nTotalAnimations(0);
|
||||
size_t nCurrentAnimation(0);
|
||||
int nTotalAnimations(0);
|
||||
int nCurrentAnimation(0);
|
||||
|
||||
QString combinedString = GetIEditor()->GetResourceSelectorHost()->GetGlobalSelection("animation");
|
||||
SplitString(combinedString, cSelectedAnimations, ',');
|
||||
|
||||
@@ -203,7 +203,7 @@ void ReflectedPropertyControl::CreateItems(XmlNodeRef node, CVarBlockPtr& outBlo
|
||||
outBlockPtr = new CVarBlock;
|
||||
for (size_t i = 0, iGroupCount(node->getChildCount()); i < iGroupCount; ++i)
|
||||
{
|
||||
XmlNodeRef groupNode = node->getChild(i);
|
||||
XmlNodeRef groupNode = node->getChild(static_cast<int>(i));
|
||||
|
||||
if (groupNode->haveAttr("hidden"))
|
||||
{
|
||||
@@ -308,7 +308,7 @@ void ReflectedPropertyControl::CreateItems(XmlNodeRef node, CVarBlockPtr& outBlo
|
||||
int nMin(0), nMax(0);
|
||||
if (child->getAttr("min", nMin) && child->getAttr("max", nMax))
|
||||
{
|
||||
intVar->SetLimits(nMin, nMax);
|
||||
intVar->SetLimits(static_cast<float>(nMin), static_cast<float>(nMax));
|
||||
}
|
||||
}
|
||||
else if (!azstricmp(type, "float"))
|
||||
@@ -560,7 +560,7 @@ void ReflectedPropertyControl::RequestPropertyContextMenu(AzToolsFramework::Inst
|
||||
|
||||
// Popup Menu with Event selection.
|
||||
QMenu menu;
|
||||
UINT i = 0;
|
||||
unsigned int i = 0;
|
||||
|
||||
const int ePPA_CustomItemBase = 10; // reserved from 10 to 99
|
||||
const int ePPA_CustomPopupBase = 100; // reserved from 100 to x*100+100 where x is size of m_customPopupMenuPopups
|
||||
@@ -595,12 +595,12 @@ void ReflectedPropertyControl::RequestPropertyContextMenu(AzToolsFramework::Inst
|
||||
action->setData(ePPA_CustomItemBase + i);
|
||||
}
|
||||
|
||||
for (UINT j = 0; j < m_customPopupMenuPopups.size(); ++j)
|
||||
for (unsigned int j = 0; j < m_customPopupMenuPopups.size(); ++j)
|
||||
{
|
||||
SCustomPopupMenu* pMenuInfo = &m_customPopupMenuPopups[j];
|
||||
QMenu* pSubMenu = menu.addMenu(pMenuInfo->m_text);
|
||||
|
||||
for (UINT k = 0; k < pMenuInfo->m_subMenuText.size(); ++k)
|
||||
for (UINT k = 0; k < static_cast<UINT>(pMenuInfo->m_subMenuText.size()); ++k)
|
||||
{
|
||||
const UINT uID = ePPA_CustomPopupBase + ePPA_CustomPopupBase * j + k;
|
||||
QAction *action = pSubMenu->addAction(pMenuInfo->m_subMenuText[k]);
|
||||
|
||||
@@ -39,20 +39,20 @@ namespace {
|
||||
hardMin = desc.m_bHardMin;
|
||||
hardMax = desc.m_bHardMax;
|
||||
}
|
||||
reflectedVar->m_softMinVal = min;
|
||||
reflectedVar->m_softMaxVal = max;
|
||||
reflectedVar->m_softMinVal = static_cast<R>(min);
|
||||
reflectedVar->m_softMaxVal = static_cast<R>(max);
|
||||
|
||||
if (hardMin)
|
||||
{
|
||||
reflectedVar->m_minVal = min;
|
||||
reflectedVar->m_minVal = static_cast<R>(min);
|
||||
}
|
||||
else
|
||||
{
|
||||
reflectedVar->m_minVal = std::numeric_limits<int>::lowest();
|
||||
reflectedVar->m_minVal = std::numeric_limits<R>::lowest();
|
||||
}
|
||||
if (hardMax)
|
||||
{
|
||||
reflectedVar->m_maxVal = max;
|
||||
reflectedVar->m_maxVal = static_cast<R>(max);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -64,9 +64,9 @@ namespace {
|
||||
../Code/Editor/Controls/ReflectedPropertyControl/ReflectedVarWrapper.cpp:59:38: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
|
||||
reflectedVar->m_maxVal = std::numeric_limits<int>::max();
|
||||
*/
|
||||
reflectedVar->m_maxVal = static_cast<float>(std::numeric_limits<int>::max());
|
||||
reflectedVar->m_maxVal = static_cast<R>(std::numeric_limits<int>::max());
|
||||
}
|
||||
reflectedVar->m_stepSize = step;
|
||||
reflectedVar->m_stepSize = static_cast<R>(step);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +95,9 @@ void ReflectedVarIntAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
|
||||
{
|
||||
int intValue;
|
||||
pVariable->Get(intValue);
|
||||
value = intValue;
|
||||
value = static_cast<float>(intValue);
|
||||
}
|
||||
m_reflectedVar->m_value = std::round(value * m_valueMultiplier);
|
||||
m_reflectedVar->m_value = static_cast<int>(std::round(value * m_valueMultiplier));
|
||||
}
|
||||
|
||||
void ReflectedVarIntAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
|
||||
@@ -362,14 +362,14 @@ void ReflectedVarColorAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
|
||||
Vec3 v(0, 0, 0);
|
||||
pVariable->Get(v);
|
||||
const QColor col = ColorLinearToGamma(ColorF(v.x, v.y, v.z));
|
||||
m_reflectedVar->m_color.Set(col.redF(), col.greenF(), col.blueF());
|
||||
m_reflectedVar->m_color.Set(static_cast<float>(col.redF()), static_cast<float>(col.greenF()), static_cast<float>(col.blueF()));
|
||||
}
|
||||
else
|
||||
{
|
||||
int col(0);
|
||||
pVariable->Get(col);
|
||||
const QColor qcolor = ColorToQColor((uint32)col);
|
||||
m_reflectedVar->m_color.Set(qcolor.redF(), qcolor.greenF(), qcolor.blueF());
|
||||
m_reflectedVar->m_color.Set(static_cast<float>(qcolor.redF()), static_cast<float>(qcolor.greenF()), static_cast<float>(qcolor.blueF()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,9 +382,9 @@ void ReflectedVarColorAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
|
||||
}
|
||||
else
|
||||
{
|
||||
int ir = m_reflectedVar->m_color.GetX() * 255.0f;
|
||||
int ig = m_reflectedVar->m_color.GetY() * 255.0f;
|
||||
int ib = m_reflectedVar->m_color.GetZ() * 255.0f;
|
||||
int ir = static_cast<int>(m_reflectedVar->m_color.GetX() * 255.0f);
|
||||
int ig = static_cast<int>(m_reflectedVar->m_color.GetY() * 255.0f);
|
||||
int ib = static_cast<int>(m_reflectedVar->m_color.GetZ() * 255.0f);
|
||||
|
||||
pVariable->Set(static_cast<int>(RGB(ir, ig, ib)));
|
||||
}
|
||||
|
||||
@@ -86,13 +86,13 @@ QPoint CSplineCtrl::KeyToPoint(int nKey)
|
||||
QPoint CSplineCtrl::TimeToPoint(float time)
|
||||
{
|
||||
QPoint point;
|
||||
point.setX((time - m_fMinTime) * (m_rcSpline.width() / (m_fMaxTime - m_fMinTime)) + m_rcSpline.left());
|
||||
point.setX(static_cast<int>((time - m_fMinTime) * (m_rcSpline.width() / (m_fMaxTime - m_fMinTime)) + m_rcSpline.left()));
|
||||
float val = 0;
|
||||
if (m_pSpline)
|
||||
{
|
||||
m_pSpline->InterpolateFloat(time, val);
|
||||
}
|
||||
point.setY((floor((m_fMaxValue - val) * (m_rcSpline.height() / (m_fMaxValue - m_fMinValue)) + 0.5f) + m_rcSpline.top()));
|
||||
point.setY(static_cast<int>((floor((m_fMaxValue - val) * (m_rcSpline.height() / (m_fMaxValue - m_fMinValue)) + 0.5f) + m_rcSpline.top())));
|
||||
return point;
|
||||
}
|
||||
|
||||
|
||||
@@ -641,7 +641,7 @@ QPoint AbstractSplineWidget::TimeToPoint(float time, ISplineInterpolator* pSplin
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float AbstractSplineWidget::TimeToXOfs(float x)
|
||||
{
|
||||
return WorldToClient(Vec2(float(x), 0.0f)).x();
|
||||
return static_cast<float>(WorldToClient(Vec2(float(x), 0.0f)).x());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -832,8 +832,8 @@ void SplineWidget::DrawSpline(QPainter* painter, SSplineInfo& splineInfo, float
|
||||
int nTotalNumberOfDimensions(0);
|
||||
int nCurrentDimension(0);
|
||||
|
||||
int left = TimeToXOfs(startTime);//rcClip.left;
|
||||
int right = TimeToXOfs(endTime);//rcClip.right;
|
||||
int left = static_cast<int>(TimeToXOfs(startTime));//rcClip.left;
|
||||
int right = static_cast<int>(TimeToXOfs(endTime));//rcClip.right;
|
||||
QPoint p0 = TimeToPoint(pSpline->GetKeyTime(0), pSpline);
|
||||
QPoint p1 = TimeToPoint(pSpline->GetKeyTime(pSpline->GetKeyCount() - 1), pSpline);
|
||||
|
||||
@@ -898,7 +898,7 @@ void SplineWidget::DrawSpline(QPainter* painter, SSplineInfo& splineInfo, float
|
||||
|
||||
if ((x == right && pointsInLine >= 0) || (pointsInLine > 0 && fabs(lineStart.y() + gradient * (pt.x() - lineStart.x()) - pt.y()) > 1.0f))
|
||||
{
|
||||
lineStart = QPoint(pt.x() - 1, lineStart.y() + gradient * (pt.x() - 1 - lineStart.x()));
|
||||
lineStart = QPoint(pt.x() - 1, static_cast<int>(lineStart.y() + gradient * (pt.x() - 1 - lineStart.x())));
|
||||
path.lineTo(lineStart);
|
||||
gradient = float(pt.y() - lineStart.y()) / (pt.x() - lineStart.x());
|
||||
pointsInLine = 1;
|
||||
@@ -1063,7 +1063,7 @@ void SplineWidget::DrawTimeMarker(QPainter* painter)
|
||||
float x = TimeToXOfs(m_fTimeMarker);
|
||||
if (x >= m_rcSpline.left() && x <= m_rcSpline.right() + 1)
|
||||
{
|
||||
painter->drawLine(x, m_rcSpline.top(), x, m_rcSpline.bottom() + 1);
|
||||
painter->drawLine(static_cast<int>(x), m_rcSpline.top(), static_cast<int>(x), m_rcSpline.bottom() + 1);
|
||||
}
|
||||
painter->setPen(pOldPen);
|
||||
}
|
||||
@@ -1583,7 +1583,7 @@ bool AbstractSplineWidget::IsKeySelected(ISplineInterpolator* pSpline, int nKey,
|
||||
int AbstractSplineWidget::GetNumSelected()
|
||||
{
|
||||
int nSelected = 0;
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
if (ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline)
|
||||
{
|
||||
@@ -1818,7 +1818,7 @@ AbstractSplineWidget::EHitCode AbstractSplineWidget::HitTest(const QPoint& point
|
||||
}
|
||||
|
||||
// For each Spline...
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
ISplineInterpolator* pDetailSpline = m_splines[splineIndex].pDetailSpline;
|
||||
@@ -1856,7 +1856,7 @@ AbstractSplineWidget::EHitCode AbstractSplineWidget::HitTest(const QPoint& point
|
||||
// Check tangent handles first.
|
||||
{
|
||||
QPoint incomingHandlePt, outgoingHandlePt, pt;
|
||||
if (GetTangentHandlePts(incomingHandlePt, pt, outgoingHandlePt, splineIndex, i, nCurrentDimension))
|
||||
if (GetTangentHandlePts(incomingHandlePt, pt, outgoingHandlePt, static_cast<int>(splineIndex), static_cast<int>(i), nCurrentDimension))
|
||||
{
|
||||
// For the incoming handle
|
||||
if (abs(incomingHandlePt.x() - point.x()) < 4 && abs(incomingHandlePt.y() - point.y()) < 4)
|
||||
@@ -1973,7 +1973,7 @@ void AbstractSplineWidget::ScaleAmplitudeKeys(float time, float startValue, floa
|
||||
m_nHitKeyIndex = -1;
|
||||
m_nHitDimension = -1;
|
||||
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
@@ -2077,7 +2077,7 @@ void AbstractSplineWidget::TimeScaleKeys(float time, float startTime, float endT
|
||||
|
||||
float affectedRangeMin = FLT_MAX;
|
||||
float affectedRangeMax = -FLT_MAX;
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
@@ -2145,8 +2145,8 @@ void AbstractSplineWidget::TimeScaleKeys(float time, float startTime, float endT
|
||||
}
|
||||
}
|
||||
|
||||
int rangeMin = TimeToXOfs(affectedRangeMin);
|
||||
int rangeMax = TimeToXOfs(affectedRangeMax);
|
||||
int rangeMin = static_cast<int>(TimeToXOfs(affectedRangeMin));
|
||||
int rangeMax = static_cast<int>(TimeToXOfs(affectedRangeMax));
|
||||
|
||||
if (m_timeRange.start == affectedRangeMin)
|
||||
{
|
||||
@@ -2184,7 +2184,7 @@ void AbstractSplineWidget::ValueScaleKeys(float startValue, float endValue)
|
||||
m_nHitKeyIndex = -1;
|
||||
m_nHitDimension = -1;
|
||||
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
@@ -2223,7 +2223,7 @@ void AbstractSplineWidget::MoveSelectedKeys(Vec2 offset, bool copyKeys)
|
||||
}
|
||||
|
||||
// For each spline...
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
@@ -2298,7 +2298,7 @@ void AbstractSplineWidget::RemoveSelectedKeys()
|
||||
m_pHitDetailSpline = nullptr;
|
||||
m_nHitKeyIndex = -1;
|
||||
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
@@ -2338,7 +2338,7 @@ void AbstractSplineWidget::RemoveSelectedKeyTimesImpl()
|
||||
StoreUndo();
|
||||
SendNotifyEvent(SPLN_BEFORE_CHANGE);
|
||||
|
||||
for (int splineIndex = 0, end = m_splines.size(); splineIndex < end; ++splineIndex)
|
||||
for (size_t splineIndex = 0, end = m_splines.size(); splineIndex < end; ++splineIndex)
|
||||
{
|
||||
std::vector<KeyTime>::iterator itTime = m_keyTimes.begin(), endTime = m_keyTimes.end();
|
||||
for (int keyIndex = 0, endIndex = m_splines[splineIndex].pSpline->GetKeyCount(); keyIndex < endIndex; )
|
||||
@@ -2376,9 +2376,9 @@ void AbstractSplineWidget::RedrawWindowAroundMarker()
|
||||
{
|
||||
UpdateKeyTimes();
|
||||
std::vector<KeyTime>::iterator itKeyTime = std::lower_bound(m_keyTimes.begin(), m_keyTimes.end(), KeyTime(m_fTimeMarker, 0));
|
||||
int keyTimeIndex = (itKeyTime != m_keyTimes.end() ? itKeyTime - m_keyTimes.begin() : m_keyTimes.size());
|
||||
int redrawRangeStart = (keyTimeIndex >= 2 ? TimeToXOfs(m_keyTimes[keyTimeIndex - 2].time) : m_rcSpline.left());
|
||||
int redrawRangeEnd = (keyTimeIndex < int(m_keyTimes.size()) - 2 ? TimeToXOfs(m_keyTimes[keyTimeIndex + 2].time) : m_rcSpline.right() + 1);
|
||||
size_t keyTimeIndex = (itKeyTime != m_keyTimes.end() ? itKeyTime - m_keyTimes.begin() : m_keyTimes.size());
|
||||
int redrawRangeStart = (keyTimeIndex >= 2 ? static_cast<int>(TimeToXOfs(m_keyTimes[keyTimeIndex - 2].time)) : m_rcSpline.left());
|
||||
int redrawRangeEnd = (keyTimeIndex < m_keyTimes.size() - 2 ? static_cast<int>(TimeToXOfs(m_keyTimes[keyTimeIndex + 2].time)) : m_rcSpline.right() + 1);
|
||||
|
||||
QRect rc(QPoint(redrawRangeStart, m_rcSpline.top()), QPoint(redrawRangeEnd, m_rcSpline.bottom() + 1) - QPoint(1, 1));
|
||||
rc = rc.normalized().intersected(m_rcSpline);
|
||||
@@ -2478,7 +2478,7 @@ void AbstractSplineWidget::ClearSelection()
|
||||
{
|
||||
ConditionalStoreUndo();
|
||||
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
@@ -2521,7 +2521,7 @@ void AbstractSplineWidget::StoreUndo()
|
||||
if (CUndo::IsRecording() && !m_pCurrentUndo)
|
||||
{
|
||||
std::vector<ISplineInterpolator*> splines(m_splines.size());
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
splines[splineIndex] = m_splines[splineIndex].pSpline;
|
||||
}
|
||||
@@ -2564,7 +2564,7 @@ void AbstractSplineWidget::DuplicateSelectedKeys()
|
||||
|
||||
using KeysToAddContainer = std::vector<CKeyCopyInfo>;
|
||||
KeysToAddContainer keysToInsert;
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
@@ -2664,7 +2664,7 @@ void AbstractSplineWidget::KeyAll()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void AbstractSplineWidget::SelectAll()
|
||||
{
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
@@ -2815,7 +2815,7 @@ void AbstractSplineWidget::SelectRectangle(const QRect& rc, bool bSelect)
|
||||
{
|
||||
std::swap(t0, t1);
|
||||
}
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
ISplineInterpolator* pDetailSpline = m_splines[splineIndex].pDetailSpline;
|
||||
@@ -3031,7 +3031,7 @@ void AbstractSplineWidget::ModifySelectedKeysFlags(int nRemoveFlags, int nAddFla
|
||||
|
||||
SendNotifyEvent(SPLN_BEFORE_CHANGE);
|
||||
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
for (size_t splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
@@ -3188,7 +3188,7 @@ void AbstractSplineWidget::GotoNextKey(bool previousKey)
|
||||
{
|
||||
bool boFoundTheSelectedKey(false);
|
||||
|
||||
for (int splineIndex = 0, endSpline = m_splines.size(); splineIndex < endSpline; ++splineIndex)
|
||||
for (size_t splineIndex = 0, endSpline = m_splines.size(); splineIndex < endSpline; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
for (int i = 0; i < pSpline->GetKeyCount(); i++)
|
||||
@@ -3230,7 +3230,7 @@ void AbstractSplineWidget::GotoNextKey(bool previousKey)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int splineIndex = 0, endSpline = m_splines.size(); splineIndex < endSpline; ++splineIndex)
|
||||
for (size_t splineIndex = 0, endSpline = m_splines.size(); splineIndex < endSpline; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
@@ -3281,7 +3281,7 @@ void AbstractSplineWidget::RemoveAllKeysButThis()
|
||||
{
|
||||
std::vector<int> keys;
|
||||
|
||||
for (int splineIndex = 0, endSpline = m_splines.size(); splineIndex < endSpline; ++splineIndex)
|
||||
for (size_t splineIndex = 0, endSpline = m_splines.size(); splineIndex < endSpline; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
void AddSpline(ISplineInterpolator * pSpline, ISplineInterpolator * pDetailSpline, QColor anColorArray[4]);
|
||||
void RemoveSpline(ISplineInterpolator* pSpline);
|
||||
void RemoveAllSplines();
|
||||
int GetSplineCount() const { return m_splines.size(); }
|
||||
int GetSplineCount() const { return static_cast<int>(m_splines.size()); }
|
||||
ISplineInterpolator* GetSpline(int nIndex) const { return m_splines[nIndex].pSpline; }
|
||||
|
||||
void SetTimeMarker(float fTime);
|
||||
|
||||
@@ -53,7 +53,7 @@ void CTextEditorCtrl::LoadFile(const QString& sFileName)
|
||||
size_t length = file.GetLength();
|
||||
|
||||
QByteArray text;
|
||||
text.resize(length);
|
||||
text.resize(static_cast<int>(length));
|
||||
file.ReadRaw(text.data(), length);
|
||||
|
||||
setPlainText(text);
|
||||
|
||||
@@ -25,9 +25,9 @@ static const QColor ltgrayCol = QColor(110, 110, 110);
|
||||
|
||||
QColor InterpolateColor(const QColor& c1, const QColor& c2, float fraction)
|
||||
{
|
||||
const int r = (c2.red() - c1.red()) * fraction + c1.red();
|
||||
const int g = (c2.green() - c1.green()) * fraction + c1.green();
|
||||
const int b = (c2.blue() - c1.blue()) * fraction + c1.blue();
|
||||
const int r = static_cast<int>(static_cast<float>(c2.red() - c1.red()) * fraction + c1.red());
|
||||
const int g = static_cast<int>(static_cast<float>(c2.green() - c1.green()) * fraction + c1.green());
|
||||
const int b = static_cast<int>(static_cast<float>(c2.blue() - c1.blue()) * fraction + c1.blue());
|
||||
return QColor(r, g, b);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ float TimelineWidget::SnapTime(float time)
|
||||
{
|
||||
double t = floor((double)time * m_ticksStep + 0.5);
|
||||
t = t / m_ticksStep;
|
||||
return t;
|
||||
return static_cast<float>(t);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -153,10 +153,10 @@ void TimelineWidget::DrawTicks(QPainter* painter)
|
||||
painter->setPen(redpen);
|
||||
int x = TimeToClient(m_fTimeMarker);
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->drawRect(QRect(QPoint(x - 3, rc.top()), QPoint(x + 2, rc.bottom())));
|
||||
painter->drawRect(QRect(QPoint(x - 3, static_cast<int>(rc.top())), QPoint(x + 2, static_cast<int>(rc.bottom()))));
|
||||
|
||||
painter->setPen(redpen);
|
||||
painter->drawLine(x, rc.top(), x, rc.bottom());
|
||||
painter->drawLine(x, static_cast<int>(rc.top()), x, static_cast<int>(rc.bottom()));
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
|
||||
// Draw vertical line showing current time.
|
||||
@@ -190,7 +190,7 @@ void TimelineWidget::DrawTicks(QPainter* painter)
|
||||
float keyTime = (m_pKeyTimeSet ? m_pKeyTimeSet->GetKeyTime(keyTimeIndex) : 0.0f);
|
||||
|
||||
int x2 = TimeToClient(keyTime);
|
||||
painter->drawRect(QRect(QPoint(x2 - 1, rc.top()), QPoint(x2 + 2, rc.bottom())));
|
||||
painter->drawRect(QRect(QPoint(x2 - 1, static_cast<int>(rc.top())), QPoint(x2 + 2, static_cast<int>(rc.bottom()))));
|
||||
}
|
||||
|
||||
painter->setPen(pOldPen);
|
||||
|
||||
@@ -613,7 +613,7 @@ public:
|
||||
}
|
||||
|
||||
// Get boolean options
|
||||
const int numOptions = options.size();
|
||||
const int numOptions = static_cast<int>(options.size());
|
||||
for (int i = 0; i < numOptions; ++i)
|
||||
{
|
||||
options[i].second = parser.isSet(options[i].first);
|
||||
@@ -3240,7 +3240,7 @@ bool CCryEditApp::CreateLevel(bool& wasCreateLevelOperationCancelled)
|
||||
{
|
||||
QFileInfo info(fullyQualifiedLevelName);
|
||||
const AZStd::string rawProjectDirectory = Path::GetEditingGameDataFolder();
|
||||
const QString projectDirectory = QDir::toNativeSeparators(QString::fromUtf8(rawProjectDirectory.data(), rawProjectDirectory.size()));
|
||||
const QString projectDirectory = QDir::toNativeSeparators(QString::fromUtf8(rawProjectDirectory.data(), static_cast<int>(rawProjectDirectory.size())));
|
||||
const QString elidedLevelName = QStringLiteral("%1...%2").arg(levelName.left(10)).arg(levelName.right(10));
|
||||
const QString elidedLevelFileName = QStringLiteral("%1...%2").arg(info.fileName().left(10)).arg(info.fileName().right(10));
|
||||
const QString message = QObject::tr(
|
||||
@@ -3380,7 +3380,7 @@ CCryEditDoc* CCryEditApp::OpenDocumentFile(const char* lpszFileName)
|
||||
void CCryEditApp::OnResourcesReduceworkingset()
|
||||
{
|
||||
#ifdef WIN32 // no such thing on macOS
|
||||
SetProcessWorkingSetSize(GetCurrentProcess(), -1, -1);
|
||||
SetProcessWorkingSetSize(GetCurrentProcess(), std::numeric_limits<SIZE_T>::max(), std::numeric_limits<SIZE_T>::max());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3922,7 +3922,7 @@ void CCryEditApp::OpenLUAEditor(const char* files)
|
||||
|
||||
void CCryEditApp::PrintAlways(const AZStd::string& output)
|
||||
{
|
||||
m_stdoutRedirection.WriteBypassingRedirect(output.c_str(), output.size());
|
||||
m_stdoutRedirection.WriteBypassingRedirect(output.c_str(), static_cast<unsigned int>(output.size()));
|
||||
}
|
||||
|
||||
QString CCryEditApp::GetRootEnginePath() const
|
||||
|
||||
@@ -1224,7 +1224,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
|
||||
if (savedEntities)
|
||||
{
|
||||
AZ_PROFILE_SCOPE(AzToolsFramework, "CCryEditDoc::SaveLevel Updated PakFile levelEntities.editor_xml");
|
||||
pakFile.UpdateFile("LevelEntities.editor_xml", entitySaveBuffer.begin(), entitySaveBuffer.size());
|
||||
pakFile.UpdateFile("LevelEntities.editor_xml", entitySaveBuffer.begin(), static_cast<int>(entitySaveBuffer.size()));
|
||||
|
||||
// Save XML archive to pak file.
|
||||
bool bSaved = xmlAr.SaveToPak(Path::GetPath(tempSaveFile), pakFile);
|
||||
@@ -2055,7 +2055,7 @@ void CCryEditDoc::OnEnvironmentPropertyChanged(IVariable* pVar)
|
||||
}
|
||||
|
||||
// QVariant will not convert a void * to int, so do it manually.
|
||||
int nKey = reinterpret_cast<intptr_t>(pVar->GetUserData().value<void*>());
|
||||
int nKey = static_cast<int>(reinterpret_cast<intptr_t>(pVar->GetUserData().value<void*>()));
|
||||
|
||||
int nGroup = (nKey & 0xFFFF0000) >> 16;
|
||||
int nChild = (nKey & 0x0000FFFF);
|
||||
|
||||
@@ -46,7 +46,7 @@ void CDisplaySettings::SaveRegistry()
|
||||
SaveValue("Settings", "RenderFlags", m_renderFlags);
|
||||
SaveValue("Settings", "DisplayFlags", m_flags & SETTINGS_SERIALIZABLE_FLAGS_MASK);
|
||||
SaveValue("Settings", "DebugFlags", m_debugFlags);
|
||||
SaveValue("Settings", "LabelsDistance", m_labelsDistance);
|
||||
SaveValue("Settings", "LabelsDistance", static_cast<int>(m_labelsDistance));
|
||||
}
|
||||
|
||||
void CDisplaySettings::LoadRegistry()
|
||||
@@ -56,9 +56,9 @@ void CDisplaySettings::LoadRegistry()
|
||||
LoadValue("Settings", "DisplayFlags", m_flags);
|
||||
m_flags &= SETTINGS_SERIALIZABLE_FLAGS_MASK;
|
||||
LoadValue("Settings", "DebugFlags", m_debugFlags);
|
||||
int temp = m_labelsDistance;
|
||||
int temp = static_cast<int>(m_labelsDistance);
|
||||
LoadValue("Settings", "LabelsDistance", temp);
|
||||
m_labelsDistance = temp;
|
||||
m_labelsDistance = static_cast<float>(temp);
|
||||
|
||||
gSettings.objectHideMask = m_objectHideMask;
|
||||
}
|
||||
|
||||
@@ -44,14 +44,14 @@ bool SubObjectSelectionReferenceFrameCalculator::GetFrame(Matrix34& refFrame)
|
||||
|
||||
if (this->nNormals > 0)
|
||||
{
|
||||
this->normal = this->normal / this->nNormals;
|
||||
this->normal = this->normal / static_cast<float>(this->nNormals);
|
||||
if (!this->normal.IsZero())
|
||||
{
|
||||
this->normal.Normalize();
|
||||
}
|
||||
|
||||
// Average position.
|
||||
this->pos = this->pos / this->nNormals;
|
||||
this->pos = this->pos / static_cast<float>(this->nNormals);
|
||||
refFrame.SetTranslation(this->pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,18 +33,6 @@
|
||||
#include <Include/SandboxAPI.h>
|
||||
#include <Include/EditorCoreAPI.h>
|
||||
|
||||
// Warnings in STL
|
||||
#pragma warning (disable : 4786) // identifier was truncated to 'number' characters in the debug information.
|
||||
#pragma warning (disable : 4244) // conversion from 'long' to 'float', possible loss of data
|
||||
#pragma warning (disable : 4018) // signed/unsigned mismatch
|
||||
|
||||
// Disable warning when a function returns a value inside an __asm block
|
||||
#pragma warning (disable : 4035)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 64-bits related warnings.
|
||||
#pragma warning (disable : 4267) // conversion from 'size_t' to 'int', possible loss of data
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Simple type definitions.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -201,20 +201,24 @@ void CEditorPreferencesPage_ViewportGeneral::OnApply()
|
||||
ds->SetLabelsDistance(m_textLabels.m_labelsDistance);
|
||||
|
||||
gSettings.objectColorSettings.fChildGeomAlpha = m_selectionPreviewColor.m_childObjectGeomAlpha;
|
||||
gSettings.objectColorSettings.entityHighlight = QColor(m_selectionPreviewColor.m_colorEntityBBox.GetR() * 255.0f,
|
||||
m_selectionPreviewColor.m_colorEntityBBox.GetG() * 255.0f,
|
||||
m_selectionPreviewColor.m_colorEntityBBox.GetB() * 255.0f);
|
||||
gSettings.objectColorSettings.groupHighlight = QColor(m_selectionPreviewColor.m_colorGroupBBox.GetR() * 255.0f,
|
||||
m_selectionPreviewColor.m_colorGroupBBox.GetG() * 255.0f,
|
||||
m_selectionPreviewColor.m_colorGroupBBox.GetB() * 255.0f);
|
||||
gSettings.objectColorSettings.entityHighlight = QColor(
|
||||
static_cast<int>(m_selectionPreviewColor.m_colorEntityBBox.GetR() * 255.0f),
|
||||
static_cast<int>(m_selectionPreviewColor.m_colorEntityBBox.GetG() * 255.0f),
|
||||
static_cast<int>(m_selectionPreviewColor.m_colorEntityBBox.GetB() * 255.0f));
|
||||
gSettings.objectColorSettings.groupHighlight = QColor(
|
||||
static_cast<int>(m_selectionPreviewColor.m_colorGroupBBox.GetR() * 255.0f),
|
||||
static_cast<int>(m_selectionPreviewColor.m_colorGroupBBox.GetG() * 255.0f),
|
||||
static_cast<int>(m_selectionPreviewColor.m_colorGroupBBox.GetB() * 255.0f));
|
||||
gSettings.objectColorSettings.fBBoxAlpha = m_selectionPreviewColor.m_fBBoxAlpha;
|
||||
gSettings.objectColorSettings.fGeomAlpha = m_selectionPreviewColor.m_fgeomAlpha;
|
||||
gSettings.objectColorSettings.geometryHighlightColor = QColor(m_selectionPreviewColor.m_geometryHighlightColor.GetR() * 255.0f,
|
||||
m_selectionPreviewColor.m_geometryHighlightColor.GetG() * 255.0f,
|
||||
m_selectionPreviewColor.m_geometryHighlightColor.GetB() * 255.0f);
|
||||
gSettings.objectColorSettings.solidBrushGeometryColor = QColor(m_selectionPreviewColor.m_solidBrushGeometryColor.GetR() * 255.0f,
|
||||
m_selectionPreviewColor.m_solidBrushGeometryColor.GetG() * 255.0f,
|
||||
m_selectionPreviewColor.m_solidBrushGeometryColor.GetB() * 255.0f);
|
||||
gSettings.objectColorSettings.geometryHighlightColor = QColor(
|
||||
static_cast<int>(m_selectionPreviewColor.m_geometryHighlightColor.GetR() * 255.0f),
|
||||
static_cast<int>(m_selectionPreviewColor.m_geometryHighlightColor.GetG() * 255.0f),
|
||||
static_cast<int>(m_selectionPreviewColor.m_geometryHighlightColor.GetB() * 255.0f));
|
||||
gSettings.objectColorSettings.solidBrushGeometryColor = QColor(
|
||||
static_cast<int>(m_selectionPreviewColor.m_solidBrushGeometryColor.GetR() * 255.0f),
|
||||
static_cast<int>(m_selectionPreviewColor.m_solidBrushGeometryColor.GetG() * 255.0f),
|
||||
static_cast<int>(m_selectionPreviewColor.m_solidBrushGeometryColor.GetB() * 255.0f));
|
||||
}
|
||||
|
||||
void CEditorPreferencesPage_ViewportGeneral::InitializeSettings()
|
||||
@@ -252,10 +256,10 @@ void CEditorPreferencesPage_ViewportGeneral::InitializeSettings()
|
||||
m_textLabels.m_labelsDistance = ds->GetLabelsDistance();
|
||||
|
||||
m_selectionPreviewColor.m_childObjectGeomAlpha = gSettings.objectColorSettings.fChildGeomAlpha;
|
||||
m_selectionPreviewColor.m_colorEntityBBox.Set(gSettings.objectColorSettings.entityHighlight.redF(), gSettings.objectColorSettings.entityHighlight.greenF(), gSettings.objectColorSettings.entityHighlight.blueF(), 1.0f);
|
||||
m_selectionPreviewColor.m_colorGroupBBox.Set(gSettings.objectColorSettings.groupHighlight.redF(), gSettings.objectColorSettings.groupHighlight.greenF(), gSettings.objectColorSettings.groupHighlight.blueF(), 1.0f);
|
||||
m_selectionPreviewColor.m_colorEntityBBox.Set(static_cast<float>(gSettings.objectColorSettings.entityHighlight.redF()), static_cast<float>(gSettings.objectColorSettings.entityHighlight.greenF()), static_cast<float>(gSettings.objectColorSettings.entityHighlight.blueF()), 1.0f);
|
||||
m_selectionPreviewColor.m_colorGroupBBox.Set(static_cast<float>(gSettings.objectColorSettings.groupHighlight.redF()), static_cast<float>(gSettings.objectColorSettings.groupHighlight.greenF()), static_cast<float>(gSettings.objectColorSettings.groupHighlight.blueF()), 1.0f);
|
||||
m_selectionPreviewColor.m_fBBoxAlpha = gSettings.objectColorSettings.fBBoxAlpha;
|
||||
m_selectionPreviewColor.m_fgeomAlpha = gSettings.objectColorSettings.fGeomAlpha;
|
||||
m_selectionPreviewColor.m_geometryHighlightColor.Set(gSettings.objectColorSettings.geometryHighlightColor.redF(), gSettings.objectColorSettings.geometryHighlightColor.greenF(), gSettings.objectColorSettings.geometryHighlightColor.blueF(), 1.0f);
|
||||
m_selectionPreviewColor.m_solidBrushGeometryColor.Set(gSettings.objectColorSettings.solidBrushGeometryColor.redF(), gSettings.objectColorSettings.solidBrushGeometryColor.greenF(), gSettings.objectColorSettings.solidBrushGeometryColor.blueF(), 1.0f);
|
||||
m_selectionPreviewColor.m_geometryHighlightColor.Set(static_cast<float>(gSettings.objectColorSettings.geometryHighlightColor.redF()), static_cast<float>(gSettings.objectColorSettings.geometryHighlightColor.greenF()), static_cast<float>(gSettings.objectColorSettings.geometryHighlightColor.blueF()), 1.0f);
|
||||
m_selectionPreviewColor.m_solidBrushGeometryColor.Set(static_cast<float>(gSettings.objectColorSettings.solidBrushGeometryColor.redF()), static_cast<float>(gSettings.objectColorSettings.solidBrushGeometryColor.greenF()), static_cast<float>(gSettings.objectColorSettings.solidBrushGeometryColor.blueF()), 1.0f);
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ void EditorViewportWidget::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
const char* kFontName = "Arial";
|
||||
const QColor kTextColor(255, 255, 255);
|
||||
const QColor kTextShadowColor(0, 0, 0);
|
||||
const QFont font(kFontName, kFontSize / 10.0);
|
||||
const QFont font(kFontName, static_cast<int>(kFontSize / 10.0f));
|
||||
painter.setFont(font);
|
||||
|
||||
QString friendlyName = QFileInfo(GetIEditor()->GetLevelName()).fileName();
|
||||
@@ -816,29 +816,35 @@ void EditorViewportWidget::UpdateSafeFrame()
|
||||
float maxSafeFrameWidth = m_safeFrame.height() * targetAspectRatio;
|
||||
float widthDifference = m_safeFrame.width() - maxSafeFrameWidth;
|
||||
|
||||
m_safeFrame.setLeft(m_safeFrame.left() + widthDifference * 0.5);
|
||||
m_safeFrame.setRight(m_safeFrame.right() - widthDifference * 0.5);
|
||||
m_safeFrame.setLeft(static_cast<int>(m_safeFrame.left() + widthDifference * 0.5f));
|
||||
m_safeFrame.setRight(static_cast<int>(m_safeFrame.right() - widthDifference * 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
float maxSafeFrameHeight = m_safeFrame.width() / targetAspectRatio;
|
||||
float heightDifference = m_safeFrame.height() - maxSafeFrameHeight;
|
||||
|
||||
m_safeFrame.setTop(m_safeFrame.top() + heightDifference * 0.5);
|
||||
m_safeFrame.setBottom(m_safeFrame.bottom() - heightDifference * 0.5);
|
||||
m_safeFrame.setTop(static_cast<int>(m_safeFrame.top() + heightDifference * 0.5f));
|
||||
m_safeFrame.setBottom(static_cast<int>(m_safeFrame.bottom() - heightDifference * 0.5f));
|
||||
}
|
||||
|
||||
m_safeFrame.adjust(0, 0, -1, -1); // <-- aesthetic improvement.
|
||||
|
||||
const float SAFE_ACTION_SCALE_FACTOR = 0.05f;
|
||||
m_safeAction = m_safeFrame;
|
||||
m_safeAction.adjust(m_safeFrame.width() * SAFE_ACTION_SCALE_FACTOR, m_safeFrame.height() * SAFE_ACTION_SCALE_FACTOR,
|
||||
-m_safeFrame.width() * SAFE_ACTION_SCALE_FACTOR, -m_safeFrame.height() * SAFE_ACTION_SCALE_FACTOR);
|
||||
m_safeAction.adjust(
|
||||
static_cast<int>(m_safeFrame.width() * SAFE_ACTION_SCALE_FACTOR),
|
||||
static_cast<int>(m_safeFrame.height() * SAFE_ACTION_SCALE_FACTOR),
|
||||
static_cast<int>(-m_safeFrame.width() * SAFE_ACTION_SCALE_FACTOR),
|
||||
static_cast<int>(-m_safeFrame.height() * SAFE_ACTION_SCALE_FACTOR));
|
||||
|
||||
const float SAFE_TITLE_SCALE_FACTOR = 0.1f;
|
||||
m_safeTitle = m_safeFrame;
|
||||
m_safeTitle.adjust(m_safeFrame.width() * SAFE_TITLE_SCALE_FACTOR, m_safeFrame.height() * SAFE_TITLE_SCALE_FACTOR,
|
||||
-m_safeFrame.width() * SAFE_TITLE_SCALE_FACTOR, -m_safeFrame.height() * SAFE_TITLE_SCALE_FACTOR);
|
||||
m_safeTitle.adjust(
|
||||
static_cast<int>(m_safeFrame.width() * SAFE_TITLE_SCALE_FACTOR),
|
||||
static_cast<int>(m_safeFrame.height() * SAFE_TITLE_SCALE_FACTOR),
|
||||
static_cast<int>(-m_safeFrame.width() * SAFE_TITLE_SCALE_FACTOR),
|
||||
static_cast<int>(-m_safeFrame.height() * SAFE_TITLE_SCALE_FACTOR));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -857,8 +863,8 @@ void EditorViewportWidget::RenderSafeFrame(const QRect& frame, float r, float g,
|
||||
const int LINE_WIDTH = 2;
|
||||
for (int i = 0; i < LINE_WIDTH; i++)
|
||||
{
|
||||
AZ::Vector3 topLeft(frame.left() + i, frame.top() + i, 0);
|
||||
AZ::Vector3 bottomRight(frame.right() - i, frame.bottom() - i, 0);
|
||||
AZ::Vector3 topLeft(static_cast<float>(frame.left() + i), static_cast<float>(frame.top() + i), 0.0f);
|
||||
AZ::Vector3 bottomRight(static_cast<float>(frame.right() - i), static_cast<float>(frame.bottom() - i), 0.0f);
|
||||
m_debugDisplay->DrawWireBox(topLeft, bottomRight);
|
||||
}
|
||||
}
|
||||
@@ -1494,7 +1500,7 @@ bool EditorViewportWidget::AddCameraMenuItems(QMenu* menu)
|
||||
Camera::CameraBus::BroadcastResult(getCameraResults, &Camera::CameraRequests::GetCameras);
|
||||
|
||||
QVector<QAction*> additionalCameras;
|
||||
additionalCameras.reserve(getCameraResults.values.size());
|
||||
additionalCameras.reserve(static_cast<int>(getCameraResults.values.size()));
|
||||
|
||||
for (const AZ::EntityId& entityId : getCameraResults.values)
|
||||
{
|
||||
@@ -1916,7 +1922,7 @@ void EditorViewportWidget::RenderSelectedRegion()
|
||||
// Draw volume
|
||||
dc.DepthWriteOff();
|
||||
dc.CullOff();
|
||||
dc.pRenderAuxGeom->DrawTriangles(&verts[0], verts.size(), &inds[0], numInds, &colors[0]);
|
||||
dc.pRenderAuxGeom->DrawTriangles(&verts[0], static_cast<uint32>(verts.size()), &inds[0], numInds, &colors[0]);
|
||||
dc.CullOn();
|
||||
dc.DepthWriteOn();
|
||||
}
|
||||
@@ -1932,8 +1938,8 @@ Vec3 EditorViewportWidget::WorldToView3D(const Vec3& wp, [[maybe_unused]] int nF
|
||||
{
|
||||
out.x = (x / 100) * m_rcClient.width();
|
||||
out.y = (y / 100) * m_rcClient.height();
|
||||
out.x /= QHighDpiScaling::factor(windowHandle()->screen());
|
||||
out.y /= QHighDpiScaling::factor(windowHandle()->screen());
|
||||
out.x /= static_cast<float>(QHighDpiScaling::factor(windowHandle()->screen()));
|
||||
out.y /= static_cast<float>(QHighDpiScaling::factor(windowHandle()->screen()));
|
||||
out.z = z;
|
||||
}
|
||||
return out;
|
||||
@@ -1953,8 +1959,8 @@ QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width
|
||||
ProjectToScreen(wp.x, wp.y, wp.z, &x, &y, &z);
|
||||
if (_finite(x) || _finite(y))
|
||||
{
|
||||
p.rx() = (x / 100) * width;
|
||||
p.ry() = (y / 100) * height;
|
||||
p.rx() = static_cast<int>((x / 100) * width);
|
||||
p.ry() = static_cast<int>((y / 100) * height);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2108,8 +2114,8 @@ void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, flo
|
||||
void EditorViewportWidget::ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const
|
||||
{
|
||||
AzFramework::ScreenPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz});
|
||||
*sx = screenPosition.m_x;
|
||||
*sy = screenPosition.m_y;
|
||||
*sx = static_cast<float>(screenPosition.m_x);
|
||||
*sy = static_cast<float>(screenPosition.m_y);
|
||||
*sz = 0.f;
|
||||
}
|
||||
|
||||
@@ -2120,7 +2126,7 @@ void EditorViewportWidget::ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3&
|
||||
|
||||
Vec3 pos0, pos1;
|
||||
float wx, wy, wz;
|
||||
UnProjectFromScreen(vp.x(), rc.bottom() - vp.y(), 0, &wx, &wy, &wz);
|
||||
UnProjectFromScreen(static_cast<float>(vp.x()), static_cast<float>(rc.bottom() - vp.y()), 0.0f, &wx, &wy, &wz);
|
||||
if (!_finite(wx) || !_finite(wy) || !_finite(wz))
|
||||
{
|
||||
return;
|
||||
@@ -2130,7 +2136,7 @@ void EditorViewportWidget::ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3&
|
||||
return;
|
||||
}
|
||||
pos0(wx, wy, wz);
|
||||
UnProjectFromScreen(vp.x(), rc.bottom() - vp.y(), 1, &wx, &wy, &wz);
|
||||
UnProjectFromScreen(static_cast<float>(vp.x()), static_cast<float>(rc.bottom() - vp.y()), 1.0f, &wx, &wy, &wz);
|
||||
if (!_finite(wx) || !_finite(wy) || !_finite(wz))
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -45,7 +45,7 @@ bool GetPositionFromString(QString er, float* x, float* y, float* z)
|
||||
}
|
||||
if (ind > 0)
|
||||
{
|
||||
*x = er.mid(0, ind).toDouble();
|
||||
*x = er.mid(0, ind).toFloat();
|
||||
er = er.mid(ind);
|
||||
er.remove(QRegExp("^[ ,]*"));
|
||||
|
||||
@@ -57,12 +57,12 @@ bool GetPositionFromString(QString er, float* x, float* y, float* z)
|
||||
}
|
||||
if (ind > 0)
|
||||
{
|
||||
*y = er.mid(0, ind).toDouble();
|
||||
*y = er.mid(0, ind).toFloat();
|
||||
er = er.mid(ind);
|
||||
er.remove(QRegExp("^[ ,]*"));
|
||||
if (er.length())
|
||||
{
|
||||
*z = er.toDouble();
|
||||
*z = er.toFloat();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void CErrorReportTableModel::setErrorReport(CErrorReport* report)
|
||||
|
||||
int CErrorReportTableModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return parent.isValid() ? 0 : m_errorRecords.size();
|
||||
return parent.isValid() ? 0 : static_cast<int>(m_errorRecords.size());
|
||||
}
|
||||
|
||||
int CErrorReportTableModel::columnCount(const QModelIndex& parent) const
|
||||
|
||||
@@ -40,15 +40,6 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
void SetTexture(Export::TPath& outName, IRenderShaderResources* pRes, int nSlot)
|
||||
{
|
||||
SEfResTexture* pTex = pRes->GetTextureResource(nSlot);
|
||||
if (pTex)
|
||||
{
|
||||
azstrcat(outName, AZ_ARRAY_SIZE(outName), Path::GamePathToFullPath(pTex->m_Name.c_str()).toUtf8().data());
|
||||
}
|
||||
}
|
||||
|
||||
inline Export::Vector3D Vec3ToVector3D(const Vec3& vec)
|
||||
{
|
||||
Export::Vector3D ret;
|
||||
@@ -302,7 +293,7 @@ void CExportManager::ProcessEntityAnimationTrack(
|
||||
return;
|
||||
}
|
||||
|
||||
for (int trackNumber = 0; trackNumber < pEntityTrack->GetChildCount(); ++trackNumber)
|
||||
for (unsigned int trackNumber = 0; trackNumber < pEntityTrack->GetChildCount(); ++trackNumber)
|
||||
{
|
||||
CTrackViewTrack* pSubTrack = static_cast<CTrackViewTrack*>(pEntityTrack->GetChild(trackNumber));
|
||||
|
||||
@@ -964,7 +955,7 @@ bool CExportManager::AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNo
|
||||
}
|
||||
|
||||
const uint numKeys = pSequenceTrack->GetKeyCount();
|
||||
for (int keyIndex = 0; keyIndex < numKeys; ++keyIndex)
|
||||
for (uint keyIndex = 0; keyIndex < numKeys; ++keyIndex)
|
||||
{
|
||||
const CTrackViewKeyHandle& keyHandle = pSequenceTrack->GetKey(keyIndex);
|
||||
ISequenceKey sequenceKey;
|
||||
@@ -1043,7 +1034,7 @@ bool CExportManager::AddSelectedRegionObjects()
|
||||
std::vector<CBaseObject*> objects;
|
||||
GetIEditor()->GetObjectManager()->FindObjectsInAABB(box, objects);
|
||||
|
||||
int numObjects = objects.size();
|
||||
const size_t numObjects = objects.size();
|
||||
if (numObjects > m_data.m_objects.size())
|
||||
{
|
||||
m_data.m_objects.reserve(numObjects + 1); // +1 for terrain
|
||||
@@ -1164,7 +1155,7 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con
|
||||
// Export the whole sequence with baked keys
|
||||
if (ShowFBXExportDialog())
|
||||
{
|
||||
m_numberOfExportFrames = pSequence->GetTimeRange().end * m_FBXBakedExportFPS;
|
||||
m_numberOfExportFrames = static_cast<int>(pSequence->GetTimeRange().end * m_FBXBakedExportFPS);
|
||||
|
||||
if (!m_bExportOnlyPrimaryCamera)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Export
|
||||
public:
|
||||
CMesh();
|
||||
|
||||
virtual int GetFaceCount() const { return m_faces.size(); }
|
||||
virtual int GetFaceCount() const { return static_cast<int>(m_faces.size()); }
|
||||
virtual const Face* GetFaceBuffer() const { return m_faces.size() ? &m_faces[0] : 0; }
|
||||
|
||||
private:
|
||||
@@ -53,22 +53,22 @@ namespace Export
|
||||
public:
|
||||
CObject(const char* pName);
|
||||
|
||||
virtual int GetVertexCount() const { return m_vertices.size(); }
|
||||
virtual const Vector3D* GetVertexBuffer() const{ return m_vertices.size() ? &m_vertices[0] : 0; }
|
||||
int GetVertexCount() const override { return static_cast<int>(m_vertices.size()); }
|
||||
const Vector3D* GetVertexBuffer() const override { return m_vertices.size() ? &m_vertices[0] : nullptr; }
|
||||
|
||||
virtual int GetNormalCount() const { return m_normals.size(); }
|
||||
virtual const Vector3D* GetNormalBuffer() const { return m_normals.size() ? &m_normals[0] : 0; }
|
||||
int GetNormalCount() const override { return static_cast<int>(m_normals.size()); }
|
||||
const Vector3D* GetNormalBuffer() const override { return m_normals.size() ? &m_normals[0] : nullptr; }
|
||||
|
||||
virtual int GetTexCoordCount() const { return m_texCoords.size(); }
|
||||
virtual const UV* GetTexCoordBuffer() const { return m_texCoords.size() ? &m_texCoords[0] : 0; }
|
||||
int GetTexCoordCount() const override { return static_cast<int>(m_texCoords.size()); }
|
||||
const UV* GetTexCoordBuffer() const override { return m_texCoords.size() ? &m_texCoords[0] : nullptr; }
|
||||
|
||||
virtual int GetMeshCount() const { return m_meshes.size(); }
|
||||
virtual Mesh* GetMesh(int index) const { return m_meshes[index]; }
|
||||
int GetMeshCount() const override { return static_cast<int>(m_meshes.size()); }
|
||||
Mesh* GetMesh(int index) const override { return m_meshes[index]; }
|
||||
|
||||
virtual size_t MeshHash() const{return m_MeshHash; }
|
||||
size_t MeshHash() const override{return m_MeshHash; }
|
||||
|
||||
void SetMaterialName(const char* pName);
|
||||
virtual int GetEntityAnimationDataCount() const {return m_entityAnimData.size(); }
|
||||
virtual int GetEntityAnimationDataCount() const {return static_cast<int>(m_entityAnimData.size()); }
|
||||
virtual const EntityAnimData* GetEntityAnimationData(int index) const {return &m_entityAnimData[index]; }
|
||||
virtual void SetEntityAnimationData(EntityAnimData entityData){ m_entityAnimData.push_back(entityData); };
|
||||
void SetLastPtr(CBaseObject* pObject){m_pLastObject = pObject; };
|
||||
@@ -92,7 +92,7 @@ namespace Export
|
||||
: public IData
|
||||
{
|
||||
public:
|
||||
virtual int GetObjectCount() const { return m_objects.size(); }
|
||||
virtual int GetObjectCount() const { return static_cast<int>(m_objects.size()); }
|
||||
virtual Object* GetObject(int index) const { return m_objects[index]; }
|
||||
virtual Object* AddObject(const char* objectName);
|
||||
void Clear();
|
||||
|
||||
@@ -227,7 +227,7 @@ QString COBJExporter::MakeRelativePath(const char* pMainFileName, const char* pF
|
||||
const char* ch = strrchr(pMainFileName, '\\');
|
||||
if (ch)
|
||||
{
|
||||
if (strlen(pFileName) > ch - pMainFileName && !_strnicmp(pMainFileName, pFileName, ch - pMainFileName))
|
||||
if (strlen(pFileName) > static_cast<size_t>(ch - pMainFileName) && !_strnicmp(pMainFileName, pFileName, ch - pMainFileName))
|
||||
{
|
||||
return QString(pFileName + (ch - pMainFileName) + 1);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ const char* COBJExporter::TrimFloat(float fValue) const
|
||||
++nCurBuf;
|
||||
sprintf_s(pBuf, bufSize, "%f", fValue);
|
||||
|
||||
for (int i = strlen(pBuf) - 1; i > 0; --i)
|
||||
for (int i = static_cast<int>(strlen(pBuf)) - 1; i > 0; --i)
|
||||
{
|
||||
if (pBuf[i] == '0')
|
||||
{
|
||||
|
||||
@@ -215,7 +215,7 @@ bool COCMExporter::ExportToFile(const char* filename, const Export::IData* pExpo
|
||||
for (size_t a = 0; a < MeshCount; a++)
|
||||
{
|
||||
SOCMeshInfo MeshInfo;
|
||||
MeshInfo.m_MeshHash = pExportData->GetObject(a)->MeshHash();
|
||||
MeshInfo.m_MeshHash = pExportData->GetObject(static_cast<int>(a))->MeshHash();
|
||||
const tdMeshOffset::iterator it = std::find(MeshOffsets.begin(), MeshOffsets.end(), MeshInfo);
|
||||
if (it != MeshOffsets.end())
|
||||
{
|
||||
@@ -223,15 +223,15 @@ bool COCMExporter::ExportToFile(const char* filename, const Export::IData* pExpo
|
||||
}
|
||||
else
|
||||
{
|
||||
MeshInfo.m_Offset = Offset;
|
||||
Offset += SaveMesh(Writer, pExportData->GetObject(a), MeshInfo.m_OBBMat);
|
||||
MeshInfo.m_Offset = static_cast<uint32>(Offset);
|
||||
Offset += SaveMesh(Writer, pExportData->GetObject(static_cast<int>(a)), MeshInfo.m_OBBMat);
|
||||
}
|
||||
MeshOffsets.push_back(MeshInfo);
|
||||
}
|
||||
OffsetInstances = Offset;
|
||||
OffsetInstances = static_cast<uint32>(Offset);
|
||||
for (size_t a = 0; a < InstCount; a++)
|
||||
{
|
||||
SaveInstance(Writer, pExportData->GetObject(a), MeshOffsets[a]);
|
||||
SaveInstance(Writer, pExportData->GetObject(static_cast<int>(a)), MeshOffsets[a]);
|
||||
}
|
||||
Writer.Seek(4);
|
||||
Writer.Write(static_cast<uint32>(MeshOffsets.size()));
|
||||
@@ -263,7 +263,7 @@ const char* COCMExporter::TrimFloat(float fValue) const
|
||||
++nCurBuf;
|
||||
sprintf_s(pBuf, bufSize, "%f", fValue);
|
||||
|
||||
for (int i = strlen(pBuf) - 1; i > 0; --i)
|
||||
for (int i = static_cast<int>(strlen(pBuf)) - 1; i > 0; --i)
|
||||
{
|
||||
if (pBuf[i] == '0')
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
|
||||
namespace
|
||||
{
|
||||
const uint kDefaultFPS = 30.0f;
|
||||
const uint kDefaultFPS = 30u;
|
||||
}
|
||||
|
||||
CFBXExporterDialog::CFBXExporterDialog(bool bDisplayOnlyFPSSetting, QWidget* pParent)
|
||||
@@ -43,7 +43,7 @@ CFBXExporterDialog::~CFBXExporterDialog()
|
||||
|
||||
float CFBXExporterDialog::GetFPS() const
|
||||
{
|
||||
return m_ui->m_fpsCombo->currentText().toDouble();
|
||||
return m_ui->m_fpsCombo->currentText().toFloat();
|
||||
}
|
||||
|
||||
bool CFBXExporterDialog::GetExportCoordsLocalToTheSelectedObject() const
|
||||
|
||||
@@ -252,11 +252,11 @@ void CGameExporter::ExportOcclusionMesh(const char* pszGamePath)
|
||||
{
|
||||
CMemoryBlock Temp;
|
||||
const size_t Size = FileIn.size();
|
||||
Temp.Allocate(Size);
|
||||
Temp.Allocate(static_cast<int>(Size));
|
||||
FileIn.read(reinterpret_cast<char*>(Temp.GetBuffer()), Size);
|
||||
FileIn.close();
|
||||
CCryMemFile FileOut;
|
||||
FileOut.Write(Temp.GetBuffer(), Size);
|
||||
FileOut.Write(Temp.GetBuffer(), static_cast<int>(Size));
|
||||
m_levelPak.m_pakFile.UpdateFile(levelDataFile.toUtf8().data(), FileOut);
|
||||
}
|
||||
}
|
||||
@@ -281,13 +281,13 @@ void CGameExporter::ExportLevelData(const QString& path, bool /*bExportMission*/
|
||||
QString levelDataFile = path + "LevelData.xml";
|
||||
XmlString xmlData = root->getXML();
|
||||
CCryMemFile file;
|
||||
file.Write(xmlData.c_str(), xmlData.length());
|
||||
file.Write(xmlData.c_str(), static_cast<unsigned int>(xmlData.length()));
|
||||
m_levelPak.m_pakFile.UpdateFile(levelDataFile.toUtf8().data(), file);
|
||||
|
||||
QString levelDataActionFile = path + "LevelDataAction.xml";
|
||||
XmlString xmlDataAction = rootAction->getXML();
|
||||
CCryMemFile fileAction;
|
||||
fileAction.Write(xmlDataAction.c_str(), xmlDataAction.length());
|
||||
fileAction.Write(xmlDataAction.c_str(), static_cast<unsigned int>(xmlDataAction.length()));
|
||||
m_levelPak.m_pakFile.UpdateFile(levelDataActionFile.toUtf8().data(), fileAction);
|
||||
|
||||
AZStd::vector<char> entitySaveBuffer;
|
||||
@@ -298,7 +298,7 @@ void CGameExporter::ExportLevelData(const QString& path, bool /*bExportMission*/
|
||||
{
|
||||
QString entitiesFile;
|
||||
entitiesFile = QStringLiteral("%1%2.entities_xml").arg(path, "Mission0");
|
||||
m_levelPak.m_pakFile.UpdateFile(entitiesFile.toUtf8().data(), entitySaveBuffer.begin(), entitySaveBuffer.size());
|
||||
m_levelPak.m_pakFile.UpdateFile(entitiesFile.toUtf8().data(), entitySaveBuffer.begin(), static_cast<int>(entitySaveBuffer.size()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ void CGameExporter::ExportLevelInfo(const QString& path)
|
||||
XmlString xmlData = root->getXML();
|
||||
|
||||
CCryMemFile file;
|
||||
file.Write(xmlData.c_str(), xmlData.length());
|
||||
file.Write(xmlData.c_str(), static_cast<unsigned int>(xmlData.length()));
|
||||
m_levelPak.m_pakFile.UpdateFile(filename.toUtf8().data(), file);
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ void CGameExporter::ExportLevelResourceList(const QString& path)
|
||||
CCryMemFile memFile;
|
||||
for (const char* filename = pResList->GetFirst(); filename; filename = pResList->GetNext())
|
||||
{
|
||||
memFile.Write(filename, strlen(filename));
|
||||
memFile.Write(filename, static_cast<unsigned int>(strlen(filename)));
|
||||
memFile.Write("\n", 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ void CGameResourcesExporter::Save(const QString& outputDirectory)
|
||||
{
|
||||
// Save this file in target folder.
|
||||
QString trgFilename = Path::Make(outputDirectory, srcFilename);
|
||||
int fsize = file.GetLength();
|
||||
int fsize = static_cast<int>(file.GetLength());
|
||||
if (fsize > data.GetSize())
|
||||
{
|
||||
data.Allocate(fsize + 16);
|
||||
@@ -123,23 +123,6 @@ void CGameResourcesExporter::Save(const QString& outputDirectory)
|
||||
m_files.clear();
|
||||
}
|
||||
|
||||
#if defined(WIN64) || defined(APPLE) || defined(AZ_PLATFORM_LINUX)
|
||||
template <class Container1, class Container2>
|
||||
void Append(Container1& a, const Container2& b)
|
||||
{
|
||||
a.reserve (a.size() + b.size());
|
||||
for (auto it = b.begin(); it != b.end(); ++it)
|
||||
{
|
||||
a.insert(a.end(), *it);
|
||||
}
|
||||
}
|
||||
#else
|
||||
template <class Container1, class Container2>
|
||||
void Append(Container1& a, const Container2& b)
|
||||
{
|
||||
a.insert (a.end(), b.begin(), b.end());
|
||||
}
|
||||
#endif
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Go through all editor objects and gathers files from thier properties.
|
||||
@@ -150,5 +133,5 @@ void CGameResourcesExporter::GetFilesFromObjects()
|
||||
CUsedResources rs;
|
||||
GetIEditor()->GetObjectManager()->GatherUsedResources(rs);
|
||||
|
||||
Append(m_files, rs.files);
|
||||
AZStd::copy(rs.files.begin(), rs.files.end(), AZStd::back_inserter(m_files));
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ void CTriMesh::SetFromMesh(CMesh& mesh)
|
||||
face.v [j] = numv;
|
||||
face.uv[j] = numv;
|
||||
face.n [j] = mesh.m_pNorms[idx].GetN();
|
||||
face.MatID = subset.nMatID;
|
||||
face.MatID = static_cast<unsigned char>(subset.nMatID);
|
||||
face.flags = 0;
|
||||
|
||||
numv++;
|
||||
@@ -269,7 +269,7 @@ void CTriMesh::SharePositions()
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
const Vec3& v = pVertices[face.v[i]].pos;
|
||||
uint8 nHash = RoundFloatToInt((v.x + v.y + v.z) * fHashScale);
|
||||
uint8 nHash = static_cast<uint8>(RoundFloatToInt((v.x + v.y + v.z) * fHashScale));
|
||||
|
||||
int find = FindVertexInHash(v, pNewVerts, arrHashTable[nHash], fEpsilon);
|
||||
if (find < 0)
|
||||
@@ -320,7 +320,7 @@ void CTriMesh::ShareUV()
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
const Vec2 uv = pUV[face.uv[i]].GetUV();
|
||||
uint8 nHash = RoundFloatToInt((uv.x + uv.y) * fHashScale);
|
||||
uint8 nHash = static_cast<uint8>(RoundFloatToInt((uv.x + uv.y) * fHashScale));
|
||||
|
||||
int find = FindTexCoordInHash(pUV[face.uv[i]], pNewUV, arrHashTable[nHash], fEpsilon);
|
||||
if (find < 0)
|
||||
@@ -380,7 +380,7 @@ void CTriMesh::UpdateIndexedMesh(IIndexedMesh* pIndexedMesh) const
|
||||
// To find really used materials
|
||||
std::vector<int> usedMaterialIds;
|
||||
uint16 MatIdToSubset[MAX_SUB_MATERIALS];
|
||||
int nLastSubsetId = 0;
|
||||
uint16 nLastSubsetId = 0;
|
||||
memset(MatIdToSubset, 0, sizeof(MatIdToSubset));
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -398,7 +398,7 @@ void CTriMesh::UpdateIndexedMesh(IIndexedMesh* pIndexedMesh) const
|
||||
MatIdToSubset[face.MatID] = 1 + nLastSubsetId++;
|
||||
usedMaterialIds.push_back(face.MatID); // Order of material ids in usedMaterialIds correspond to the indices of chunks.
|
||||
}
|
||||
meshFace.nSubset = MatIdToSubset[face.MatID] - 1;
|
||||
meshFace.nSubset = static_cast<unsigned char>(MatIdToSubset[face.MatID] - 1);
|
||||
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
@@ -420,7 +420,7 @@ void CTriMesh::UpdateIndexedMesh(IIndexedMesh* pIndexedMesh) const
|
||||
|
||||
pIndexedMesh->SetBBox(bb);
|
||||
|
||||
pIndexedMesh->SetSubSetCount(usedMaterialIds.size());
|
||||
pIndexedMesh->SetSubSetCount(static_cast<int>(usedMaterialIds.size()));
|
||||
for (int i = 0; i < usedMaterialIds.size(); i++)
|
||||
{
|
||||
pIndexedMesh->SetSubsetMaterialId(i, usedMaterialIds[i]);
|
||||
@@ -677,11 +677,11 @@ void CTriMesh::GetEdgesByVertex(MeshElementsArray& inVertices, MeshElementsArray
|
||||
std::sort(inVertices.begin(), inVertices.end());
|
||||
for (int i = 0; i < GetEdgeCount(); i++)
|
||||
{
|
||||
if (stl::binary_find(inVertices.begin(), inVertices.end(), pEdges[i].v[0]) != inVertices.end())
|
||||
if (stl::binary_find(inVertices.begin(), inVertices.end(), static_cast<int>(pEdges[i].v[0])) != inVertices.end())
|
||||
{
|
||||
outEdges.push_back(i);
|
||||
}
|
||||
else if (stl::binary_find(inVertices.begin(), inVertices.end(), pEdges[i].v[1]) != inVertices.end())
|
||||
else if (stl::binary_find(inVertices.begin(), inVertices.end(), static_cast<int>(pEdges[i].v[1])) != inVertices.end())
|
||||
{
|
||||
outEdges.push_back(i);
|
||||
}
|
||||
@@ -696,15 +696,15 @@ void CTriMesh::GetFacesByVertex(MeshElementsArray& inVertices, MeshElementsArray
|
||||
std::sort(inVertices.begin(), inVertices.end());
|
||||
for (int i = 0; i < GetFacesCount(); i++)
|
||||
{
|
||||
if (stl::binary_find(inVertices.begin(), inVertices.end(), pFaces[i].v[0]) != inVertices.end())
|
||||
if (stl::binary_find(inVertices.begin(), inVertices.end(), static_cast<int>(pFaces[i].v[0])) != inVertices.end())
|
||||
{
|
||||
outFaces.push_back(i);
|
||||
}
|
||||
else if (stl::binary_find(inVertices.begin(), inVertices.end(), pFaces[i].v[1]) != inVertices.end())
|
||||
else if (stl::binary_find(inVertices.begin(), inVertices.end(), static_cast<int>(pFaces[i].v[1])) != inVertices.end())
|
||||
{
|
||||
outFaces.push_back(i);
|
||||
}
|
||||
else if (stl::binary_find(inVertices.begin(), inVertices.end(), pFaces[i].v[2]) != inVertices.end())
|
||||
else if (stl::binary_find(inVertices.begin(), inVertices.end(), static_cast<int>(pFaces[i].v[2])) != inVertices.end())
|
||||
{
|
||||
outFaces.push_back(i);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ void GotoPositionDialog::OnChangeEdit()
|
||||
const QStringList parts = m_transform.split(QRegularExpression("[\\s,;\\t]"), Qt::SkipEmptyParts);
|
||||
for (int i = 0; i < argCount && i < parts.count(); ++i)
|
||||
{
|
||||
transform[i] = parts[i].toDouble();
|
||||
transform[i] = parts[i].toFloat();
|
||||
}
|
||||
|
||||
m_ui->m_dymX->setValue(transform[0]);
|
||||
|
||||
@@ -477,7 +477,7 @@ bool CLevelFileDialog::ValidateLevelPath(const QString& levelPath) const
|
||||
QString currentPath = (Path::GetEditingGameDataFolder() + "/" + kLevelsFolder).c_str();
|
||||
for (size_t i = 0; i < splittedPath.size() - 1; ++i)
|
||||
{
|
||||
currentPath += "/" + splittedPath[i];
|
||||
currentPath += "/" + splittedPath[static_cast<int>(i)];
|
||||
|
||||
if (CFileUtil::FileExists(currentPath) || CheckLevelFolder(currentPath))
|
||||
{
|
||||
|
||||
@@ -504,7 +504,7 @@ static inline QString CopyAndRemoveColorCode(const char* sText)
|
||||
*d++ = *s++;
|
||||
}
|
||||
|
||||
ret.resize(d - ret.data());
|
||||
ret.resize(static_cast<int>(d - ret.data()));
|
||||
|
||||
return QString::fromLatin1(ret);
|
||||
}
|
||||
|
||||
@@ -1672,7 +1672,7 @@ void MainWindow::OnUpdateConnectionStatus()
|
||||
tooltip += m_connectionListener->LastAssetProcessorTask().c_str();
|
||||
tooltip += "\n";
|
||||
AZStd::set<AZStd::string> failedJobs = m_connectionListener->FailedJobsList();
|
||||
int failureCount = failedJobs.size();
|
||||
int failureCount = static_cast<int>(failedJobs.size());
|
||||
if (failureCount)
|
||||
{
|
||||
tooltip += "\n Failed Jobs\n";
|
||||
|
||||
@@ -840,8 +840,8 @@ void CBaseObject::DrawDefault(DisplayContext& dc, const QColor& labelColor)
|
||||
{
|
||||
dc.DrawLine(GetParentAttachPointWorldTM().GetTranslation(), wp, IsFrozen() ? kLinkColorGray : kLinkColorParent, IsFrozen() ? kLinkColorGray : kLinkColorChild);
|
||||
}
|
||||
int nChildCount = GetChildCount();
|
||||
for (int i = 0; i < nChildCount; ++i)
|
||||
size_t nChildCount = GetChildCount();
|
||||
for (size_t i = 0; i < nChildCount; ++i)
|
||||
{
|
||||
const CBaseObject* pChild = GetChild(i);
|
||||
dc.DrawLine(pChild->GetParentAttachPointWorldTM().GetTranslation(), pChild->GetWorldPos(), pChild->IsFrozen() ? kLinkColorGray : kLinkColorParent, pChild->IsFrozen() ? kLinkColorGray : kLinkColorChild);
|
||||
@@ -1022,10 +1022,10 @@ void CBaseObject::DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& l
|
||||
if (camDist < dc.settings->GetLabelsDistance() || (dc.flags & DISPLAY_SELECTION_HELPERS))
|
||||
{
|
||||
float range = maxDist / 2.0f;
|
||||
Vec3 c(labelColor.redF(), labelColor.greenF(), labelColor.redF());
|
||||
Vec3 c(static_cast<f32>(labelColor.redF()), static_cast<f32>(labelColor.greenF()), static_cast<f32>(labelColor.redF()));
|
||||
if (IsSelected())
|
||||
{
|
||||
c = Vec3(dc.GetSelectedColor().redF(), dc.GetSelectedColor().greenF(), dc.GetSelectedColor().blueF());
|
||||
c = Vec3(static_cast<f32>(dc.GetSelectedColor().redF()), static_cast<f32>(dc.GetSelectedColor().greenF()), static_cast<f32>(dc.GetSelectedColor().blueF()));
|
||||
}
|
||||
|
||||
float col[4] = { c.x, c.y, c.z, 1 };
|
||||
@@ -1033,7 +1033,7 @@ void CBaseObject::DrawLabel(DisplayContext& dc, const Vec3& pos, const QColor& l
|
||||
{
|
||||
if (IsHighlighted())
|
||||
{
|
||||
c = Vec3(dc.GetSelectedColor().redF(), dc.GetSelectedColor().greenF(), dc.GetSelectedColor().blueF());
|
||||
c = Vec3(static_cast<f32>(dc.GetSelectedColor().redF()), static_cast<f32>(dc.GetSelectedColor().greenF()), static_cast<f32>(dc.GetSelectedColor().blueF()));
|
||||
}
|
||||
col[0] = c.x;
|
||||
col[1] = c.y;
|
||||
@@ -1263,9 +1263,9 @@ int CBaseObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint&
|
||||
|
||||
if (event == eMouseWheel)
|
||||
{
|
||||
double angle = 1;
|
||||
float angle = 1;
|
||||
Quat rot = GetRotation();
|
||||
rot.SetRotationXYZ(Ang3(0, 0, rot.GetRotZ() + DEG2RAD(flags > 0 ? angle * (-1) : angle)));
|
||||
rot.SetRotationXYZ(Ang3(0.f, 0.f, rot.GetRotZ() + DEG2RAD(flags > 0 ? angle * (-1) : angle)));
|
||||
SetRotation(rot);
|
||||
}
|
||||
return MOUSECREATE_CONTINUE;
|
||||
@@ -1375,7 +1375,7 @@ bool CBaseObject::IsHiddenBySpec() const
|
||||
return false;
|
||||
}
|
||||
|
||||
return (m_nMinSpec != 0 && gSettings.editorConfigSpec != 0 && m_nMinSpec > gSettings.editorConfigSpec);
|
||||
return (m_nMinSpec != 0 && gSettings.editorConfigSpec != 0 && m_nMinSpec > static_cast<uint32>(gSettings.editorConfigSpec));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -1857,10 +1857,10 @@ bool CBaseObject::HitTestRectBounds(HitContext& hc, const AABB& box)
|
||||
|
||||
const int kMaxSizeOfEdgeList0(4);
|
||||
Edge2D edgelist0[kMaxSizeOfEdgeList0] = {
|
||||
Edge2D(Vec2(hc.rect.left(), hc.rect.top()), Vec2(hc.rect.right(), hc.rect.top())),
|
||||
Edge2D(Vec2(hc.rect.right(), hc.rect.top()), Vec2(hc.rect.right(), hc.rect.bottom())),
|
||||
Edge2D(Vec2(hc.rect.right(), hc.rect.bottom()), Vec2(hc.rect.left(), hc.rect.bottom())),
|
||||
Edge2D(Vec2(hc.rect.left(), hc.rect.bottom()), Vec2(hc.rect.left(), hc.rect.top()))
|
||||
Edge2D(Vec2(static_cast<f32>(hc.rect.left()), static_cast<f32>(hc.rect.top())), Vec2(static_cast<f32>(hc.rect.right()), static_cast<f32>(hc.rect.top()))),
|
||||
Edge2D(Vec2(static_cast<f32>(hc.rect.right()), static_cast<f32>(hc.rect.top())), Vec2(static_cast<f32>(hc.rect.right()), static_cast<f32>(hc.rect.bottom()))),
|
||||
Edge2D(Vec2(static_cast<f32>(hc.rect.right()), static_cast<f32>(hc.rect.bottom())), Vec2(static_cast<f32>(hc.rect.left()), static_cast<f32>(hc.rect.bottom()))),
|
||||
Edge2D(Vec2(static_cast<f32>(hc.rect.left()), static_cast<f32>(hc.rect.bottom())), Vec2(static_cast<f32>(hc.rect.left()), static_cast<f32>(hc.rect.top())))
|
||||
};
|
||||
|
||||
const int kMaxSizeOfEdgeList1(8);
|
||||
@@ -1888,12 +1888,12 @@ bool CBaseObject::HitTestRectBounds(HitContext& hc, const AABB& box)
|
||||
pointsForRegion1.reserve(kMaxSizeOfEdgeList1);
|
||||
for (int i = 0; i < kMaxSizeOfEdgeList1; ++i)
|
||||
{
|
||||
pointsForRegion1.push_back(Vec3(obb_p[i].x(), obb_p[i].y(), 0));
|
||||
pointsForRegion1.push_back(Vec3(static_cast<f32>(obb_p[i].x()), static_cast<f32>(obb_p[i].y()), 0.0f));
|
||||
}
|
||||
|
||||
std::vector<Vec3> convexHullForRegion1;
|
||||
ConvexHull2D(convexHullForRegion1, pointsForRegion1);
|
||||
nEdgeList1Count = convexHullForRegion1.size();
|
||||
nEdgeList1Count = static_cast<int>(convexHullForRegion1.size());
|
||||
if (nEdgeList1Count < 3 || nEdgeList1Count > kMaxSizeOfEdgeList1)
|
||||
{
|
||||
return true;
|
||||
@@ -1978,8 +1978,8 @@ bool CBaseObject::HitHelperAtTest(HitContext& hc, const Vec3& pos)
|
||||
{
|
||||
float fScreenScale = hc.view->GetScreenScaleFactor(pos);
|
||||
|
||||
iconSizeX *= OBJECT_TEXTURE_ICON_SCALE / fScreenScale;
|
||||
iconSizeY *= OBJECT_TEXTURE_ICON_SCALE / fScreenScale;
|
||||
iconSizeX = static_cast<int>(static_cast<float>(iconSizeX) * OBJECT_TEXTURE_ICON_SCALE / fScreenScale);
|
||||
iconSizeY = static_cast<int>(static_cast<float>(iconSizeY) * OBJECT_TEXTURE_ICON_SCALE / fScreenScale);
|
||||
}
|
||||
|
||||
// Hit Test icon of this object.
|
||||
@@ -2062,7 +2062,7 @@ void CBaseObject::GetAllChildren(TBaseObjects& outAllChildren, CBaseObject* pObj
|
||||
{
|
||||
const CBaseObject* pBaseObj = pObj ? pObj : this;
|
||||
|
||||
for (int i = 0, iChildCount(pBaseObj->GetChildCount()); i < iChildCount; ++i)
|
||||
for (size_t i = 0, iChildCount(pBaseObj->GetChildCount()); i < iChildCount; ++i)
|
||||
{
|
||||
CBaseObject* pChild = pBaseObj->GetChild(i);
|
||||
if (pChild == nullptr)
|
||||
@@ -2078,7 +2078,7 @@ void CBaseObject::GetAllChildren(DynArray< _smart_ptr<CBaseObject> >& outAllChil
|
||||
{
|
||||
const CBaseObject* pBaseObj = pObj ? pObj : this;
|
||||
|
||||
for (int i = 0, iChildCount(pBaseObj->GetChildCount()); i < iChildCount; ++i)
|
||||
for (size_t i = 0, iChildCount(pBaseObj->GetChildCount()); i < iChildCount; ++i)
|
||||
{
|
||||
CBaseObject* pChild = pBaseObj->GetChild(i);
|
||||
if (pChild == nullptr)
|
||||
@@ -2094,7 +2094,7 @@ void CBaseObject::GetAllChildren(CSelectionGroup& outAllChildren, CBaseObject* p
|
||||
{
|
||||
const CBaseObject* pBaseObj = pObj ? pObj : this;
|
||||
|
||||
for (int i = 0, iChildCount(pBaseObj->GetChildCount()); i < iChildCount; ++i)
|
||||
for (size_t i = 0, iChildCount(pBaseObj->GetChildCount()); i < iChildCount; ++i)
|
||||
{
|
||||
CBaseObject* pChild = pBaseObj->GetChild(i);
|
||||
if (pChild == nullptr)
|
||||
@@ -2114,7 +2114,7 @@ void CBaseObject::CloneChildren(CBaseObject* pFromObject)
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0, nChildCount(pFromObject->GetChildCount()); i < nChildCount; ++i)
|
||||
for (size_t i = 0, nChildCount(pFromObject->GetChildCount()); i < nChildCount; ++i)
|
||||
{
|
||||
CBaseObject* pFromChildObject = pFromObject->GetChild(i);
|
||||
|
||||
@@ -2729,7 +2729,7 @@ void CBaseObject::SetMinSpec(uint32 nSpec, bool bSetChildren)
|
||||
// Set min spec for all childs.
|
||||
if (bSetChildren)
|
||||
{
|
||||
for (int i = m_childs.size() - 1; i >= 0; --i)
|
||||
for (size_t i = m_childs.size() - 1; i >= 0; --i)
|
||||
{
|
||||
m_childs[i]->SetMinSpec(nSpec, true);
|
||||
}
|
||||
|
||||
@@ -83,12 +83,12 @@ struct SANDBOX_API DisplayContext
|
||||
// Draw functions
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Set current materialc color.
|
||||
void SetColor(float r, float g, float b, float a = 1) { m_color4b = ColorB(int(r * 255.0f), int(g * 255.0f), int(b * 255.0f), int(a * 255.0f)); };
|
||||
void SetColor(const Vec3& color, float a = 1) { m_color4b = ColorB(int(color.x * 255.0f), int(color.y * 255.0f), int(color.z * 255.0f), int(a * 255.0f)); };
|
||||
void SetColor(const QColor& rgb, float a) { m_color4b = ColorB(rgb.red(), rgb.green(), rgb.blue(), int(a * 255.0f)); };
|
||||
void SetColor(const QColor& color) { m_color4b = ColorB(color.red(), color.green(), color.blue(), color.alpha()); };
|
||||
void SetColor(float r, float g, float b, float a = 1) { m_color4b = ColorB(static_cast<uint8>(r * 255.0f), static_cast<uint8>(g * 255.0f), static_cast<uint8>(b * 255.0f), static_cast<uint8>(a * 255.0f)); };
|
||||
void SetColor(const Vec3& color, float a = 1) { m_color4b = ColorB(static_cast<uint8>(color.x * 255.0f), static_cast<uint8>(color.y * 255.0f), static_cast<uint8>(color.z * 255.0f), static_cast<uint8>(a * 255.0f)); };
|
||||
void SetColor(const QColor& rgb, float a) { m_color4b = ColorB(static_cast<uint8>(rgb.red()), static_cast<uint8>(rgb.green()), static_cast<uint8>(rgb.blue()), static_cast<uint8>(a * 255.0f)); };
|
||||
void SetColor(const QColor& color) { m_color4b = ColorB(static_cast<uint8>(color.red()), static_cast<uint8>(color.green()), static_cast<uint8>(color.blue()), static_cast<uint8>(color.alpha())); };
|
||||
void SetColor(const ColorB& color) { m_color4b = color; };
|
||||
void SetAlpha(float a = 1) { m_color4b.a = int(a * 255.0f); };
|
||||
void SetAlpha(float a = 1) { m_color4b.a = static_cast<uint8>(a * 255.0f); };
|
||||
ColorB GetColor() const { return m_color4b; }
|
||||
|
||||
void SetSelectedColor(float fAlpha = 1);
|
||||
|
||||
@@ -63,7 +63,7 @@ void DisplayContext::InternalDrawLine(const Vec3& v0, const ColorB& colV0, const
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void DisplayContext::DrawPoint(const Vec3& p, int nSize)
|
||||
{
|
||||
pRenderAuxGeom->DrawPoint(ToWorldSpacePosition(p), m_color4b, nSize);
|
||||
pRenderAuxGeom->DrawPoint(ToWorldSpacePosition(p), m_color4b, static_cast<uint8>(nSize));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -856,7 +856,10 @@ void DisplayContext::DrawLine(const Vec3& p1, const Vec3& p2, const ColorF& col1
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void DisplayContext::DrawLine(const Vec3& p1, const Vec3& p2, const QColor& rgb1, const QColor& rgb2)
|
||||
{
|
||||
InternalDrawLine(ToWorldSpacePosition(p1), ColorB(rgb1.red(), rgb1.green(), rgb1.blue(), 255), ToWorldSpacePosition(p2), ColorB(rgb2.red(), rgb2.green(), rgb2.blue(), 255));
|
||||
InternalDrawLine(ToWorldSpacePosition(p1),
|
||||
ColorB(static_cast<uint8>(rgb1.red()), static_cast<uint8>(rgb1.green()), static_cast<uint8>(rgb1.blue()), 255),
|
||||
ToWorldSpacePosition(p2),
|
||||
ColorB(static_cast<uint8>(rgb2.red()), static_cast<uint8>(rgb2.green()), static_cast<uint8>(rgb2.blue()), 255));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -63,7 +63,7 @@ protected:
|
||||
|
||||
void Undo([[maybe_unused]] bool bUndo) override
|
||||
{
|
||||
for (int i = 0, iLinkSize(m_Links.size()); i < iLinkSize; ++i)
|
||||
for (int i = 0, iLinkSize = static_cast<int>(m_Links.size()); i < iLinkSize; ++i)
|
||||
{
|
||||
SLink& link = m_Links[i];
|
||||
CBaseObject* pObj = GetIEditor()->GetObjectManager()->FindObject(link.entityID);
|
||||
@@ -1217,7 +1217,7 @@ XmlNodeRef CEntityObject::Export([[maybe_unused]] const QString& levelPath, XmlN
|
||||
if (!m_links.empty())
|
||||
{
|
||||
XmlNodeRef linksNode = objNode->newChild("EntityLinks");
|
||||
for (int i = 0, num = m_links.size(); i < num; i++)
|
||||
for (size_t i = 0, num = m_links.size(); i < num; i++)
|
||||
{
|
||||
if (m_links[i].target)
|
||||
{
|
||||
@@ -1283,7 +1283,7 @@ void CEntityObject::UpdateVisibility(bool bVisible)
|
||||
CBaseObject::UpdateVisibility(bVisible);
|
||||
|
||||
bool bVisibleWithSpec = bVisible && !IsHiddenBySpec();
|
||||
if (bVisibleWithSpec != m_bVisible)
|
||||
if (bVisibleWithSpec != static_cast<bool>(m_bVisible))
|
||||
{
|
||||
m_bVisible = bVisibleWithSpec;
|
||||
}
|
||||
@@ -1368,8 +1368,8 @@ void CEntityObject::PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx
|
||||
// Clone event targets.
|
||||
if (!pFromEntity->m_eventTargets.empty())
|
||||
{
|
||||
int numTargets = pFromEntity->m_eventTargets.size();
|
||||
for (int i = 0; i < numTargets; i++)
|
||||
size_t numTargets = pFromEntity->m_eventTargets.size();
|
||||
for (size_t i = 0; i < numTargets; i++)
|
||||
{
|
||||
CEntityEventTarget& et = pFromEntity->m_eventTargets[i];
|
||||
CBaseObject* pClonedTarget = ctx.FindClone(et.target);
|
||||
@@ -1386,7 +1386,7 @@ void CEntityObject::PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx
|
||||
// Clone links.
|
||||
if (!pFromEntity->m_links.empty())
|
||||
{
|
||||
int numTargets = pFromEntity->m_links.size();
|
||||
int numTargets = static_cast<int>(pFromEntity->m_links.size());
|
||||
for (int i = 0; i < numTargets; i++)
|
||||
{
|
||||
CEntityLink& et = pFromEntity->m_links[i];
|
||||
@@ -1437,7 +1437,7 @@ void CEntityObject::RemoveAllEntityLinks()
|
||||
{
|
||||
while (!m_links.empty())
|
||||
{
|
||||
RemoveEntityLink(m_links.size() - 1);
|
||||
RemoveEntityLink(static_cast<int>(m_links.size() - 1));
|
||||
}
|
||||
m_links.clear();
|
||||
SetModified(false);
|
||||
@@ -1448,7 +1448,7 @@ void CEntityObject::ReleaseEventTargets()
|
||||
{
|
||||
while (!m_eventTargets.empty())
|
||||
{
|
||||
RemoveEventTarget(m_eventTargets.size() - 1, false);
|
||||
RemoveEventTarget(static_cast<int>(m_eventTargets.size() - 1), false);
|
||||
}
|
||||
m_eventTargets.clear();
|
||||
SetModified(false);
|
||||
@@ -1518,7 +1518,7 @@ void CEntityObject::SaveLink(XmlNodeRef xmlNode)
|
||||
}
|
||||
|
||||
XmlNodeRef linksNode = xmlNode->newChild("EntityLinks");
|
||||
for (int i = 0, num = m_links.size(); i < num; i++)
|
||||
for (size_t i = 0, num = m_links.size(); i < num; i++)
|
||||
{
|
||||
XmlNodeRef linkNode = linksNode->newChild("Link");
|
||||
linkNode->setAttr("TargetId", m_links[i].targetId);
|
||||
@@ -1534,26 +1534,26 @@ void CEntityObject::OnObjectEvent(CBaseObject* target, int event)
|
||||
if (event == CBaseObject::ON_DELETE)
|
||||
{
|
||||
// Find this target in events list and remove.
|
||||
int numTargets = m_eventTargets.size();
|
||||
int numTargets = static_cast<int>(m_eventTargets.size());
|
||||
for (int i = 0; i < numTargets; i++)
|
||||
{
|
||||
if (m_eventTargets[i].target == target)
|
||||
{
|
||||
RemoveEventTarget(i);
|
||||
numTargets = m_eventTargets.size();
|
||||
numTargets = static_cast<int>(m_eventTargets.size());
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event == CBaseObject::ON_PREDELETE)
|
||||
{
|
||||
int numTargets = m_links.size();
|
||||
int numTargets = static_cast<int>(m_links.size());
|
||||
for (int i = 0; i < numTargets; i++)
|
||||
{
|
||||
if (m_links[i].target == target)
|
||||
{
|
||||
RemoveEntityLink(i);
|
||||
numTargets = m_eventTargets.size();
|
||||
numTargets = static_cast<int>(m_eventTargets.size());
|
||||
i--;
|
||||
}
|
||||
}
|
||||
@@ -1589,7 +1589,7 @@ int CEntityObject::AddEventTarget(CBaseObject* target, const QString& event, con
|
||||
m_eventTargets.push_back(et);
|
||||
|
||||
SetModified(false);
|
||||
return m_eventTargets.size() - 1;
|
||||
return static_cast<int>(m_eventTargets.size() - 1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -1659,13 +1659,13 @@ int CEntityObject::AddEntityLink(const QString& name, GUID targetEntityId)
|
||||
|
||||
SetModified(false);
|
||||
|
||||
return m_links.size() - 1;
|
||||
return static_cast<int>(m_links.size() - 1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CEntityObject::EntityLinkExists(const QString& name, GUID targetEntityId)
|
||||
{
|
||||
for (int i = 0, num = m_links.size(); i < num; ++i)
|
||||
for (size_t i = 0, num = m_links.size(); i < num; ++i)
|
||||
{
|
||||
if (m_links[i].targetId == targetEntityId && name.compare(m_links[i].name, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user