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

2023-10-27

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

两个节点的代码对比

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的本质并没有区别

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

虚幻引擎程序化资源生成框架PCG 之Extents Modifier 和 Bounds Modifier 的相关文章

随机推荐

  • CentOS下安装配置Phabricator

    1 下载快捷安装sh http download csdn net detail u012547633 9882697 把centos版的phabricator安装脚本下载到opt目录并安装 cd opt chmod 777 install
  • java版本号分段比较_版本号判断,例如:1.0.0比较1.0.1

    有的时候可能会判断客户端的版本号信息 多位数的版本号判断做个记录 代码分享者 zzp 注意 Java中应该吧分割的正则使用 来分割小数点字符串 分割 NSArray curVerArr currentVersion componentsSe
  • 了解Chat GPT

    CHATGPT是一款强大的人工智能语言模型 可以回答任何问题和开启有趣的对话 以下是一些使用CHATGPT的技巧和提示 提问明确 CHATGPT能够回答任何问题 但它需要清晰和明确的问题来给出准确的答案 因此 在提问时要尽可能明确和具体 尝
  • 【JDBC】-- Java连接数据库方法(Mysql8+idea)

    Java Database Connectivity 简称JDBC 是Java语言中用来规范客户端程序如何来访问数据库的应用程序接口 提供了诸如查询和更新数据库中数据的方法 Java如何连接数据库 下面使用Mysql8版本 编译器使用ide
  • Flink_CDC搭建及简单使用

    Flink CDC搭建及简单使用 1 CDC简介 CDC Change Data Capture 在广义的概念上 只要能捕获数据变更的技术 都可以称为 CDC 但通常我们说的CDC 技术主要面向数据库 包括常见的mysql Oracle M
  • Dubbo-admin 新版本启动问题记录

    Dubbo admin 新版本启动问题记录 文章目录 Dubbo admin 新版本启动问题记录 1 安装步骤 a 下载zookeeper b 下载并编译dubbo 2 总结 1 安装步骤 直接按照官网下载下来的软件 并按照说明安装软件会存
  • Vagrant虚拟机安装,磁盘扩容以及局域网内访问教程

    1 下载vagrant以及virtualBox 配上vagrant virtualBox线上下载地址 vagrant下载地址 virtualBox下载地址 2 开始准备安装镜像文件 找到需要安装的系统镜像文件 配上vagrant镜像地址 v
  • Linux strace 命令 说明

    Strace是Linux中一个调试和跟踪工具 它可以接管被跟踪进程执行的系统调用和收到的信号 然后把每一个执行的系统调用的名字 参数和返回值打印出来 可以通过strace找到问题出现在user层还是kernel层 strace 显示这些调用
  • 集群基础3——haproxy负载均衡apache

    文章目录 一 环境说明 二 安装配置httpd 三 安装配置haproxy 四 验证http负载均衡 五 配置https负载均衡 六 haproxy网页监控 6 1 监控参数详解 6 2 页面操作 一 环境说明 使用haproxy对apac
  • jmeter中body data使用post请求的json格式提交

    之前介绍过jmeter中post的默认提交形式form表达提交 Content type application x www form urlencoded 使用直接 填写参数的形式 本次介绍的是jmeter中body data使用也就是j
  • 学历和工作年限决定了程序员的工资水平吗?

    根据中国互联网络信息中心 CNNIC 近日发布的第 45 次 中国互联网络发展状况统计报告 可知 截至 2020 年 03 月 中国网民规模为 9 04 亿 较 2018 年底增加 7508 万 其中农村网民规模达 2 55 亿 占网民整体
  • 时序预测

    时序预测 MATLAB实现SVM 支持向量机 时间序列多步预测 目录 时序预测 MATLAB实现SVM 支持向量机 时间序列多步预测 预测效果 模型描述 程序设计 学习总结 参考资料 预测效果 模型描述 Options 可用的选项即表示的涵
  • maven环境快速搭建

    最近 开发中要用到maven 所以对maven进行了简单的学习 因为有个maven高手在身边 所以 很快就上手了 我这里算是自我总结吧 关于maven是什么东东 请参考其它文章 准备工作 Jdk 1 5以上java开发环境 Eclipse
  • 图解TCP/IP

    第1章 网络基础知识 本章总结了深入理解TCP IP所必备的基础知识 其中包括计算机与网络发展的历史及其标准化过程 OSI参考模型 网络概念的本质 网络构建的设备等 1 5 4 OSI参考模型中各个分层的作用 应用层 为应用程序提供服务并规
  • Python爬虫入门6:模拟浏览器访问网页的http报文体压缩传输

    前往老猿Python博客 https blog csdn net LaoYuanPython 一 引言 在前面章节中介绍了使用urllib包的request模块访问网页的方法 但上节特别说明http报文头Accept Encoding最好不
  • pytorch和tensorflow有什么区别?

    PyTorch 是一种用于构建深度学习模型的功能完备框架 同时tensorflow也是常用的框架之一 大家在学习的时候 尝尝会用来做比较 那么pytorch和tensorflow有什么区别 大家所关心的问题 解答来了 pytorch和ten
  • vue拖拽实现

    拖拽介绍 目标是将左侧list中的item拖入右侧card中 如下所示 将list1和list3拖入右侧拖拽区 一 拖拽样式实现 使用vue vuetifyjs实现 页面布局可根据不同的UI库自行修改 html内容
  • C++消消乐

    键盘版 include
  • 5、JSON.parse()

    JSON parse JSON 通常用于与服务端交换数据 在接收服务器数据时一般是字符串 我们可以使用 JSON parse 方法将数据转换为 JavaScript 对象 语法 JSON parse text reviver 参数说明 te
  • 虚幻引擎程序化资源生成框架PCG 之Extents Modifier 和 Bounds Modifier

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