Sign in to follow this  
  • entries
    235
  • comments
    509
  • views
    172042

Auto-Portals

Sign in to follow this  
SimmerD

97 views

Today I added a time-saving feature to the level editor, an auto-portal generator.

Before today, the process of portalization was only semi-automated. Basically, the designer wrapped her 'rooms' in one or more cells. Cells can overlap, and often do. Usually when cells overlap in an empty area, a designer selects the nearby doorway triangles, then hits a button to fit a portal to the selected triangles' bounding box. If the portal was too far away from the nearby cells, she would get an error when building the level.

Now it's a bit easier, just selected the cells you wish to auto-portal, make sure they overlap, or nearly overlap their neighbors, and hit the Auto Portal button.



Here's how the algorithm works. For each selected cell, take its bounding box, and look for other cells crossing it. If you fail, try growing it in x & z by 1 meter, if you fail again, try one more time growing it and searching.

Once you find another cell, keep track of the intersection bounding box between you and the other cell.

Now use the intersection box to look for another portal on the same wall of the cell facing the same way, if you find one, then skip this portal. Two doors on the same cell must be done the old way.

Now use the intersection box to look for a door entity. If you find one, set the portal to match the door entity's bounding box, add a 'portal' facet to the doorway so it can enable & disable this portal at runtime as the door opens & closes.

If no door, look for triangles touching this intersection box. If you find some, find their bounding box, intersect it with the intersection box to make a smaller box, and make the portal fit this new smaller box.

If you don't find one, then use the original intersection box as the portal box.

Once you try to create a portal, the editor will cast a ray from 2 meters on one side of the portal to 2 meters on the other side of the portal. If it hits triangles, it skips creating the portal.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now