View Issue Details

IDProjectCategoryView StatusLast Update
0002063FSSCPmodelspublic2010-02-20 19:14
Reporterwarfull Assigned ToWanderer  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.11 
Summary0002063: No collision with warped-in ships using hyperspace warpin type.
DescriptionShip-ship collision dont work if ships warpin during the mission with hyperspace warpin type.
Cause : when ship warpin a new object is created and some new collisions pairs are added to the pair list.
At this time object is very far from the battle zone and have no velocity.
The first time collision is checked the obj_pair.next_check_time value is computed according distance and ship velocity or max speed for this ship resulting in a too long delay for the next check.

Here you can find the fix i used : (only 4 lines with comments)
int WE_Hyperspace::warpStart()
{
    if(!this->isValid())
        return 0;

    total_time_start = timestamp();
    total_time_end = timestamp(total_duration);

    if(direction == WD_WARP_IN)
    {
        shipp->flags |= SF_ARRIVING_STAGE_2;
        objp->phys_info.flags |= PF_WARP_IN;
        objp->phys_info.vel.xyz.z = (scale_factor / sip->warpin_time)*1000.0f; // compute pseudo-velocity and update object
        objp->flags &= ~OF_PHYSICS; // disable physics during effect

    }
    else if(direction == WD_WARP_OUT)
    {
        shipp->flags |= SF_DEPART_WARP;
    }
    else
    {
        this->warpEnd();
    }

    pos_final = objp->pos;

    return 1;
}

int WE_Hyperspace::warpFrame(float frametime)
{
    if(!this->isValid())
        return 0;

    if(timestamp_elapsed(total_time_end))
    {
        objp->pos = pos_final;
        objp->phys_info.vel.xyz.z = 0.0f; // get back to 0 velocity
        objp->flags |= OF_PHYSICS; // enable physics
        this->warpEnd();
    }
    else
    {
        float progress = ((float)timestamp() - (float)total_time_start)/(float)total_duration;
        float scale = 0.0f;
        if(direction == WD_WARP_IN)
            scale = scale_factor*(progress*progress -1);
        else
            scale = scale_factor*progress*progress;
        vm_vec_scale_add(&objp->pos, &pos_final, &objp->orient.vec.fvec, scale);
    }
    return 1;
}

TagsNo tags attached.

Activities

Wanderer

2010-01-05 09:43

developer   ~0011488

Code committed to SVN. I'll resolve the bug if no issue with the patch are seen.

chief1983

2010-01-05 21:01

administrator   ~0011498

Do we _want_ collisions here? I mean, we don't currently have a way to prevent warping in into other ships do we?

Wanderer

2010-02-12 11:29

developer   ~0011656

Problem is that if the collision timings are wrong the ship might be able to collide with other ships at all for a long time. Weapons/ship pairs would probably have their timings right as the weapon lifetimes are so short.

Wanderer

2010-02-20 19:14

developer   ~0011705

resolving the issue

Issue History

Date Modified Username Field Change
2009-12-09 12:07 warfull New Issue
2010-01-05 09:40 Wanderer Status new => assigned
2010-01-05 09:40 Wanderer Assigned To => Wanderer
2010-01-05 09:43 Wanderer Note Added: 0011488
2010-01-05 21:01 chief1983 Note Added: 0011498
2010-02-12 11:29 Wanderer Note Added: 0011656
2010-02-20 19:14 Wanderer Note Added: 0011705
2010-02-20 19:14 Wanderer Status assigned => resolved
2010-02-20 19:14 Wanderer Resolution open => fixed