泄露

From Valve Developer Community
Jump to navigation Jump to search
English (en)Deutsch (de)Español (es)Français (fr)Русский (ru)中文 (zh)Translate (Translate)
Info content.png
This page needs to be translated.
This page either contains information that is only partially or incorrectly translated, or there isn't a translation yet.
If this page cannot be translated for some reason, or is left untranslated for an extended period of time after this notice is posted, the page should be requested to be deleted.
Also, please make sure the article complies with the alternate languages guide.(en)

什么是泄露?

BSP 地图本身必须保证完全封闭。关卡内部,即世界的任何部分不能和外部,即虚空相连。即便是天空也必须要用tools/toolsskybox纹理的固体封闭地图。当地图没有封闭好,或者有实体在虚空,则在编译地图的时候VBSP就会发生泄露事故,当这种情况发生时,VBSP无法判定地图的哪部分在内部,哪部分在外部,使得无法正常编译地图。

此案例展示了一个在几何方面上具有明显空隙的固体。这会导致编译过程中出现泄露信息:

几何空间上的缝隙会导致泄露事故。

当这样的地图被编译时,与虚空之间存在间隙,VBSP会在编译日志中生成与此类似的错误:

ProcessBlock_Thread: 0...1...2...3...4...5...6...7...8...9...10 (0)
**** leaked ****
Entity light (-1607.69 -1094.12 -183.00) leaked!

出现此错误消息后,VBSP会告诉您关卡中存在泄漏,以及它试图从虚空进入关卡时找到的第一个实体(本案例以范围光为示例)。它还以X、Y和Z坐标为您提供该实体的位置。

Template:Note:zh-cn

Template:Note:zh-cn

Template:Note:zh-cn

Template:Note:zh-cn

泄露导致的debuff

关卡中的泄露会导致许多不良影响. VBSP会报告泄露,并且不会正确生成Portalfile(实际上根本不会生成) (mapname.prt),.VVIS使用Portalfile进行渲染计算.因为没有Portalfile,VVIS将无法正常运行. 当发生泄露时, VRAD也会无法正常工作,或只进行照明,而不进行光线反射.

地图通常根本无法运行.VVIS可能会直接渲染整张地图,这对帧数不利,或直接整个区域都不可见.更坏的情况是,VRAD会直接把地图渲染成黑色.


寻找泄露

有时泄露并不像上面的示例那么明显.可能只是因为一些失误而造成的. VBSP为你提供了一个pointfile去帮助你找到泄露的尸体.它被渲染成从虚空到编译报告中所描述的实体的一条红线.在发生泄漏事故后, a mapname.lin将会生成于vmf的同一目录下.

加载Pointfile

加载pointfile可以使Hammer编辑器的视图里精准显示地图内有哪处地方泄露 ; 使用方法: 在hammer编辑器上方栏里找到map,然后再点选Load Pointfile即可

开启 Load Pointfile 后,hammer视图里应有一处地方是标示着红线的,如图.

右图为加载pointfile的示例。标示红线于 3D 和 2D 视图中,并且该红线是以实体为中心而向外散发至地图外部(即虚空)

通过加载pointfile,你可以沿着红线找到泄漏源。最好从VBSP指定的实体(也就每次地图编译时弹出的编译窗口里显示的一串红字标示的实体)开始找起,然后沿着红线走,直到找到地图中缺口。把洞补上并重新编译地图以查看你是否已修复泄漏。

Finding the endpoint

If you're having trouble locating the start entity, you can use the Go to Coordinates command on the View menu to find the entity and the start of the pointfile line. Simply enter the coordinates given by VBSP for the entity location, and the 2D and 3D views will be centered on that location. Follow the line to find your leak.

Another method to find the source of the leak is to zoom out in one or more of the 2D views. After loading the pointfile, zoom out until you see the red line. Follow the line until you reach the entity at the one of the endpoints. Then select the entity, and choose Center 3D Views on Selection from the View menu. Now you can follow the pointfile line to find the leak.

Other causes of leaks

Besides gaps in outside geometry, there are other map errors that can cause VBSP to generate a leak error.

Entities outside the level

Placing any entity in the void will cause a leak.

All entities need to be inside the playable level space or skybox. VBSP treats all brush entities as if they are not there, so attempting to seal a map with a brush entity, such as a func_door, will create the same condition as if there were a gap in their place.

Improperly constructed areaportals

Areaportals that do not seal areas will cause leaks.

Leak error messages can also be generated when an areaportal does not properly seal the two areas it connects. Find leaks with areaportals using the same methods as geometry gap leaks.

Special geometry does not seal the world

Seal areas behind non-solid geometry to prevent leaks.

Displacements and water also do not seal maps and will cause leaks. You can fix this type of leak by adding a solid brush behind them to seal the map. Using a brush with the tools/toolsnodraw material will seal the map, but not add any additional rendering cost, so it's a great way to seal the map behind displacements. Water should be sealed off with whatever is sealing off the area above it (probably tools/toolsskybox or another typical texture, such as bricks.) Do not use nodraw to seal off water, as this will cause a weird trailing effect.

Mismatched entity origins

An origin helper separated from its parent entity and moved outside the level will cause a leak.

A more subtle cause of leaks can be with any entities that have origin helpers, such as func_door_rotating or func_rot_button. While the entity itself may be inside the world, if the origin helper is outside the map, the entity will cause a leak. If you find a pointfile heading to a empty spot outside of the map, and there is no entity there, an origin helper is a good thing to look for.

One way to quickly tell if an entity origin is causing the leak is to:

  1. Load the pointfile.
  2. Find the endpoint(s) of the pointfile.
  3. Choose Select All from the Edit Menu.
  4. Make sure Show Helpers is checked on the View Menu.
  5. If you see an origin helper appear at the pointfile, you know that's the problem.

If you have an origin helper causing a leak, you can select the object and manually move the origin back into the world, use the Center Origins command from the Tools Menu, or simply right-click on the origin helper and select Center on entity.

Mismatched entity origins usually occur when a brush entity with one of these helpers is moved while in Solids mode. Moving a brush entity in solids mode does not move the entity's origin helper.

Translucent geometry

Brushes with translucent materials, like glass, can also cause leaks if they're on the edge of a map. If your pointfile is going straight through a brush, check the textures on all sides of that brush.

Func_viscluster

Func_viscluster can also cause leaks when they cross areaportal surfaces, or are too close to them. Disabling all func_visclusters and compiling to see if the leak is gone should be done, at least as last resort.

待完善: How do you actually fix this?

虚假泄漏

尽管非常罕见,但是VBSP还是有可能在你编译地图时报告假泄漏,如果你确定VBSP报告的泄漏是不应该出现的,那么你可以把你的地图复制粘贴到新的地图文件中。如果编译成功,那么你之前的文件可能损坏了。

Conclusion: An ounce of prevention

Using the pointfile tools makes finding leaks relatively painless, but one of the most important ways to fix leaks is by preventing them in the first place. Taking your time when building, and making sure brushes are snapped properly to the grid can go a long way towards eliminating leaks before they occur. The cleaner and more organized your geometry, the more likely you are to be able to spot leaks when they occur, or even prevent them from happening in the first place. You can also help prevent lots of extra work by compiling your level as you go along, instead of building your whole level before trying to compile it. Finding one leak at a time while the map is only partially complete is a lot easier and faster than finding leaks in a complete map that is full of geometry.