View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002706 | FSSCP | models | public | 2012-08-28 18:00 | 2012-12-09 05:58 |
Reporter | MjnMixael | Assigned To | Valathil | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.6.13 | ||||
Target Version | 3.6.16 | ||||
Summary | 0002706: Weapons not colliding | ||||
Description | Weapons are not colliding with objects correctly in all cases. Noticed this with the new HTL Comm Node I'm working on. The mesh is solid and I can collide with it via my ship. However, weapons are not hitting the outer hull. | ||||
Steps To Reproduce | I can make the mesh available if need be, though I'm sure this is an issue with other models that don't have shields. Shields still seem to be working. | ||||
Additional Information | It seems like the weapons are passing through the outer hull and colliding with the opposite normal on the inside hull. In the attached image, I've been shooting at the Node for a good 30 seconds, you can see no hit effects of any kind. | ||||
Tags | No tags attached. | ||||
|
|
|
Forgot to include that this works correctly in 9100, but not in 9103. |
|
bug_fixes.patch (4,908 bytes)
Index: code/object/objcollide.cpp =================================================================== --- code/object/objcollide.cpp (revision 9114) +++ code/object/objcollide.cpp (working copy) @@ -47,6 +47,8 @@ struct checkobject; extern checkobject CheckObjects[MAX_OBJECTS]; +extern int Cmdline_old_collision_sys; + void obj_pairs_close() { if (Obj_pairs != NULL) { @@ -1019,21 +1021,50 @@ else crw_status[i] = CRW_NO_PAIR; } - + // first pass is to see if any of the weapons don't have collision pairs. - opp = &pair_used_list; - opp = opp->next; - while( opp != NULL ) { - // for each collide pair, if the two objects can still collide, then set the remove_weapon - // parameter for the weapon to 0. need to check both parameters - if ( opp->a->type == OBJ_WEAPON ) - crw_check_weapon( opp->a->instance, opp->next_check_time ); + if ( Cmdline_old_collision_sys ) { + opp = &pair_used_list; + opp = opp->next; + while( opp != NULL ) { + // for each collide pair, if the two objects can still collide, then set the remove_weapon + // parameter for the weapon to 0. need to check both parameters + if ( opp->a->type == OBJ_WEAPON ) + crw_check_weapon( opp->a->instance, opp->next_check_time ); - if ( opp->b->type == OBJ_WEAPON ) - crw_check_weapon( opp->b->instance, opp->next_check_time ); + if ( opp->b->type == OBJ_WEAPON ) + crw_check_weapon( opp->b->instance, opp->next_check_time ); - opp = opp->next; + opp = opp->next; + } + } else { + SCP_hash_map<uint, collider_pair>::iterator it; + collider_pair *pair_obj; + + for ( it = Collision_cached_pairs.begin(); it != Collision_cached_pairs.end(); ++it ) { + pair_obj = &it->second; + + if ( !pair_obj->initialized ) { + continue; + } + + if ( pair_obj->a->type == OBJ_WEAPON && pair_obj->signature_a == pair_obj->a->signature ) { + crw_check_weapon(pair_obj->a->instance, pair_obj->next_check_time); + + if ( crw_status[pair_obj->a->instance] == CRW_CAN_DELETE ) { + pair_obj->initialized = false; + } + } + + if ( pair_obj->b->type == OBJ_WEAPON && pair_obj->signature_b == pair_obj->b->signature ) { + crw_check_weapon(pair_obj->b->instance, pair_obj->next_check_time); + + if ( crw_status[pair_obj->b->instance] == CRW_CAN_DELETE ) { + pair_obj->initialized = false; + } + } + } } // for each weapon which could be removed, delete the object @@ -1144,6 +1175,7 @@ void obj_reset_colliders() { Collision_sort_list.clear(); + Collision_cached_pairs.clear(); } void obj_collide_retime_cached_pairs(int checkdly) Index: code/object/object.cpp =================================================================== --- code/object/object.cpp (revision 9114) +++ code/object/object.cpp (working copy) @@ -192,11 +192,8 @@ return original_num_to_free; } - if ( Cmdline_old_collision_sys ) { - deleted_weapons = collide_remove_weapons(); - } else { - deleted_weapons = 0; - } + deleted_weapons = collide_remove_weapons(); + num_to_free -= deleted_weapons; if ( !num_to_free ){ return original_num_to_free; Index: code/ship/ship.cpp =================================================================== --- code/ship/ship.cpp (revision 9114) +++ code/ship/ship.cpp (working copy) @@ -9188,8 +9188,13 @@ sp->model_instance_num = model_create_instance(sip->model_num); // Valathil - Reinitialize collision checks - obj_remove_pairs(objp); - obj_add_pairs(objp->instance); + if ( Cmdline_old_collision_sys ) { + obj_remove_pairs(objp); + obj_add_pairs(objp->instance); + } else { + obj_remove_collider(OBJ_INDEX(objp)); + obj_add_collider(OBJ_INDEX(objp)); + } // The E - If we're switching during gameplay, make sure we get valid primary/secondary selections if ( by_sexp ) { Index: code/ship/shipfx.cpp =================================================================== --- code/ship/shipfx.cpp (revision 9114) +++ code/ship/shipfx.cpp (working copy) @@ -1121,7 +1121,7 @@ if ( mc.bsp_leaf ) { if ( mc.bsp_leaf->tmap_num < 255 ) { - polymodel *pm = model_get(sip->cockpit_model_num); + polymodel *pm = model_get(sip->model_num); int tmap_num = mc.bsp_leaf->tmap_num; if ( !(pm->maps[tmap_num].is_transparent) && strcmp(bm_get_filename(mc.hit_bitmap), "glass.dds") ) { Index: code/weapon/weapons.cpp =================================================================== --- code/weapon/weapons.cpp (revision 9114) +++ code/weapon/weapons.cpp (working copy) @@ -4887,11 +4887,7 @@ //if ( !(Objects[parent_objnum].flags & OF_PLAYER_SHIP) ) // return -1; - if ( Cmdline_old_collision_sys ) { - num_deleted = collide_remove_weapons(); - } else { - num_deleted = 0; - } + num_deleted = collide_remove_weapons(); nprintf(("WARNING", "Deleted %d weapons because of lack of slots\n", num_deleted)); if (num_deleted == 0){ |
|
Uploaded patch with potential fixes. |
|
Tested and still having collision issues with weapons. 'Use old collision detection system' resolves the problems. A good example is the retail (No Mods) Shivan Comm Node in Into the Lion's Den. |
|
Having issues as well with anything that is a rotating subsystem. I can fly into the object so it does have collision detection vs ships. Missiles and beams go straight through on my testing in TBP. I did record damage to the subsystem if the weapon fire hit something else on the ship behind the subsystem. If they don't hit anything after passing through the subsystem no damage was taken. I did manage to get a series of hits at one point from a certain angle but was not able to reproduce those hits. Collisions worked fine with the old collision flag enabled. Also tested with the retail comm node. While shots did hit about half the time they seemed to not hit the correct spot in most cases. For instance hitting the lower arm as it rotated toward you would either go through and hit something else or hit the back side of the arm. This was in r9368 |
|
|
|
Uploaded a test mission with retail data. Includes ships with all kinds of rotating subsystems to showcase the issue. The Charybdis is actually a great example because you can shoot right through the domes, but you can hit the hull just fine. |
|
|
|
collideshipship.cpp.patch (538 bytes)
Index: code/object/collideshipship.cpp =================================================================== --- code/object/collideshipship.cpp (revision 9405) +++ code/object/collideshipship.cpp (working copy) @@ -314,8 +314,6 @@ model_instance_find_world_point(&ship_ship_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_num, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient, &zero); } } - // Don't look at this submodel again - pmi->submodel[*smv].collision_checked = true; } } |
|
This was the most aggravating 2 days of debugging ever. Has nothing to do with Swifties code or anything. Just that the new code checks the collision pairs in a different order and there was a bug where after the first ship2ship collision only other ship2ship collisions were registered on subsytems cause a flag was set wrongly because of a copypasta. Attached a patch that fixes |
|
Problem with just removing that section. Prior to 6878, it was this: "pm->submodel[submodel_list[i]].blown_off = 1;" This indicates to me that it was setting up to only skip if the submodel in question had been blown off. Now it's applying regardless of the submodel state. Rather than just removing the code there, can we reinstate that as being a "if you're blown off, don't bother, otherwise, update"? If we can validate that blown off submodels are already being appropriately culled elsewhere, then awesome, I'm all for this fix. But otherwise, I think we need to make sure that it is working as intended originally. |
|
au contraire mon ami look at the beginning of the loop before the removed statement there is clearly the if blown off thing in there. Also the blown off thing is checked in other places as well. I didn't want to go too deep into it but this whole iterate over all stuff and set collision_checked thing seems to be useless anyway and seems to come from a copypasta from debris and asteroid collision code. |
|
Fix committed to trunk@9414. |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-08-28 18:00 | MjnMixael | New Issue | |
2012-08-28 18:00 | MjnMixael | File Added: ImageBin.jpg | |
2012-08-28 18:00 | MjnMixael | Note Added: 0013949 | |
2012-09-05 00:59 | Swifty | Assigned To | => Swifty |
2012-09-05 00:59 | Swifty | Status | new => assigned |
2012-09-05 01:03 | Goober5000 | Relationship added | related to 0002708 |
2012-09-09 13:40 | Swifty | File Added: bug_fixes.patch | |
2012-09-09 13:41 | Swifty | Note Added: 0013957 | |
2012-09-25 00:49 | MjnMixael | Note Added: 0013973 | |
2012-09-25 01:03 | MjnMixael | Note Edited: 0013973 | |
2012-11-05 05:45 | Goober5000 | Target Version | => 3.6.16 |
2012-11-27 03:35 | FUBAR-BDHR | Note Added: 0014193 | |
2012-12-07 16:33 | MjnMixael | File Added: weaponcollisions.fs2 | |
2012-12-07 16:34 | MjnMixael | Note Added: 0014348 | |
2012-12-07 20:21 | MjnMixael | File Added: Mantis Sandbox.7z | |
2012-12-08 23:09 | Valathil | File Added: collideshipship.cpp.patch | |
2012-12-08 23:09 | Valathil | Assigned To | Swifty => Valathil |
2012-12-08 23:11 | Valathil | Note Added: 0014362 | |
2012-12-08 23:11 | Valathil | Status | assigned => code review |
2012-12-09 01:21 | Zacam | Note Added: 0014367 | |
2012-12-09 01:25 | Zacam | Note Edited: 0014367 | |
2012-12-09 01:26 | Zacam | Note Edited: 0014367 | |
2012-12-09 05:36 | Valathil | Note Added: 0014376 | |
2012-12-09 05:58 | Zacam | Changeset attached | => fs2open trunk r9414 |
2012-12-09 05:58 | Zacam | Note Added: 0014378 | |
2012-12-09 05:58 | Zacam | Status | code review => resolved |
2012-12-09 05:58 | Zacam | Resolution | open => fixed |