ALCCClippingVolume:3DGS 裁剪體
裁剪體 Actor,用盒形或球形體積裁掉 LCC 場景的一部分。
| 模塊 | LCC4UnrealRuntime |
| 頭文件 | Tools/LCCClippingVolume.h |
| 父類 | AVolume |
| 面板顯示名 | LCC Clipping Volume |
#include "Tools/LCCClippingVolume.h"
使用步驟、演示效果與屬性面板說明見場景編輯 - 裁剪框。本頁只列接口。
Properties
| 屬性 | 類型 | 說明 |
|---|---|---|
bEnabled | bool | 是否參與裁剪 |
Mode | EClipType | Inside 裁掉體積內部,Outside 裁掉體積外部 |
VolumeType | EClipVolumeType | Box 盒形,Sphere 球形 |
取值含義見 EClipType 與 EClipVolumeType。
三個屬性都沒有 Setter,直接賦值即可。運行時改屬性或改變換都會在下一幀自動生效,不需要手動通知渲染側。
Methods
SetUpdateComponent / Refresh(已廢棄)
UFUNCTION(BlueprintCallable, Category = "XGrids", meta = (DeprecatedFunction))
void SetUpdateComponent(ULCCComponentBase* Component);
UFUNCTION(BlueprintCallable, Category = "XGrids", meta = (DeprecatedFunction))
void Refresh();
兩個方法都已廢棄,實現為空操作,調用不會有任何效果也不會報錯。
裁剪數據現在每幀讀取,屬性與變換的改動下一幀自動反映到畫面上。舊版本需要先 SetUpdateComponent 建立綁定、改完再調 Refresh() 的那套流程不再需要。
已有代碼中的調用可以直接刪除。藍圖裏這兩個節點會顯示廢棄警告,替換方式就是移除節點。
運行時創建
#include "Tools/LCCClippingVolume.h"
#include "LCCComponentBase.h"
ALCCClippingVolume* AMyTool::CreateBoxClip(
ULCCComponentBase* Component, const FVector& Location, const FVector& Extent)
{
ALCCClippingVolume* Volume = GetWorld()->SpawnActor<ALCCClippingVolume>(
ALCCClippingVolume::StaticClass(), Location, FRotator::ZeroRotator);
if (!Volume)
{
return nullptr;
}
Volume->VolumeType = EClipVolumeType::Box;
Volume->Mode = EClipType::Inside;
Volume->bEnabled = true;
// AVolume 的尺寸通過縮放控制
Volume->SetActorScale3D(Extent / 100.0f);
Component->AddClippingVolume(Volume);
return Volume;
}
臨時開關裁剪效果不要增刪數組,直接改 bEnabled 更輕量:
for (ALCCClippingVolume* Volume : MyVolumes)
{
if (Volume)
{
Volume->bEnabled = bEnable;
}
}
運行時移動裁剪體做動畫,直接改變換即可:
// 讓裁剪體掃過場景
FVector Loc = ClipVolume->GetActorLocation();
Loc.X += 200.0f * DeltaTime;
ClipVolume->SetActorLocation(Loc);
藍圖節點見場景編輯 - 藍圖方法。
Notes
- 裁剪只影響渲染,不影響碰撞。裁掉的區域仍可被射線打中、仍會擋住角色。
- 多個裁剪體同時作用時各自獨立判定,效果疊加。既有
Inside又有Outside時容易出現意外結果。 - 同時生效的裁剪體數量有上限,未授權時為 50 個,超出的不參與渲染並輸出警告。裁剪體與剖切面共用這個配額。授權說明見版本與授權。
- 銷毀裁剪體只會觸發一次渲染更新,不會從 Component 的
ClippingVolumes數組裏移除元素,數組中會殘留失效指針(渲染時會自動跳過)。需要保持數組乾淨的話,銷毀前先調RemoveClippingVolume。
See Also
- 場景編輯:完整使用說明
- ALCCSectionPlane:用平面剖切
- ULCCComponentBase:
AddClippingVolume與RemoveClippingVolume