SonicEraZoR / Portal-Base

Port of Portal 1 2007 leaked source code to Source SDK 2013. Also includes fixes for Half-Life 2 maps and gameplay.
Other
109 stars 15 forks source link

fix a bug that place portal at someplace may crash the game. #14

Closed DearVa closed 2 years ago

DearVa commented 2 years ago

Place the portal on someplace will crash the game. It is because that CPortalSimulator::CreateLocalCollision fails on ConvertPolyhedronsToCollideable and returns NULL. I've made a check and if it fails, the portal will not be placed on the new place.

DearVa commented 2 years ago

This happens when a Polyhedron is not convex...

DearVa commented 2 years ago

Hey, I found a SIGGRAPH paper that could convert a non-convex polyhedron into convex polthedrons. Maybe this can also solve the problem caused by Displacement?

DearVa commented 2 years ago

The reorientation of player's camera when go through a portal is faster just like in Portal 2. And you can adjust it by changing "cl_reorient_rate" and "cl_reorient_acceleration_rate" in console (Default value in Portal 1 is 120 and 400).

SonicEraZoR commented 2 years ago

Thanks for contributing!

DearVa commented 2 years ago

Though... It's not grace enough. This bug is caused by non-convex polyhedron but I add lots of checks to make it not crashing. Please forgive my ugly code. If I can solve it, I may revert these changes. By the way, I'm now working on improving the Path-finding algorithm to enable NPC go through portals. Now physics-based NPC like manhack or cscanner works well but non-physics-based can be teleported to unexpected location.

DearVa commented 2 years ago

If a NPC can't reach it's destination, it will try to go through portals. If go through a portal is a shorter route, it will also go through it.

SonicEraZoR commented 2 years ago

Nah it's fine, game not crashing at random places is already a huge improvement even if you can't place portals there, there aren't that many places crashes happen anyway. And any help is appreciated anyway.

Yeah, pathfinding that accounts for portals sounds pretty cool, I'd be really glad if you could help me with that.

SonicEraZoR commented 2 years ago

Hey, I found a SIGGRAPH paper that could convert a non-convex polyhedron into convex polthedrons. Maybe this can also solve the problem caused by Displacement?

Thanks I'll check this out

SonicEraZoR commented 2 years ago

Hmm, at what places does it fix the crashing though?

DearVa commented 2 years ago

d1_trainstation_03 image image

SonicEraZoR commented 2 years ago

Ok I see, didn't even know about this bug, I thought this was a fix for another bug: if you place portal on the floor in the red barn on d1_canals_06 the physics engine will crash. But your fix is also nice to have.

DearVa commented 2 years ago

Ok I see, didn't even know about this bug, I thought this was a fix for another bug: if you place portal on the floor in the red barn on d1_canals_06 the physics engine will crash. But your fix is also nice to have.

Did you mean this barn? image

SonicEraZoR commented 2 years ago

Yeah. but you need to climb up the ladder first so everything in the barn spawns in

DearVa commented 2 years ago

crashed : (