Files
UnrealEngineUWP/Engine/Source/Runtime/AnimGraphRuntime/Public/BoneControllers/AnimNode_AnimDynamics.h
Ori Cohen a0625fdf15 Copying //UE4/Dev-Framework to //UE4/Dev-Main (Source: //UE4/Dev-Framework @ 3058661)
#lockdown Nick.Penwarden
#rb none

==========================
MAJOR FEATURES + CHANGES
==========================

Change 3038116 on 2016/07/05 by James.Golding

	Resave QA-Promotion with new heightfield GUID to fix crash on load (broken DDC in Guildford)

Change 3038271 on 2016/07/05 by Lukasz.Furman

	fixed bug with instanced behavior tree nodes writing over memory of other nodes
	#jira UE-32789

Change 3038295 on 2016/07/05 by Lukasz.Furman

	changed behavior tree node injection to modify shared template instead of switching nodes to instanced
	fixes GC reference chain between AI using the same behavior tree

Change 3038504 on 2016/07/05 by Zak.Middleton

	#ue4 - Fix typo in comment (debugging arrow).

	github #2352
	#jira 30255

Change 3039151 on 2016/07/06 by James.Golding

	UE-30046 Add bAllowCPUAccess flag to UStaticMesh

Change 3039281 on 2016/07/06 by Ori.Cohen

	Fix attached partially simulating ragdolls not moving with actor.

	#JIRA UE-32830

Change 3039286 on 2016/07/06 by Benn.Gallagher

	Fixed crash with large clothing simulation meshes. Extended max verts from ~16k to ~65k and made it so you can no longer force import clothing above the maximum threshold that the vertex buffer is allowed to hold.

Change 3039313 on 2016/07/06 by Benn.Gallagher

	Enabled override of angular joint bias on AnimDynamics

Change 3039335 on 2016/07/06 by Ori.Cohen

	Fixed skeletal mesh components with non simulated root bodies incorrectly detaching from component hierarchy.

	#JIRA UE-32833

Change 3039412 on 2016/07/06 by Ori.Cohen

	PR #2382: Bug when setting constraint orientation using axes parameters (Contributed by DaveC79)

	#JIRA UE-30725

Change 3039799 on 2016/07/06 by Tom.Looman

	- Renamed SuggestProjectileVelocity_MediumArc to _CustomArc and added support for high/low arcs using float param. (Migrated from Odin)
	- Fixed bug in override gravity for the suggest projectile velocity functions.

Change 3039903 on 2016/07/06 by Ori.Cohen

	Ensure that skeletal mesh components do NOT teleport unless explicitly asked to.

Change 3039932 on 2016/07/06 by Lina.Halper

	Merging using //Orion/Dev-General_to_//UE4/Dev-Framework

	serialize crash is always bad, so dupe checkin.

Change 3040059 on 2016/07/06 by Ori.Cohen

	Fix bug where FixedFramerate was only clamping delta times that were above (very slow delta time was not getting changed to the fixed framerate)

	#JIRA UE-32730

Change 3040203 on 2016/07/06 by Jon.Nabozny

	Fix scaling multiple selected Actors by changing scale-base translation calculations to local space.

	#jira UE-32357

Change 3040211 on 2016/07/06 by Ori.Cohen

	Fix constraints being unselectable in phat when a render mesh is on top

	#JIRA UE-32479

Change 3040273 on 2016/07/06 by Ori.Cohen

	Fix vehicle drag adding instead of removing energy when in reverse.

	#JIRA UE-28957

Change 3040293 on 2016/07/06 by Zak.Middleton

	#ue4 - Add FMath::ClosestPointOnInfiniteLine() to distinguish it from the (poorly named) ClosestPointOnLine() that actually works on segments.

Change 3040325 on 2016/07/06 by Zak.Middleton

	#ue4 - Avoid checking for "client only" builds when recording demos. It could be a demo recording in standalone. Minor impact to previous optimization.

	#udn https://udn.unrealengine.com/questions/301595/412-413-regression-in-actorgetnetmode.html

Change 3040950 on 2016/07/07 by Thomas.Sarkanen

	Removed GWorld from FTimerManager

	Switched LastAssignedHandle to a static member.

	#jira UE-31485 - Remove GWorld from FTimerManager

Change 3041054 on 2016/07/07 by Jon.Nabozny

	Fix warning about negation operator on FRotator introduced in CL 3040203.

Change 3041214 on 2016/07/07 by Ori.Cohen

	Fix hit events on skeletal mesh component not respecting the AND between skeletal mesh component and the ragdoll bodies

	#JIRA UE-29538

Change 3041319 on 2016/07/07 by James.Golding

	UE-29771
	- Rename LocalAtoms to BoneSpaceTransforms
	- Rename SpaceBases to ComponentSpaceTransforms

Change 3041432 on 2016/07/07 by James.Golding

	UE-30937 Add FindCollisionUV util to GameplayStatics, but only works if you set new bSupportUVFromHitResults flag in PhysicsSettings, as we need to store UV info in the BodySetup. This is kept with the cooked mesh data in the DDC.
	Also remove PhysicsSettings.h from PhysicalMaterial.h

Change 3041434 on 2016/07/07 by James.Golding

	Improve comment on UStaticMesh::bAllowCPUAccess

Change 3041701 on 2016/07/07 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3041498

Change 3041760 on 2016/07/07 by Ori.Cohen

	Fix bug where turning collision off and on for a welded root body would not re-weld child bodies.

	#JIRA UE-32438

Change 3041771 on 2016/07/07 by Marc.Audy

	Add GetParentActor convience accessor

Change 3041798 on 2016/07/07 by Marc.Audy

	Don't double call BeginPlay on ChildActors when loading sublevels (4.12)
	#jira UE-32772

Change 3041857 on 2016/07/07 by Jon.Nabozny

	Allow modifying and reading EnableGravity flags on individual bones within a SkeletalMeshComponent via BoneName.

	#jira UE-32272

Change 3041914 on 2016/07/07 by Marc.Audy

	Fix mismatch function prototype

Change 3042041 on 2016/07/07 by Jon.Nabozny

	Fix CIS issue introduced by CL 3041857

Change 3042402 on 2016/07/08 by James.Golding

	Fix CIS after no longer globally including PhysicsSettings.h

Change 3042517 on 2016/07/08 by Martin.Wilson

	Fix root motion when actor and component transforms do not match

	#jira UE-32944

Change 3043021 on 2016/07/08 by mason.seay

	Assets for testing poses

Change 3043246 on 2016/07/08 by Marc.Audy

	Eliminate USoundWave::CompressionName
	Add USoundWave::HasCompressedFormat
	#jira UE-32546

Change 3044376 on 2016/07/11 by James.Golding

	- UE-32907 : Change UStaticMesh::GetPhysicsTriMeshData to only return required verts (ie will not return verts of sections with collision disabled)
	- Add UVInfo mem usage to UBodySetup::GetResourceSize
	- Remove BodySetup.h from EnginePrivate.h
	- Remove outdated comment in PhysUtils.cpp

Change 3044464 on 2016/07/11 by Ori.Cohen

	Fix CIS

	#JIRA UE-33005

Change 3044519 on 2016/07/11 by Ori.Cohen

	PR #2379: Option to Generate Overlaps for Actor during Level Streaming (Contributed by error454)

	#JIRA UE-30712

Change 3044774 on 2016/07/11 by Zak.Middleton

	#ue4 - Fix typos in comments.

Change 3044854 on 2016/07/11 by Mieszko.Zielinski

	Made AI sight's default trace channel configurable and set it to ECC_Visibility #UE4

	#jira UE-32013

Change 3044855 on 2016/07/11 by Mieszko.Zielinski

	Fixed BB key selectors not being resolved properly in BP implemented nodes #UE4

	#jira UE-32458

Change 3044887 on 2016/07/11 by Zak.Middleton

	#ue4 - Added new Blueprint library math/vector functions: FindClosestPointOnSegment, FindClosestPointOnLine, GetPointDistanceToSegment, GetPointDistanceToLine.

	- Fixed comments on FindNearestPointsOnLineSegments.
	- Fixed comments on FMath::PointDistToLine, and renamed "Line" parameter to "Direction".

	Merge CL 3036162.

Change 3044910 on 2016/07/11 by Mieszko.Zielinski

	Fixed  AISense_Sight not reporting any hits on ECC_Visibility channel #UE4

Change 3045144 on 2016/07/11 by Lukasz.Furman

	exposed pathfollowing's reach test modifier: goal radius as parameter of move request

Change 3045174 on 2016/07/11 by Marc.Audy

	Remove incorrect SetMobility reference from comment
	#jira UE-30492

Change 3045233 on 2016/07/11 by Marc.Audy

	Correct function name in warning

Change 3045284 on 2016/07/11 by mason.seay

	Test Assets for pose blending

Change 3045342 on 2016/07/11 by Michael.Noland

	PR #2284: Added PAPER2D_API to FSpriteDrawCallRecord (Contributed by grisevg)
	#jira UE-29522

Change 3045343 on 2016/07/11 by Michael.Noland

	PR #2533: Fixed bug that caused the tabs in the Flipbook, Sprite, and CodeProject editors to show the editor name rather than the asset name (Contributed by DevVancouver)
	#jira UE-32403

Change 3045344 on 2016/07/11 by Michael.Noland

	Paper2D: Fixed BP-created tile map components being incapable of having collision generated for them (still requires calling SetLayerCollision with rebuild=true or RebuildCollision)
	Paper2D: Exposed the ability to directly rebuild collision on a UPaperTileMap
	#jira UE-31632

Change 3045382 on 2016/07/11 by Ori.Cohen

	Expose mobility filtering query params. Allows users to filter out static mobility for example from scene queries.

	#JIRA UE-29937

Change 3045529 on 2016/07/11 by Zak.Middleton

	#ue4 - Improve comment about FFindFloorResult.bBlockingHit, explaining it is a valid blocking hit that was not in penetration. Other conditions can be determined from the HitResult itself.

Change 3045601 on 2016/07/11 by Michael.Noland

	Paper2D: Expose UPaperTileMap and UPaperTileSet as BlueprintType
	#jira UE-20962

Change 3046039 on 2016/07/12 by Jurre.deBaare

	Instanced HLOD materials to reduce permutations + compilation time

Change 3046147 on 2016/07/12 by Ori.Cohen

	PR #1615: Traceworldforposition should trace async scene too
	#JIRA UE-21728

Change 3046180 on 2016/07/12 by Ori.Cohen

	Introduce a shape complexity project setting

	#JIRA UE-31159

Change 3046280 on 2016/07/12 by Ori.Cohen

	Change physics blend weights to only affect rendering data. For effects that require updating physx we recommend using the new physical animation component.

	#JIRA UE-31525, UE-19252

Change 3046282 on 2016/07/12 by Benn.Gallagher

	Fix for crash or notify corruption when reverting the "Event" struct in montage notify editor.
	  - Made default slot 0, as a montage should always have at least one slot
	  - Made it impossible to revert the "Event" struct as it contains stuff that shouldn't be reverted. Can still revert its members though
	#jira UE-32626

Change 3046284 on 2016/07/12 by Benn.Gallagher

	Fix for crash or notify corruption when reverting the "Event" struct in montage notify editor.
	  - Made default slot 0, as a montage should always have at least one slot
	  - Made it impossible to revert the "Event" struct as it contains stuff that shouldn't be reverted. Can still revert its members though
	(2nd CL, missed file)
	#jira UE-32626

Change 3046416 on 2016/07/12 by Jon.Nabozny

	PR #2512: Change InstancedStaticMesh allow transform update to teleport (Contributed by joelmcginnis)

	#jira UE32123

Change 3046428 on 2016/07/12 by Michael.Noland

	Paper2D: Fixed inconsistent lighting on lit grouped sprites (caused by bad normals on any grouped sprites that were rotated away from (0,0,0))
	#jira UE-33055

Change 3046429 on 2016/07/12 by Michael.Noland

	Paper2D: Fixed inconsistent lighting on lit tilemaps in standalone or cooked builds (caused by trying to use the canonical Paper2D tangent basis before it has been initialized)
	#jira UE-25994

Change 3046475 on 2016/07/12 by Ori.Cohen

	Added strength multiplyer for physical animation

	#JIRA UE-33075

Change 3046518 on 2016/07/12 by Ori.Cohen

	Make sure to refresh contact points when turning simulation on for bodies.

	#JIRA UE-31286

Change 3046658 on 2016/07/12 by Ori.Cohen

	Fix the case where setting body blend weight doesn't turn off blend override.

Change 3046720 on 2016/07/12 by Ori.Cohen

	Added option to allow skeletal mesh simulation to NOT affect component transform.

	#JIRA UE-33089

Change 3046908 on 2016/07/12 by Ori.Cohen

	Fix welded body not properly unwelding when in a chain of welded bodies

	#JIRA UE-32531

Change 3047015 on 2016/07/12 by Lukasz.Furman

	fixed nested repath requests

Change 3047102 on 2016/07/12 by Ori.Cohen

	Added physics component to content example

Change 3047848 on 2016/07/13 by Ori.Cohen

	Expose transform update mode to phat

	#JIRA UE-33227

Change 3047853 on 2016/07/13 by Ori.Cohen

	Update physical animation level and content. Was missing some blueprints

Change 3047897 on 2016/07/13 by Ori.Cohen

	PR #2066: PhysX: Remove copy-paste code from LoadPhysXModules (Contributed by bozaro)

	#JIRA UE-27102

Change 3048026 on 2016/07/13 by Benn.Gallagher

	Altered reference gathering for retargetting to consider nodes in the Ubergraph. This catches refrerences as variables in the event graph and default values on event graph pins.
	#jira UE-23823

Change 3048592 on 2016/07/13 by Marc.Audy

	Change check when physics state exists but not registered to ensure and add additional logging information.
	#jira UE-32935

Change 3048790 on 2016/07/13 by Ori.Cohen

	Fix CIS for shipping physx builds.

	#JIRA UE-33246

Change 3048801 on 2016/07/13 by Ori.Cohen

	Update RootBodyTransform when ref skeleton has offset

Change 3048891 on 2016/07/13 by Marc.Audy

	Fix copy paste bug with AudioComponent::SetPitchMultiplier

Change 3049549 on 2016/07/14 by Thomas.Sarkanen

	Prevented stale anim asset references from persisting in wired pins

	Made sure to clear out the old asset in asset players when pins are made/destroyed. This requires a temporary string reference to the asset in UAnimGraphNode_AssetPlayerBase.
	Fixed up anim getters to properly use pin-default assets (previously they used the internal asset ptr that was not guaranteed to be in sync). Also fixe dup error messaging to be a bit more helpful when editing transition rules.
	Fixed up the various animation asset players to correctly display names when the asset is not set internally. Also correctly report compilation errors when pins are connected.
	Moved FA3NodeOptionalPinManager to new file ane renamed to FAnimBlueprintNodeOptionalPinManager to avoid circular includes.

	#jira UE-31015 - Asset Pins Keep Reference To Old 'Static' Asset

Change 3049576 on 2016/07/14 by Thomas.Sarkanen

	Fix CIS linker errors

Change 3049611 on 2016/07/14 by Benn.Gallagher

	Fixed "Isolate" checkbox in Persona mesh details not working on sections with clothing assigned (previously disabled drawing for all sections)
	Fixed "Highlight" checkbox in Persona mesh details not working after Section/Chunk refactor
	#jira UE-31016
	#jira UE-33061

Change 3049663 on 2016/07/14 by Benn.Gallagher

	CIS fix after Persona render fixes

Change 3049794 on 2016/07/14 by Marc.Audy

	Some cleanup and ensuring ActiveSound adds references to all of its used assets

Change 3049823 on 2016/07/14 by Tom.Looman

	Added Player Connect and Disconnect Multicast Events to GameMode

	PR #2398: Player Connect and Disconnect Multicast Events (for Plugins) (Contributed by dreckard)

Change 3049896 on 2016/07/14 by Ori.Cohen

	Fix cases where updating welded bodies is causing physx body to ignore the kinematic flag.

	#JIRA UE-31660

Change 3049921 on 2016/07/14 by Benn.Gallagher

	PR #2294: Reduce PhysX simulate() memory churn (Contributed by roberttroughton)
	    - Modifications: Per PxScene buffers, 16 byte alignment required for simulate call, skip clothing scenes (unused, we simulate per-actor)
	#jira UE-29573

Change 3049929 on 2016/07/14 by Zak.Middleton

	#ue4 - Make GetDefault<T>(UClass*) assert that the class is castable to T.

Change 3049956 on 2016/07/14 by Zak.Middleton

	#ue4 - Back out changelist 3049929 until I fix CastChecked<> compile issue.

Change 3049992 on 2016/07/14 by Jon.Nabozny

	Fix infite jumps when JumpMaxHoldTime is set. Also, allow multi-jumping out of the box.

	#JIRA: UE-31601

Change 3050017 on 2016/07/14 by James.Golding

	PR #2412: Make CalcSceneView and GetProjectionData in ULocalPlayer virtual (Contributed by yehaike)

Change 3050061 on 2016/07/14 by Zak.Middleton

	#ue4 - Make GetDefault<T>(UClass*) assert that the class is castable to T.

Change 3050254 on 2016/07/14 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3049614

Change 3050416 on 2016/07/14 by mason.seay

	Test map and asset for slicing proc meshes

Change 3050881 on 2016/07/14 by Zak.Middleton

	#ue4 - Make FSavedMove_Character::CanCombineWith easier to debug. Consolidate duplicate code to one block.

	github #2047

Change 3051401 on 2016/07/15 by Thomas.Sarkanen

	Prevented animation from restarting each time a new section is selected/inspected in the montage editor

	Preserved playback state when changing section.
	Added SetWeight function to montage instance as when switching between sections the montage would blend from ref-pose while paused.

	#jira UE-31014 - Moving Montage Event Unpauses Playback
	#jira UE-25101 - Improve Montage Replay Usability issue

Change 3051717 on 2016/07/15 by Benn.Gallagher

	Removed call to set sleepVelocityFrameDecayConstant on destructible shapes after advice from Nvidia and investigation by some licensees. Feature was used in the past to better settle piles but now PhysX can handle it fine and by setting it we were causing a hit in island generation.
	#jira UE-18558

Change 3051729 on 2016/07/15 by Benn.Gallagher

	Changed enum combo boxes so that they use rich tooltips instead of text tooltips.
	  - They look the same when there isn't a documentation entry for them (Just the enum name)
	  - Enum docs stored in /Shared/Enums/{EnumType} and the excerpt names are just the enum name

Change 3051825 on 2016/07/15 by Marc.Audy

	Display HiddenInGame for SceneComponents except when part of flattened properties in an Actor such as StaticMeshActor
	#jira UE-29435

Change 3051850 on 2016/07/15 by Marc.Audy

	Reduce priority of audio thread
	Add a frame sync to avoid audio thread drifiting behind

Change 3051920 on 2016/07/15 by Tom.Looman

	Added ActorComponent Activate/Deactivate events

	#JIRA UE-31077

Change 3051923 on 2016/07/15 by Tom.Looman

	PR #2370: Exposing "OverrideWith" and "CopyProperties" in PlayerState to Blueprint Children (Contributed by eXifreXi)

Change 3052038 on 2016/07/15 by Martin.Wilson

	Possible fix for fortnite crash + ensure incase the situation occurs again

	#jira UE-33258

Change 3052042 on 2016/07/15 by Jurre.deBaare

	Copying //Tasks/Framework/DEV-UEFW-21-AlembicImporter to Dev-Framework (//UE4/Dev-Framework)

Change 3052171 on 2016/07/15 by Ori.Cohen

	Improve UI for constraint profiles. Polish UI for physical animation profile.

	#JIRA UEFW-101, UE-33290

Change 3052243 on 2016/07/15 by Martin.Wilson

	Pose watching: Ability to draw bones of pose at any point in the anim graph.

	#jira UE-12181 (originally Epic Friday project)

Change 3053202 on 2016/07/18 by Thomas.Sarkanen

	FAnimInstanceProxy::EvaulateAnimation is now split into two for easier extensibility

	#jira UE-30107 - Split out part of FAnimInstanceProxy::EvaulateAnimation to allow users to use node evaluate without code duplication

Change 3053203 on 2016/07/18 by Thomas.Sarkanen

	Fixed properties that are fed to skeletal mesh components via construction script not updating when edited

	Forced skeletal mesh components to re-init their anim instance on reregister when in an editor world (a previous optimization was preventing this).
	Switched order of RerunConstructionScripts and ReregisterAllComponentsto be in-line with the undo/redo case  to prevent edits being a frame out of date.

	#jira UE-31890 - Variables cast from the Construction Script do not update in AnimBP AnimGraph

Change 3053241 on 2016/07/18 by Martin.Wilson

	Add parent bone space to GetSocketTransform

	#jira UE-29814

Change 3053270 on 2016/07/18 by Jurre.deBaare

	PR #2105: Disable creation of array modifiers (Contributed by projectgheist)

Change 3053273 on 2016/07/18 by Jurre.deBaare

	Default ini for asset viewer and HDR images

	#jira UE-32903

Change 3053527 on 2016/07/18 by Ori.Cohen

	Fix CIS

	#JIRA UE-33375

Change 3053620 on 2016/07/18 by Thomas.Sarkanen

	Socket chooser now has a search box

	Uses new FTextFilterExpressionEvaluator to filter bones & sockets by name.
	Search box has focus when the menu appears.

	#jira UE-23698 - Need a way to search through the Choose Socket or Bone: UI when attaching to a skeletal mesh

Change 3053626 on 2016/07/18 by Martin.Wilson

	Fix crash caused by skeletalmeshcomponent being destroyed during a notify

	#jira UE-33258

Change 3053761 on 2016/07/18 by Martin.Wilson

	Mac build compile fix

Change 3053858 on 2016/07/18 by Lina.Halper

	Merging using //UE4/Dev-Framework/_to_//Fortnite/Main/

	Fix on crashing recursive asset

Change 3053864 on 2016/07/18 by Ori.Cohen

	Make sure phat UI changes when picking different constraint profiles

Change 3053866 on 2016/07/18 by Ori.Cohen

	Submit content example for constraint profiles

Change 3053915 on 2016/07/18 by Lina.Halper

	The cached animinstance won't refresh until animation is replaced if you open while anim bp is opened
	This is the fix for that.

	#jira: UE-32927

Change 3053969 on 2016/07/18 by James.Golding

	PR #2571: Added a SimEventCallbackFactory (Contributed by NaturalMotionTechnology)

Change 3054004 on 2016/07/18 by Ori.Cohen

	Fix crash in welding when children have no owner component and ensure query only does not get welded by mistake.

	#jira UE-33333

Change 3054410 on 2016/07/18 by Lina.Halper

	Fixed issue with moving translation not working with mirrored parent due to inverse position.

	Changed to Transform.

	#jira: UE-31521

Change 3054659 on 2016/07/18 by Lina.Halper

	Fix for retargeting of pose asset

	- Moved animsequence::retarget to be out to AnimationRuntime
	- PoseAsset is now using that function to retarget correctly

	#code review: Martin.Wilson, Ori.Cohen

Change 3054777 on 2016/07/18 by Jurre.deBaare

	Fixing integration blocker, had this fix locally already

	#jira UE-33427

Change 3056619 on 2016/07/19 by Ori.Cohen

	Temporarily turn off audio threading due to heap corruption.

	#JIRA UE-33320

Change 3057770 on 2016/07/20 by Aaron.McLeran

	Doing sync trace for occlusion if audio thread is enabled
	#jira UE-33494

Change 3057778 on 2016/07/20 by Aaron.McLeran

	#jira UE-33494 Fix async line traces from audio thread causing crash (re-enable threaded audio)

Change 3057788 on 2016/07/20 by Aaron.McLeran

	#jira UE-33494 Fix async line traces from audio thread causing crash (re-enable threaded audio)

	Enabling audio thread (with a capital T for True)

Change 3057850 on 2016/07/20 by Ori.Cohen

	Temporarily turn off audio threading as the feature is still experimental

Change 3057876 on 2016/07/20 by Martin.Wilson

	Fix Graph Linked External Object issue when saving recompressed animations

	#jira UE-33567

Change 3058371 on 2016/07/20 by Ori.Cohen

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework)

[CL 3058682 by Ori Cohen in Main branch]
2016-07-20 18:23:54 -04:00

444 lines
18 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "AnimPhysicsSolver.h"
#include "AnimNode_SkeletalControlBase.h"
#include "AnimNode_AnimDynamics.generated.h"
DECLARE_CYCLE_STAT_EXTERN(TEXT("Anim Dynamics Overall"), STAT_AnimDynamicsOverall, STATGROUP_Physics, ANIMGRAPHRUNTIME_API);
DECLARE_CYCLE_STAT_EXTERN(TEXT("Anim Dynamics Wind Data Update"), STAT_AnimDynamicsWindData, STATGROUP_Physics, ANIMGRAPHRUNTIME_API);
DECLARE_CYCLE_STAT_EXTERN(TEXT("Anim Dynamics Bone Evaluation"), STAT_AnimDynamicsBoneEval, STATGROUP_Physics, ANIMGRAPHRUNTIME_API);
DECLARE_DWORD_COUNTER_STAT_EXTERN(TEXT("Anim Dynamics Sub-Steps"), STAT_AnimDynamicsSubSteps, STATGROUP_Physics, ANIMGRAPHRUNTIME_API);
/** Supported angular constraint types */
UENUM()
enum class AnimPhysAngularConstraintType : uint8
{
Angular,
Cone
};
/** Supported linear axis constraints */
UENUM()
enum class AnimPhysLinearConstraintType : uint8
{
Free,
Limited,
};
UENUM(BlueprintType)
enum class AnimPhysSimSpaceType : uint8
{
Component UMETA(ToolTip = "Sim origin is the location/orientation of the skeletal mesh component."),
Actor UMETA(ToolTip = "Sim origin is the location/orientation of the actor containing the skeletal mesh component."),
World UMETA(ToolTip = "Sim origin is the world origin. Teleporting characters is not recommended in this mode."),
RootRelative UMETA(ToolTip = "Sim origin is the location/orientation of the root bone."),
BoneRelative UMETA(ToolTip = "Sim origin is the location/orientation of the bone specified in RelativeSpaceBone"),
};
/** Helper mapping a rigid body to a bone reference */
struct FAnimPhysBoneRigidBody
{
FAnimPhysBoneRigidBody(TArray<FAnimPhysShape>& Shapes, const FVector& Position, const FBoneReference& LinkedBone)
: PhysBody(Shapes, Position)
, BoundBone(LinkedBone)
{}
FAnimPhysRigidBody PhysBody;
FBoneReference BoundBone;
};
/** Helper describing a body linked to an optional parent (can be nullptr) */
struct FAnimPhysLinkedBody
{
FAnimPhysLinkedBody(TArray<FAnimPhysShape>& Shapes, const FVector& Position, const FBoneReference& LinkedBone)
: RigidBody(Shapes, Position, LinkedBone)
, ParentBody(nullptr)
{}
FAnimPhysBoneRigidBody RigidBody;
FAnimPhysBoneRigidBody* ParentBody;
};
/** Constraint setup struct, holds data required to build a physics constraint */
USTRUCT()
struct FAnimPhysConstraintSetup
{
GENERATED_BODY()
FAnimPhysConstraintSetup()
: LinearXLimitType(AnimPhysLinearConstraintType::Limited)
, LinearYLimitType(AnimPhysLinearConstraintType::Limited)
, LinearZLimitType(AnimPhysLinearConstraintType::Limited)
, AngularConstraintType(AnimPhysAngularConstraintType::Angular)
, TwistAxis(AnimPhysTwistAxis::AxisX)
, ConeAngle(0.0f)
, AngularXAngle_DEPRECATED(0.0f)
, AngularYAngle_DEPRECATED(0.0f)
, AngularZAngle_DEPRECATED(0.0f)
{}
/** Whether to limit the linear X axis */
UPROPERTY(EditAnywhere, Category = Linear)
AnimPhysLinearConstraintType LinearXLimitType;
/** Whether to limit the linear Y axis */
UPROPERTY(EditAnywhere, Category = Linear)
AnimPhysLinearConstraintType LinearYLimitType;
/** Whether to limit the linear Z axis */
UPROPERTY(EditAnywhere, Category = Linear)
AnimPhysLinearConstraintType LinearZLimitType;
/** Minimum linear movement per-axis (Set zero here and in the max limit to lock) */
UPROPERTY(EditAnywhere, Category = Linear, meta = (UIMax = "0", ClampMax = "0"))
FVector LinearAxesMin;
/** Maximum linear movement per-axis (Set zero here and in the min limit to lock) */
UPROPERTY(EditAnywhere, Category = Linear, meta = (UIMin = "0", ClampMin = "0"))
FVector LinearAxesMax;
/** Method to use when constraining angular motion */
UPROPERTY(EditAnywhere, Category = Angular)
AnimPhysAngularConstraintType AngularConstraintType;
/** Axis to consider for twist when constraining angular motion (forward axis) */
UPROPERTY(EditAnywhere, Category = Angular)
AnimPhysTwistAxis TwistAxis;
/** Angle to use when constraining using a cone */
UPROPERTY(EditAnywhere, Category = Angular, meta = (UIMin = "0", UIMax = "90", ClampMin = "0", ClampMax = "90"))
float ConeAngle;
/** X-axis limit for angular motion when using the "Angular" constraint type (Set to 0 to lock, or 180 to remain free) */
UPROPERTY()
float AngularXAngle_DEPRECATED;
/** Y-axis limit for angular motion when using the "Angular" constraint type (Set to 0 to lock, or 180 to remain free) */
UPROPERTY()
float AngularYAngle_DEPRECATED;
/** Z-axis limit for angular motion when using the "Angular" constraint type (Set to 0 to lock, or 180 to remain free) */
UPROPERTY()
float AngularZAngle_DEPRECATED;
UPROPERTY(EditAnywhere, Category = Angular, meta = (UIMin = "-180", UIMax = "180", ClampMin = "-180", ClampMax = "180"))
FVector AngularLimitsMin;
UPROPERTY(EditAnywhere, Category = Angular, meta = (UIMin = "-180", UIMax = "180", ClampMin = "-180", ClampMax = "180"))
FVector AngularLimitsMax;
/** Axis on body1 to match to the angular target direction. */
UPROPERTY(EditAnywhere, Category = Angular)
AnimPhysTwistAxis AngularTargetAxis;
/** Target direction to face for body1 (in body0 local space) */
UPROPERTY(EditAnywhere, Category = Angular)
FVector AngularTarget;
/** The values below are calculated on initialisation and used when building the limits */
/** If all axes are locked we can use 3 linear limits instead of the 6 needed for limited axes */
UPROPERTY()
bool bLinearFullyLocked;
};
USTRUCT()
struct FAnimPhysPlanarLimit
{
GENERATED_BODY();
/** When using a driving bone, the plane transform will be relative to the bone transform */
UPROPERTY(EditAnywhere, Category=PlanarLimit)
FBoneReference DrivingBone;
/** Transform of the plane, this is either in component-space if no DrivinBone is specified
* or in bone-space if a driving bone is present.
*/
UPROPERTY(EditAnywhere, Category=PlanarLimit)
FTransform PlaneTransform;
};
/** Whether spheres keep bodies inside, or outside of their shape */
UENUM()
enum class ESphericalLimitType : uint8
{
Inner,
Outer
};
USTRUCT()
struct FAnimPhysSphericalLimit
{
GENERATED_BODY();
FAnimPhysSphericalLimit()
: SphereLocalOffset(FVector::ZeroVector)
, LimitRadius(0.0f)
, LimitType(ESphericalLimitType::Outer)
{}
/** Bone to attach the sphere to */
UPROPERTY(EditAnywhere, Category = SphericalLimit)
FBoneReference DrivingBone;
/** Local offset for the sphere, if no driving bone is set this is in node space, otherwise bone space */
UPROPERTY(EditAnywhere, Category = SphericalLimit)
FVector SphereLocalOffset;
/** Radius of the sphere */
UPROPERTY(EditAnywhere, Category = SphericalLimit)
float LimitRadius;
/** Whether to lock bodies inside or outside of the sphere */
UPROPERTY(EditAnywhere, Category = SphericalLimit)
ESphericalLimitType LimitType;
};
USTRUCT()
struct ANIMGRAPHRUNTIME_API FAnimNode_AnimDynamics : public FAnimNode_SkeletalControlBase
{
GENERATED_BODY();
FAnimNode_AnimDynamics();
/** The space used to run the simulation */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup, meta = (PinHiddenByDefault))
AnimPhysSimSpaceType SimulationSpace;
/** When in BoneRelative sim space, the simulation will use this bone as the origin */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup)
FBoneReference RelativeSpaceBone;
/** Set to true to use the solver to simulate a connected chain */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup)
bool bChain;
/** The bone to attach the physics body to, if bChain is true this is the top of the chain */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup)
FBoneReference BoundBone;
/** If bChain is true this is the bottom of the chain, otherwise ignored */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup, meta=(EditCondition = bChain))
FBoneReference ChainEnd;
/** Extents of the box to use for simulation */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup)
FVector BoxExtents;
/** Vector relative to the body being simulated to attach the constraint to */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup)
FVector LocalJointOffset;
/** Scale for gravity, higher values increase forces due to gravity */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup, meta = (PinHiddenByDefault))
float GravityScale;
/** If true the body will attempt to spring back to its initial position */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup)
bool bLinearSpring;
/** If true the body will attempt to align itself with the specified angular target */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup)
bool bAngularSpring;
/** Spring constant to use when calculating linear springs, higher values mean a stronger spring.*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup, meta = (PinHiddenByDefault))
float LinearSpringConstant;
/** Spring constant to use when calculating angular springs, higher values mean a stronger spring */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup, meta = (PinHiddenByDefault))
float AngularSpringConstant;
/** Whether or not wind is enabled for the bodies in this simulation */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Wind)
bool bEnableWind;
/** Scale to apply to calculated wind velocities in the solver */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Wind)
float WindScale;
/** If true, the override value will be used for linear damping */
UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadWrite, Category = Setup)
bool bOverrideLinearDamping;
/** Overridden linear damping value */
UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadWrite, Category = Setup, meta = (PinHiddenByDefault))
float LinearDampingOverride;
/** If true, the override value will be used for angular damping */
UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadWrite, Category = Setup)
bool bOverrideAngularDamping;
/** Overridden angular damping value */
UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadWrite, Category = Setup, meta = (PinHiddenByDefault))
float AngularDampingOverride;
/** If true, the override value will be used for the angular bias for bodies in this node.
* Angular bias is essentially a twist reduction for chain forces and defaults to a value to keep chains stability
* in check. When using single-body systems sometimes angular forces will look like they are "catching-up" with
* the mesh, if that's the case override this and push it towards 1.0f until it settles correctly
*/
UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadWrite, Category = Setup)
bool bOverrideAngularBias;
/** Overridden angular bias value
* Angular bias is essentially a twist reduction for chain forces and defaults to a value to keep chains stability
* in check. When using single-body systems sometimes angular forces will look like they are "catching-up" with
* the mesh, if that's the case override this and push it towards 1.0f until it settles correctly
*/
UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadWrite, Category = Setup, meta = (PinHiddenByDefault))
float AngularBiasOverride;
/** If true we will perform physics update, otherwise skip - allows visualisation of the initial state of the bodies */
UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadWrite, Category = Setup)
bool bDoUpdate;
/** If true we will perform bone transform evaluation, otherwise skip - allows visualisation of the initial anim state compared to the physics sim */
UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadWrite, Category = Setup)
bool bDoEval;
/** Number of update passes on the linear and angular limits before we solve the position of the bodies recommended to be four times the value of NumSolverIterationsPostUpdate */
UPROPERTY(EditAnywhere, AdvancedDisplay, Category = Setup)
int32 NumSolverIterationsPreUpdate;
/** Number of update passes on the linear and angular limits after we solve the position of the bodies, recommended to be around a quarter of NumSolverIterationsPreUpdate */
UPROPERTY(EditAnywhere, AdvancedDisplay, Category = Setup)
int32 NumSolverIterationsPostUpdate;
/** Data describing the constraints we will apply to the body */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Constraint)
FAnimPhysConstraintSetup ConstraintSetup;
/** Whether to evaluate planar limits */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PlanarLimit)
bool bUsePlanarLimit;
/** List of available planar limits for this node */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=PlanarLimit)
TArray<FAnimPhysPlanarLimit> PlanarLimits;
/** Whether to evaluate spherical limits */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SphericalLimit)
bool bUseSphericalLimits;
/** List of available spherical limits for this node */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SphericalLimit)
TArray<FAnimPhysSphericalLimit> SphericalLimits;
/** Resolution method for planar limits */
UPROPERTY(EditAnywhere, Category = Collision)
AnimPhysCollisionType CollisionType;
/** Radius to use if CollisionType is set to CustomSphere */
UPROPERTY(EditAnywhere, Category = Collision, meta = (UIMin = "1", ClampMin = "1"))
float SphereCollisionRadius;
/** An external force to apply to all bodies in the simulation when ticked, specified in world space */
UPROPERTY(EditAnywhere, Category = Forces, meta = (PinShownByDefault))
FVector ExternalForce;
// FAnimNode_SkeletalControlBase interface
virtual void Initialize(const FAnimationInitializeContext& Context) override;
virtual void UpdateInternal(const FAnimationUpdateContext& Context) override;
virtual void EvaluateBoneTransforms(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, TArray<FBoneTransform>& OutBoneTransforms) override;
virtual void GatherDebugData(FNodeDebugData& DebugData) override;
virtual bool HasPreUpdate() const override { return true; }
virtual void PreUpdate(const UAnimInstance* InAnimInstance) override;
virtual bool NeedsDynamicReset() const { return true; }
virtual void ResetDynamics() { RequestInitialise(); }
// End of FAnimNode_SkeletalControlBase interface
void RequestInitialise() { bRequiresInit = true; }
void InitPhysics(USkeletalMeshComponent* Component, FCSPose<FCompactPose>& MeshBases);
void TermPhysics();
void UpdateLimits(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases);
int32 GetNumBodies() const;
const FAnimPhysRigidBody& GetPhysBody(int32 BodyIndex) const;
#if WITH_EDITOR
// Accessors for editor code (mainly for visualization functions)
FVector GetBodyLocalJointOffset(int32 BodyIndex) const;
// Gets the number of currently bound bones (always 1 unless using a chain)
int32 GetNumBoundBones() const;
// Gets the specified bound bone reference
const FBoneReference* GetBoundBoneReference(int32 Index) const;
#endif
protected:
// FAnimNode_SkeletalControlBase protected interface
virtual void InitializeBoneReferences(const FBoneContainer& RequiredBones) override;
virtual bool IsValidToEvaluate(const USkeleton* Skeleton, const FBoneContainer& RequiredBones);
// End of FAnimNode_SkeletalControlBase protected interface
private:
// Given a bone index, get it's transform in the currently selected simulation space
FTransform GetBoneTransformInSimSpace(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, const FCompactPoseBoneIndex& BoneIndex);
// Given a transform in simulation space, convert it back to component space
FTransform GetComponentSpaceTransformFromSimSpace(AnimPhysSimSpaceType SimSpace, USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, const FTransform& InSimTransform);
// Given a transform in component space, convert it to the current sim space
FTransform GetSimSpaceTransformFromComponentSpace(AnimPhysSimSpaceType SimSpace, USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, const FTransform& InComponentTransform);
// Given a world-space vector, convert it into the current simulation space
FVector TransformWorldVectorToSimSpace(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, const FVector& InVec);
void ConvertSimulationSpace(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, AnimPhysSimSpaceType From, AnimPhysSimSpaceType To);
// We can't get clean bone positions unless we are in the evaluate step.
// Requesting an init or reinit sets this flag for us to pick up during evaluate
bool bRequiresInit;
// Maximum time to consider when accumulating time debt to avoid spiraling
static const float MaxTimeDebt;
// Cached timestep from the update phase (needed in evaluate phase)
float NextTimeStep;
// Current amount of time debt
float TimeDebt;
// Current time dilation
float CurrentTimeDilation;
// Cached physics settings. We cache these on initialise to avoid the cost of accessing UPhysicsSettings a lot each frame
float MaxPhysicsDeltaTime;
float MaxSubstepDeltaTime;
int32 MaxSubsteps;
//////////////////////////////////////////////////////////////////////////
// Cached sim space that we last used
AnimPhysSimSpaceType LastSimSpace;
// Active body list
TArray<FAnimPhysLinkedBody> Bodies;
// Pointers back to the base bodies to pass to the simulation
TArray<FAnimPhysRigidBody*> BaseBodyPtrs;
// List of current linear limits built for the current frame
TArray<FAnimPhysLinearLimit> LinearLimits;
// List of current angular limits built for the current frame
TArray<FAnimPhysAngularLimit> AngularLimits;
// List of spring force generators created for this frame
TArray<FAnimPhysSpring> Springs;
// Local space offsets for each body
TArray<FVector> JointOffsets;
// List of bone references for all bodies in this node
TArray<FBoneReference> BoundBoneReferences;
// Gravity direction in sim space
FVector SimSpaceGravityDirection;
};