Networking Overhaul: Modern packets, buffers, handshake, dispatch & security hardening
See Readme
This commit is contained in:
@@ -44,33 +44,6 @@ void CActorInstance::INSTANCEBASE_Transform()
|
||||
UpdateAttribute();
|
||||
}
|
||||
|
||||
/*
|
||||
void CActorInstance::TEMP_Update()
|
||||
{
|
||||
//DWORD t1=ELTimer_GetMSec();
|
||||
OnUpdate();
|
||||
//DWORD t2=ELTimer_GetMSec();
|
||||
UpdateBoundingSphere();
|
||||
//DWORD t3=ELTimer_GetMSec();
|
||||
|
||||
#ifdef __PERFORMANCE_CHECKER__
|
||||
{
|
||||
static FILE* fp=fopen("perf_actor_update.txt", "w");
|
||||
|
||||
if (t3-t1>3)
|
||||
{
|
||||
fprintf(fp, "AIU.Total %d (Time %f)\n",
|
||||
t3-t1, ELTimer_GetMSec()/1000.0f);
|
||||
fprintf(fp, "AIU.UP %d\n", t2-t1);
|
||||
fprintf(fp, "AIU.UBS %d\n", t3-t2);
|
||||
fprintf(fp, "-------------------------------- \n");
|
||||
fflush(fp);
|
||||
}
|
||||
fflush(fp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
void CActorInstance::OnUpdate()
|
||||
{
|
||||
|
||||
@@ -294,36 +294,6 @@ void CActorInstance::ChangeMaterial(const char * c_szFileName)
|
||||
|
||||
SetMaterialImagePointer(c_rkSkinItem.m_ePart, c_rkSkinItem.m_stSrcFileName.c_str(), static_cast<CGraphicImage*>(pkRes));
|
||||
}
|
||||
/*
|
||||
void CActorInstance::SetPart(DWORD dwPartIndex, DWORD dwItemID)
|
||||
{
|
||||
if (dwPartIndex>=CRaceData::PART_MAX_NUM)
|
||||
return;
|
||||
|
||||
if (!m_pkCurRaceData)
|
||||
{
|
||||
assert(m_pkCurRaceData);
|
||||
return;
|
||||
}
|
||||
|
||||
CItemData * pItemData;
|
||||
if (!CItemManager::Instance().GetItemDataPointer(dwItemID, &pItemData))
|
||||
return;
|
||||
|
||||
RegisterModelThing(dwPartIndex, pItemData->GetModelThing());
|
||||
for (DWORD i = 0; i < pItemData->GetLODModelThingCount(); ++i)
|
||||
{
|
||||
CGraphicThing * pThing;
|
||||
if (!pItemData->GetLODModelThingPointer(i, &pThing))
|
||||
continue;
|
||||
|
||||
RegisterLODThing(dwPartIndex, pThing);
|
||||
}
|
||||
SetModelInstance(dwPartIndex, dwPartIndex, 0);
|
||||
|
||||
m_adwPartItemID[dwPartIndex] = dwItemID;
|
||||
}
|
||||
*/
|
||||
|
||||
DWORD CActorInstance::GetPartItemID(DWORD dwPartIndex)
|
||||
{
|
||||
|
||||
@@ -737,107 +737,6 @@ void CArea::__LoadAttribute(TObjectInstance * pObjectInstance, const char * c_sz
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void CArea::__LoadAttribute(TObjectInstance * pObjectInstance, const char * c_szAttributeFileName)
|
||||
{
|
||||
// AABB를 사용한 충돌 정보 자동 생성.
|
||||
const bool bFileExist = CResourceManager::Instance().IsFileExist(c_szAttributeFileName);
|
||||
|
||||
CAttributeData * pAttributeData = (CAttributeData *) CResourceManager::Instance().GetResourcePointer(c_szAttributeFileName);
|
||||
|
||||
CAttributeInstance * pAttrInstance = ms_AttributeInstancePool.Alloc();
|
||||
pAttrInstance->Clear();
|
||||
pAttrInstance->SetObjectPointer(pAttributeData);
|
||||
|
||||
if (false == bFileExist)
|
||||
{
|
||||
if (pAttributeData->IsEmpty())
|
||||
{
|
||||
if (NULL != pObjectInstance && NULL != pObjectInstance->pThingInstance)
|
||||
{
|
||||
CGraphicThingInstance* object = pObjectInstance->pThingInstance;
|
||||
|
||||
D3DXVECTOR3 v3Min, v3Max;
|
||||
|
||||
object->GetBoundingAABB(v3Min, v3Max);
|
||||
|
||||
CStaticCollisionData collision;
|
||||
collision.dwType = COLLISION_TYPE_AABB;
|
||||
collision.quatRotation = D3DXQUATERNION(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
strcpy(collision.szName, "DummyCollisionAABB");
|
||||
collision.v3Position = (v3Min + v3Max) * 0.5f;
|
||||
|
||||
D3DXVECTOR3 vDelta = (v3Max - v3Min);
|
||||
collision.fDimensions[0] = vDelta.x * 0.5f; // v3Min, v3Max를 구하기 위한 가로, 세로, 높이의 절반값 저장
|
||||
collision.fDimensions[1] = vDelta.y * 0.5f;
|
||||
collision.fDimensions[2] = vDelta.z * 0.5f;
|
||||
|
||||
|
||||
pAttributeData->AddCollisionData(collision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pAttributeData->IsEmpty())
|
||||
{
|
||||
pObjectInstance->pAttributeInstance = pAttrInstance;
|
||||
}
|
||||
else
|
||||
{
|
||||
pAttrInstance->Clear();
|
||||
ms_AttributeInstancePool.Free(pAttrInstance);
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
void CArea::__LoadAttribute(TObjectInstance * pObjectInstance, const char * c_szAttributeFileName)
|
||||
{
|
||||
// Sphere를 사용한 충돌 정보 자동 생성.
|
||||
const bool bFileExist = CResourceManager::Instance().IsFileExist(c_szAttributeFileName);
|
||||
|
||||
CAttributeData * pAttributeData = (CAttributeData *) CResourceManager::Instance().GetResourcePointer(c_szAttributeFileName);
|
||||
|
||||
CAttributeInstance * pAttrInstance = ms_AttributeInstancePool.Alloc();
|
||||
pAttrInstance->Clear();
|
||||
pAttrInstance->SetObjectPointer(pAttributeData);
|
||||
|
||||
if (false == bFileExist)
|
||||
{
|
||||
if (pAttributeData->IsEmpty())
|
||||
{
|
||||
if (NULL != pObjectInstance && NULL != pObjectInstance->pThingInstance)
|
||||
{
|
||||
CGraphicThingInstance* object = pObjectInstance->pThingInstance;
|
||||
|
||||
D3DXVECTOR3 v3Center;
|
||||
float fRadius = 0.0f;
|
||||
|
||||
object->GetBoundingSphere(v3Center, fRadius);
|
||||
|
||||
CStaticCollisionData collision;
|
||||
collision.dwType = COLLISION_TYPE_SPHERE;
|
||||
collision.quatRotation = D3DXQUATERNION(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
strcpy(collision.szName, "DummyCollisionSphere");
|
||||
collision.fDimensions[0] = fRadius * 0.25;
|
||||
collision.v3Position = v3Center;
|
||||
|
||||
pAttributeData->AddCollisionData(collision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pAttributeData->IsEmpty())
|
||||
{
|
||||
pObjectInstance->pAttributeInstance = pAttrInstance;
|
||||
}
|
||||
else
|
||||
{
|
||||
pAttrInstance->Clear();
|
||||
ms_AttributeInstancePool.Free(pAttrInstance);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
bool CArea::Load(const char * c_szPathName)
|
||||
{
|
||||
|
||||
@@ -47,72 +47,6 @@ bool DetectCollisionDynamicSphereVSDynamicSphere(const CDynamicSphereInstance &
|
||||
float r = c_rSphere1.fRadius+c_rSphere2.fRadius;
|
||||
float rsq = r*r;
|
||||
|
||||
/*if (D3DXVec3LengthSq(&(c_rSphere1.v3Position -c_rSphere2.v3Position ))<=rsq) return true;
|
||||
if (D3DXVec3LengthSq(&(c_rSphere1.v3Position -c_rSphere2.v3LastPosition ))<=rsq) return true;
|
||||
if (D3DXVec3LengthSq(&(c_rSphere1.v3LastPosition -c_rSphere2.v3Position ))<=rsq) return true;
|
||||
if (D3DXVec3LengthSq(&(c_rSphere1.v3LastPosition -c_rSphere2.v3LastPosition ))<=rsq) return true;*/
|
||||
|
||||
/*
|
||||
if (square_distance_between_linesegment_and_point(
|
||||
c_rSphere1.v3Position,
|
||||
c_rSphere1.v3LastPosition,
|
||||
c_rSphere2.v3Position
|
||||
)<=rsq) return true;
|
||||
if (square_distance_between_linesegment_and_point(
|
||||
c_rSphere1.v3Position,
|
||||
c_rSphere1.v3LastPosition,
|
||||
c_rSphere2.v3LastPosition
|
||||
)<=rsq) return true;
|
||||
if (square_distance_between_linesegment_and_point(
|
||||
c_rSphere2.v3Position,
|
||||
c_rSphere2.v3LastPosition,
|
||||
c_rSphere1.v3Position
|
||||
)<=rsq) return true;
|
||||
if (square_distance_between_linesegment_and_point(
|
||||
c_rSphere2.v3Position,
|
||||
c_rSphere2.v3LastPosition,
|
||||
c_rSphere1.v3LastPosition
|
||||
)<=rsq) return true;
|
||||
|
||||
D3DXVECTOR3 da=c_rSphere1.v3Position-c_rSphere1.v3LastPosition;
|
||||
D3DXVECTOR3 db=c_rSphere2.v3Position-c_rSphere2.v3LastPosition;
|
||||
D3DXVECTOR3 n;
|
||||
float la = D3DXVec3Length(&da);
|
||||
float lb = D3DXVec3Length(&db);
|
||||
if (la==0||lb==0)
|
||||
{
|
||||
D3DXVECTOR3 vA, vB;
|
||||
IntersectLineSegments(
|
||||
c_rSphere1.v3LastPosition.x,c_rSphere1.v3LastPosition.y,c_rSphere1.v3LastPosition.z,
|
||||
c_rSphere1.v3Position.x, c_rSphere1.v3Position.y, c_rSphere1.v3Position.z,
|
||||
c_rSphere2.v3LastPosition.x,c_rSphere2.v3LastPosition.y,c_rSphere2.v3LastPosition.z,
|
||||
c_rSphere2.v3Position.x, c_rSphere2.v3Position.y, c_rSphere2.v3Position.z,
|
||||
false, 1.e-5f, vA.x, vA.y, vA.z, vB.x, vB.y, vB.z);
|
||||
return (D3DXVec3LengthSq(&(vA-vB))<=r*r);
|
||||
}
|
||||
D3DXVECTOR3 p=c_rSphere2.v3Position - c_rSphere1.v3LastPosition;
|
||||
D3DXVec3Cross(&n, &da, &db);
|
||||
float from_plane = D3DXVec3Dot(&n,&p)/la/lb;
|
||||
if (from_plane>r || from_plane<-r)
|
||||
return false;
|
||||
p-=(from_plane/la/lb)*n;
|
||||
float ta = D3DXVec3Dot(&p,&da)/la/la;
|
||||
float tb = D3DXVec3Dot(&p,&db)/lb/lb;
|
||||
|
||||
// FIXME 구 체크가 아니다
|
||||
|
||||
if (ta<0)
|
||||
return false;
|
||||
if (tb<0)
|
||||
return false;
|
||||
if (ta>1)
|
||||
return false;
|
||||
if (tb>1)
|
||||
return false;
|
||||
return true;
|
||||
|
||||
*/
|
||||
//*/
|
||||
// using gpg line-collision
|
||||
|
||||
// AABB check
|
||||
@@ -133,144 +67,14 @@ bool DetectCollisionDynamicSphereVSDynamicSphere(const CDynamicSphereInstance &
|
||||
if (mi4.y<mi1.y || mi2.y<mi3.y) return false;
|
||||
if (mi4.z<mi1.z || mi2.z<mi3.z) return false;
|
||||
|
||||
D3DXVECTOR3 vA, vB;/*
|
||||
IntersectLineSegments(
|
||||
c_rSphere1.v3LastPosition.x,c_rSphere1.v3LastPosition.y,c_rSphere1.v3LastPosition.z,
|
||||
c_rSphere1.v3Position.x, c_rSphere1.v3Position.y, c_rSphere1.v3Position.z,
|
||||
c_rSphere2.v3LastPosition.x,c_rSphere2.v3LastPosition.y,c_rSphere2.v3LastPosition.z,
|
||||
c_rSphere2.v3Position.x, c_rSphere2.v3Position.y, c_rSphere2.v3Position.z,
|
||||
false, 1.e-1f, vA.x, vA.y, vA.z, vB.x, vB.y, vB.z);*/
|
||||
D3DXVECTOR3 vA, vB;
|
||||
IntersectLineSegments(c_rSphere1.v3LastPosition, c_rSphere1.v3Position,
|
||||
c_rSphere2.v3LastPosition, c_rSphere2.v3Position,
|
||||
vA, vB);
|
||||
const auto vvv = (vA - vB);
|
||||
return (D3DXVec3LengthSq(&vvv)<=rsq);
|
||||
//*/
|
||||
|
||||
/*
|
||||
// NOTE : AABB 체크 할 것
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
D3DXVECTOR3 v3Distance = c_rSphere1.v3Position - c_rSphere2.v3Position;
|
||||
float fDistance = D3DXVec3Length(&v3Distance);
|
||||
float fRadiusSummary = c_rSphere1.fRadius + c_rSphere2.fRadius;
|
||||
|
||||
if (fDistance < fRadiusSummary)
|
||||
return true;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
D3DXVECTOR3 v3LastDistance = c_rSphere1.v3LastPosition - c_rSphere2.v3LastPosition; // A
|
||||
D3DXVECTOR3 v3Advance = c_rSphere1.v3Advance - c_rSphere2.v3Advance; // B
|
||||
|
||||
float fdotAdvanceAdvance = D3DXVec3Dot(&v3Advance, &v3Advance);
|
||||
if (0.0f == fdotAdvanceAdvance)
|
||||
return false;
|
||||
|
||||
float fdotDistanceAdvance = D3DXVec3Dot(&v3LastDistance, &v3Advance);
|
||||
float fdotDistanceDistance = D3DXVec3Dot(&v3LastDistance, &v3LastDistance);
|
||||
float Value1 = fdotDistanceAdvance - fdotAdvanceAdvance * (fdotDistanceDistance - (fRadiusSummary * fRadiusSummary));
|
||||
if (Value1 < 0.0f)
|
||||
return false;
|
||||
|
||||
float Value2 = (-fdotDistanceAdvance - sqrtf(Value1)) / fdotAdvanceAdvance;
|
||||
if (Value2 < 0.0f)
|
||||
return false;
|
||||
if (Value2 >= 1.0f)
|
||||
return false;
|
||||
|
||||
return true;*/
|
||||
}
|
||||
|
||||
/*
|
||||
// Dynamic VS Static
|
||||
bool DetectCollisionDynamicSphereVSStaticPlane(const CDynamicSphereInstance & c_rSphere, const TPlaneData & c_rPlane)
|
||||
{
|
||||
D3DXVECTOR3 v3SpherePosition = c_rSphere.v3Position - c_rPlane.v3Position;
|
||||
D3DXVECTOR3 v3SphereLastPosition = c_rSphere.v3LastPosition - c_rPlane.v3Position;
|
||||
|
||||
float fPosition1 = D3DXVec3Dot(&c_rPlane.v3Normal, &v3SpherePosition);
|
||||
float fPosition2 = D3DXVec3Dot(&c_rPlane.v3Normal, &v3SphereLastPosition);
|
||||
|
||||
if (fPosition1 >0.0f && fPosition2 < 0.0f || fPosition1 <0.0f && fPosition2 >0.0f || (fPosition1) <= c_rSphere.fRadius && fPosition1 >= -c_rSphere.fRadius)
|
||||
{
|
||||
D3DXVECTOR3 v3QuadPosition1 = c_rSphere.v3Position - c_rPlane.v3QuadPosition[0];
|
||||
D3DXVECTOR3 v3QuadPosition2 = c_rSphere.v3Position - c_rPlane.v3QuadPosition[3];
|
||||
if (D3DXVec3Dot(&v3QuadPosition1, &c_rPlane.v3InsideVector[0]) < c_rSphere.fRadius)
|
||||
if (D3DXVec3Dot(&v3QuadPosition1, &c_rPlane.v3InsideVector[1]) < c_rSphere.fRadius)
|
||||
if (D3DXVec3Dot(&v3QuadPosition2, &c_rPlane.v3InsideVector[2]) < c_rSphere.fRadius)
|
||||
if (D3DXVec3Dot(&v3QuadPosition2, &c_rPlane.v3InsideVector[3]) < c_rSphere.fRadius)
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DetectCollisionDynamicSphereVSStaticSphere(const CDynamicSphereInstance & c_rSphere, const TSphereData & c_rSphereData)
|
||||
{
|
||||
D3DXVECTOR3 v3Distance = c_rSphere.v3Position - c_rSphereData.v3Position;
|
||||
float fDistanceSq = D3DXVec3LengthSq(&v3Distance);
|
||||
float fRadiusSummary = c_rSphere.fRadius + c_rSphereData.fRadius;
|
||||
if (fDistanceSq < fRadiusSummary*fRadiusSummary)
|
||||
return true;
|
||||
|
||||
//D3DXVECTOR3 v3LastDistance = c_rSphere.v3LastPosition - c_rSphereData.v3Position;
|
||||
//if (D3DXVec3Dot(&v3LastDistance, &v3Distance) < 0.0f)
|
||||
// return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DetectCollisionDynamicSphereVSStaticCylinder(const CDynamicSphereInstance & c_rSphere, const TCylinderData & c_rCylinderData)
|
||||
{
|
||||
if (c_rSphere.v3Position.z + c_rSphere.fRadius < c_rCylinderData.v3Position.z)
|
||||
return false;
|
||||
|
||||
if (c_rSphere.v3Position.z - c_rSphere.fRadius > c_rCylinderData.v3Position.z + c_rCylinderData.fHeight)
|
||||
return false;
|
||||
|
||||
D3DXVECTOR3 v3curDistance = c_rSphere.v3Position - c_rCylinderData.v3Position;
|
||||
float fDistance = D3DXVec3Length(&v3curDistance);
|
||||
|
||||
if (fDistance <= c_rSphere.fRadius + c_rCylinderData.fRadius)
|
||||
return true;
|
||||
|
||||
//D3DXVECTOR3 v3lastDistance = c_rSphere.v3LastPosition - c_rCylinderData.v3Position;
|
||||
|
||||
//if (D3DXVec3Dot(&v3curDistance, &v3lastDistance) < 0.0f)
|
||||
// return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
bool DetectCollisionDynamicSphereVSStaticBox(const TSphereInstance & c_rSphere, const TBoxData & c_rBoxData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
// Static VS Static
|
||||
/*
|
||||
bool DetectCollisionStaticSphereVSStaticSphere(const TSphereData & c_rSphere1, const TSphereData & c_rSphere2)
|
||||
{
|
||||
D3DXVECTOR3 v3Distance = c_rSphere1.v3Position - c_rSphere2.v3Position;
|
||||
float fDistance = D3DXVec3Length(&v3Distance);
|
||||
|
||||
if (fDistance < c_rSphere1.fRadius + c_rSphere2.fRadius)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DetectCollisionStaticSphereVSStaticCylinder(const TSphereData & c_rSphere, const TCylinderData & c_rCylinder)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
/*bool DetectCollisionStaticSphereVSStaticBox(const TSphereData & c_rSphere, const TBoxData & c_rBox)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool IsCWAcuteAngle(float begin, float end)
|
||||
@@ -402,33 +206,3 @@ float CharacterRotationToCameraRotation(float fCharacterRotation)
|
||||
return fmod((540.0f - fCharacterRotation), 360.0f);
|
||||
}
|
||||
|
||||
/*
|
||||
bool DetectCollisionDynamicSphereVSStaticPlane(const TSphereInstance & c_rSphere, const TPlaneData & c_rPlane)
|
||||
{
|
||||
D3DXVECTOR3 v3SpherePosition = c_rSphere.v3Position - c_rPlane.v3Position;
|
||||
D3DXVECTOR3 v3SphereLastPosition = c_rSphere.v3LastPosition - c_rPlane.v3Position;
|
||||
|
||||
float fPosition1 = D3DXVec3Dot(&c_rPlane.v3Normal, &v3SpherePosition);
|
||||
float fPosition2 = D3DXVec3Dot(&c_rPlane.v3Normal, &v3SphereLastPosition);
|
||||
|
||||
if (fPosition1 * fPosition2 < 0.0f || fabs(fPosition1) <= c_rSphere.fRadius)
|
||||
{
|
||||
float fT = -fPosition1 / D3DXVec3Dot(&c_rPlane.v3Normal, &c_rSphere.v3Advance);
|
||||
D3DXVECTOR3 v3CollisionPosition = c_rSphere.v3LastPosition + c_rSphere.v3Advance * fT;
|
||||
D3DXVECTOR3 v3QuadPosition1 = v3CollisionPosition - c_rPlane.v3BeginPosition;
|
||||
D3DXVECTOR3 v3QuadPosition2 = v3CollisionPosition - c_rPlane.v3EndPosition;
|
||||
D3DXVec3Normalize(&v3QuadPosition1, &v3QuadPosition1);
|
||||
D3DXVec3Normalize(&v3QuadPosition2, &v3QuadPosition2);
|
||||
|
||||
if (D3DXVec3Dot(&v3QuadPosition1, &c_rPlane.v3InsideVector[0]) < 0.0f)
|
||||
if (D3DXVec3Dot(&v3QuadPosition1, &c_rPlane.v3InsideVector[1]) < 0.0f)
|
||||
if (D3DXVec3Dot(&v3QuadPosition2, &c_rPlane.v3InsideVector[2]) < 0.0f)
|
||||
if (D3DXVec3Dot(&v3QuadPosition2, &c_rPlane.v3InsideVector[3]) < 0.0f)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -565,61 +565,6 @@ bool CMapOutdoor::GetPickingPointWithRayOnlyTerrain(const CRay & rRay, D3DXVECTO
|
||||
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
{
|
||||
bool bTerrainPick = false;
|
||||
D3DXVECTOR3 v3TerrainPick;
|
||||
|
||||
CTerrain * pTerrain;
|
||||
|
||||
D3DXVECTOR3 v3Start, v3End, v3Dir, v3CurPos;
|
||||
float fRayRange;
|
||||
rRay.GetStartPoint(&v3Start);
|
||||
rRay.GetDirection(&v3Dir, &fRayRange);
|
||||
rRay.GetEndPoint(&v3End);
|
||||
|
||||
Vector3d v3dStart, v3dEnd;
|
||||
v3dStart.Set(v3Start.x, v3Start.y, v3Start.z);
|
||||
v3dEnd.Set(v3End.x - v3Start.x, v3End.y - v3Start.y, v3End.z - v3Start.z);
|
||||
|
||||
float fAdd = 1.0f / fRayRange;
|
||||
|
||||
float ft = 0.0f;
|
||||
while (ft < 1.0f)
|
||||
{
|
||||
D3DXVec3Lerp(&v3CurPos, &v3Start, &v3End, ft);
|
||||
BYTE byTerrainNum;
|
||||
float fMultiplier = 1.0f;
|
||||
if (GetTerrainNum(v3CurPos.x, v3CurPos.y, &byTerrainNum))
|
||||
{
|
||||
if (GetTerrainPointer(byTerrainNum, &pTerrain))
|
||||
{
|
||||
int ix, iy;
|
||||
PR_FLOAT_TO_INT(v3CurPos.x, ix);
|
||||
PR_FLOAT_TO_INT(fabs(v3CurPos.y), iy);
|
||||
float fMapHeight = pTerrain->GetHeight(ix, iy);
|
||||
if ( fMapHeight >= v3CurPos.z)
|
||||
{
|
||||
bTerrainPick = true;
|
||||
v3TerrainPick = v3CurPos;
|
||||
break;
|
||||
}
|
||||
else
|
||||
fMultiplier = fMAX(1.0f, 0.01f * ( v3CurPos.z - fMapHeight ) );
|
||||
}
|
||||
}
|
||||
ft += fAdd * fMultiplier;
|
||||
}
|
||||
|
||||
if (bTerrainPick)
|
||||
{
|
||||
*v3IntersectPt = v3TerrainPick;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
void CMapOutdoor::GetHeightMap(const BYTE & c_rucTerrainNum, WORD ** pwHeightMap)
|
||||
{
|
||||
|
||||
@@ -47,27 +47,6 @@ CTerrainQuadtreeNode * CMapOutdoor::AllocQuadTreeNode(long x0, long y0, long x1,
|
||||
|
||||
Node->PatchNum = y0 * m_wPatchCount + x0;
|
||||
|
||||
/*
|
||||
const float fTerrainMin = -(float) (m_lViewRadius * m_lCellScale);
|
||||
|
||||
minx = fTerrainMin + x0 * c_byPatchSize * m_lCellScale;
|
||||
maxx = fTerrainMin + (x1 + 1) * c_byPatchSize * m_lCellScale;
|
||||
miny = fTerrainMin + y0 * c_byPatchSize * m_lCellScale;
|
||||
maxy = fTerrainMin + (y1 + 1) * c_byPatchSize * m_lCellScale;
|
||||
minz = 0.0f;
|
||||
maxz = 0.0f;
|
||||
|
||||
/ * Set up 8 vertices that belong to the bounding box * /
|
||||
Node->center.x = minx + (maxx - minx) * 0.5f;
|
||||
Node->center.y = miny + (maxy - miny) * 0.5f;
|
||||
Node->center.z = minz + (maxz - minz) * 0.5f;
|
||||
|
||||
Node->radius = sqrtf(
|
||||
(maxx-minx)*(maxx-minx)+
|
||||
(maxy-miny)*(maxy-miny)+
|
||||
(maxz-minz)*(maxz-minz)
|
||||
)/2.0f;
|
||||
*/
|
||||
|
||||
Node->center.x = 0.0f;
|
||||
Node->center.y = 0.0f;
|
||||
@@ -105,36 +84,6 @@ void CMapOutdoor::SubDivideNode(CTerrainQuadtreeNode * Node)
|
||||
SubDivideNode (tempnode);
|
||||
}
|
||||
|
||||
/*
|
||||
void CMapOutdoor::RecurseDeleteQuadTree(CTerrainQuadtreeNode *Node)
|
||||
{
|
||||
if (Node == NULL)
|
||||
return;
|
||||
|
||||
if (Node->NW_Node != NULL)
|
||||
{
|
||||
RecurseDeleteQuadTree(Node->NW_Node);
|
||||
Node->NW_Node = NULL;
|
||||
}
|
||||
if (Node->NE_Node != NULL)
|
||||
{
|
||||
RecurseDeleteQuadTree(Node->NE_Node);
|
||||
Node->NE_Node = NULL;
|
||||
}
|
||||
if (Node->SW_Node != NULL)
|
||||
{
|
||||
RecurseDeleteQuadTree(Node->SW_Node);
|
||||
Node->SW_Node = NULL;
|
||||
}
|
||||
if (Node->SE_Node != NULL)
|
||||
{
|
||||
RecurseDeleteQuadTree(Node->SE_Node);
|
||||
Node->SE_Node = NULL;
|
||||
}
|
||||
|
||||
free(Node);
|
||||
}
|
||||
*/
|
||||
|
||||
void CMapOutdoor::FreeQuadTree()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user