Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: zookeeper on November 14, 2009, 12:23:41 pm

Title: Mysterious collision detection problem
Post by: zookeeper on November 14, 2009, 12:23:41 pm
I've spent a couple of days trying to figure out a problem that I've more or less reduced to this very minimal test case. The problem: you can shoot/fly through some parts of the turret, both the base and the arm. The attached .zip contains just the .pof file in question.

It's modelled in 3ds Max 9, and exported to a .dae with the ColladaMax exporter. In pcs2 I simply make it recalculate the moment of inertia, change the texture to a retail one (so I don't have to include an irrelevant custom one) and set the rotation axis for the Turret01 subobject to "Z Axis". Obviously I've went through every detail I can think of and I can't find anything wrong with it that'd explain why it happens: there's no inverted face normals, I did reset x-form and all that in max, also tried the -node removal in the .dae, etc. I have no idea from which point in the whole process the problem originates from.

Much appreciation to anyone who can solve the mystery. :confused:

[attachment deleted by admin]
Title: Re: Mysterious collision detection problem
Post by: Spoon on November 14, 2009, 05:16:04 pm
I've noticed similar problems with some of the ships i've exported from 3dsmax 6 (plugin not colladamax). Certain area's of a ship will have shots passing through the hull. Also encountered a lot of this when I tried a humanoid shape, made the legs and feet seperate subsystems. All shots would simply pass through the feet completely and the legs were only hittable at the upper part.

So yeah... if anyone has any clue. I'd like to hear it as well
Title: Re: Mysterious collision detection problem
Post by: Scooby_Doo on November 14, 2009, 05:33:10 pm
I believe subsystems don't extend the bounding box.  You'll need to place tiny polys (real small triangles will work) at the extended areas (tips of the toe, heal, etc).
Title: Re: Mysterious collision detection problem
Post by: Col. Fishguts on November 14, 2009, 05:34:16 pm
Yes, it's a known feature/bug of PCS2 (I'm not 100% if it was different in PCS1). Submodels that lie outside the bounding box of one of the main parent meshes will have no collision detection.

You can get around this by cleverly placing invisible polys which are part of the main mesh to extend the bounding box OR make it so that one of the lower LOD main meshes (detail1, detail2 or detail3) has a bounding box that encompasses all the submodels. Because I found this out by accident on a model where all the no-collision-detection vanished as soon as I included a lower LOD that was big enough to encompass all the submodels of detail0.
Title: Re: Mysterious collision detection problem
Post by: zookeeper on November 14, 2009, 06:12:14 pm
Awesome, thanks a whole lot! That indeed seems to solve the basic collision detection issue. I'm still left with other problems though, but at least this is a very good start.
Title: Re: Mysterious collision detection problem
Post by: Spoon on November 15, 2009, 06:33:01 am
Indeed, I too must thank you guys, Scooby_Doo&Col. Fishguts.
Title: Re: Mysterious collision detection problem
Post by: zookeeper on November 15, 2009, 09:44:39 am
All right, now I'm stumped on this:

In working.pof, collision detection works fine and the turret also actually shoots at stuff.

In not-working.pof, the turret just sits there idly and never does anything. Also, while collision detection works in the sense that shots impact the turret base and barrels just fine, flying my ship into the barrel results in an assert crash: ASSERTION: "pm->submodel[submodel_num].movement_type == MOVEMENT_TYPE_ROT" at modelread.cpp:3941

In both working.pof and not-working.pof the turret is exactly the same, the only difference is that in not-working.pof I extruded out one side of the detail0 object and moved the extruded vertices out. Nothing else changed, so this must be due to some odd bounding box -like thing. However, I have no idea whatsoever what it could be exactly or how I should fix/prevent it. Again, the situation could be summarized as: :confused:

[attachment deleted by admin]
Title: Re: Mysterious collision detection problem
Post by: Water on November 15, 2009, 01:11:05 pm
Are you sure the turret works properly? From what I can see, all the rotation points are in the same place. Body, turret and barrel.
Title: Re: Mysterious collision detection problem
Post by: zookeeper on November 15, 2009, 01:46:43 pm
Are you sure the turret works properly? From what I can see, all the rotation points are in the same place. Body, turret and barrel.
Well, it shoots at stuff. I'm not sure what you mean about the rotation points though, since AFAIK they are in different places. Turret01 has an offset and Turret01-arm has a non-zero offset, meaning the pivot/rotation points are in different places, no?
Title: Re: Mysterious collision detection problem
Post by: chief1983 on November 15, 2009, 03:06:39 pm
I think your crash might be related to a bug I reported (http://scp.indiegames.us/mantis/view.php?id=1946).