虚幻引擎程序化资源生成框架PCG 之Extents Modifier 和 Bounds Modifier

news/2024/10/21 3:35:20/

Extents Modifier 和 Bounds Modifier这两个节点看起来很像,都是修改Point的Bouding Box,查看一下源代码,简单看一下它们的区别

文章目录

  • 两个节点的代码对比
    • Bounds Modifier
      • 源代码
    • Bounds Modifier
      • 源代码
  • 小结

两个节点的代码对比

Bounds Modifier

源代码

switch (Mode){case EPCGBoundsModifierMode::Intersect:ProcessPoints(Context, Inputs, Outputs, [&Bounds, bAffectSteepness, Steepness](const FPCGPoint& InPoint, FPCGPoint& OutPoint){OutPoint = InPoint;OutPoint.SetLocalBounds(InPoint.GetLocalBounds().Overlap(Bounds));if (bAffectSteepness){OutPoint.Steepness = FMath::Min(InPoint.Steepness, Steepness);}return true;});break;case EPCGBoundsModifierMode::Include:ProcessPoints(Context, Inputs, Outputs, [&Bounds, bAffectSteepness, Steepness](const FPCGPoint& InPoint, FPCGPoint& OutPoint){OutPoint = InPoint;OutPoint.SetLocalBounds(InPoint.GetLocalBounds() + Bounds);if (bAffectSteepness){OutPoint.Steepness = FMath::Max(InPoint.Steepness, Steepness);}return true;});break;case EPCGBoundsModifierMode::Translate:ProcessPoints(Context, Inputs, Outputs, [&BoundsMin, &BoundsMax, bAffectSteepness, Steepness](const FPCGPoint& InPoint, FPCGPoint& OutPoint){OutPoint = InPoint;OutPoint.BoundsMin += BoundsMin;OutPoint.BoundsMax += BoundsMax;if (bAffectSteepness){OutPoint.Steepness = FMath::Clamp(InPoint.Steepness + Steepness, 0.0f, 1.0f);}return true;});break;case EPCGBoundsModifierMode::Scale:ProcessPoints(Context, Inputs, Outputs, [&BoundsMin, &BoundsMax, bAffectSteepness, Steepness](const FPCGPoint& InPoint, FPCGPoint& OutPoint){OutPoint = InPoint;OutPoint.BoundsMin *= BoundsMin;OutPoint.BoundsMax *= BoundsMax;if (bAffectSteepness){OutPoint.Steepness = FMath::Clamp(InPoint.Steepness * Steepness, 0.0f, 1.0f);}return true;});break;case EPCGBoundsModifierMode::Set:ProcessPoints(Context, Inputs, Outputs, [&Bounds, bAffectSteepness, Steepness](const FPCGPoint& InPoint, FPCGPoint& OutPoint){OutPoint = InPoint;OutPoint.SetLocalBounds(Bounds);if (bAffectSteepness){OutPoint.Steepness = Steepness;}return true;});break;}

Bounds Modifier

源代码

switch (Mode){case EPCGPointExtentsModifierMode::Minimum:ProcessPoints(Context, Inputs, Outputs, [Extents](const FPCGPoint& InPoint, FPCGPoint& OutPoint){OutPoint = InPoint;OutPoint.SetExtents(FVector::Min(Extents, InPoint.GetExtents()));return true;});break;case EPCGPointExtentsModifierMode::Maximum:ProcessPoints(Context, Inputs, Outputs, [Extents](const FPCGPoint& InPoint, FPCGPoint& OutPoint){OutPoint = InPoint;OutPoint.SetExtents(FVector::Max(Extents, InPoint.GetExtents()));return true;});break;case EPCGPointExtentsModifierMode::Add:ProcessPoints(Context, Inputs, Outputs, [Extents](const FPCGPoint& InPoint, FPCGPoint& OutPoint){OutPoint = InPoint;OutPoint.SetExtents(Extents + InPoint.GetExtents());return true;});break;case EPCGPointExtentsModifierMode::Multiply:ProcessPoints(Context, Inputs, Outputs, [Extents](const FPCGPoint& InPoint, FPCGPoint& OutPoint){OutPoint = InPoint;OutPoint.SetExtents(Extents * InPoint.GetExtents());return true;});break;case EPCGPointExtentsModifierMode::Set:ProcessPoints(Context, Inputs, Outputs, [Extents](const FPCGPoint& InPoint, FPCGPoint& OutPoint){OutPoint = InPoint;OutPoint.SetExtents(Extents);return true;});break;}

从代码上看,除了运算模式的区别,和它们的名字一样Bounds Modifier操作的目标是Point的Bounds而Extents Modifier 操作的目标是Point的Extents,并且Bounds Modifier可以选择性地影响Steepness,而Extents Modifier没有这个选项。所以问题的关键就是Bounds和Extents的区别。下面我们看一下PCGPoint的代码:

USTRUCT(BlueprintType)
struct PCG_API FPCGPoint
{GENERATED_BODY()
public:FPCGPoint() = default;FPCGPoint(const FTransform& InTransform, float InDensity, int32 InSeed);FBox GetLocalBounds() const;FBox GetLocalDensityBounds() const;void SetLocalBounds(const FBox& InBounds);FBoxSphereBounds GetDensityBounds() const;UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Properties)FTransform Transform;UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Properties)float Density = 1.0f;UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Properties)FVector BoundsMin = -FVector::One();UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Properties)FVector BoundsMax = FVector::One();UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Properties)FVector4 Color = FVector4::One();UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Properties, meta = (ClampMin = "0", ClampMax = "1"))float Steepness = 0.5f;UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Properties)int32 Seed = 0;UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Properties|Metadata")int64 MetadataEntry = -1;FVector GetExtents() const { return (BoundsMax - BoundsMin) / 2.0; }void SetExtents(const FVector& InExtents){const FVector Center = GetLocalCenter();BoundsMin = Center - InExtents;BoundsMax = Center + InExtents;}FVector GetScaledExtents() const { return GetExtents() * Transform.GetScale3D(); }FVector GetLocalCenter() const { return (BoundsMax + BoundsMin) / 2.0; }void SetLocalCenter(const FVector& InCenter){const FVector Delta = InCenter - GetLocalCenter();BoundsMin += Delta;BoundsMax += Delta;}using PointCustomPropertyGetter = TFunction<bool(const FPCGPoint&, void*)>;using PointCustomPropertySetter = TFunction<bool(FPCGPoint&, const void*)>;static bool HasCustomPropertyGetterSetter(FName Name);static TUniquePtr<IPCGAttributeAccessor> CreateCustomPropertyAccessor(FName Name);
};

在Point中并没有Extents这个成员变量,而只有BoundsMin和BoundsMax这两个Vector3的成员变量

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Properties)FVector BoundsMin = -FVector::One();UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Properties)FVector BoundsMax = FVector::One();

Extents和Bounds之间的关系:

FVector GetExtents() const { return (BoundsMax - BoundsMin) / 2.0; }
	void SetExtents(const FVector& InExtents){const FVector Center = GetLocalCenter();BoundsMin = Center - InExtents;BoundsMax = Center + InExtents;}

小结

Extents Modifier 和 Bounds Modifier的本质并没有区别


http://www.ppmy.cn/news/665350.html

相关文章

554、Vue 3 学习笔记 -【常用Composition API(二)】 2023.06.30

目录 一、常用Composition API1. 拉开序幕的setup2. ref函数3. reactive函数4. Vue3.0中的响应式原理5. reactive对比ref 二、参考链接 一、常用Composition API 1. 拉开序幕的setup &#xff08;1&#xff09;Vue3.0中一个新的配置项&#xff0c;值为一个函数。 &#xff08…

苹果笔记本有uefi启动吗_联想和华硕笔记本重装系统时新BIOS无法设置u盘启动怎么办...

华硕笔记本设置u盘启动 1、新型的华硕笔记本都支持快捷键选择u盘启动&#xff0c;必须先插入制作好的U盘启动盘&#xff0c;然后在启动过程中&#xff0c;不停按esc按键&#xff1b; 2、这时候会出现Please select boot device这个启动项选择菜单&#xff0c;其中图中的General…

苹果计算机cpu 型号怎么看,怎么看macbook型号_怎么看mac具体型号

2017-03-04 11:13:40 大家知道那个电脑主板型号怎么看不,因为想要新买一个电脑,想要看一下电脑配置怎么样,但是因为不知道怎么看电脑主板型号,所以想要请教一下大家。 2016-12-09 14:42:55 你好,1、包装盒上面写有具体型号,如果能找到盒子的话; 2、点击左上角苹果logo-…

每天一点Python——day45

#第四十五天 #字典元素的特点&#xff1a; #例&#xff1a;字典中的所有元素都是一个key-value对【键值对】&#xff0c;key不允许重复&#xff0c;value可以重复 a{name:张三,name:李四} print(a) #只会输出李四&#xff0c;因为键不允许重复&#xff0c;否则会出现值覆盖的情…

Unity URP 获取Camera Stack

URP 获取Camera Stack 1.using UnityEngine.Rendering.Universal; 2.Camera.main.GetUniversalAdditionalCameraData().cameraStack

Java爬虫与Python爬虫有什么区别

Java爬虫和Python爬虫是两种常见的网络爬虫实现方式&#xff0c;它们在语言特性、开发环境和生态系统等方面存在一些区别。 1. 语言特性&#xff1a;Java是一种面向对象的编程语言&#xff0c;而Python是一种脚本语言。Java较为严谨&#xff0c;需要明确定义类、方法和变量&…

非凡linux考试题目和答案,阿尔卡特朗讯最全笔试及答案

[笔试]阿尔卡特NGN software dev.笔试题目 笔试题, 笔试题目 [此帖已被设为推荐] 1、为什么电话里的声音与面对面谈话的声音不同&#xff0c;阐述失真原因。 2、BHCA 与 Erl 的含义&#xff0c;以及两者之间的关系。 3、全球通与神州性有什么区别&#xff1b;有了全球通&#x…

上海贝尔2452交换机_上海贝尔阿尔卡特交换机配置手册 V2.0

Alcatel-lucentMES2452交流机的装备手册&#xff0c;能够作为MES系列交流机的典型装备。系统根底.pdf系统装备及办理.pdf端口根本装备.pdfVLANMAC地址表办理装备.pdf链路会聚装备.pdfMSTP装备.pdfVlanL2二层组播装备.pdf802.1x装备.pdfDHCPDynamic端口安全装备.pdf端口阻隔装备…