| 2519 | } |
| 2520 | |
| 2521 | int CScriptObjectSystem::RayWorldIntersection(IFunctionHandler *pH) |
| 2522 | { |
| 2523 | assert(pH->GetParamCount()>=3 && pH->GetParamCount()<=6); |
| 2524 | |
| 2525 | CScriptObjectVector vPos(m_pScriptSystem, true); |
| 2526 | CScriptObjectVector vDir(m_pScriptSystem, true); |
| 2527 | |
| 2528 | int nMaxHits,iEntTypes=ent_all; |
| 2529 | |
| 2530 | pH->GetParam(1, *vPos); |
| 2531 | pH->GetParam(2, *vDir); |
| 2532 | pH->GetParam(3, nMaxHits); |
| 2533 | pH->GetParam(4, iEntTypes); |
| 2534 | |
| 2535 | if (nMaxHits>10) |
| 2536 | nMaxHits=10; |
| 2537 | |
| 2538 | ray_hit RayHit[10]; |
| 2539 | |
| 2540 | //filippo: added support for skip certain entities. |
| 2541 | int skipId1 = -1; |
| 2542 | int skipId2 = -1; |
| 2543 | |
| 2544 | IPhysicalEntity *skipPhys1 = NULL; |
| 2545 | IPhysicalEntity *skipPhys2 = NULL; |
| 2546 | |
| 2547 | pH->GetParam(5, skipId1); |
| 2548 | pH->GetParam(6, skipId2); |
| 2549 | |
| 2550 | if (skipId1!=-1) |
| 2551 | { |
| 2552 | IEntity *skipEnt1 = m_pEntitySystem->GetEntity(skipId1); |
| 2553 | if (skipEnt1) |
| 2554 | skipPhys1 = skipEnt1->GetPhysics(); |
| 2555 | } |
| 2556 | |
| 2557 | if (skipId2!=-1) |
| 2558 | { |
| 2559 | IEntity *skipEnt2 = m_pEntitySystem->GetEntity(skipId2); |
| 2560 | if (skipEnt2) |
| 2561 | skipPhys2 = skipEnt2->GetPhysics(); |
| 2562 | } |
| 2563 | |
| 2564 | Vec3 src = vPos.Get(); |
| 2565 | Vec3 dst = vDir.Get()-src; |
| 2566 | |
| 2567 | int nHits=m_pPhysicalWorld->RayWorldIntersection(src, dst, iEntTypes, |
| 2568 | geom_colltype0<<rwi_colltype_bit | rwi_stop_at_pierceable, RayHit, nMaxHits,skipPhys1,skipPhys2); |
| 2569 | |
| 2570 | _SmartScriptObject pObj(m_pScriptSystem); |
| 2571 | |
| 2572 | for (int i=0;i<nHits;i++) |
| 2573 | { |
| 2574 | _SmartScriptObject pHitObj(m_pScriptSystem); |
| 2575 | CScriptObjectVector vOutPos(m_pScriptSystem); |
| 2576 | CScriptObjectVector vOutNormal(m_pScriptSystem); |
| 2577 | ray_hit &Hit=RayHit[i]; |
| 2578 | vOutPos.Set(Hit.pt); |
no test coverage detected