Bug 2929 - bbox over entity
Status: RESOLVED FIXED
Alias: None
Product: Tremulous
Classification: Unclassified
Component: Video
Version: unspecified
Hardware: PC Linux
: P2 minor
Assignee: Tremulous Bugs
QA Contact:
URL:
: 4695
Depends on:
Blocks:
 
Reported: 2006-11-25 10:11 EST by rasz
Modified: 2011-01-19 15:44:05 EST
4 users (show)

See Also:


Attachments
Fix (769 bytes, patch)
2010-08-11 00:42 EDT, WilliamH
Screenshot describing buggy behavior (99.31 KB, image/jpeg)
2010-08-20 16:50 EDT, WilliamH
alternative fix (989 bytes, patch)
2010-09-06 13:14 EDT, gimhael
Second Alternate Fix (1.84 KB, patch)
2010-12-30 23:25 EST, WilliamH
cleaned up second alternative fix (1.79 KB, patch)
2011-01-16 18:10 EST, Chris "Lakitu7" Schwarz

Comment 1 Tony J. White 2006-12-04 01:45:38 EST
This is a client side problem that has been fixed in cgame.  The bbox shown is correct, the model was just drawing in the wrong place.
Comment 2 Tim Angus 2006-12-04 04:26:54 EST
Actually I think this one is actually valid. It happens because the buildable drawing code uses a cap trace (so that things sit on slopes properly), whereas the server side uses a box trace.

It's been there forever, but it's pretty much a corner case so I've always avoided doing anything about it.
Comment 3 Martin Doucha 2006-12-04 08:11:42 EST
How about just tying the bbox and model together using some common point (origin)?
Comment 4 Tim Angus 2006-12-04 08:18:35 EST
Because that wouldn't work. In that case anything that sat on a non-axial surface would appear to float above it.

The fix is really to further restrict where buildings can be placed, so that they can't sit with say >50% of their base overhanging an edge. That has the side effect of preventing some of the more "creative" base designs though. I think such things look ridiculous, but some may complain.
Comment 5 rasz 2006-12-04 13:22:54 EST
like this ? http://www.keepmyfile.com/image/388a0b1245600
this is latest svn :(

imo martin has a point, player doesnt care about bboxes, he wants to shoot stuff and kill it or jump over it.
Is there some restriction that doesnt let bboxes to cross map surfaces? if not then just tie "bbox and model together using some common point
(origin)", like for example the center or the model. 
I mean whats worse, invisible BBox that blocks you, and you have no idea where to shoot, or a little smaller bbox (some of it would end up inside map geometry) in the right place? Just use current client buildable drawing code for determining where stuff should go, and then slapping bbox over it regardless of map geometry.



and proper down to single triangle collision detection procedure would really be neat :P
Comment 6 Tim Angus 2006-12-04 13:48:58 EST
Just... let me deal with it.
Comment 7 Mirek 2008-01-18 13:35:17 EST
It's very bad when is allowed build on top of each other buildable and bbox is somewhere else than model. And building like this is so fun...
Comment 8 WilliamH 2010-08-11 00:42:28 EDT
Created attachment 2392 [details]
Fix

The function CG_PositionAndOrientateBuildable uses CG_CapTrace initially to
place the buildable, and if errors are detected, then it resorts to CG_Trace.
However, it appears that not all of the errors can be caught, resulting in the
nasty visual bugs described above. Using CG_Trace in all cases fixes the bug
and does not appear to degrade performance significantly or break anything else
as far as I have found.
Comment 9 WilliamH 2010-08-11 00:44:18 EDT
*** Bug 4695 has been marked as a duplicate of this bug. ***
Comment 10 WilliamH 2010-08-20 16:50:25 EDT
Created attachment 2413 [details]
Screenshot describing buggy behavior

Simply mandating that a specific portion of the buildable's bbox be touching a solid suface would not fix this unless the mandated portion was close to 100%. Not only is it merely a workaround, but it does not solve this in all cases. The new screenshot shows the a telenode glitched into a skid of barrels on niveus. It would be perfectly natural for a telenode to be built there if thinking of the real properties of steel, and most of the telenode is built on a solid surface (actually I believe its all solid for player movement purposes).

To make this even more difficult I believe this picture means that one could also engineer a map where 99% of the buildable is placed on a solid surface.

I think the only true solution here is a change in the trace. Even if a box trace isn't used in the end, a cap trace is insufficient.
Comment 11 gimhael 2010-09-06 13:14:39 EDT
Created attachment 2443 [details]
alternative fix

I think that the main problem is that cap traces don't work well for "flat" structures, i.e. whose height is less than their width.

This is because the engine constructs the largest capsule that fits entirely within the bbox passed. A capsule is defined as two hemispheres connected by a vertical cylinder of the same radius.

When the bbox height equals the width, the capsule degrades to a sphere, if the height is less than the witdth, the "capsule" is a sphere with diameter equal to the height. So for a telenode (width = 80 units, height = 10 units) the capsule trace traces only a diameter 10 sphere, which fits between the barrels, although a diameter 80 sphere would not.

This patch increases the height of the bbox for the cap trace, so that the capsule uses always the full width of the bbox.
Comment 12 WilliamH 2010-12-30 23:25:23 EST
Created attachment 2547 [details]
Second Alternate Fix

This patch prevents buildables from appearing more than 15 quake distance units away from where it would be rendered using a bbox trace, enough to prevent buildables appearing to be invisible, but still allowing buildables to sink into the ground.
Comment 13 gimhael 2011-01-10 08:10:27 EST
I suggest two small improvements to your patch:

You can use the function Distance(tr.endpos, box_tr.endpos) to calculate mag, and the assignment tr = box_tr does an unnecessary struct copy, but you're only interested in the fraction component, so you should just use a temporary float var for the fraction value.
Comment 14 Chris "Lakitu7" Schwarz 2011-01-16 18:10:38 EST
Created attachment 2557 [details]
cleaned up second alternative fix

Applied gimhael's suggestions and otherwise cleaned up WilliamH's "second alternative fix" patch.

After testing it a bit I think about does it and really ought to make everyone happy. I'm going to ci it shortly if nobody objects. Going once, going twice?
Comment 15 Chris "Lakitu7" Schwarz 2011-01-19 15:44:05 EST
r2104. Thank you all.