You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb none #lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 3198996 on 2016/11/15 by Marc.Audy BeginPlay calls will now be dispatched in a consistent order regardless of placed in persistent level, streamed in level, or dynamically spawned AActor::BeginPlay is now protected, you should call DispatchBeginPlay instead. #jira UE-21136 Change 3199019 on 2016/11/15 by Marc.Audy Mark user-facing BeginPlay calls as protected Change 3200128 on 2016/11/16 by Thomas.Sarkanen Dont propgate threaded update flag from UAnimBluepint to CDO if we fail thread safety checks Also fully deprecated (with _DEPRECATED) older flags in UAnimInstance. #jira UE-38362 - Disable multi-threaded update when anim blueprints are not thread-safe Change 3200133 on 2016/11/16 by Martin.Wilson Fix Set Anim Instance Class not working on the second attempt (InitAnim would not be called) #jira UE-18798 Change 3200167 on 2016/11/16 by Martin.Wilson Newly added virtual bones are now selected in the skeleton tree #jira UE-37776 Change 3200255 on 2016/11/16 by James.Golding Stop SkeletalMeshTypes.h being globally included Change 3200289 on 2016/11/16 by Jurre.deBaare Hidden Material References from Mesh Components Fix #fix Make sure that in PostEditChangeProp we reset the override material arrays #misc changed a property comparison to use GET_MEMBER_NAME_CHECKED instead #jira UE-38108 Change 3200291 on 2016/11/16 by Jurre.deBaare Imported Alembic skeletal anims have cut-off shadow due to moving out of the bounds #fix retrieve bounds from alembic archive at various levels (global, transform, meshes) and build archive bounds which is set on the animation sequence #jira UE-37274 Change 3200293 on 2016/11/16 by Jurre.deBaare Overlapping UV's cause merge actor texture baking issues #fix Only look for overlapping UVs if vertex data baking is actually expected/enabled #jira UE-37220 Change 3200294 on 2016/11/16 by Jurre.deBaare Scrubbing Playback Speed under Geometry Cache in the details panel is too sensitive #fix Make the UIMin/Max smaller than the clamping value for proper user interaction while sliding (thanks James for the tip!) #jira UE-36679 Change 3200295 on 2016/11/16 by Jurre.deBaare Merge Actor Specific LOD level can be set to 8 #fix Change clamping value and added UI clamp metadata #jira UE-37134 Change 3200296 on 2016/11/16 by Jurre.deBaare In Merge Actors if you select use specific Lod level you have access to all the merge material settings #fix Added edit condition to non-grayed out material settings #jira UE-36667 Change 3200303 on 2016/11/16 by Thomas.Sarkanen Fixed diagonal current scrub value in anim curves #jira UE-35787 - The red time indicator for viewing curves in persona is slightly tilted Change 3200304 on 2016/11/16 by Thomas.Sarkanen Rezero is now explicit about what it does (current vs. specified frame) Also no longer ingores Z-offset (legacy feature - root motion can have any translation, not just 2D). #jira UE-35985 - Rezero doesn't work by frame Change 3200307 on 2016/11/16 by Thomas.Sarkanen Add curve panel to anim BP editor Also improve curve modification message routing. We were needlessly passing delegates up and down the widget hierarchy and conflating smart name edits with curve edits (key addition etc.). #jira UE-35742 - Anim Curve Viewer allowed in Anim BP Change 3200313 on 2016/11/16 by Jurre.deBaare Animations with materials driven by scalar parameters from curves wont update until persona is closed and reopened #fix in debug skeletal mesh component just mark the cached parameters dirty every tick #jira UE-35786 Change 3200316 on 2016/11/16 by Jurre.deBaare Converted Skeletal To Static Mesh Gets Corrupted When Merged #fix Assume that the all static meshes will contain valid texture coordinates for channel 0 (which is expect by static mesh code as well) #misc Ensure that we set the lightmap index for converted skeletal meshes to either an empty one or the highest one used #jira UE-37988 Change 3200321 on 2016/11/16 by Jurre.deBaare Scrolling/scroll bar are disabled in Alembic Import window if you scroll a certain way down #fix change the way the layout is constructed #jira UE-37260 Change 3200323 on 2016/11/16 by Jurre.deBaare Toggling sky in Persona does not effect reflections #fix turn of skylight together with the actual environment sphere #misc found incorrect copy paste in toggling floor/environment visibility with key stroke #jira UE-26796 Change 3200324 on 2016/11/16 by Jurre.deBaare Open Merge Actor menu on right clicking two selected actors #fix Added option 'Merge Actors' to right-click context menu when having selected one or multiple actors in the viewport #jira UE-36892 Change 3200331 on 2016/11/16 by Benn.Gallagher Added support for suspending clothing simulations at runtime, exposed also to blueperints. And aded option in Persona to pause simulations when animations are paused. #jira UE-38620 Change 3200334 on 2016/11/16 by Jurre.deBaare Dynamic light settings in Persona viewport cause edges to appear hardened #fix Makeing the directional light stationary to ups the shadowing quality #jira UE-37188 Change 3200356 on 2016/11/16 by Jurre.deBaare Rate scale option for animation nodes in blend spaces #added Rate scale variable to blend space samples, these rates are now multiplied with the global rate scale during playback #misc bumped framework object version to update all blendspaces on load #jira UE-16207 Change 3200380 on 2016/11/16 by Jurre.deBaare Fix for Mac CIS issues Change 3200383 on 2016/11/16 by Marc.Audy Split FAttenuationSettings in to FBaseAttenuationSettings and FSoundAttenuationSettings in preparation for reuse of the base attenuation for force feedback Change 3200385 on 2016/11/16 by James.Golding Refactor SkeletalMesh to use same color buffer type as StaticMesh Change3200407on 2016/11/16 by James.Golding Fix CIS error in FbxAutomationTests.cpp Change 3200417 on 2016/11/16 by Jurre.deBaare Fix for CIS issues #fix Rogue } Change 3200446 on 2016/11/16 by Martin.Wilson Change fix for Set Anim Instance Class from CL 3200133 #jira UE-18798 Change 3200579 on 2016/11/16 by Martin.Wilson Fix for serialization crash in Odin #jir UE-38683 Change 3200659 on 2016/11/16 by Martin.Wilson Fix build errors Change 3200801 on 2016/11/16 by Lina.Halper Fix error message Change 3200873 on 2016/11/16 by Lina.Halper Test case for Update Rate Optimization - LOD_URO_Map.umap - test map - LODPawn - pawn that contains mesh with URO setting - You can tweak the value in LODPawn Change 3201017 on 2016/11/16 by Lina.Halper - Allow slave component to be removed when setting master pose to nullptr - licensee reported this issue. https://udn.unrealengine.com/questions/321037/skeletalmeshcomponent.html Change 3201765 on 2016/11/17 by Jurre.deBaare Improved tooltip for FBlendParameter.GridNum Change 3201817 on 2016/11/17 by Thomas.Sarkanen Added display/edit of bone transforms in details panel Added UBoneProxy tickable editor object held by the skeleton tree that updates its internal transforms in Tick(). Updated various bits of supporting code to allow selection to be properly preserved in cases such as undo/redo. This allows the bone proxy object to be displayed over an undo/redo event. It also fixes some inconsistency with selection between the skeleton tree and the preview scene. Breaking change: Updated FOnPreviewMeshChangedMulticaster delegate signature to take both the old and new skeletal mesh. This is to allow clients to skip certain logic if the skeletal mesh hasnt really changed (in this case de-selection). #jira UE-38144 - Selected Bone Transform not visible in Persona on the AnimBP tab Change3201819on 2016/11/17 by Thomas.Sarkanen Fix CIS error Change 3201901 on 2016/11/17 by Lina.Halper With new system, the skeleton curve count is not the one we should check but BoneContainer.GetAnimCurveNameUids(). - removed GetCurveNumber from skeleton - changed curve count to use BoneContainer's curve list. #code review: Laurent.Delayen Change 3201999 on 2016/11/17 by Thomas.Sarkanen Add local/world transform editing to bone editing Added details customization & support code for world-space editing of bone transforms #jira UE-38144 - Selected Bone Transform not visible in Persona on the AnimBP tab Change 3202111 on 2016/11/17 by mason.seay Potential test assets for HLOD Change 3202240 on 2016/11/17 by Thomas.Sarkanen Fixed extra whitespace not being removed in front of console commands. GitHub #2843 #jira UE-37019 - GitHub 2843 : Fixed extra whitespace not being removed in front of console commands. Change 3202259 on 2016/11/17 by Jurre.deBaare Readded missing shadows in advanced preview scene Change3203180on 2016/11/17 by mason.seay Moved and updated URO Map Change 3203678 on 2016/11/18 by Thomas.Sarkanen Bug fix for menu extenders in PhAT. GitHub #2550 #jira UE-32678 - GitHub 2550 : Bug fix for menu extenders in PhAT. Change 3203679 on 2016/11/18 by Thomas.Sarkanen Fixed LOD hysteresis not being properly converted from the old metric This addreses some 'LOD lag' issues seen when just treating as an equivalent fudge factor, as the magnitude needed to have an effect has changed. #jira UE-38640 - Skeletal mesh LODs render incorrectly and incosistently Change 3203747 on 2016/11/18 by Jurre.deBaare Crash when repeatedly undoing and readding of animation to a AnimOffset 1D - IsValidBlendSampleIndex #fix Ensure we reset the hightlighting / dragging / selection state when PostUndo is called, this makes sure we repopulate tooltips if need etc. #jira UE-38734 Change 3203748 on 2016/11/18 by Jurre.deBaare Crash Generating Proxy Meshes after replacing static meshes in the level #fix just calculate bounds for the used UVs (old behaviour was wrong) #jira UE-38764 Change 3203751 on 2016/11/18 by james.cobbett Changes to TM-PoseSnapshot and new test assets Change 3203799 on 2016/11/18 by Thomas.Sarkanen Switched fudged auto-LOD calculations to use a pow() decay instead of a recprocal Still a fudge when LOD reduction has not been performed in-engine, but a fudge with similar outcomes to the previous method. Also fixed up the naming of some variables that still referred to screen areas & LOD distances. #jira UE-38674 - LOD distance switching have changed since 4.14 and merged lod actors seem to switch at incorrect screen scales as a result Change 3203856 on 2016/11/18 by james.cobbett TM-PoseSnapshot - Rebuild lighting and updated anims Change 3203880 on 2016/11/18 by Ori.Cohen Copying //UE4/Dev-Physics-Upgrade to Dev-Framework (//UE4/Dev-Framework) Change 3203940 on 2016/11/18 by Ori.Cohen Fix missing newline for ps4 Change 3203960 on 2016/11/18 by Ori.Cohen Readd fix for linux macro expansion warning Change 3203975 on 2016/11/18 by Ori.Cohen Fix for linux toolchain not knowing about no-unused-local-typedef Change 3203989 on 2016/11/18 by Ori.Cohen Make sure physx automation doesn't try to build html5 APEX. Change 3204031 on 2016/11/18 by james.cobbett Minor update to test level Change 3204035 on 2016/11/18 by Marc.Audy Additional Attenuation refactor cleanup Change 3204044 on 2016/11/18 by Ori.Cohen Fix typo of NV_SIMD_SSE2 Change 3204049 on 2016/11/18 by Ori.Cohen Fix missing newline for PS4 compiler Change 3204463 on 2016/11/18 by mason.seay Finalized URO test map Change 3204621 on 2016/11/18 by mason.seay Small improvements Change 3204751 on 2016/11/18 by Ori.Cohen Make PhAT highlight selected bodies and constraints in the tree view Change 3205868 on 2016/11/21 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3205744 Change 3205887 on 2016/11/21 by Jurre.deBaare Fix for similar crash in blendspace editor like UE-38734 Change 3206121 on 2016/11/21 by Marc.Audy PR #2935: Minor subtitle issues (Contributed by projectgheist) #jira UE-38803 #jira UE-38692 Change 3206187 on 2016/11/21 by Marc.Audy PR #2935: Minor subtitle issues (Contributed by projectgheist) Additional bits #jira UE-38519 #jira UE-38803 #jira UE-38692 Change 3206318 on 2016/11/21 by Marc.Audy Fix Linux compiler whinging Change 3206379 on 2016/11/21 by Marc.Audy Fix crash when streaming in a sublevel with a child actor in it (4.14.1) #jira UE-38906 Change 3206591 on 2016/11/21 by Marc.Audy Refactor restrictions to allow hidden and clarify disabled Change 3206776 on 2016/11/21 by Marc.Audy ForceFeedback component allows rumble events to be placed or spawned in to the world with attenuation settings that dictate how intensely the rumble pattern will be applied to the player based on their distance to the effect. ForceFeedback Attenuation settings can be defined via the content browser or directly on the component. #jira UEFW-244 Change3206901on 2016/11/21 by Marc.Audy Fix compile error in automation tests Change 3207235 on 2016/11/22 by danny.bouimad Updated Map Change3207264on 2016/11/22 by Thomas.Sarkanen Disable bone editing in anim blueprint editor #jira UE-38876 - Transform options in bone Details panel in Anim Blueprint Persona editor appear editable Change 3207303 on 2016/11/22 by Lina.Halper Clear material curve by setting it directly because the flag might not exist #jira: UE-36902 Change 3207331 on 2016/11/22 by Jon.Nabozny Fix overflow issues in SerializeProperties_DynamicArray_r. Also, fix crash from not ensuring properties were serialized successfully. Change 3207357 on 2016/11/22 by Danny.Bouimad Updating testcontent for pose drivers Change 3207425 on 2016/11/22 by Lina.Halper Fix frame count issue with montage #jira: UE-30048 Change 3207478 on 2016/11/22 by Lina.Halper Fix so that curve warning doesn't happen when your name is same. #jira: UE-34246 Change 3207526 on 2016/11/22 by Marc.Audy Fix crash when property restriction introduces a hidden entry Change 3207731 on 2016/11/22 by danny.bouimad MoreUpdates Change 3207764 on 2016/11/22 by Lina.Halper #fix order of morphtarget to first process animation and then BP for slave component Change 3207842 on 2016/11/22 by Ben.Zeigler Fix it so ActiveStructRedirects are checked in addition to ActiveClassRedirects when serializing a raw UStruct reference, such as in a blueprint UStructProperty. This fixes issue with the attenuation settings struct rename, and should have always been working this way. ActiveClassRedirects will still work. Change 3208202 on 2016/11/22 by Ben.Zeigler #jira UE-38811 Fix regression with gimbal locking in player camera manager. The quat->rotator->quat->rotator conversions are introducing more error than in 4.13, so a pitch limit of -89.99 was too precise. Change 3208510 on 2016/11/23 by Wes.Hunt Disable UBT Telemetry on internal builds #jira AN-1059 #tests build a few different ways, add more diagnostics to clarify if the provider is being used. Change 3208734 on 2016/11/23 by Martin.Wilson Change EnsureAllIndicesHaveHandles to try and maintain validity of as many of the handles as possible + Make FRichCurve key member private as it needs to stay in sync with map on base class #jira UE-38899 Change 3208782 on 2016/11/23 by Thomas.Sarkanen Fixed material and vert count issues with skeletal to static mesh conversion Material remapping was not bein gbuilt, so material indices were overwitten inappropriately. Vertex tangentY was being recalculated incorrectly (discarding the W component when transformed), so vertices were not correctly re-merged later in the static mesh build phase. #jira UE-37898 - Materials are incorrect on static mesh made from skeletal mesh Change 3208798 on 2016/11/23 by James.Golding UE-38478 - Fix collision on procmesh created in BeginPlay in cooked builds Change 3208801 on 2016/11/23 by Jurre.deBaare Hidden Material References from Mesh Components Fix #fix forgot to mark the renderstate dirty and wrapped it to only apply when overridematerials actually contain something #jira UE-38108 Change 3208807 on 2016/11/23 by Thomas.Sarkanen CIS fix Change 3208824 on 2016/11/23 by danny.bouimad More content updates for Testing Change 3208827 on 2016/11/23 by Danny.Bouimad Removing Old Pose driver Testassets I created awhile ago. Change 3209026 on 2016/11/23 by Martin.Wilson CIS Fix for FRichCurve Change 3209083 on 2016/11/23 by Marc.Audy Don't crash if after an undo the previously selected object no longer exists (4.14.1) #jira UE-38991 Change 3209085 on 2016/11/23 by Marc.Audy Don't crash if a negative length passed in to UKismetStringLibrary::GetSubstring (4.14.1) #jira UE-38992 Change 3209124 on 2016/11/23 by Ben.Zeigler #jira UE-38867 Fix some game mode log messages From PR #2955 Change 3209231 on 2016/11/23 by Marc.Audy Auto removal Change 3209232 on 2016/11/23 by Marc.Audy GetComponents now optionally can include components in Child Actors Change 3209233 on 2016/11/23 by Marc.Audy ParseIntoArray resets instead of empty Change3209235on 2016/11/23 by Marc.Audy Allow child actor components to be selected in viewports Fix selection highlight not working on nested child actors #jira UE-16688 Change 3209247 on 2016/11/23 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3209194 Change 3209299 on 2016/11/23 by Marc.Audy Use MoveTemp to reduce some memory churn in graph schema actions Change 3209347 on 2016/11/23 by Marc.Audy Don't dispatch a tick function that had been scheduled but has been disabled before being executed. #jira UE-37459 Change 3209507 on 2016/11/23 by Ben.Zeigler #jira UE-38185 Keep player controllers in their same order during a seamless travel From PR #2908 Change 3209882 on 2016/11/24 by Thomas.Sarkanen Copy-to-array now works with the fast path Refactored the copy record generation/validation code to be clearer with better seperation of concerns. Made sure we always properly generate a full exec chain for our events, despite some other them potentially using the fast path (this may have been a bug waiting to happen). Fixed a potentiual bug with sub anim instances were potentiall fast path non-array properties were skipped. Added tests for fast path validity to EditorTests project. Assets to follow. #jira UE-34569 - Fast Path gets turned off if you link to multiple input pins Change 3209884 on 2016/11/24 by Thomas.Sarkanen File I missed Change 3209885 on 2016/11/24 by Thomas.Sarkanen Support assets for fast path tests Change 3209939 on 2016/11/24 by Benn.Gallagher Fixed anim blueprint compiler not following reroute nodes when building cached pose fragment list #jira UE-35557 Change 3209941 on 2016/11/24 by Jurre.deBaare Removing and readding a point to the Anim Offset graph results in the animation to not preview correctly. #fix make sure that when we delete a sample point we reset the preview base pose #misc changed how the preview base pose is determined/updated #jira UE-38733 Change 3209942 on 2016/11/24 by Thomas.Sarkanen Fixed transactions being made when setting bone space in details panel Also added reset to defaults to allow easy removal of bone modifications. #jira UE-38957 - Switching between Local and World Location in Persona Bone Transform options creates an Undo transaction Change 3209945 on 2016/11/24 by james.cobbett Test assets for Pose Snapshot Test Case Change 3210239 on 2016/11/25 by Mieszko.Zielinski Making Navmesh react to changes done to static mesh's collision setup via the SM Editor #UE4 #jira UE-29415 Change 3210279 on 2016/11/25 by Benn.Gallagher Fixed anim sub-instances only allowing one pin to work when any pin required a call out to the VM for evaluation #jira UE-38040 Change 3210288 on 2016/11/25 by danny.bouimad Cleaned up Pose Driver Anim BP's Change 3210334 on 2016/11/25 by Benn.Gallagher Fixed preview mesh references getting broken in physics assets when renaming the preview mesh asset. Added explicit reference collection for the TAssetPtr #jira UE-22145 Change 3210349 on 2016/11/25 by James.Golding UE-35783 Fix scrolling in PoseAsset editor panels Change 3210356 on 2016/11/25 by James.Golding UE-38420 Disable 'Convert to Static Mesh' option if no MeshComponents selected (e.g. cables) Change 3210357 on 2016/11/25 by Jurre.deBaare Numeric textbox value label incorrect for aimoffset/blendspaces in grid #fix change lambda capture type (was referencing local variable) Change 3210358 on 2016/11/25 by Jurre.deBaare Crash Generating Proxy Mesh with Transition Screen Size set to 1 #fix 1.0 was not included within the possible range #jira UE-38810 Change 3210364 on 2016/11/25 by James.Golding Improve BuildVertexBuffers to use stride and avoid copying colors Change 3210371 on 2016/11/25 by Jurre.deBaare You can no longer enable tooltip display when using anim offset #fix Added back ability to show advanced preview sample weighting to tooltip under CTRL down #jira UE-38808 It's not clear that the user has to hold shift to preview in blend spaces #fix Preview value is now set by default and has a tooltip state, this will inform the user how to move the preview value #jira UE-38711 #misc refactored out some duplicate code :) Change 3210387 on 2016/11/25 by james.cobbett Updating test asset Change 3210550 on 2016/11/26 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3209927 Brings IWYU in and required substantial fixups Change 3210551 on 2016/11/26 by Marc.Audy Delete empty cpp files Change 3211002 on 2016/11/28 by Lukasz.Furman added navigation update on editting volume's brush #ue4 Change 3211011 on 2016/11/28 by Marc.Audy Roll back CL# 3210334 as it is causing deadlocks during GC Change 3211039 on 2016/11/28 by Jurre.deBaare Merge Actors tool is splitting every vertex on spline meshes, causing hard edged vertex colors. #fix prevent using the wedge map when propagating spline mesh vertex colours #jira UE-36011 Change 3211053 on 2016/11/28 by Ori.Cohen Make sure objects without simple collision do not simulate. Fixes crash when two trimesh only objects collide #JIRA UE-38989 Change 3211101 on 2016/11/28 by mason.seay Adjusting trigger collision so it can't be triggered by projectiles Change 3211171 on 2016/11/28 by Jurre.deBaare Previewing outside of Blendspace Graph points causes unexpected weighting #jira UE-32775 Second Animation Sample added to AimOffset or Blendspace swaps with the first sample #jira UE-36755 #fix Changed behaviour for calculating blendspace grid weighting for one, two or colinear triangles - One: fill grid weights to single sample - Two: find closest point on line between the two samples for the grid point, and weight according to the distance on the line - Colinear: find two closest samples and apply behaviour above #misc rename variables to make the code more clear and correct Change 3211491 on 2016/11/28 by Marc.Audy Provide proper tooltip for GetParentActor/Component Expose GetAttachParentActor/SocketName to blueprints De-virtualize Actor GetAttach... functions #jira UE-39056 Change 3211570 on 2016/11/28 by Lina.Halper Title doesn't update when asset is being dropped #jira: UE-39019 Change 3211766 on 2016/11/28 by Ori.Cohen Remove warning when a constraint has two empty components. This can be a valid usecase for when components are determined dynamically. #JIRA UE-36089 Change 3211938 on 2016/11/28 by Mason.Seay CSV's for testing gameplay tags Change 3212090 on 2016/11/28 by Ori.Cohen Expose angular SLERP drive to blueprints #JIRA UE-36690 Change 3212102 on 2016/11/28 by Marc.Audy Fix shadow variable issue #jira UE-39099 Change 3212182 on 2016/11/28 by Ori.Cohen PR #2902: Fix last collision preset display (Contributed by max99x) #JIRA UE-38100 Change 3212196 on 2016/11/28 by dan.reynolds AEOverview Update: Minor tweaks and fixes Added Attenuation Curve Tests Renamed SC to SCLA for Sound Class prefix WIP SCON (Sound Concurrency) Change 3212347 on 2016/11/28 by Ben.Zeigler #jira UE-39098 Fix issues with adding tag redirectors with the editor open, it now checks the redirector list in the editor Fix chained tag redirectors to work properly Const fixes and removed a bad error message spam, and fix rename message Change 3212385 on 2016/11/28 by Marc.Audy Avoid duplicate GetWorld() calls Change 3212386 on 2016/11/28 by Marc.Audy auto shoo Change 3213018 on 2016/11/29 by Marc.Audy Fix shadow variable for real Change 3213037 on 2016/11/29 by Ori.Cohen Fix deprecation warnings Change 3213039 on 2016/11/29 by Marc.Audy Generalize logic for when a component prevents an Actor from auto destroying Add forcefeedback component to the components that will hold up the auto destroy of an actor Change 3213088 on 2016/11/29 by Marc.Audy Move significance manager out of experimental Change 3213187 on 2016/11/29 by Marc.Audy Add InsertDefaulted to mirror options available when Adding Change 3213254 on 2016/11/29 by Marc.Audy add auto-complete for showdebug forcefeedback Change 3213260 on 2016/11/29 by Marc.Audy Allow systems to inject auto-complete console entries Change 3213276 on 2016/11/29 by Marc.Audy add auto-complete entry for showdebug significancemanager Change 3213331 on 2016/11/29 by James.Golding Split SkeletalMesh skin weights into their own stream Remove unused FGPUSkinVertexColor struct Remove unused FSkeletalMeshVertexBuffer::bInfluencesByteSwapped bool Fix FSkeletalMeshMerge::GenerateLODModel to handle >4 weights Update friendly name for FColorVertexBuffer now it's used by skel mesh as well Change 3213349 on 2016/11/29 by Ben.Zeigler Fix tag rename feedback message Change 3213355 on 2016/11/29 by Ben.Zeigler #jira UE-39115 PR #2987: Added IsPaused to AGameModeBase (Contributed by RoyAwesome) Change 3213406 on 2016/11/29 by Ori.Cohen Make sure body transforms are not set while the physx simulation is running. #JIRA UE-37270 Change 3213508 on 2016/11/29 by Jurre.deBaare When performing a merge actor on an actor merging multiple materials certain maps aren't generated #fix Apparently rendering out specular etc now outputs its value only to the red channel, so had to change how we populate the combined metallic/roughness/specular map #jira UE-38526 Change 3213557 on 2016/11/29 by Ben.Zeigler #jira UE-22145 Fix issues where TAssetPtrs weren't getting properly fixed up during rename fixup, it now runs the StringAssetReference fixup on the nested reference. This should fix lots of weird issues with references going away Change 3213634 on 2016/11/29 by Ori.Cohen Make sure if no shapes are found for vehicle wheels we create spheres and attach them to the actor. Change 3213639 on 2016/11/29 by Ori.Cohen Fix from nvidia for vehicle suspension exploding when given a bad normal. #JIRA UE-38716 Change 3213812 on 2016/11/29 by James.Golding UE-35925 Remove hard-coded asset<->animnode mapping, add SupportsAssetClass virtual instead Change 3213824 on 2016/11/29 by Ori.Cohen Fix CIS Change 3213873 on 2016/11/29 by Ori.Cohen Fix welded bodies not properly computing mass properties. #JIRA UE-35184 Change 3213950 on 2016/11/29 by Mieszko.Zielinski Fixed navigation collision being generated wrong for StaticMeshes created from BSP #Orion #jira UE-37221 Change 3213951 on 2016/11/29 by Mieszko.Zielinski Fixed perception system having issue with registering perception listener spawned in sublevels #UE4 #jira UE-37850 Change 3214005 on 2016/11/29 by Ori.Cohen Fix mass kg override not propagating to blueprint instances. Change 3214046 on 2016/11/29 by Marc.Audy Duplicate all instanced subobjects, not just those that are editinlinenew Make AABrush.Brush instanced rather than export #jira UE-39066 Change 3214064 on 2016/11/29 by Marc.Audy Use GetComponents directly where safe instead of copying in to an array Change 3214116 on 2016/11/29 by James.Golding Fix tooltip when dragging anim assets onto players Change 3214136 on 2016/11/29 by Ori.Cohen Make it so moving bodies is immediate when in editor. Useful for editor tools that rely on physx data #JIRA UE-35864 Change 3214162 on 2016/11/29 by Mieszko.Zielinski Fixed a bug in EnvQueryGenerator_SimpleGrid resuting in one extra column and row of points being generated #UE4 #jira UE-12077 Change 3214177 on 2016/11/29 by Marc.Audy Use correct SocketName (broken in CL#2695130) #jira UE-39153 Change 3214427 on 2016/11/29 by dan.reynolds AEOverview Update Fixed Attenuation tests when overlapping attenuation ranges between streamed levels Added Sound Concurrency Far then Prevent New testmap Removed some Sound Concurrency assets Change 3214469 on 2016/11/29 by dan.reynolds AEOverview Update Added Sound Concurrency Test for Stop Farthest then Oldest Change 3214842 on 2016/11/30 by Jurre.deBaare LookAt AimOffset in the Anim Graph causes character to explode #jira UE-38533 #fix ensure that the source socket exists on the skeleton during compilation (as far as we can), and skip blendspace evaluation in case of it not being valid during runtime Change 3214866 on 2016/11/30 by james.cobbett Updating Pose Snapshot test assets Change 3214964 on 2016/11/30 by thomas.sarkanen Added test data for facial animtion curves Change 3215015 on 2016/11/30 by Jurre.deBaare When a Aim Offset axis value is edited drastically the preview mesh will be deformed #fix change the way we change data when axis values are changed, simply remap normalized samples to new axis range #misc marked some data/functions editor only (not needed during runtime so reduces footprint a little bit) #jira UE-38880 Change 3215029 on 2016/11/30 by Marc.Audy Fix CIS Change 3215033 on 2016/11/30 by Marc.Audy Add a delegate for when new classes are added via hotreload Change existing hotload class reinstancing delegates to be multicast Change 3215048 on 2016/11/30 by Jon.Nabozny Use getKinematicTarget whenever a body is kinematic. This should fix some edge cases in FBodyInstance where stale transforms may be used when operations are run in PrePhysics. #jira UE-37877 Change 3215052 on 2016/11/30 by Marc.Audy Generalize the volume actor factory logic Create volume factories when hotreload adds a new volume class #jira UE-39064 Change 3215055 on 2016/11/30 by Marc.Audy Probable fix for IOS CIS failure Change 3215091 on 2016/11/30 by Lina.Halper Easy alternative fix for blending two curves per bone. For now we just combine. To fix this properly - i.e. per bone to affect curve - it is very expensive process, so opting into this for 4.15. #jira: UE-39182 Change 3215179 on 2016/11/30 by Jurre.deBaare Preview viewport should only use rendering features supported in project #fix replace the skylight with a sphere reflection component, this will not give image based lighting but does supply the user with a reflection map + intensity #jira UE-37252 Change 3215189 on 2016/11/30 by Jurre.deBaare CIS fix Change 3215326 on 2016/11/30 by Ben.Zeigler #jira UE-39077 Fix OnActive gameplay cues on standalone servers, it was incorrectly assuming it was in mixed replication mode. Regression caused by CL #3104976 Change 3215523 on 2016/11/30 by James.Golding Fix cooking old skel meshes in commandlet - vertex buffer was not recreated so UpdateUVChannelData would crash Change 3215539 on 2016/11/30 by Marc.Audy Fix failure to cleanup objects in a hidden always loaded sub-level #jira UE-39139 Change 3215568 on 2016/11/30 by Aaron.McLeran UE-39197 Delay node of 0.0 causes crash Change3215719on 2016/11/30 by Aaron.McLeran UE-39074 Audio related Client crash experienced on latest live build ++UT+Release-Next-CL-3193528 Change 3215773 on 2016/11/30 by Aaron.McLeran PR #2819 : Fixed typo in SoundWave.h Change 3215828 on 2016/11/30 by James.Golding PR #2900: fixed a former change that overlooked the 2 character difference between 16 and 32. (Contributed by MartinMittringAtOculus) Change3215831on 2016/11/30 by James.Golding UE-36688 Add BlendOption (with CustomCurve) to PoseBlendNode Change 3215904 on 2016/11/30 by Marc.Audy Fix significance calculations Change 3215955 on 2016/11/30 by James.Golding UE-36791 Fix scaling of rotated convex elements, by baking element transform into cooked convex data. Change 3215959 on 2016/11/30 by James.Golding Remove LogTemp warning from FAnimBlueprintCompiler::FinishCompilingClass Change 3216057 on 2016/11/30 by Marc.Audy Don't reset expose on spawn properties when in a PIE world #jira UE-36771 Change 3216114 on 2016/11/30 by James.Golding Move SkeletalMeshComponent and SkinnedMeshComponent functions out of SkeletalMesh.cpp into correct cpp files Change 3216144 on 2016/11/30 by Jon.Nabozny Fix FConstraintInstance scaling issues in FSkeletalMeshComponent::InitArticulated. InitArticulated uses the default Constraint Template from the Physics Asset a skeletal mesh is associated with. This caused issues if a skeletal mesh had bone scales that differed from those in the physics asset. #jira UE-38434 Change 3216148 on 2016/11/30 by Jon.Nabozny Create test map and asset for Skeletal Mesh Component Scaling and Skeletal Mesh Uniform Import Scaling. Change 3216160 on 2016/11/30 by Aaron.McLeran Fixing a memory leak in concurrency management Change 3216164 on 2016/11/30 by James.Golding Move SkeletalMeshActor code into its own cpp file Fix CIS for SkeletalMeshComponent.cpp Change 3216371 on 2016/11/30 by dan.reynolds AEOverview Update Minor tweaks Completed Sound Concurrency Rule Test Maps Added additional test files Change 3216509 on 2016/11/30 by Marc.Audy Fix missing include Change 3216510 on 2016/11/30 by Marc.Audy Code cleanup Change3216723on 2016/12/01 by Jurre.deBaare When clearing a blend sample animation the animation will try and blend to the ref pose #fix do not delete sample when animation == nullptr but mark it as invalid, it then will be rendered in red on the grid and discarded during triangle/line generation #fix indice mapping for 2d blend spaces was incorrect before (luckily never caused an error) #misc weird whitespace changes #jira UE-39078 Change 3216745 on 2016/12/01 by Jurre.deBaare - Blend space triangulation was incorrect in some cases, due to refactor some data was not initialised. - UDN user was hitting a check within the triangle flipping behaviour #fix Revisited the conditions to determine whether or not a point lies within a triangles circumcircle #fix In case we cannot flip the current triangle we skip it and move onto the next one instead of putting in a hard check #misc refactored triangle flipping code to make it smaller (more readible) Change 3216903 on 2016/12/01 by mason.seay Imported mesh for quick test Change 3216904 on 2016/12/01 by Jurre.deBaare CIS Fix #fix replaced condition by both non-editor as editor valid one Change 3216998 on 2016/12/01 by Lukasz.Furman fixed AI slowing down on ramps due to 3D input vector being constrained by movement component #jira UE-39233 #2998 Change 3217012 on 2016/12/01 by Lina.Halper Checking in James' fix on drag/drop to replace assets #code review: James.Golding #jira: UE-39150 Change 3217031 on 2016/12/01 by james.cobbett Updating Pose Snapshot Assets. Again. Change 3217033 on 2016/12/01 by Martin.Wilson Update bounds on all skel meshes when physics asset is changed #jira UE-38572 Change 3217181 on 2016/12/01 by Martin.Wilson Fix imported animations containing a black thumbnail #jira UE-36559 Change 3217183 on 2016/12/01 by Martin.Wilson Add some extra debugging code for future animation compression / ddc issues Change 3217184 on 2016/12/01 by james.cobbett Fixing a test asset by checking a check box. Sigh. Change 3217216 on 2016/12/01 by Martin.Wilson Undo part of CL 3217183. Will need to add this back differently. Change 3217274 on 2016/12/01 by Marc.Audy When serializing in an enum tagged property follow redirects #jira UE-39215 Change 3217419 on 2016/12/01 by james.cobbett Changes to test assets for more Pose Snapshot tests Change 3217449 on 2016/12/01 by Aaron.McLeran Adding new audio setting to disable EQ and reverb. Hooked up to XAudio2 (for now). Change 3217513 on 2016/12/01 by Marc.Audy Improve bWantsBeginPlay deprecation message Change 3217620 on 2016/12/01 by mason.seay Updated test assets for HLOD Change 3217872 on 2016/12/01 by Aaron.McLeran UEFW-113 Adding master reverb to audio mixer - Added new submix editor to create new submixes - Created new default master submixes for reverb and EQ and master submixes - Fixed a number of minor issues found in auido mixer while working on feature Change 3218053 on 2016/12/01 by Ori.Cohen Added mass debug rendering #JIRA UE-36608 Change 3218143 on 2016/12/01 by Aaron.McLeran Fixing up reverb to support multi-channel (5.1 and 7.1) configurations. - Added default reverb send amount Change 3218440 on 2016/12/01 by Zak.Middleton #ue4 - Made some static FNames const. Change 3218715 on 2016/12/02 by james.cobbett Fixed bug in test asset. Change 3218836 on 2016/12/02 by james.cobbett Fixing up test asset Change 3218884 on 2016/12/02 by james.cobbett Moar test asset changes Change 3218943 on 2016/12/02 by Ori.Cohen Make sure welded bodies include the center of mass offset. Note this also changes the COM nudge to be world space instead of local space #JIRA UE-35184 Change 3218955 on 2016/12/02 by Marc.Audy Fix initialization order issues Remove monolithic includes Change signature to pass string by const ref Change 3219149 on 2016/12/02 by Ori.Cohen Fix SetCollisionObjectType not working on skeletal mesh components #JIRA UE-37821 Change 3219162 on 2016/12/02 by Martin.Wilson Fix compile error when blend space on aim offset nodes is exposed as pin #jira UE-39285 Change 3219198 on 2016/12/02 by Marc.Audy UEnum::FindValue/IndexByName will now correctly follow redirects #jira UE-39215 Change 3219340 on 2016/12/02 by Zak.Middleton #ue4 - Optimized and cleaned up some Actor methods related to location and rotation. - Inlined GetActorForwardVector(), GetActorUpVector(), GetActorRightVector(). Wrapped them to simply call the methods on USceneComponent rather than using a different approach to computing these vectors. - Inlined blueprint versions: K2_GetActorLocation(), K2_GetActorRotation(), K2_GetRootComponent(). - Cleaned up template methods that are used to delay compilation of USceneComponent calls to make them private and prefix "Template" to their names so they don't show up in autocomplete for calls to the public methods. Change 3219482 on 2016/12/02 by Ori.Cohen Fix crash when double deleting a clothing actor due to destroying USkeletalMesh before USkeletalMeshComponent. #JIRA UE-39172 Change 3219676 on 2016/12/02 by Martin.Wilson Make clearer that ref pose is from skeleton Change 3219687 on 2016/12/02 by Aaron.McLeran Supporting multi-channel reverb with automatic downmixing of input to stereo Change3219688on 2016/12/02 by Martin.Wilson Fix crash when remapping additive animations after skeleton hierarchy change #jira UE-39040 Change 3219699 on 2016/12/02 by Zak.Middleton #ue4 - Fix template's use of old GetActorRotation() function. Change 3219969 on 2016/12/02 by Ben.Zeigler #jira UE-24800 Disable replicatied movement updates for actors that are welded to something else, to avoid them fighting with the welded parent's replication Modified from shelve Zak.Middleton made of PR #1885, after some more testing Change 3220010 on 2016/12/02 by Aaron.McLeran Fixing up sound class editor Change 3220013 on 2016/12/02 by Aaron.McLeran Deleting monolithic file Change 3220249 on 2016/12/02 by Aaron.McLeran Changing reverb settings parameter thread sync method - Switching to a simple ring buffer rather than using a crit sect Change 3220251 on 2016/12/02 by Aaron.McLeran Removing hard-coded audio mixer module name for the case when using -audiomixer argument, -added new entry to ini file that allows you to specify the audio mixer module name used for the platform. Change 3221118 on 2016/12/05 by Jurre.deBaare Back out changelist 3220249 to fix CIS Change 3221363 on 2016/12/05 by Martin.Wilson Change slot node category from Blends to Montage Change 3221375 on 2016/12/05 by Jon.Nabozny Change AGameModeBase::GetGameSessionClass to return GameSessionClass when set. #jira UE-39325 Change 3221402 on 2016/12/05 by Jon.Nabozny Add sanitization code around PhsyX flags and refactor the ways flags are managed through a single code path. #jira UE-33562 Change 3221441 on 2016/12/05 by Thomas.Sarkanen Fixed crash when reimporting a mesh when a different animation was open #jira UE-39281 - Editor crashes when reimporting a skeletal mesh after enabling recalculate tangents Change 3221473 on 2016/12/05 by Marc.Audy Get rid of auto. Use GetComponents directly instead of copying in to temporary arrays Change 3221584 on 2016/12/05 by Jon.Nabozny Fix CIS for Mac builds from CL-3221375 Change 3221631 on 2016/12/05 by Martin.Wilson Possible fix for rare marker sync crash on live servers #jira UE-39235 #test ai match, animation seemed fine, no crashes Change 3221660 on 2016/12/05 by mason.seay Resubmitting to add Viewport Bookmark Change 3221683 on 2016/12/05 by Mieszko.Zielinski Temp (but decent) fix to ARecastNavMesh::GetRandomPointInNavigableRadius sometimes retrieving invalid locations even if there's a valid piece of navmesh in the area #UE4 #jira UE-30355 Change 3221750 on 2016/12/05 by Jon.Nabozny Real CIS fix. Change 3221917 on 2016/12/05 by Jon.Nabozny Fix CIS for real this time. Change 3222370 on 2016/12/05 by mason.seay Start of Gameplay Tag testmap Change 3222396 on 2016/12/05 by Aaron.McLeran UEFW-44 Implementing EQ master submix effect for audio mixer - New thread safe param setting temlate class (for setting EQ and Reverb params) - Hook up reverb submix effect to source voices - Implementation of FBiquad for biquad filter coefficients and audioprocessing - Implementation of Filter class which hold FBiquad instance per channel, computes coefficents once - Implementation of equalizer class which is a serial bank of filters set to ParametricEQ filter type Change 3222425 on 2016/12/05 by Aaron.McLeran Checking in missing files Change 3222429 on 2016/12/05 by Aaron.McLeran Last missing file! Change 3222783 on 2016/12/05 by Jon.Nabozny Update SkelMeshScaling map. Change 3223173 on 2016/12/06 by Martin.Wilson Fix crash in thumbnail rendering when creating a new montage #jira UE-39352 Change3223179on 2016/12/06 by Marc.Audy auto/NULL cleanup Change 3223329 on 2016/12/06 by Marc.Audy Fix (hard to explain) memory corruption #jira UE-39366 Change 3223334 on 2016/12/06 by Jon.Nabozny Add HasBeenInitialized check inside AActor::InitializeComponents Change 3223340 on 2016/12/06 by Jon.Nabozny Refactor SkeletalMesh constraint scaling fixes. Add a check on bodies to ensure they are valid. #jira UE-39238 Change 3223372 on 2016/12/06 by Marc.Audy Probably fix HTML5 CIS failure Change 3223511 on 2016/12/06 by Jon.Nabozny Fix Mac CIS shadow warning Change 3223541 on 2016/12/06 by Lukasz.Furman fixed missing NavCollision data in static meshes #jira UE-39367 Change 3223672 on 2016/12/06 by Ben.Zeigler #jira UE-39394 Fix GameplayTagContainerCustomization to work like GameplayTagCustomization as a popup instead of a window, this fixes the references button Remove unnecessary code from both customizations Change 3223751 on 2016/12/06 by Marc.Audy Properly remove components from their owner when manipulating through editinlinenew properties #jira UE-30548 Change 3223831 on 2016/12/06 by Ben.Zeigler #jira UE-39293 Don't show non-working tag operations when ini tag editing is not enabled #jira UE-39344 Improve feedback messages when deleting explicit tags that have other explicit tag children Don't allow deleting a leaf explicit tag whose implicit parent tags are still referenced and it is the only thing keeping them alive Add Tag Source to tooltip in management mode Fix RequestGameplayTagChildrenInDictionary to work properly Change 3223862 on 2016/12/06 by Marc.Audy Hide deprecated attach functions for all games not just Paragon Change 3224003 on 2016/12/06 by Marc.Audy Put behavior of player camera back to how it was prior to Ansel plugin support changes. Make photography only work a different way. #jira UE-39207 Change 3224602 on 2016/12/07 by Jurre.deBaare Crash on creating LODs with Medic #fix Added clamp for UVs -1024 to 1024 #jira UE-37726 Change 3224604 on 2016/12/07 by Jurre.deBaare Fix for incorrect normal calculation in certain circumstances #fix Make sure we propagate the matrices to samples after we (re)calculated normals #fix Conditionally swap/inverse the vertex data buffers instead of always #fix Set preview mesh for alembic import animation sequences #misc removed commented out code and added debug code Change 3224609 on 2016/12/07 by Jurre.deBaare Alembic Import Issues (skeletal) w. UVs and smoothing groups #fix Changed the way we populate smoothing group indices for alembic caches #misc removed commented out code, set base preview pose for alembic imported skeletal meshes / anim sequences #jira UE-36412 Change 3224783 on 2016/12/07 by James.Golding Support per-instance skeletal mesh vertex color override Change 3224784 on 2016/12/07 by James.Golding Add skelmesh vert color override map. Fix my vert color material to work on skel mesh. Change 3225131 on 2016/12/07 by Jurre.deBaare Crash when baking matrix animation when importing an alembic file as skeletal #fix condition whether or not to apply matrices had not been moved over in previous change #jira UE-39439 Change 3225491 on 2016/12/07 by Lina.Halper - Morphtarget fix on the first frame #jira: UE-37702 Change 3225597 on 2016/12/07 by mason.seay Updated materials on meshes to ones that don't have physical materials, also rebuilt lighting Change 3225758 on 2016/12/07 by Aaron.McLeran UE-39421 Fix for sound class graph bug Change 3225957 on 2016/12/07 by Ben.Zeigler #jira UE-39433 Fix crash with mass debug data Change 3225967 on 2016/12/07 by Lina.Halper Fix not removing link up cache when removed. #jira: UE-33738 Change 3225990 on 2016/12/07 by Ben.Zeigler #jira OR-32975 Sort gameplay tags before saving out modified ini, to help with merge issues Change 3226123 on 2016/12/07 by Aaron.McLeran Fix for sound class asset creation from within the sound class graph Change 3226165 on 2016/12/07 by mason.seay Replaced skelmesh gun with static mesh cube Change 3226336 on 2016/12/07 by Aaron.McLeran Fixing up sound class replacement code. If you delete a sound class but replace with another, now it properly replaces sound classes in the sound class graphs without totally destroying them Change 3226701 on 2016/12/08 by Thomas.Sarkanen Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ CL 3226613 Change 3226710 on 2016/12/08 by Jurre.deBaare Fix for alembic import crash #misc update num mesh samples and take into account user set start frame in case of skipping preroll frames Change3226834on 2016/12/08 by Jurre.deBaare Fix for incorrect matrix samples being applied during Alembic cache importing #fix Change way we loop through samples and determine correct matrix and mesh sample indices Change 3227330 on 2016/12/08 by Jurre.deBaare Temporary fix for animBP compilation error, underlying issue is causing the skeleton to not be fully loaded when we are validating the animation node. This makes the socket name check fail and consequently output a compilation error #UE-39499 #fix Ensure that the skeleton is loaded by checking for RF_NeedPostLoad #misc corrected socket name output, removed unnecessary nullptr check Change 3227575 on 2016/12/08 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3227387 Change 3227602 on 2016/12/08 by Marc.Audy Copyright 2016 to 2017 updates for new Framework files [CL 3227721 by Marc Audy in Main branch]
859 lines
48 KiB
Plaintext
859 lines
48 KiB
Plaintext
Title:Introduction to C++ Programming in UE4
|
||
Crumbs:
|
||
Description:Introductory guide for C++ programmers new to Unreal Engine
|
||
Availability:Public
|
||
Version:4.9
|
||
|
||

|
||
|
||
## Unreal C++ is Awesome!
|
||
|
||
This guide is about learning how to write C++ code in Unreal Engine. Do not worry, C++ programming in Unreal Engine is fun, and actually not hard to get started with! We like to think of Unreal C++ as "assisted C++", because we have so many features to help make C++ easier for everyone.
|
||
|
||
Before we go on, it is really important that you are already familiar with C++ or another programming language. This page is written with the assumption that you have some C++ experience, but if you know C#, Java, or JavaScript, you should find many aspects familiar.
|
||
|
||
If you are coming in with no programming experience at all, we have got you covered also! Check out our [Blueprint Visual Scripting guide](Engine/Blueprints) and you will be on your way. You can create entire games using Blueprint scripting!
|
||
|
||
It is possible to write "plain old C++ code" in Unreal Engine, but you will be most successful after reading through this guide and learning the basics about the Unreal programming model. We will talk more about that as we go along.
|
||
|
||
## C++ and Blueprints
|
||
|
||
Unreal Engine provides two methods, C++ and Blueprints Visual Scripting, to create new gameplay elements. Using C++, programmers add the base gameplay systems that designers can then build upon or with to create the custom gameplay for a level or the game. In these cases, the C++ programmer works in their favorite IDE (usually Microsoft Visual Studio, or Apple's Xcode) and the designer works in the Unreal Editor's Blueprint Editor.
|
||
|
||
The gameplay API and framework classes are available to both of these systems, which can be used separately, but show their true power when used in conjunction to complement each other. What does that really mean, though? It means that the engine works best when programmers are creating gameplay building blocks in C++ and designers take those blocks and make interesting gameplay.
|
||
|
||
With that said, let us take a look at a typical workflow for the C++ programmer that is creating building blocks for the designer. In this case, we are going to create a class that is later extended via Blueprints by a designer or programmer. In this class, we are going to create some properties that the designer can set and we are going to derive new values from those properties. The whole process is very easy to do using the tools and C++ macros we provide for you.
|
||
|
||
### Class Wizard
|
||
|
||
First thing we are going to do is use the class wizard within the Unreal Editor to generate the basic C++ class that will be extended by Blueprints later. The image below shows the wizard’s first step where we are creating a new Actor.
|
||
|
||

|
||
|
||
The second step in the process tells the wizard the name of the class you want generated. Here's the second step with the default name used.
|
||
|
||

|
||
Once you choose to create the class, the wizard will generate the files and open your development environment so that you can start editing it. Here is the class definition that is generated for you. For more information on the Class Wizard, follow this [link.](Programming/Development/ManagingGameCode/CppClassWizard)
|
||
|
||
#include "GameFramework/Actor.h"
|
||
#include "MyActor.generated.h"
|
||
|
||
UCLASS()
|
||
class AMyActor : public AActor
|
||
{
|
||
GENERATED_BODY()
|
||
|
||
public:
|
||
// Sets default values for this actor's properties
|
||
AMyActor();
|
||
|
||
// Called every frame
|
||
virtual void Tick( float DeltaSeconds ) override;
|
||
|
||
protected:
|
||
// Called when the game starts or when spawned
|
||
virtual void BeginPlay() override;
|
||
};
|
||
|
||
The class wizard generates your class with **BeginPlay()** and **Tick()** specified as overloads. **BeginPlay()** is an event that lets you know the Actor has entered the game in a playable state. This is a good place to initiate gameplay logic for your class. **Tick()** is called once per frame with the amount of elapsed time since the last call passed in. There you can do any recurring logic. However if you do not need that functionality, it is best to remove it to save yourself a small amount of performance. If you remove it, make sure to remove the line in the constructor that indicated ticking should occur. The constructor below contains the line in question.
|
||
|
||
AMyActor::AMyActor()
|
||
|
||
{
|
||
|
||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you do not need it.
|
||
|
||
PrimaryActorTick.bCanEverTick = true;
|
||
|
||
}
|
||
|
||
### Making a property show up in the editor
|
||
|
||
We have our class created, so now let us create some properties that can be set by designers in the Unreal Editor. Exposing a property to the editor is quite easy using our special macro, **UPROPERTY()**. All you have to do is use the **UPROPERTY(EditAnywhere)** macro before your property declaration as seen in the class below.
|
||
|
||
UCLASS()
|
||
class AMyActor : public AActor
|
||
{
|
||
GENERATED_BODY()
|
||
|
||
UPROPERTY(EditAnywhere)
|
||
int32 TotalDamage;
|
||
|
||
...
|
||
};
|
||
|
||
That is all you need to do to be able to edit that value in the editor. There are more ways to control how and where it is edited. This is done by passing more information into the **UPROPERTY()** macro. For instance, if you want the TotalDamage property to appear in a section with related properties, you can use the categorization feature. The property declaration below shows this.
|
||
|
||
UPROPERTY(EditAnywhere, Category="Damage")
|
||
int32 TotalDamage;
|
||
|
||
When the user looks to edit this property, it now appears under the Damage heading along with any other properties that you have marked with this category name. This is a great way to place commonly used settings together for editing by designers.
|
||
|
||
Now let us expose that same property to Blueprints.
|
||
|
||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Damage")
|
||
int32 TotalDamage;
|
||
|
||
As you can see, there is a Blueprint specific parameter to make a property available for reading and writing. There's a separate option, BlueprintReadOnly, you can use if you want the property to be treated as const in Blueprints. There are quite a few options available for controlling how a property is exposed to the engine. To see more options, follow this [link.](Programming/UnrealArchitecture/Reference/Properties/Specifiers)
|
||
|
||
Before continuing to the section below, let us add a couple of properties to this sample class. There is already a property to control the total amount of damage this actor will deal out, but let us take that further and make that damage happen over time. The code below adds one designer settable property and one that is visible to the designer but not changeable by them.
|
||
|
||
UCLASS()
|
||
class AMyActor : public AActor
|
||
{
|
||
GENERATED_BODY()
|
||
|
||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Damage")
|
||
int32 TotalDamage;
|
||
|
||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Damage")
|
||
float DamageTimeInSeconds;
|
||
|
||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Transient, Category="Damage")
|
||
float DamagePerSecond;
|
||
|
||
...
|
||
};
|
||
|
||
DamageTimeInSeconds is a property the designer can modify. The DamagePerSecond property is a calculated value using the designer's settings (see the next section). The VisibleAnywhere flag marks that property as viewable, but not editable in the Unreal Editor. The Transient flag means that it won't be saved or loaded from disk; it is meant to be a derived, non-persistent value. The image below shows the properties as part of the class defaults.
|
||
|
||

|
||
|
||
### Setting defaults in my constructor
|
||
|
||
Setting default values for properties in a constructor works the same as your typical C++ class. Below are two examples of setting default values in a constructor and are equivalent in functionality.
|
||
|
||
AMyActor::AMyActor()
|
||
{
|
||
TotalDamage = 200;
|
||
DamageTimeInSeconds = 1.f;
|
||
}
|
||
|
||
AMyActor::AMyActor() :
|
||
TotalDamage(200),
|
||
DamageTimeInSeconds(1.f)
|
||
{
|
||
}
|
||
|
||
Here is the same view of the properties after adding default values in the constructor.
|
||
|
||

|
||
|
||
In order to support per instance designer set properties, values are also loaded from the instance data for a given object. This data is applied after the constructor. You can create default values based off of designer set values by hooking into the **PostInitProperties()** call chain. Here is an example of that process where **TotalDamage** and **DamageTimeInSeconds** are designer specified values. Even though these are designer specified, you can still provide sensible default values for them, as we did in the example above.
|
||
[REGION:note]
|
||
If you do not provide a default value for a property, the engine will automatically set that property to zero or nullptr in the case of pointer types.
|
||
[/REGION]
|
||
void AMyActor::PostInitProperties()
|
||
{
|
||
Super::PostInitProperties();
|
||
DamagePerSecond = TotalDamage / DamageTimeInSeconds;
|
||
}
|
||
|
||
Here again is the same view of the properties after we have added the **PostInitProperties()** code that you see above.
|
||
|
||

|
||
|
||
###Hot Reloading
|
||
|
||
Here is a cool feature of Unreal that you might be surprised about if you are used to programming C++ in other projects. You can compile your C++ changes without shutting down the editor! There are two ways to do this:
|
||
|
||
1. With the editor still running, go ahead and build from Visual Studio or Xcode like you normally would. The editor will detect the newly compiled DLLs and reload your changes instantly!
|
||
|
||

|
||
[REGION:note]
|
||
If you are attached with the debugger, you'll need to detach first so that Visual Studio will allow you to Build.
|
||
[/REGION]
|
||
2. Or, simply click the **Compile **button on the editor's main toolbar.
|
||
|
||

|
||
|
||
You can use this feature in the sections below as we advance through the tutorial.
|
||
|
||
### Extending a C++ Class via Blueprints
|
||
|
||
So far, we have created a simple gameplay class with the C++ Class Wizard and added some properties for the designer to set. Let us now take a look at how a designer can start creating unique classes from our humble beginnings here.
|
||
|
||
First thing we are going to do is create a new Blueprint class from our AMyActor class. Notice in the image below that the name of the base class selected shows up as MyActor instead of AMyActor. This is intentional and hides the naming conventions used by our tools from the designer, making the name friendlier to them.
|
||
|
||

|
||
|
||
Once you choose **Select**, a new, default named Blueprint class is created for you. In this case, I set the name to CustomActor1 as you can see in the snapshot of the **Content Browser** below.
|
||
|
||

|
||
|
||
This is the first class that we are going to customize with our designer hats on. First thing we are going to do is change the default values for our damage properties. In this case, the designer changed the **TotalDamage** to 300 and the time it takes to deliver that damage to 2 seconds. This is how the properties now appear.
|
||
|
||

|
||
|
||
Our calculated value does not match what we would expect. It should be 150 but it is still at the default value of 200. The reason for this is that we are only calculating our damage per second value after the properties have been initialized from the loading process. Runtime changes in the Unreal Editor are not accounted for. There is a simple solution to this problem because the engine notifies the target object when it has been changed in the editor. The code below shows the added hooks needed to calculate the derived value as it changes in the editor.
|
||
|
||
void AMyActor::PostInitProperties()
|
||
{
|
||
Super::PostInitProperties();
|
||
|
||
CalculateValues();
|
||
}
|
||
|
||
void AMyActor::CalculateValues()
|
||
{
|
||
DamagePerSecond = TotalDamage / DamageTimeInSeconds;
|
||
}
|
||
|
||
#if WITH_EDITOR
|
||
void AMyActor::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||
{
|
||
CalculateValues();
|
||
|
||
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||
}
|
||
#endif
|
||
|
||
One thing to note is that the **PostEditChangeProperty()** method is inside an editor specific #ifdef. This is so that building your game only the code that you need for the game, removing any extra code that might increase the size of your executable unnecessarily. Now that we have that code compiled in, the **DamagePerSecond** value matches what we would expect it to be as seen in the image below.
|
||
|
||

|
||
|
||
### Calling Functions across the C++ and Blueprint Boundary
|
||
|
||
So far, we have shown how to expose properties to Blueprints, but there is one last introductory topic that we should cover before you dive deeper into the engine. During the creation of the gameplay systems, designers will need to be able to call functions created by a C++ programmer as well as the gameplay programmer calling functions implemented in Blueprints from C++ code. Let us start by first making the CalculateValues() function callable from Blueprints. Exposing a function to Blueprints is just as simple as exposing a property. It takes only one macro placed before the function declaration! The code snippet below show what is needed for this.
|
||
|
||
UFUNCTION(BlueprintCallable, Category="Damage")
|
||
void CalculateValues();
|
||
|
||
The **UFUNCTION()** macro handles exposing the C++ function to the reflection system. The BlueprintCallable option exposes it to the Blueprints Virtual Machine. Every Blueprint exposed function requires a category associated with it, so that the right click context menu works properly. The image below shows how the category affects the context menu.
|
||
|
||

|
||
|
||
As you can see, the function is selectable from the **Damage** category. The Blueprint code below shows a change in the TotalDamage value followed by a call to recalculate the dependent data.
|
||
|
||

|
||
|
||
This uses the same function that we added earlier to calculate our dependent property. Much of the engine is exposed to Blueprints via the **UFUNCTION()** macro, so that people can build games without writing C++ code. However, the best approach is to use C++ for building base gameplay systems and performance critical code with Blueprints used to customize behavior or create composite behaviors from C++ building blocks.
|
||
|
||
Now that our designers can call our C++ code, let us explore one more powerful way to cross the C++/Blueprint boundary. This approach allows C++ code to call functions that are defined in Blueprints. We often use the approach to notify the designer of an event that they can respond to as they see fit. Often that includes the spawning of effects or other visual impact, such as hiding or unhiding an actor. The code snippet below shows a function that is implemented by Blueprints.
|
||
|
||
UFUNCTION(BlueprintImplementableEvent, Category="Damage")
|
||
void CalledFromCpp();
|
||
|
||
This function is called like any other C++ function. Under the covers, the Unreal Engine generates a base C++ function implementation that understands how to call into the Blueprint VM. This is commonly referred to as a Thunk. If the Blueprint in question does not provide a function body for this method, then the function behaves just like a C++ function with no body behaves: it does nothing. What if you want to provide a C++ default implementation while still allowing a Blueprint to override the method? The UFUNCTION() macro has an option for that too. The code snippet below shows the changes needed in the header to achieve this.
|
||
|
||
UFUNCTION(BlueprintNativeEvent, Category="Damage")
|
||
void CalledFromCpp();
|
||
|
||
This version still generates the thunking method to call into the Blueprint VM. So how do you provide the default implementation? The tools also generate a new function declaration that looks like <function name>_Implementation(). You must provide this version of the function or your project will fail to link. Here is the implementation code for the declaration above.
|
||
|
||
void AMyActor::CalledFromCpp_Implementation()
|
||
{
|
||
// Do something cool here
|
||
}
|
||
|
||
Now this version of the function is called when the Blueprint in question does not override the method. One thing to note, is that in previous versions of the build tools the _Implementation() declaration was auto generated. In any version 4.8 or higher, you'll be expected to explicitly add that to the header.
|
||
|
||
Now that we have walked through the common gameplay programmer workflow and methods to work with designers to build out gameplay features, it is time for you to choose your own adventure. You can either continue with this document to read more about how we use C++ in the engine or you can jump right into one of our samples that we include in the launcher to get a more hands on experience.
|
||
|
||
## Diving Deeper
|
||
|
||
I see you are still with me on this adventure. Excellent. The next topics of discussion revolve around what our gameplay class hierarchy looks like. In this section, we'll start with the base building blocks and talk through how they relate to each other. This is where we'll look at how the Unreal Engine uses both inheritance and composition to build custom gameplay features.
|
||
|
||
### Gameplay Classes: Objects, Actors, and Components
|
||
|
||
There are 4 main class types that you derive from for the majority of gameplay classes. They are **UObject**, **AActor**, **UActorComponent**, and **UStruct**. Each of these building blocks are described in the following sections. Of course, you can create types that do not derive from any of these classes, but they will not participate in the features that are built into the engine. Typical use of classes that are created outside of the **UObject** hierarchy are: integrating 3rd party libraries; wrapping of OS specific features; etc.
|
||
|
||
#### Unreal Objects (UObject)
|
||
|
||
The base building block in the Unreal Engine is called UObject. This class, coupled with **UClass**, provides a number of the most important base services in the engine:
|
||
|
||
* Reflection of properties and methods
|
||
* Serialization of properties
|
||
* Garbage collection
|
||
* Finding UObjects by name
|
||
* Configurable values for properties
|
||
* Networking support for properties and methods
|
||
|
||
Each class that derives from UObject has a singleton UClass created for it that contains all of the meta data about the class instance. UObject and UClass together are at the root of everything that a gameplay object does during its lifetime. The best way to think of the difference between a UClass and a UObject is that the UClass describes what an instance of a UObject will look like, what properties are available for serialization, networking, etc. Most gameplay development does not involve directly deriving from UObjects, but instead from AActor and UActorComponent. You do not need to know the details of how UClass/UObject works in order to write gameplay code, but it is good to know that these systems exist.
|
||
|
||
#### AActor
|
||
|
||
An AActor is an object that is meant to be part of the gameplay experience. AActors are either placed in a level by a designer or created at runtime via gameplay systems. All objects that can be placed into a level extend from this class. Examples include **AStaticMeshActor**, **ACameraActor**, and **APointLight** actors. AActor derives from UObject, so enjoys all of the standard features listed in the previous section. AActors can be explicitly destroyed via gameplay code (C++ or Blueprints) or via the standard garbage collection mechanism when the owning level is unloaded from memory. AActors are responsible for the high-level behaviors of your game's objects. AActors are also the base type that can be replicated during networking. During network replication, AActors can also distribute information for any UActorComponents owned by that AActor that require network support.
|
||
|
||
AActors have their own behaviors (specialization through inheritance), but they also act as containers for a hierarchy of UActorComponents (specialization through composition). This is done through the AActor's RootComponent member, which contains a single UActorComponent that, in turn, can contain many others. Before an AActor can be placed in a level, that AActor must contain at least a **USceneComponent** which contains the translation, rotation, and scale for that AActor.
|
||
|
||
AActors have a series of events that are called during the lifecycle of the AActor. The list below is a simplified set of the events that illustrate the lifecycle.
|
||
|
||
* BeginPlay - called when the object first comes into gameplay existence
|
||
* Tick - called once per frame to do work over time
|
||
* EndPlay - called when the object is leaving the gameplay space
|
||
|
||
See [](Programming/UnrealArchitecture/Actors) for a more detailed discussion on AActor.
|
||
|
||
##### Runtime Lifecycle
|
||
|
||
Just above we discussed a subset of an AActor's lifecycle. For actors that are placed in a level, understanding the lifecycle is pretty easy to imagine: actors are loaded and come into existence and eventually the level is unloaded and the actors are destroyed. What is the process for runtime creation and destruction? Unreal Engine calls the creation of an AActor at runtime spawning. Spawning an actor is a bit more complicated than creating a normal object in the game. The reason is that an AActor needs to be registered with a variety of runtime systems in order to serve all of its needs. The initial location and rotation for the actor need to be set. Physics may need to know about it. The manager responsible for telling an actor to tick needs to know. And so on. Because of this, we have a method devoted to the spawning of an actor, **UWorld::SpawnActor()**. Once that actor is spawned successfully, its **BeginPlay()** method is called, followed by **Tick()** the next frame.
|
||
|
||
Once an actor has lived out its lifetime, you can get rid of it by calling **Destroy()**. During that process **EndPlay()** will be called where you can do any custom logic for destruction. Another option for controlling how long an actor exists is to use the Lifespan member. You can set a timespan in the constructor of the object or with other code at runtime. Once that amount of time has expired, the actor will automatically have **Destroy()** called on it.
|
||
|
||
To learn more about spawning actors see the [](Programming/UnrealArchitecture/Actors/Spawning) page.
|
||
|
||
#### UActorComponent
|
||
|
||
UActorComponents have their own behaviors and are usually responsible for functionality that is shared across many types of AActors, e.g. providing visual meshes, particle effects, camera perspectives, and physics interactions. While AActors are often given high-level goals related to their overall roles your game, UActorComponents usually perform the individual tasks that support those higher-level objectives. Components can also be attached to other Components, or can be the root Component of an Actor. A Component can only attach to one parent Component or Actor, but it may have many child Components attached to itself. Picture a tree of Components. Child Components have location, rotation, and scaling relative to their parent Component or Actor.
|
||
|
||
While there are many ways to use Actors and Components, one way to think of the Actors-Component relationship is that Actors might answer the question "what is this thing?" while Components might answer "what is this thing made of?"
|
||
|
||
* RootComponent - this is the member of AActor that holds the top level Component in the AActor's tree of Components
|
||
* Ticking - Components are ticked as part of the owning AActor's Tick()
|
||
|
||
##### Dissecting the First Person Character
|
||
|
||
Over the last few sections we have done a lot of talking and not a lot of showing. In order to illustrate the relationship of an AActor and its UActorComponents, let us dig into the Blueprint that is created when you generate a new project based off of the First Person Template. The image below is the **Component** tree for the **FirstPersonCharacter** Actor. The **RootComponent** is the **CapsuleComponent**. Attached to the **CapsuleComponent** is the **ArrowComponent**, the **Mesh** component, and the **FirstPersonCameraComponent**. The leaf most component is the Mesh1P component which is parented to the **FirstPersonCameraComponent**, meaning that the first person mesh is relative to the first person camera.
|
||
|
||

|
||
|
||
Visually, this tree of **Components** looks like the image below, where you see all of the components in 3D space except for the **Mesh** component.
|
||
|
||

|
||
|
||
This tree of components is attached to the one actor class. As you can see from this example, you can build complex gameplay objects using both inheritance and composition. Use inheritance when you want to customize an existing AActor or UActorComponent. Use composition when you want many different AActor types to share the functionality.
|
||
|
||
#### UStruct
|
||
|
||
To use a UStruct, you do not have to extend from any particular class, you just have mark the struct with USTRUCT() and our build tools will do the base work for you. Unlike a UObject, UStructs are not garbage collected. If you create dynamic instances of them, you must manage their lifecycle yourself. UStructs are meant to be plain old data types that have the UObject reflection support for editing within the Unreal Editor, Blueprint manipulation, serialization, networking, etc.
|
||
|
||
Now that we have talked about the basic hierarchy used in our gameplay class construction, it is time to choose your path again. You can read about our gameplay classes [here](Programming/UnrealArchitecture/Reference/Classes), head out to our samples in the launcher armed with more information, or continue digging deeper into our C++ features for building games.
|
||
|
||
## Diving Deeper Still
|
||
|
||
Alright, it is clear you want to know more. Let us keep on going deeper into how the engine works.
|
||
|
||
### Unreal Reflection System
|
||
|
||
[Blog Post: Unreal Property System (Reflection)](https://www.unrealengine.com/blog/unreal-property-system-reflection)
|
||
|
||
Gameplay classes make use of special markup, so before we go over them, let us cover some of the basics of the Unreal property system. UE4 uses its own implementation of reflection that enables dynamic features such as garbage collection, serialization, network replication, and Blueprint/C++ communication. These features are opt-in, meaning you have to add the correct markup to your types, otherwise Unreal will ignore them and not generate the reflection data for them. Here is a quick overview of the basic markup:
|
||
|
||
* **UCLASS() **- Used to tell Unreal to generate reflection data for a class. The class must derive from UObject.
|
||
* **USTRUCT() **- Used to tell Unreal to generate reflection data for a struct.
|
||
* **GENERATED_BODY()** - UE4 replaces this with all the necessary boilerplate code that gets generated for the type.
|
||
* **UPROPERTY() **- Enables a member variable of a UCLASS or a USTRUCT to be used as a UPROPERTY. A UPROPERTY has many uses. It can allow the variable to be replicated, serialized, and accessed from Blueprints. They are also used by the garbage collector to keep track of how many references there are to a UObject.
|
||
* **UFUNCTION() **- Enables a class method of a UCLASS or a USTRUCT to be used as a UFUNCTION. A UFUNCTION can allow the class method to be called from Blueprints and used as RPCs, among other things.
|
||
|
||
Here is an example declaration of a UCLASS:
|
||
|
||
#include "MyObject.generated.h"
|
||
|
||
UCLASS(Blueprintable)
|
||
class UMyObject : public UObject
|
||
{
|
||
GENERATED_BODY()
|
||
|
||
public:
|
||
MyUObject();
|
||
|
||
UPROPERTY(BlueprintReadOnly, EditAnywhere)
|
||
float ExampleProperty;
|
||
|
||
UFUNCTION(BlueprintCallable)
|
||
void ExampleFunction();
|
||
};
|
||
|
||
You'll first notice the inclusion of "MyClass.generated.h". Unreal will generate all the reflection data and put it into this file. You must include this file as the last include in the header file that declares your type.
|
||
|
||
You'll also have noticed that we can also add additional specifiers to the markup. I've added some of the more common ones for demonstration. These allow us to specify certain behavior that our types have.
|
||
|
||
* **Blueprintable** - This class can be extended by a Blueprint.
|
||
* **BlueprintReadOnly **- This property can only be read from a Blueprint, and not written to.
|
||
* **Category** - Defines what section this property appears under in the Details view of the Editor. For organizational purposes.
|
||
* **BlueprintCallable **- This function can be called from Blueprints.
|
||
|
||
There are too many specifiers to list here, but the following links can be used as reference:
|
||
|
||
[List of UCLASS Specifiers](Programming/UnrealArchitecture/Reference/Classes/Specifiers)
|
||
|
||
[List of UPROPERTY Specifiers](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Properties/Specifiers/index.html)
|
||
|
||
[List of UFUNCTION Specifiers](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Functions/Specifiers/index.html)
|
||
|
||
[List of USTRUCT Specifiers](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Structs/Specifiers/index.html)
|
||
|
||
### Object/Actor Iterators
|
||
|
||
Object iterators are a very useful tool to iterate over all instances of a particular UObject type and its subclasses.
|
||
|
||
// Will find ALL current UObjects instances
|
||
for (TObjectIterator<UObject> It; It; ++It)
|
||
{
|
||
UObject* CurrentObject = *It;
|
||
UE_LOG(LogTemp, Log, TEXT("Found UObject named: %s"), *CurrentObject.GetName());
|
||
}
|
||
|
||
You can limit the scope of the search by providing a more specific type to the iterator. Suppose you had a class called UMyClass that derived from UObject. You could find all instances of that class (and those that derive from it) like this:
|
||
|
||
for (TObjectIterator<UMyClass> It; It; ++It)
|
||
{
|
||
// ...
|
||
}
|
||
[REGION:warning]
|
||
Using object iterators in PIE (Play In Editor) can lead to unexpected results. Since the editor is loaded, the object iterator will return all UObjects created for your game world instance, in addition to those that are just being used by the editor.
|
||
[/REGION]
|
||
Actor iterators work in much the same way as object iterators, but only work for objects that derive from AActor. Actor iterators do not have the problem noted below, and will only return objects being used by the current game world instance.
|
||
|
||
When creating an actor iterator, you need to give it a pointer to a **UWorld** instance. Many UObject classes, such as **APlayerController**, provide a **GetWorld** method to help you. If you are not sure, you can check the **ImplementsGetWorld** method on a UObject to see if it implements the GetWorld method.
|
||
|
||
APlayerController* MyPC = GetMyPlayerControllerFromSomewhere();
|
||
UWorld* World = MyPC->GetWorld();
|
||
|
||
// Like object iterators, you can provide a specific class to get only objects that are
|
||
// or derive from that class
|
||
for (TActorIterator<AEnemy> It(World); It; ++It)
|
||
{
|
||
// ...
|
||
}
|
||
|
||
[REGION:note]
|
||
Since AActor derives from UObject, you can use **TObjectIterator** to find instances of AActors as well. Just be careful in PIE!
|
||
[/REGION]
|
||
|
||
## Memory Management and Garbage Collection
|
||
|
||
In this section we will go over basic memory management and the garbage collection system in UE4.
|
||
|
||
[Wiki: Garbage Collection & Dynamic Memory Allocation](https://wiki.unrealengine.com/Garbage_Collection_%26_Dynamic_Memory_Allocation)
|
||
|
||
### UObjects and Garbage Collection
|
||
|
||
UE4 uses the reflection system to implement a garbage collection system. With garbage collection, you will not have to manually manage deleting your UObjects, you just need to maintain valid references to them. Your classes need to derive from UObject in order to be enabled for garbage collection. Here is the simple example class we will be using:
|
||
|
||
UCLASS()
|
||
class MyGCType : public UObject
|
||
{
|
||
GENERATED_BODY()
|
||
};
|
||
|
||
In the garbage collector, there is this concept called the root set. This root set is basically a list of objects that the collector knows about will never be garbage collected. An object will not be garbage collected as long as there is a path of references from an object in the root set to the object in question. If no such path to the root set exists for an object, it is called unreachable and will be collected (deleted) the next time the garbage collector is ran. The engine runs the garbage collector at certain intervals.
|
||
|
||
What counts as a "reference"? Any UObject pointer stored in a UPROPERTY. Let us start with a simple example.
|
||
|
||
void CreateDoomedObject()
|
||
{
|
||
MyGCType* DoomedObject = NewObject<MyGCType>();
|
||
}
|
||
|
||
When we call the above function, we create a new UObject, but we do not store a pointer to it in any UPROPERTY, and it isn’t a part of the root set. Eventually, the garbage collector will detect this object is unreachable, and destroy it.
|
||
|
||
### Actors and Garbage collection
|
||
|
||
Actors are not usually garbage collected. Once spawned, you must manually call **Destroy()** on them. They will not be deleted immediately, and instead will be cleaned up during the next garbage collection phase.
|
||
|
||
This is a more common case, where you have actors with UObject properties.
|
||
|
||
UCLASS()
|
||
class AMyActor : public AActor
|
||
{
|
||
GENERATED_BODY()
|
||
|
||
public:
|
||
UPROPERTY()
|
||
MyGCType* SafeObject;
|
||
|
||
MyGCType* DoomedObject;
|
||
|
||
AMyActor(const FObjectInitializer& ObjectInitializer)
|
||
: Super(ObjectInitializer)
|
||
{
|
||
SafeObject = NewObject<MyGCType>();
|
||
DoomedObject = NewObject<MyGCType>();
|
||
}
|
||
};
|
||
|
||
void SpawnMyActor(UWorld* World, FVector Location, FRotator Rotation)
|
||
{
|
||
World->SpawnActor<AMyActor>(Location, Rotation);
|
||
}
|
||
|
||
When we call the above function, we spawn an actor into the world. The actor’s constructor creates two objects. One gets assigned to a UPROPERTY, the other to a bare pointer. Since actors are automatically a part of the root set, SafeObject will not be garbage collected because it can be reached from a root set object. DoomedObject, however, will not fare so well. We didn’t mark it with UPROPERTY, so the collector does not know it is being referenced, and will eventually destroy it.
|
||
|
||
When a UObject is garbage collected, all UPROPERTY references to it will be set to nullptr for you. This makes it safe for you to check if an object has been garbage collected or not.
|
||
|
||
if (MyActor->SafeObject != nullptr)
|
||
{
|
||
// Use SafeObject
|
||
}
|
||
|
||
This is important since, as mentioned before, actors that have had Destroy() called on them are not removed until the garbage collector runs again. You can check the **IsPendingKill()** method to see if a UObject is awaiting its deletion. If that method returns true, you should consider the object dead and not use it.
|
||
|
||
### UStructs
|
||
|
||
UStructs, as mentioned earlier, are meant to be a lightweight version of a UObject. As such, UStructs cannot be garbage collected. If you must use dynamic instances of UStructs, you may want to use smart pointers instead, which we will go over later.
|
||
|
||
### Non-UObject References
|
||
|
||
Normal, non-UObjects can also have the ability to add a reference to an object and prevent garbage collection. To do that, your object must derive from **FGCObject** and override its **AddReferencedObjects** class.
|
||
|
||
class FMyNormalClass : public FGCObject
|
||
{
|
||
public:
|
||
UObject* SafeObject;
|
||
|
||
FMyNormalClass(UObject* Object)
|
||
: SafeObject(Object)
|
||
{
|
||
}
|
||
|
||
void AddReferencedObjects(FReferenceCollector& Collector) override
|
||
{
|
||
Collector.AddReferencedObject(SafeObject);
|
||
}
|
||
};
|
||
|
||
We use the **FReferenceCollector** to manually add a hard reference to the UObject we need and do not want garbage collected. When the object is deleted and its destructor is run, the object will automatically clear all references that it added.
|
||
|
||
### Class Naming Prefixes
|
||
|
||
Unreal Engine provides tools that generate code for you during the build process. These tools have some class naming expectations and will trigger warnings or errors if the names do not match the expectations. The list of class prefixes below delineates what the tools are expecting.
|
||
|
||
* Classes derived from **Actor** prefixed with **A**, e.g. AController.
|
||
* Classes derived from **Object** are prefixed with **U**, e.g. UComponent.
|
||
* **Enums** are prefixed with **E**, e.g. EFortificationType.
|
||
* **Interface** classes are usually prefixed with **I**, e.g. IAbilitySystemInterface.
|
||
* **Template** classes are prefixed by **T**, e.g. TArray.
|
||
* Classes that derive from **SWidget** (Slate UI) are prefixed by **S**, e.g. SButton.
|
||
* Everything else is prefixed by the [letter F](https://forums.unrealengine.com/showthread.php?60061-Unreal-trivia-What-does-the-F-prefix-on-classes-and-structs-stand-for), e.g. FVector.
|
||
|
||
### Numeric Types
|
||
|
||
Since different platforms have different sizes for basic types such as **short**, **int**, and **long**, UE4 provides the following types which you should use as an alternative:
|
||
|
||
* **int8**/**uint8 **: 8-bit signed/unsigned integer
|
||
* **int16**/**uint16 **: 16-bit signed/unsigned integer
|
||
* **int32**/**uint32 **: 32-bit signed/unsigned integer
|
||
* **int64**/**uint64 **: 64-bit signed/unsigned integer
|
||
|
||
Floating point numbers are also supported with the standard **float **(32-bit)** **and **double** (64-bit) types.
|
||
|
||
Unreal Engine has a template, **TNumericLimits<t>**, for finding the minimum and maximum ranges value types can hold. For more information follow this [link](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Math/TNumericLimits/index.html).
|
||
|
||
### Strings
|
||
|
||
UE4 provides several different classes for working with strings, depending on your needs.
|
||
|
||
[Full Topic: String Handling](Programming/UnrealArchitecture/StringHandling)
|
||
|
||
#### FString
|
||
|
||
**FString **is a mutable string, analogous to std::string. FString has a large suite of methods for making it easy to work with strings. To create a new FString, use the **TEXT()** macro:
|
||
|
||
FString MyStr = TEXT("Hello, Unreal 4!").
|
||
|
||
[Full Topic: FString API](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Containers/FString/index.html)
|
||
|
||
#### FText
|
||
|
||
**FText** is similar to FString, but it is meant for localized text. To create a new FText, use the **NSLOCTEXT** macro. This macro takes a namespace, key, and a value for the default language:
|
||
|
||
FText MyText = NSLOCTEXT("Game UI", "Health Warning Message", "Low Health!")
|
||
|
||
You could also use the **LOCTEXT** macro, so you only have to define a namespace once per file. Make sure to undefine it at the bottom of your file.
|
||
|
||
// In GameUI.cpp
|
||
#define LOCTEXT_NAMESPACE "Game UI"
|
||
|
||
//...
|
||
FText MyText = LOCTEXT("Health Warning Message", "Low Health!")
|
||
//...
|
||
|
||
#undef LOCTEXT_NAMESPACE
|
||
// End of file
|
||
|
||
[Full Topic: FText API](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Internationalization/FText/index.html)
|
||
|
||
#### FName
|
||
|
||
A **FName** stores a commonly recurring string as an identifier in order to save memory and CPU time when comparing them. Rather than storing the complete string many times across every object that references it, a FName uses a smaller storage footprint **Index** that maps to a given string. This stores the contents of the string once, saving memory when that string is used across many objects. Two strings can be compared quickly by checking to see if **NameA.Index** equals **NameB.Index**, avoiding checking each character in the string for equality.
|
||
|
||
[Full Topic: FName API](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/UObject/FName/index.html)
|
||
|
||
#### TCHAR
|
||
|
||
**TCHARs** are used as a way of storing characters independent of the character set being used, which may differ between platforms. Under the hood, UE4 strings use TCHAR arrays to store data in the **UTF-16** encoding. You can access the raw data by using the overloaded dereference operator which returns TCHAR.
|
||
|
||
[Full Topic: Character Encoding](Programming/UnrealArchitecture/StringHandling/CharacterEncoding)
|
||
|
||
This is needed for some functions, such as **FString::Printf**, where the **‘%s’** string format specifier expects a TCHAR instead of an FString.
|
||
|
||
FString Str1 = TEXT("World");
|
||
int32 Val1 = 123;
|
||
FString Str2 = FString::Printf(TEXT("Hello, %s! You have %i points."), *Str1, Val1);
|
||
|
||
The **FChar** type provides a set of static utility functions for working with individual TCHARs.
|
||
|
||
TCHAR Upper('A');
|
||
TCHAR Lower = FChar::ToLower(Upper); // 'a'
|
||
|
||
[REGION:note]
|
||
The FChar type is defined as **TChar<TCHAR>** (as it is listed in the API).
|
||
[/REGION]
|
||
|
||
[Full Topic: TChar API](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Misc/TChar/index.html)
|
||
|
||
### Containers
|
||
|
||
Containers are classes whose primary function is to store collections of data. The most common of these classes are **TArray**,** TMap**, and **TSet**. Each of these are dynamically sized, and so will grow to whatever size you need.
|
||
|
||
[Full Topic: Containers API](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Containers/index.html)
|
||
|
||
#### TArray
|
||
|
||
Of these three containers the primary container you’ll use in Unreal Engine 4 is TArray, it functions much like **std::vector** does, but offers a lot more functionality. Here are some common operations:
|
||
|
||
TArray<AActor*> ActorArray = GetActorArrayFromSomewhere();
|
||
|
||
// Tells how many elements (AActors) are currently stored in ActorArray.
|
||
int32 ArraySize = ActorArray.Num();
|
||
|
||
// TArrays are 0-based (the first element will be at index 0)
|
||
int32 Index = 0;
|
||
// Attempts to retrieve an element at the given index
|
||
TArray* FirstActor = ActorArray[Index];
|
||
|
||
// Adds a new element to the end of the array
|
||
AActor* NewActor = GetNewActor();
|
||
ActorArray.Add(NewActor);
|
||
|
||
// Adds an element to the end of the array only if it is not already in the array
|
||
ActorArray.AddUnique(NewActor); // Won't change the array because NewActor was already added
|
||
|
||
// Removes all instances of 'NewActor' from the array
|
||
ActorArray.Remove(NewActor);
|
||
|
||
// Removes the element at the specified index
|
||
// Elements above the index will be shifted down by one to fill the empty space
|
||
ActorArray.RemoveAt(Index);
|
||
|
||
// More efficient version of 'RemoveAt', but does not maintain order of the elements
|
||
ActorArray.RemoveAtSwap(Index);
|
||
|
||
// Removes all elements in the array
|
||
ActorArray.Empty();
|
||
|
||
TArrays have the added benefit of having their elements garbage collected. This assumes that the TArray is marked as a UPROPERTY, and that it stores UObject derived pointers.
|
||
|
||
UCLASS()
|
||
class UMyClass : UObject
|
||
{
|
||
GENERATED_BODY();
|
||
|
||
// ...
|
||
|
||
UPROPERTY()
|
||
TArray<AActor*> GarbageCollectedArray;
|
||
};
|
||
|
||
We'll cover the garbage collection in depth in a later section.
|
||
|
||
[Full Topic: TArrays](Programming/UnrealArchitecture/TArrays)
|
||
|
||
[Full Topic: TArray API](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Containers/TArray/index.html)
|
||
|
||
#### TMap
|
||
|
||
A **TMap** is a collection of key-value pairs, similar to **std::map**. TMap has quick methods for finding, adding, and removing elements based on their key. You can use any type for the key, as long as it has a **GetTypeHash** function defined for it, which we will go over later.
|
||
|
||
Let us say you were creating a grid-based board game and needed to store and query what piece is on each square. A TMap would provide you with an easy way to do that. If your board size is small and is always the same size, there are obviously more efficient ways at going about this, but let us roll with it for example's sake!
|
||
|
||
enum class EPieceType
|
||
{
|
||
King,
|
||
Queen,
|
||
Rook,
|
||
Bishop,
|
||
Knight,
|
||
Pawn
|
||
};
|
||
|
||
struct FPiece
|
||
{
|
||
int32 PlayerId;
|
||
EPieceType Type;
|
||
FIntPoint Position;
|
||
|
||
FPiece(int32 InPlayerId, EPieceType InType, FIntVector InPosition) :
|
||
PlayerId(InPlayerId),
|
||
Type(InType),
|
||
Position(InPosition)
|
||
{
|
||
}
|
||
};
|
||
|
||
class FBoard
|
||
{
|
||
private:
|
||
|
||
// Using a TMap, we can refer to each piece by its position
|
||
TMap<FIntPoint, FPiece> Data;
|
||
|
||
public:
|
||
bool HasPieceAtPosition(FIntPoint Position)
|
||
{
|
||
return Data.Contains(Position);
|
||
}
|
||
FPiece GetPieceAtPosition(FIntPoint Position)
|
||
{
|
||
return Data[Position];
|
||
}
|
||
|
||
void AddNewPiece(int32 PlayerId, EPieceType Type, FIntPoint Position)
|
||
{
|
||
FPiece NewPiece(PlayerId, Type, Position);
|
||
Data.Add(Position, NewPiece);
|
||
}
|
||
|
||
void MovePiece(FIntPoint OldPosition, FIntPoint NewPosition)
|
||
{
|
||
FPiece Piece = Data[OldPosition];
|
||
Piece.Position = NewPosition;
|
||
Data.Remove(OldPosition);
|
||
Data.Add(NewPosition, Piece);
|
||
}
|
||
|
||
void RemovePieceAtPosition(FIntPoint Position)
|
||
{
|
||
Data.Remove(Position);
|
||
}
|
||
|
||
void ClearBoard()
|
||
{
|
||
Data.Empty();
|
||
}
|
||
};
|
||
|
||
[Full Topic: TMaps](Programming/UnrealArchitecture/TMap)
|
||
|
||
[Full Topic: TMap API](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Containers/TMapBase/index.html)
|
||
|
||
#### TSet
|
||
|
||
A **TSet** stores a collection of unique values, similar to **std::set**. With the **AddUnique** and **Contains** methods, TArrays can already be used as sets. However, TSet has faster implementations of these operations, at the cost of not being able to use them as UPROPERTYs like TArrays. TSets are also do not index their elements like TArrays do.
|
||
|
||
TSet<AActor*> ActorSet = GetActorSetFromSomewhere();
|
||
|
||
int32 Size = ActorSet.Num();
|
||
|
||
// Adds an element to the set, if the set does not already contain it
|
||
AActor* NewActor = GetNewActor();
|
||
ActorSet.Add(NewActor);
|
||
|
||
// Check if an element is already contained by the set
|
||
if (ActorSet.Contains(NewActor))
|
||
{
|
||
// ...
|
||
}
|
||
|
||
// Remove an element from the set
|
||
ActorSet.Remove(NewActor);
|
||
|
||
// Removes all elements from the set
|
||
ActorSet.Empty();
|
||
|
||
// Creates a TArray that contains the elements of your TSet
|
||
TArray<AActor*> ActorArrayFromSet = ActorSet.Array();
|
||
|
||
[Full Topic: TSet API](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Containers/TSet/index.html)
|
||
|
||
Remember that currently, the only container class that can be marked as a UPROPERTY is TArray. This means other container classes cannot be replicated, saved, or have their elements garbage collected for you.
|
||
|
||
#### Container Iterators
|
||
|
||
Using iterators, you can loop through each element of a container. Here is an example of what the iterator syntax looks like, using a TSet.
|
||
|
||
void RemoveDeadEnemies(TSet<AEnemy*>& EnemySet)
|
||
{
|
||
// Start at the beginning of the set, and iterate to the end of the set
|
||
for (auto EnemyIterator = EnemySet.CreateIterator(); EnemyIterator; ++EnemyIterator)
|
||
{
|
||
// The * operator gets the current element
|
||
AEnemy* Enemy = *EnemyIterator;
|
||
if (Enemy.Health == 0)
|
||
{
|
||
// 'RemoveCurrent' is supported by TSets and TMaps
|
||
EnemyIterator.RemoveCurrent();
|
||
}
|
||
}
|
||
}
|
||
|
||
Other supported operations you can use with iterators:
|
||
|
||
// Moves the iterator back one element
|
||
--EnemyIterator;
|
||
|
||
// Moves the iterator forward/backward by some offset, where Offset is an integer
|
||
EnemyIterator += Offset;
|
||
EnemyIterator -= Offset;
|
||
|
||
// Gets the index of the current element
|
||
int32 Index = EnemyIterator.GetIndex();
|
||
|
||
// Resets the iterator to the first element
|
||
EnemyIterator.Reset();
|
||
|
||
#### For-each Loop
|
||
|
||
Iterators are nice, but can be a bit cumbersome if you just want to loop through each element once. Each container class also supports the for each style syntax to loop over the elements. TArray and TSet return each element, whereas TMap returns a key-value pair.
|
||
|
||
// TArray
|
||
TArray<AActor*> ActorArray = GetArrayFromSomewhere();
|
||
for (AActor* OneActor : ActorArray)
|
||
{
|
||
// ...
|
||
}
|
||
|
||
// TSet - Same as TArray
|
||
TSet<AActor*> ActorSet = GetSetFromSomewhere();
|
||
for (AActor* UniqueActor : ActorSet)
|
||
{
|
||
// ...
|
||
}
|
||
|
||
// TMap - Iterator returns a key-value pair
|
||
TMap<FName, AActor*> NameToActorMap = GetMapFromSomewhere();
|
||
for (auto& KVP : NameToActorMap)
|
||
{
|
||
FName Name = KVP.Key;
|
||
AActor* Actor = KVP.Value;
|
||
|
||
// ...
|
||
}
|
||
|
||
Remember that the **auto** keyword does not automatically specify a pointer/reference for you, you need to add that yourself.
|
||
|
||
#### Using your own types with TSet/TMap (Hash Functions)
|
||
|
||
TSet and TMap require the use of *hash functions* internally. If you create your own class that you want to use it in a TSet or as the key to a TMap, you need to create your own hash function first. Most UE4 types that you would commonly put in these types already define their own hash function.
|
||
|
||
A hash function takes a const pointer/reference to your type and returns a uint64. This return value is known as the *hash code *for an object, and should be a number that is pseudo-unique to that object. Two objects that are equal should always return the same hash code.
|
||
|
||
class FMyClass
|
||
{
|
||
uint32 ExampleProperty1;
|
||
uint32 ExampleProperty2;
|
||
|
||
// Hash Function
|
||
friend uint32 GetTypeHash(const FMyClass& MyClass)
|
||
{
|
||
// HashCombine is a utility function for combining two hash values
|
||
uint32 HashCode = HashCombine(MyClass.ExampleProperty1, MyClass.ExampleProperty2);
|
||
return HashCode;
|
||
}
|
||
|
||
// For demonstration purposes, two objects that are equal
|
||
// should always return the same hash code.
|
||
bool operator==(const FMyClass& LHS, const FMyClass& RHS)
|
||
{
|
||
return LHS.ExampleProperty1 == RHS.ExampleProperty1
|
||
&& LHS.ExampleProperty2 == RHS.ExampleProperty2;
|
||
}
|
||
};
|
||
|
||
Now, TSet<FMyClass> and TMap<FMyClass, ...> will use the proper hash function when hashing keys. If you using pointers as keys (i.e. `TSet<FMyClass*>`) implement `uint32 GetTypeHash(const FMyClass* MyClass)` as well.
|
||
|
||
[Blog Post: UE4 Libraries You Should Know About](https://www.unrealengine.com/blog/ue4-libraries-you-should-know-about)
|
||
|