예제 #1
0
void clear_sim(void)
{
	invadedSites.clear();
	accessibleBonds.clear();
	growth.clear();
	removed.clear();
	r_squared_array.clear();
	counter = 0;
	chem_level_list.clear();
	burst_list.clear();
}
int plPXPhysicalControllerCore::SweepControllerPath(const hsPoint3& startPos, const hsPoint3& endPos, hsBool vsDynamics, hsBool vsStatics, 
                            uint32_t& vsSimGroups, std::multiset< plControllerSweepRecord >& WhatWasHitOut)
{
    NxCapsule tempCap;
    tempCap.p0 =plPXConvert::Point( startPos);
    tempCap.p0.z = tempCap.p0.z + fPreferedRadius;
    tempCap.radius = fPreferedRadius ;
    tempCap.p1 = tempCap.p0;
    tempCap.p1.z = tempCap.p1.z + fPreferedHeight;

    NxVec3 vec;
    vec.x = endPos.fX - startPos.fX;
    vec.y = endPos.fY - startPos.fY;
    vec.z = endPos.fZ - startPos.fZ;

    int numberofHits = 0;
    int HitsReturned = 0;
    WhatWasHitOut.clear();
    NxScene *myscene = plSimulationMgr::GetInstance()->GetScene(fWorldKey);
    NxSweepQueryHit whatdidIhit[10];
    unsigned int flags = NX_SF_ALL_HITS;
    if(vsDynamics)
        flags |= NX_SF_DYNAMICS;
    if(vsStatics)
        flags |= NX_SF_STATICS;
    numberofHits = myscene->linearCapsuleSweep(tempCap, vec, flags, nil, 10, whatdidIhit, nil, vsSimGroups);
    if(numberofHits)
    {//we hit a dynamic object lets make sure it is not animatable
        for(int i=0; i<numberofHits; i++)
        {
            plControllerSweepRecord CurrentHit;
            CurrentHit.ObjHit=(plPhysical*)whatdidIhit[i].hitShape->getActor().userData;
            CurrentHit.Norm.fX = whatdidIhit[i].normal.x;
            CurrentHit.Norm.fY = whatdidIhit[i].normal.y;
            CurrentHit.Norm.fZ = whatdidIhit[i].normal.z;
            if(CurrentHit.ObjHit != nil)
            {
                hsPoint3 where;
                where.fX = whatdidIhit[i].point.x;
                where.fY = whatdidIhit[i].point.y;
                where.fZ = whatdidIhit[i].point.z;
                CurrentHit.locHit = where;
                CurrentHit.TimeHit = whatdidIhit[i].t ;
                WhatWasHitOut.insert(CurrentHit);
                HitsReturned++;
            }
        }
    }

    return HitsReturned;
}
예제 #3
0
void record_sim(int i)
{
	std::deque<str_and_Bond>::iterator iter;
	double temp_x;
	double temp_y;
	double temp_r_sq;

	for(iter=growth.begin(); iter!=growth.end(); iter++)
	{
		temp_x = iter->second.second.first;
		temp_y = iter->second.second.second;
		temp_r_sq = temp_x*temp_x+temp_y*temp_y;
		r_squared_array.insert(temp_r_sq);
	}

	long int count = 0;

	std::multiset<long long int>::iterator iter2 = r_squared_array.begin();

	for(int j=0; j<num_r_values; j++)
	{

		while(count<growth.size() && *iter2 < r[j]*r[j])
		{
			count++;
			iter2++;
		}
		M_array[i][j] = count;
	}

	for(iter=removed.begin(); iter!=removed.end(); iter++)
	{
		temp_x = iter->second.second.first;
		temp_y = iter->second.second.second;
		temp_r_sq = temp_x*temp_x+temp_y*temp_y;
		r_squared_array.insert(temp_r_sq);
	}

	count = 0;
	iter2 = r_squared_array.begin();

	for(int j=0; j<num_r_values; j++)
	{

		while(count<growth.size() + removed.size() && *iter2 < r[j]*r[j])
		{
			count++;
			iter2++;
		}
		Both_array[i][j] = count;
	}

	r_squared_array.clear();

	for(iter=removed.begin(); iter!=removed.end(); iter++)
	{
		temp_x = iter->second.second.first;
				temp_y = iter->second.second.second;
				temp_r_sq = temp_x*temp_x+temp_y*temp_y;
				r_squared_array.insert(temp_r_sq);
	}

	count = 0;
	iter2 = r_squared_array.begin();

	for(int j=0; j<num_r_values; j++)
	{

		while(count<removed.size() && *iter2 < r[j]*r[j])
		{
			count++;
			iter2++;
		}
		Removed_array[i][j] = count;
	}

	std::map<Site, int>::iterator iter3;

	for(iter3 = chem_level_list.begin(); iter3 != chem_level_list.end(); iter3++)
	{
		if(iter3->second < chem_level_cutoff)
		{
			chem_level_array[i][iter3->second]++;
		}
	}

	std::deque<boost::tuple<int, int, long int> >::iterator burst_iter = burst_list.begin();
	std::deque<boost::tuple<int, int, long int> >::iterator burst_list_end = burst_list.end();

	int burst_x;
	int burst_y;
	long int burst_size;

	while(burst_iter != burst_list_end)
	{
		burst_x = burst_iter->get<0>();
		burst_y = burst_iter->get<1>();
		burst_size = burst_iter->get<2>();

		burst_array.push_back(boost::make_tuple(i, burst_x, burst_y, burst_size));

		burst_iter++;
	}
}