继续解析《Electric Dreams》项目中的自定义节点和子图:
ApplyHierarchy
文章目录
- 前导文章
- 标准组合拳
- ApplyHierarchy
- Execute with Context
- Iteration Loop Body
- Point Loop Body
- 应用场景
- 小结

前导文章
《UE5《Electric Dreams》项目PCG技术解析 之 理解Assembly(以SplineExample为例)》
《虚幻引擎程序化资源生成框架PCG 之 UPCGBlueprintElement源码笔记(一)》
《虚幻引擎程序化资源生成框架PCG 之 UPCGBlueprintElement源码笔记(二)数据流》
《UE5《Electric Dreams》项目PCG技术解析 之 PCGCustomNodes详解(一)》
《UE5《Electric Dreams》项目PCG技术解析 之 PCGCustomNodes详解(二)Look At》
《UE5《Electric Dreams》项目PCG技术解析 之 PCGCustomNodes详解(三)SG_CopyPointsWithHierarchy》
标准组合拳

上一篇博文《UE5《Electric Dreams》项目PCG技术解析 之 PCGCustomNodes详解(三)SG_CopyPointsWithHierarchy》,我们分析了这套组合拳中SG_CopyPointsWithHierarchy的工作原理,简单来说:
SG_CopyPointsWithHierarchy其实就是携带source中层级信息和相对Transform的高级版CopyPoints。- 它需要和"PCGSettings"一起工作(需要"PCGSettings"中原始
ActorIndex和ParentIndex信息)。 - 一般要和本文中介绍的
ApplyHierarchy一起使用构成组合拳。
ApplyHierarchy
在使用ApplyHierarchy之前,点云里存在一个由Actor Index和Parent Index索引构成的树形结构,而Relative Transform则代表着每个层级子级Point和父级Point之间的"相对变换"。ApplyHierarchy的作用就是将这个树形结构中一层层的Relative Transform应用到每个Point的Position、Rotation、Scale属性(Property)上。
Execute with Context
以上部分(包含Iteration Loop)的作用就是构造2个数组Ids和Hierarchy Depths:
Ids数组:数组的Index对应Point的Index;数组的Value对应Actor Index,这样通过Actor Index或Parent Index就可以反向找到实际的IndexHierarchy Depths数组:和上面的逻辑类似,建立Point的Index和Hierarchy Depth一一对应关系。

逐层(Depth)将Relative Transform转换成Point的Position、Rotation、Scale属性(Property)上,逻辑有点像“俄罗斯方块”。
Iteration Loop Body

Point Loop Body
通过Actor Index或Parent Index反向找到实际的Index

将该层(Depth)的Relative Transform转换成Point的Position、Rotation、Scale

删除无效的Point。

应用场景
注意:在“组合拳”中使用Transform Points变换的对象为Relative Transform

小结
SG_CopyPointsWithHierarchy构造了一个虚拟的"树形结构",而ApplyHierarchy是将"树形结构"和层级之间的Relative Transform应用到Point的Position、Rotation、Scale属性上。



















