IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 游戏开发 -> UE4/5 插件分拆 《第一季》运行时地形06 Voxel 结构解读 -> 正文阅读

[游戏开发]UE4/5 插件分拆 《第一季》运行时地形06 Voxel 结构解读

目录 目录 目录 Runtime?PostConfigInit?Voxel

目录 Voxel依赖:

引擎类: "Core", "CoreUObject","Engine"
,"TraceLog"
,"DeveloperSettings"
,"Projects"
网络类:?"Networking", "Sockets","HTTP","zlib"
3D图形:??"RHI", "RenderCore",
"nvTessLib",
"ForsythTriOptimizer"
2D图形:?"Slate", "SlateCore"
地形:?"Landscape"
物理碰撞:?"PhysX","PhysicsCore"


build.cs 使用了

SetupModulePhysicsSupport(Target); //物理碰撞

PublicDefinitions.Add("VOXEL_DEBUG=1");
PublicDefinitions.Add("VOXEL_PLUGIN_NAME=TEXT(\"VoxelFree\")");


进入Module内文件 250个.h? ,150个.cpp

001插件启动类

Voxel.Build.cs C#编译引导
VoxelModule.h? 模组名:IModuleInterface :{ StartupModule(),??ShutdownModule()?}
VoxelModule.cpp?

启动步骤依次为

VoxelValue.h 会有一个编译自检int8/int16对float的转换
打印debug状态 1/0

材质数据校对 //FVoxelMaterial

压缩/解压校对 //FVoxelSerializationUtilities
将VoxelFree重新定位到Voxel

等待下一帧 //FTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateLambda([=](float){//doSomething;return false;}));

获得当前版本号

		int32 VoxelPluginVersion = 0;
		GConfig->GetInt(TEXT("VoxelPlugin"), TEXT("VoxelPluginVersion"), VoxelPluginVersion, GEditorPerProjectIni);

如果小于当前版本,就提示去网址看说明书,可点击

		const auto OpenLink = [=](const FString& Url)
		{
			FString Error;
			FPlatformProcess::LaunchURL(*Url, nullptr, &Error);
			if (!Error.IsEmpty())
			{
				FMessageDialog::Open(EAppMsgType::Ok, FText::FromString("Failed to open " + Url + "\n:" + Error));
			}
		};

			FVoxelMessages::FNotification Notification;
			Notification.UniqueId = OBJECT_LINE_ID();
			Notification.Message = "Voxel Plugin has been updated to 1.2!";
			Notification.Duration = 1e6f;
			Notification.OnClose = FSimpleDelegate::CreateLambda(Close);
			
			auto& Button = Notification.Buttons.Emplace_GetRef();
			Button.Text = "Show Release Notes";
			Button.Tooltip = "See the latest plugin release notes";
			Button.OnClick = FSimpleDelegate::CreateLambda([=]() 
			{
				OpenLink("https://releases.voxelplugin.com");
				Close();
			});
			
			FVoxelMessages::ShowNotification(Notification);

如果点了网址,就将最后版本设为当前版本,没点就不设置,下次继续提醒

			const auto Close = [=]()
			{
				GConfig->SetInt(TEXT("VoxelPlugin"), TEXT("VoxelPluginVersion"), LatestVoxelPluginVersion, GEditorPerProjectIni);
			};

我跟了一下,最终响应在VoxelEditor模组内的FVoxelMessagesEditor, 是一个

?这样的东西,最后还有一个欢迎词,和一些连接,之后就完了。


引用内部包

#include "VoxelValue.h" int8/int16对float的转换,FVoxelValue带自检
#include "VoxelMaterial.h" 材质,暂略
#include "VoxelMessages.h"?FVoxelMessages一种可点击提示信息
#include "IVoxelPool.h"
#include "VoxelUtilities/VoxelSerializationUtilities.h"

其中只有IVoxelPool::Shutdown(); 在 ShutdownModule(), 证明常驻
IVoxelPool.h 只引用 VoxelMinimal.h ,?

VoxelMinimal.h 很可能是轮子, 轮子类有

#include "VoxelLog.h" --cpp:VoxelDefinitions.cpp
?//#define LOG_VOXEL(Verbosity, Format, ...) UE_LOG(LogVoxel, Verbosity, Format, ##__VA_ARGS__) 一个简单的log输出macro, 就一行
#include "VoxelStats.h"? 引用 "VoxelDefinitions.h" --cpp:VoxelDefinitions.cpp
?出了一堆 VOXEL_*_SCOPE_ * 和?VOXEL_*_COUNTER_ * 和*VOXEL_MEMORY* 的macro , 应该是性能监察,可知作者用了多少时间去调试
#include "VoxelDebug.h"? 引用 "VoxelEngineVersionHelpers.h"
?里面就一个模板 static?FVoxelDebug::Broadcast<T>(...)
#include "VoxelMacros.h"? 引用 "VoxelDefinitions.h"
?这里确定了计算精度是 float 还是 double
?//DATA_CHUNK_SIZE = 16 //VoxelDefinitions.h
?//TNumericLimits<uint16>::Max()0xffff //NumericLimits.h
?static_assert((DATA_CHUNK_SIZE * DATA_CHUNK_SIZE * DATA_CHUNK_SIZE)< TNumericLimits<uint16>::Max(), "CellIndex type is too small");编译时检查chunksize大小
以下这段对vs的Intellisense和rider作了设置,? 填了引擎 CORE_API, ENGINE_API 定义这两个坑

#if defined(__INTELLISENSE__) || defined(__RSCPP_VERSION)
#define INTELLISENSE_PARSER 1
#else
#define INTELLISENSE_PARSER 0
#endif

#if INTELLISENSE_PARSER
#define CORE_API
#define ENGINE_API
#undef VOXEL_DEBUG
#define VOXEL_DEBUG 1
#error "Compiler defined as parser"
#endif

将check(b), ensure(b) 重新 定义为?checkVoxelSlow 和?ensureVoxelSlow 非 debug 不检查
文本转换 FName STATIC_FNAME(Name), FString STATIC_FSTRING(String)
唯一值?UNIQUE_ID()
UE对象名称文本值?
GET_MEMBER_NAME_STATIC(ClassName, MemberName)??
GET_OWN_MEMBER_NAME(MemberName)
DEBUG 相关
OBJECT_LINE_ID() FUNCTION_FNAME?FUNCTION_ERROR??VOXEL_DEPRECATED

#include "VoxelSharedPtr.h"? ?--06详解
?UE4有自己的智能指针
?这里插件作者又把UE的指针封装了一遍, 我们看看都有些什么

template<typename T>
using TVoxelSharedRef = TSharedRef<T, ESPMode::ThreadSafe>;?
using TVoxelSharedPtr = TSharedPtr<T, ESPMode::ThreadSafe>;
using TVoxelWeakPtr = TWeakPtr<T, ESPMode::ThreadSafe>;
StaticCastVoxel* // const 转 非 const
MakeVoxel* // 用构造参数生成
MakeVoxel*Copy // 对象生成
using TVoxelSharedFromThis = TSharedFromThis<T, ESPMode::ThreadSafe>;
?
#include "VoxelDefinitions.h" -cpp:VoxelDefinitions.cpp
? ? ? ? 默认的参数设置,?
? ? ? ? #include 客户参数设置 VoxelUserDefinitions.h
????????-cpp:VoxelDefinitions.cpp 同时也是以下声明的定义

  • #include "VoxelDefinitions.h" //轮
  • #include "VoxelLog.h"?//轮
  • #include "VoxelStats.h"?//轮
  • #include "VoxelFeedbackContext.h"
  • #include "VoxelIntBox.h"
  • #include "VoxelItemStack.h"
  • #include "VoxelEditorDelegates.h"
  • #include "VoxelPlaceableItems/VoxelPlaceableItem.h"

#include "VoxelDelegateHelpers.h"?引用 "VoxelSharedPtr.h" "VoxelEngineVersionHelpers.h"

? ?定义了TBaseSPFunctorDelegateInstance 继承于?TCommonDelegateInstanceState
? ?重定义了TDelegateFromLambda

  • MakeLambdaDelegate
  • MakeWeakObjectPtrDelegate
  • MakeWeakPtrDelegate
  • MakeVoxelWeakPtrDelegate

? ?重定义了TLambdaConditionalForward

  • MakeWeakPtrLambda
  • MakeVoxelWeakPtrLambda

#include "VoxelEngineVersionHelpers.h"
使用版本号作define判断
?#include "Launch/Resources/Version.h"
?#if ENGINE_MINOR_VERSION < 24

#include "VoxelContainers/NoGrowArray.h"

定义了TNoGrowAllocator
using TNoGrowArray = TArray<T, TNoGrowAllocator<TAllocator>>;
using TNoGrowArray64 = TArray<T, TNoGrowAllocator<TAllocator>>;

干脆把整个VoxelContainers文件夹都解读了

VoxelArray3.h 定义?TVoxelArray3(int i,int j,int k) {I + J * Size.X + K * Size.X * Size.Y}

VoxelArrayView.h 定义?TVoxelArrayView 就是一个 TArray封装

VoxelSparseArray.h 定义?
TVoxelSparseArray 非连续数组
TVoxelTypedSparseArray 对?TVoxelSparseArray封装
#define DEFINE_TYPED_VOXEL_SPARSE_ARRAY_ID(Name) using Name = TVoxelTypedSparseArrayId<class Name##_Unique>;

VoxelStaticArray.h 引用?#include "VoxelUtilities/VoxelBaseUtilities.h"
TVoxelStaticArray 一个静态长度数组

template<typename T, uint32 Size, uint32 Alignment = alignof(T)>
class alignas(Alignment) TVoxelStaticArray{
	FORCEINLINE T* RESTRICT GetData()
	{
		return reinterpret_cast<T*>(Data);
	}
	FORCEINLINE const T* RESTRICT GetData() const
	{
		return reinterpret_cast<const T*>(Data);
	}
private:
	uint8 Data[Size * sizeof(T)];
}

TVoxelStaticBitArray 封装了?TVoxelStaticArray<uint32, FVoxelUtilities::DivideCeil(Size, 32)>

	FORCEINLINE void Set(uint32 Index)
	{
		checkVoxelSlow(Index < Size);
		Array[Index / 32] |= (1u << (Index % 32));
	}
	FORCEINLINE void Clear(uint32 Index)
	{
		checkVoxelSlow(Index < Size);
		Array[Index / 32] &= ~(1u << (Index % 32));
	}
	FORCEINLINE bool Test(uint32 Index) const
	{
		checkVoxelSlow(Index < Size);
		return Array[Index / 32] & (1u << (Index % 32));
	}

VoxelUtilities/VoxelBaseUtilities.h

封装了一堆数据方法,以FVoxelUtilities::开头


最后?IVoxelPool.h

virtual IVoxelPool:: 一个等待实现的接口类
?? ?virtual void QueueTask(EVoxelTaskType Type, IVoxelQueuedWork* Task) = 0;
?? ?virtual void QueueTasks(EVoxelTaskType Type, const TArray<IVoxelQueuedWork*>& Tasks) = 0;

static IVoxelPool:: 静态缓存Pool的方法
分别储存于WorldsPools 和?GlobalPool
static TMap<TWeakObjectPtr<UWorld>, TVoxelSharedPtr<IVoxelPool>> IVoxelPool::WorldsPools;
static TVoxelSharedPtr<IVoxelPool> IVoxelPool::GlobalPool;


未解读文件:

目录?FastNoise
目录 VoxelAssets
目录 VoxelComponents
目录 VoxelContainers
目录 VoxelCooking
目录 VoxelData
目录 VoxelDebug
目录 VoxelEvents
目录 VoxelGenerators
目录 VoxelImporters
目录 VoxelMultiplayer
目录 VoxelPlaceableItems
目录 VoxelRender
目录 VoxelShaders
目录 VoxelSpawners
目录 VoxelTools
目录 VoxelUtilities
FastNoise.h
VoxelAsyncWork.h
VoxelBoolVector.h
VoxelCancelCounter.h
VoxelCharacter.h
VoxelDefaultPool.h
VoxelDiff.h
VoxelDirection.h
VoxelEditorDelegates.h
VoxelEditorDelegatesInterface.h
VoxelEnums.h
VoxelFeedbackContext.h
VoxelIntBox.h
VoxelIntBoxLibrary.h
VoxelInterpolator.h
VoxelInvokerSettings.h
VoxelItemStack.h
VoxelMacros.h
VoxelMaterial.h
VoxelMaterialBuilder.h
VoxelMinimal.h
VoxelObjectArchive.h
VoxelOctree.h
VoxelOctreeId.h
VoxelPriorityHandler.h
VoxelQueryZone.h
VoxelQueuedWork.h
VoxelQueueWithNum.h
VoxelRange.h
VoxelSaveStruct.h
VoxelSettings.h
VoxelSharedMutex.h
VoxelSharedPtr.h
VoxelSimpleOctree.h
VoxelStaticWorld.h
VoxelTexture.h
VoxelThreadPool.h
VoxelTickable.h
VoxelUniqueError.h
VoxelVector.h
VoxelWorld.h
VoxelWorldCreateInfo.h
VoxelWorldInterface.h
VoxelWorldRootComponent.h

  游戏开发 最新文章
6、英飞凌-AURIX-TC3XX: PWM实验之使用 GT
泛型自动装箱
CubeMax添加Rtthread操作系统 组件STM32F10
python多线程编程:如何优雅地关闭线程
数据类型隐式转换导致的阻塞
WebAPi实现多文件上传,并附带参数
from origin ‘null‘ has been blocked by
UE4 蓝图调用C++函数(附带项目工程)
Unity学习笔记(一)结构体的简单理解与应用
【Memory As a Programming Concept in C a
上一篇文章      下一篇文章      查看所有文章
加:2021-09-14 13:41:42  更:2021-09-14 13:42:58 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/17 13:51:55-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码