diff --git a/Sources/Engine/Base/Base.h b/Sources/Engine/Base/Base.h old mode 100644 new mode 100755 index 12151f1..5ecf0dc --- a/Sources/Engine/Base/Base.h +++ b/Sources/Engine/Base/Base.h @@ -77,4 +77,14 @@ with this program; if not, write to the Free Software Foundation, Inc., #define ENGINE_API #endif +#ifdef PLATFORM_PANDORA +# define INDEX_T unsigned short +# define INDEX_GL GL_UNSIGNED_SHORT +# define FASTMATH __attribute__((pcs("aapcs-vfp"))) +#else +# define INDEX_T INDEX +# define INDEX_GL GL_UNSIGNED_INT +# define FASTMATH +#endif + #endif diff --git a/Sources/Engine/Base/Profiling.h b/Sources/Engine/Base/Profiling.h old mode 100644 new mode 100755 index 4bd9154..ad59143 --- a/Sources/Engine/Base/Profiling.h +++ b/Sources/Engine/Base/Profiling.h @@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #endif -#if ENGINE_INTERNAL +#if ENGINE_INTERNAL && !defined(PANDORA) #include #include @@ -68,7 +68,7 @@ private: class CProfileForm { public: -#if ENGINE_INTERNAL +#if ENGINE_INTERNAL && !defined(PANDORA) // implementation: CTString pf_strTitle; // main title of the profiling form CTString pf_strAveragingUnits; // name for averaging units diff --git a/Sources/Engine/Base/Statistics.cpp b/Sources/Engine/Base/Statistics.cpp index ffb84a1..67ceac5 100644 --- a/Sources/Engine/Base/Statistics.cpp +++ b/Sources/Engine/Base/Statistics.cpp @@ -195,3 +195,8 @@ void STAT_Report(CTString &strReport) { _sfStats.Report(strReport); } + +void STAT_Enable(BOOL enable) +{ + _sfStats.sf_enabled = enable; +} diff --git a/Sources/Engine/Base/Statistics.h b/Sources/Engine/Base/Statistics.h index 121b77d..b351780 100644 --- a/Sources/Engine/Base/Statistics.h +++ b/Sources/Engine/Base/Statistics.h @@ -24,6 +24,7 @@ ENGINE_API void STAT_Reset(void); // make a new report ENGINE_API void STAT_Report(CTString &strReport); +ENGINE_API void STAT_Enable(BOOL enable); #endif /* include-once check. */ diff --git a/Sources/Engine/Base/Statistics_Internal.h b/Sources/Engine/Base/Statistics_Internal.h index 3ba689f..de18cdb 100644 --- a/Sources/Engine/Base/Statistics_Internal.h +++ b/Sources/Engine/Base/Statistics_Internal.h @@ -77,6 +77,7 @@ public: CStaticArray sf_ascCounters; // profiling counters CStaticArray sf_astTimers; // profiling timers CStaticArray sf_aslLabels; // profiling labels + BOOL sf_enabled; // interface: enum StatLabelIndex @@ -157,13 +158,15 @@ public: inline void StartTimer(INDEX iTimer) { CStatTimer &st = sf_astTimers[iTimer]; ASSERT( sf_astTimers[iTimer].st_tvStarted.tv_llValue == -1); - st.st_tvStarted = _pTimer->GetHighPrecisionTimer(); + if (sf_enabled) + st.st_tvStarted = _pTimer->GetHighPrecisionTimer(); }; /* Stop a timer. */ inline void StopTimer(INDEX iTimer) { CStatTimer &st = sf_astTimers[iTimer]; ASSERT( sf_astTimers[iTimer].st_tvStarted.tv_llValue != -1); - st.st_tvElapsed += _pTimer->GetHighPrecisionTimer()-st.st_tvStarted; + if (sf_enabled) + st.st_tvElapsed += _pTimer->GetHighPrecisionTimer()-st.st_tvStarted; st.st_tvStarted.tv_llValue = -1; }; diff --git a/Sources/Engine/Base/Timer.cpp b/Sources/Engine/Base/Timer.cpp index b82043b..4902937 100755 --- a/Sources/Engine/Base/Timer.cpp +++ b/Sources/Engine/Base/Timer.cpp @@ -180,6 +180,8 @@ void CTimer_TimerFunc_internal(void) _pTimer->tm_tvLastTimeOnTime = tvTimeNow; _pTimer->tm_tmLastTickOnTime = tmTickNow; + _pTimer->tm_tvLowPrecisionTimer = tvTimeNow; + // } CTSTREAM_END; } diff --git a/Sources/Engine/Base/Timer.h b/Sources/Engine/Base/Timer.h index f0660e1..04a9347 100755 --- a/Sources/Engine/Base/Timer.h +++ b/Sources/Engine/Base/Timer.h @@ -78,6 +78,8 @@ public: CTimerValue tm_tvLastTimeOnTime; // last time when timer was on time TIME tm_tmLastTickOnTime; // last tick when timer was on time + CTimerValue tm_tvLowPrecisionTimer; + TIME tm_RealTimeTimer; // this really ticks at 1/TickQuantum frequency FLOAT tm_fLerpFactor; // factor used for lerping between frames FLOAT tm_fLerpFactor2; // secondary lerp-factor used for unpredicted movement @@ -137,6 +139,8 @@ public: /* Get current timer value of high precision timer. */ CTimerValue GetHighPrecisionTimer(void); + inline CTimerValue GetLowPrecisionTimer(void) const { return tm_tvLowPrecisionTimer; }; + /* * rcg10072001 * put current process to sleep for at least (milliseconds) milliseconds. diff --git a/Sources/Engine/Brushes/Brush.h b/Sources/Engine/Brushes/Brush.h index 7458953..3bc91de 100644 --- a/Sources/Engine/Brushes/Brush.h +++ b/Sources/Engine/Brushes/Brush.h @@ -407,6 +407,8 @@ public: /* Create a BSP polygon from this polygon. */ void CreateBSPPolygon(BSPPolygon &bspo); void CreateBSPPolygonNonPrecise(BSPPolygon &bspo); + void CreateBSPPolygon(BSPPolygon &bspo); + void CreateBSPPolygonNonPrecise(BSPPolygon &bspo); /* Create shadow map for the polygon. */ void MakeShadowMap(CWorld *pwoWorld, BOOL bDoDirectionalLights); /* Initialize shadow map for the polygon. */ @@ -422,20 +424,21 @@ public: void Triangulate(void); public: // interface: + FLOATaabbox3D bpo_boxBoundingBox; // bounding box + ULONG bpo_ulFlags; // flags + CBrushPlane *bpo_pbplPlane; // plane of this polygon CStaticArray bpo_abpePolygonEdges; // edges in this polygon CStaticArray bpo_apbvxTriangleVertices; // triangle vertices CStaticArray bpo_aiTriangleElements; // element indices inside vertex arrays CBrushPolygonTexture bpo_abptTextures[3]; // texture on this polygon COLOR bpo_colColor; // color of this polygon - ULONG bpo_ulFlags; // flags COLOR bpo_colShadow; // color of shadow on this polygon CBrushShadowMap bpo_smShadowMap; // shadow map of this polygon CMappingDefinition bpo_mdShadow; // mapping of shadow on polygon CBrushPolygonProperties bpo_bppProperties; // additional properties class CScreenPolygon *bpo_pspoScreenPolygon; // used in rendering - FLOATaabbox3D bpo_boxBoundingBox; // bounding box CBrushSector *bpo_pbscSector; // sector of this polygon CRelationSrc bpo_rsOtherSideSectors; // relation to sectors on other side of portal @@ -479,7 +482,7 @@ public: // get amount of memory used by this object SLONG GetUsedMemory(void); -}; +} __attribute__((aligned(64))); // get pointer to embedding brush polygon inline CBrushPolygon *CBrushShadowMap::GetBrushPolygon(void) { @@ -562,7 +565,7 @@ public: FLOATaabbox3D bsc_boxBoundingBox; // bounding box in absolute space FLOATaabbox3D bsc_boxRelative; // bounding box in relative space CListNode bsc_lnInActiveSectors; // node in sectors active in some operation (e.g. rendering) - DOUBLEbsptree3D &bsc_bspBSPTree; // the local bsp tree of the sector + FLOATbsptree3D &bsc_bspBSPTree; // the local bsp tree of the sector CRelationDst bsc_rdOtherSidePortals; // relation to portals pointing to this sector CRelationSrc bsc_rsEntities; // relation to all entities in this sector CTString bsc_strName; // sector name diff --git a/Sources/Engine/Brushes/BrushArchive.cpp b/Sources/Engine/Brushes/BrushArchive.cpp index f7b5e0a..2478446 100644 --- a/Sources/Engine/Brushes/BrushArchive.cpp +++ b/Sources/Engine/Brushes/BrushArchive.cpp @@ -150,10 +150,10 @@ void CBrushArchive::LinkPortalsAndSectors(void) } // create a BSP polygon from the brush polygon CBrushPolygon &brpo2 = *itbpo2; - BSPPolygon bspo2; + BSPPolygon bspo2; brpo2.CreateBSPPolygonNonPrecise(bspo2); // split the polygon with the BSP of the sector - DOUBLEbspcutter3D bcCutter(bspo2, *itbsc1->bsc_bspBSPTree.bt_pbnRoot); + FLOATbspcutter3D bcCutter(bspo2, *itbsc1->bsc_bspBSPTree.bt_pbnRoot); // if anything remains on the border looking outside if (bcCutter.bc_abedInside.Count()>0 ||bcCutter.bc_abedBorderInside.Count()>0 diff --git a/Sources/Engine/Brushes/BrushPolygon.cpp b/Sources/Engine/Brushes/BrushPolygon.cpp index e5b971b..c8c60a1 100644 --- a/Sources/Engine/Brushes/BrushPolygon.cpp +++ b/Sources/Engine/Brushes/BrushPolygon.cpp @@ -100,6 +100,34 @@ void CBrushPolygon::CreateBSPPolygon(BSPPolygon &bspo) }} bspo.bpo_abedPolygonEdges.Unlock(); } + +void CBrushPolygon::CreateBSPPolygon(BSPPolygon &bspo) +{ + ASSERT(GetFPUPrecision()==FPT_53BIT); + CBrushPolygon &brpo = *this; + + // set the plane of the bsp polygon + ((FLOATplane3D &)bspo) = DOUBLEtoFLOAT(*brpo.bpo_pbplPlane->bpl_ppldPreciseAbsolute); + bspo.bpo_ulPlaneTag = (size_t)brpo.bpo_pbscSector->bsc_abplPlanes.Index(brpo.bpo_pbplPlane); + + // create the array of edges in the bsp polygon + INDEX ctEdges = brpo.bpo_abpePolygonEdges.Count(); + bspo.bpo_abedPolygonEdges.New(ctEdges); + + // for all edges in the polygon + bspo.bpo_abedPolygonEdges.Lock(); + {for(INDEX iEdge=0; iEdge &bed = bspo.bpo_abedPolygonEdges[iEdge]; + // create the bsp edge in the bsp polygon + Vector v0, v1; + brped.GetVertexCoordinatesPreciseAbsolute(v0, v1); + bed.bed_vVertex0 = DOUBLEtoFLOAT(v0); + bed.bed_vVertex1 = DOUBLEtoFLOAT(v1); + }} + bspo.bpo_abedPolygonEdges.Unlock(); +} + void CBrushPolygon::CreateBSPPolygonNonPrecise(BSPPolygon &bspo) { CBrushPolygon &brpo = *this; @@ -133,6 +161,39 @@ void CBrushPolygon::CreateBSPPolygonNonPrecise(BSPPolygon &bspo) bspo.bpo_abedPolygonEdges.Unlock(); } +void CBrushPolygon::CreateBSPPolygonNonPrecise(BSPPolygon &bspo) +{ + CBrushPolygon &brpo = *this; + + // offset for epsilon testing + const FLOAT fOffset = -0.01f; + + // set the plane of the bsp polygon + ((FLOATplane3D &)bspo) = brpo.bpo_pbplPlane->bpl_plAbsolute; + bspo.bpo_ulPlaneTag = (size_t)brpo.bpo_pbscSector->bsc_abplPlanes.Index(brpo.bpo_pbplPlane); + // calculate offset for points + FLOAT3D vOffset = ((FLOAT3D&)brpo.bpo_pbplPlane->bpl_plAbsolute)*-fOffset; + // offset the plane + bspo.Offset(fOffset); + + // create the array of edges in the bsp polygon + INDEX ctEdges = brpo.bpo_abpePolygonEdges.Count(); + bspo.bpo_abedPolygonEdges.New(ctEdges); + + // for all edges in the polygon + bspo.bpo_abedPolygonEdges.Lock(); + {for(INDEX iEdge=0; iEdge &bed = bspo.bpo_abedPolygonEdges[iEdge]; + // create the offseted bsp edge in the bsp polygon + FLOAT3D v0, v1; + brped.GetVertexCoordinatesAbsolute(v0, v1); + bed.bed_vVertex0 = v0+vOffset; + bed.bed_vVertex1 = v1+vOffset; + }} + bspo.bpo_abedPolygonEdges.Unlock(); +} + /* * Select adjacent polygons with same color as this one. */ diff --git a/Sources/Engine/Brushes/BrushSector.cpp b/Sources/Engine/Brushes/BrushSector.cpp old mode 100644 new mode 100755 index 09d9f90..e8ddae8 --- a/Sources/Engine/Brushes/BrushSector.cpp +++ b/Sources/Engine/Brushes/BrushSector.cpp @@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc., //template CDynamicArray; CBrushSector::CBrushSector(const CBrushSector &c) -: bsc_bspBSPTree(*new DOUBLEbsptree3D) +: bsc_bspBSPTree(*new FLOATbsptree3D) { ASSERT(FALSE); }; @@ -53,8 +53,8 @@ CBrushSector::CBrushSector(void) , bsc_ulFlags2(0) , bsc_ulTempFlags(0) , bsc_ulVisFlags(0) -, bsc_bspBSPTree(*new DOUBLEbsptree3D) , bsc_strName("") +, bsc_bspBSPTree(*new FLOATbsptree3D) { }; @@ -140,7 +140,7 @@ void CBrushSector::CalculateBoundingBoxes(CSimpleProjection3D_DOUBLE &prRelative ((pen->en_ulFlags&ENF_ZONING) || pen->en_RenderType==CEntity::RT_FIELDBRUSH) ) { // create an array of bsp polygons for sector polygons INDEX ctPolygons = bsc_abpoPolygons.Count(); - CDynamicArray< BSPPolygon > arbpoPolygons; + CDynamicArray< BSPPolygon > arbpoPolygons; arbpoPolygons.New(ctPolygons); // for all polygons in this sector @@ -148,7 +148,7 @@ void CBrushSector::CalculateBoundingBoxes(CSimpleProjection3D_DOUBLE &prRelative {for(INDEX iPolygon=0; iPolygon &bspo = arbpoPolygons[iPolygon]; + BSPPolygon &bspo = arbpoPolygons[iPolygon]; brpo.CreateBSPPolygon(bspo); }} arbpoPolygons.Unlock(); @@ -234,14 +234,14 @@ void CBrushSector::FindEntitiesInSector(void) // if the sphere is inside the sector if (bsc_bspBSPTree.TestSphere( - FLOATtoDOUBLE(vSphereCenter), FLOATtoDOUBLE(fSphereRadius))>=0) { + vSphereCenter, fSphereRadius)>=0) { // make oriented bounding box of the entity FLOATobbox3D boxEntity(iten->en_boxSpatialClassification, iten->en_plPlacement.pl_PositionVector, iten->en_mRotation); // if the box is inside the sector if (boxSector.HasContactWith(boxEntity) && - bsc_bspBSPTree.TestBox(FLOATtoDOUBLE(boxEntity))>=0) { + bsc_bspBSPTree.TestBox(boxEntity)>=0) { // relate the entity to the sector if (iten->en_RenderType==CEntity::RT_BRUSH ||iten->en_RenderType==CEntity::RT_FIELDBRUSH diff --git a/Sources/Engine/Classes/MovableEntity.es b/Sources/Engine/Classes/MovableEntity.es index 7bc441e..518787d 100644 --- a/Sources/Engine/Classes/MovableEntity.es +++ b/Sources/Engine/Classes/MovableEntity.es @@ -899,8 +899,8 @@ functions: } // get min/max parameters of entity inside sector - double dMin, dMax; - bsc.bsc_bspBSPTree.FindLineMinMax(FLOATtoDOUBLE(vMin), FLOATtoDOUBLE(vMax), dMin, dMax); + float dMin, dMax; + bsc.bsc_bspBSPTree.FindLineMinMax(vMin, vMax, dMin, dMax); // if sector content is not default INDEX iContent = bsc.GetContentType(); diff --git a/Sources/Engine/Entities/Entity.cpp b/Sources/Engine/Entities/Entity.cpp old mode 100644 new mode 100755 index 9117b76..9061cfc --- a/Sources/Engine/Entities/Entity.cpp +++ b/Sources/Engine/Entities/Entity.cpp @@ -1826,7 +1826,6 @@ void CEntity::FindSectorsAroundEntity(void) // make oriented bounding box of the entity FLOATobbox3D boxEntity = FLOATobbox3D(en_boxSpatialClassification, en_plPlacement.pl_PositionVector, en_mRotation); - DOUBLEobbox3D boxdEntity = FLOATtoDOUBLE(boxEntity); // unset spatial clasification en_rdSectors.Clear(); @@ -1850,10 +1849,10 @@ void CEntity::FindSectorsAroundEntity(void) // if the sphere is inside the sector if (itbsc->bsc_bspBSPTree.TestSphere( - FLOATtoDOUBLE(vSphereCenter), FLOATtoDOUBLE(fSphereRadius))>=0) { + vSphereCenter, fSphereRadius)>=0) { // if the box is inside the sector - if (itbsc->bsc_bspBSPTree.TestBox(boxdEntity)>=0) { + if (itbsc->bsc_bspBSPTree.TestBox(boxEntity)>=0) { // relate the entity to the sector if (en_RenderType==RT_BRUSH ||en_RenderType==RT_FIELDBRUSH @@ -1890,7 +1889,6 @@ void CEntity::FindSectorsAroundEntityNear(void) // make oriented bounding box of the entity FLOATobbox3D oboxEntity = FLOATobbox3D(en_boxSpatialClassification, en_plPlacement.pl_PositionVector, en_mRotation); - DOUBLEobbox3D oboxdEntity = FLOATtoDOUBLE(oboxEntity); CListHead lhActive; // for each sector around this entity @@ -1921,13 +1919,13 @@ void CEntity::FindSectorsAroundEntityNear(void) (pbsc->bsc_boxBoundingBox.HasContactWith(boxEntity))&& // the sphere is inside the sector (pbsc->bsc_bspBSPTree.TestSphere( - FLOATtoDOUBLE(vSphereCenter), FLOATtoDOUBLE(fSphereRadius))>=0)&& + vSphereCenter, fSphereRadius)>=0)&& // (use more detailed testing for moving brushes) (en_RenderType!=RT_BRUSH|| // oriented box touches box of sector ((oboxEntity.HasContactWith(FLOATobbox3D(pbsc->bsc_boxBoundingBox)))&& // oriented box is in bsp - (pbsc->bsc_bspBSPTree.TestBox(oboxdEntity)>=0))); + (pbsc->bsc_bspBSPTree.TestBox(oboxEntity)>=0))); // if it is not if (!bIn) { // if it has link @@ -2866,7 +2864,7 @@ CBrushSector *CEntity::GetSectorFromPoint(const FLOAT3D &vPointAbs) // for each sector around entity {FOREACHSRCOFDST(en_rdSectors, CBrushSector, bsc_rsEntities, pbsc) // if point is in this sector - if( pbsc->bsc_bspBSPTree.TestSphere(FLOATtoDOUBLE(vPointAbs), 0.01)>=0) { + if( pbsc->bsc_bspBSPTree.TestSphere(vPointAbs, 0.01)>=0) { // return that return pbsc; } diff --git a/Sources/Engine/Entities/Entity.h b/Sources/Engine/Entities/Entity.h old mode 100644 new mode 100755 diff --git a/Sources/Engine/Entities/FieldBSPTesting.cpp b/Sources/Engine/Entities/FieldBSPTesting.cpp index 2dd4fd2..33f954c 100644 --- a/Sources/Engine/Entities/FieldBSPTesting.cpp +++ b/Sources/Engine/Entities/FieldBSPTesting.cpp @@ -43,11 +43,10 @@ static BOOL EntityIsInside(CEntity *pen) const FLOAT3D &v = pen->en_plPlacement.pl_PositionVector; const FLOATmatrix3D &m = pen->en_mRotation; FLOATobbox3D boxEntity = FLOATobbox3D(pen->en_boxSpatialClassification, v, m); - DOUBLEobbox3D boxdEntity = FLOATtoDOUBLE(boxEntity); // if the box touches the sector's BSP if (boxEntity.HasContactWith(FLOATobbox3D(_pbsc->bsc_boxBoundingBox)) && - _pbsc->bsc_bspBSPTree.TestBox(boxdEntity)<=0) { + _pbsc->bsc_bspBSPTree.TestBox(boxEntity)<=0) { // for each collision sphere CStaticArray &absSpheres = pen->en_pciCollisionInfo->ci_absSpheres; @@ -56,7 +55,7 @@ static BOOL EntityIsInside(CEntity *pen) ms.ms_vRelativeCenter0 = ms.ms_vCenter*m+v; // if the sphere is in the sector if (_pbsc->bsc_bspBSPTree.TestSphere( - FLOATtoDOUBLE(ms.ms_vRelativeCenter0), ms.ms_fR)<=0) { + ms.ms_vRelativeCenter0, ms.ms_fR)<=0) { return TRUE; } } diff --git a/Sources/Engine/Graphics/Benchmark.cpp b/Sources/Engine/Graphics/Benchmark.cpp old mode 100644 new mode 100755 index dd5df5e..8585c31 --- a/Sources/Engine/Graphics/Benchmark.cpp +++ b/Sources/Engine/Graphics/Benchmark.cpp @@ -48,7 +48,7 @@ static CTexParams _tpLocal; static CStaticStackArray _avtx; static CStaticStackArray _atex; static CStaticStackArray _acol; -static CStaticStackArray _aiElements; +static CStaticStackArray _aiElements; @@ -88,7 +88,7 @@ static DOUBLE FillRatePass(INDEX ct) avtx[3].x = _pixSizeI; avtx[3].y = 0; avtx[3].z = 0.5f; GFXTexCoord atex[4] = { {0,0}, {0,1}, {1,1}, {1,0} }; GFXColor acol[4] = { 0xFF0000FF, 0xFF00FF00, 0xFFFF0000, 0xFFFF00FF }; - INDEX aidx[6] = { 0,1,2, 0,2,3}; + INDEX_T aidx[6] = { 0,1,2, 0,2,3}; gfxSetVertexArray( &avtx[0], 4); gfxSetTexCoordArray( &atex[0], FALSE); gfxSetColorArray( &acol[0]); diff --git a/Sources/Engine/Graphics/DepthCheck.cpp b/Sources/Engine/Graphics/DepthCheck.cpp old mode 100644 new mode 100755 index 1f1aa5c..17e267b --- a/Sources/Engine/Graphics/DepthCheck.cpp +++ b/Sources/Engine/Graphics/DepthCheck.cpp @@ -251,7 +251,7 @@ extern void CheckDelayedDepthPoints( const CDrawPort *pdp, INDEX iMirrorLevel/*= ASSERT( pdp!=NULL && iMirrorLevel>=0); // check only if time lapse allows - const CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); + const CTimerValue tvNow = _pTimer->GetLowPrecisionTimer(); const TIME tmDelta = (tvNow-_tvLast[iMirrorLevel]).GetSeconds(); ASSERT( tmDelta>=0); if( gap_iOptimizeDepthReads==2 && tmDelta<0.1f) return; diff --git a/Sources/Engine/Graphics/DrawPort.cpp b/Sources/Engine/Graphics/DrawPort.cpp index ce03348..2a07517 100755 --- a/Sources/Engine/Graphics/DrawPort.cpp +++ b/Sources/Engine/Graphics/DrawPort.cpp @@ -1567,7 +1567,7 @@ void CDrawPort::AddTexture( const FLOAT fI0, const FLOAT fJ0, const FLOAT fI1, c GFXVertex *pvtx = _avtxCommon.Push(4); GFXTexCoord *ptex = _atexCommon.Push(4); GFXColor *pcol = _acolCommon.Push(4); - INDEX *pelm = _aiCommonElements.Push(6); + INDEX_T *pelm = _aiCommonElements.Push(6); pvtx[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0; pvtx[1].x = fI0; pvtx[1].y = fJ1; pvtx[1].z = 0; pvtx[2].x = fI1; pvtx[2].y = fJ1; pvtx[2].z = 0; @@ -1591,7 +1591,7 @@ void CDrawPort::AddTexture( const FLOAT fI0, const FLOAT fJ0, const FLOAT fI1, c GFXVertex *pvtx = _avtxCommon.Push(4); GFXTexCoord *ptex = _atexCommon.Push(4); GFXColor *pcol = _acolCommon.Push(4); - INDEX *pelm = _aiCommonElements.Push(6); + INDEX_T *pelm = _aiCommonElements.Push(6); pvtx[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0; pvtx[1].x = fI0; pvtx[1].y = fJ1; pvtx[1].z = 0; pvtx[2].x = fI1; pvtx[2].y = fJ1; pvtx[2].z = 0; @@ -1619,7 +1619,7 @@ void CDrawPort::AddTriangle( const FLOAT fI0, const FLOAT fJ0, GFXVertex *pvtx = _avtxCommon.Push(3); /* GFXTexCoord *ptex = */ _atexCommon.Push(3); GFXColor *pcol = _acolCommon.Push(3); - INDEX *pelm = _aiCommonElements.Push(3); + INDEX_T *pelm = _aiCommonElements.Push(3); pvtx[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0; pvtx[1].x = fI1; pvtx[1].y = fJ1; pvtx[1].z = 0; pvtx[2].x = fI2; pvtx[2].y = fJ2; pvtx[2].z = 0; @@ -1646,7 +1646,7 @@ void CDrawPort::AddTexture( const FLOAT fI0, const FLOAT fJ0, const FLOAT fU0, c GFXVertex *pvtx = _avtxCommon.Push(4); GFXTexCoord *ptex = _atexCommon.Push(4); GFXColor *pcol = _acolCommon.Push(4); - INDEX *pelm = _aiCommonElements.Push(6); + INDEX_T *pelm = _aiCommonElements.Push(6); pvtx[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0; pvtx[1].x = fI1; pvtx[1].y = fJ1; pvtx[1].z = 0; pvtx[2].x = fI2; pvtx[2].y = fJ2; pvtx[2].z = 0; diff --git a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp old mode 100644 new mode 100755 index 18c0033..01718eb --- a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp +++ b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp @@ -62,7 +62,7 @@ static GfxAPIType eAPI; static CStaticStackArray _avtxPass; static CStaticStackArray _atexPass[MAXTEXUNITS]; static CStaticStackArray _acolPass; -static CStaticStackArray _aiElements; +static CStaticStackArray _aiElements; // general coordinate stack referenced by the scene polygons CStaticStackArray _avtxScene; @@ -141,7 +141,7 @@ __forceinline void AddElements( ScenePolygon *pspo) { const INDEX ctElems = pspo->spo_ctElements; - INDEX *piDst = _aiElements.Push(ctElems); + INDEX_T *piDst = _aiElements.Push(ctElems); #if (defined __MSVC_INLINE__) __asm { diff --git a/Sources/Engine/Graphics/GfxLibrary.cpp b/Sources/Engine/Graphics/GfxLibrary.cpp old mode 100644 new mode 100755 index 7bd6422..287d705 --- a/Sources/Engine/Graphics/GfxLibrary.cpp +++ b/Sources/Engine/Graphics/GfxLibrary.cpp @@ -66,8 +66,8 @@ BOOL CVA_bModels = FALSE; CStaticStackArray _avtxCommon; CStaticStackArray _atexCommon; CStaticStackArray _acolCommon; -CStaticStackArray _aiCommonElements; -CStaticStackArray _aiCommonQuads; // predefined array for rendering quads thru triangles in glDrawElements() +CStaticStackArray _aiCommonElements; +CStaticStackArray _aiCommonQuads; // predefined array for rendering quads thru triangles in glDrawElements() // global texture parameters CTexParams _tpGlobal[GFX_MAXTEXUNITS]; @@ -795,7 +795,7 @@ extern BOOL ProbeMode( CTimerValue tvLast) } // clamp and determine probe mode if( gfx_tmProbeDecay>999) gfx_tmProbeDecay = 999; - CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); + CTimerValue tvNow = _pTimer->GetLowPrecisionTimer(); const TIME tmDelta = (tvNow-tvLast).GetSeconds(); if( tmDelta>gfx_tmProbeDecay) return TRUE; return FALSE; @@ -1718,7 +1718,7 @@ void CGfxLibrary::ReduceShadows(void) // clamp shadow caching variables shd_fCacheSize = Clamp( shd_fCacheSize, 0.1f, 128.0f); shd_tmFlushDelay = Clamp( shd_tmFlushDelay, 0.1f, 120.0f); - CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); // readout current time + CTimerValue tvNow = _pTimer->GetLowPrecisionTimer(); // readout current time const TIME tmAcientDelay = Clamp( shd_tmFlushDelay*3, 60.0f, 300.0f); // determine cached shadowmaps stats (if needed) diff --git a/Sources/Engine/Graphics/GfxLibrary.h b/Sources/Engine/Graphics/GfxLibrary.h old mode 100644 new mode 100755 index eba0a14..68dd196 --- a/Sources/Engine/Graphics/GfxLibrary.h +++ b/Sources/Engine/Graphics/GfxLibrary.h @@ -33,8 +33,8 @@ with this program; if not, write to the Free Software Foundation, Inc., extern CStaticStackArray _avtxCommon; extern CStaticStackArray _atexCommon; extern CStaticStackArray _acolCommon; -extern CStaticStackArray _aiCommonElements; -extern CStaticStackArray _aiCommonQuads; +extern CStaticStackArray _aiCommonElements; +extern CStaticStackArray _aiCommonQuads; #include #include diff --git a/Sources/Engine/Graphics/Gfx_wrapper.cpp b/Sources/Engine/Graphics/Gfx_wrapper.cpp old mode 100644 new mode 100755 index b284d7d..b9b3790 --- a/Sources/Engine/Graphics/Gfx_wrapper.cpp +++ b/Sources/Engine/Graphics/Gfx_wrapper.cpp @@ -126,7 +126,7 @@ void (*gfxSetVertexArray)( GFXVertex4 *pvtx, INDEX ctVtx) = NULL; void (*gfxSetNormalArray)( GFXNormal *pnor) = NULL; void (*gfxSetTexCoordArray)( GFXTexCoord *ptex, BOOL b4) = NULL; void (*gfxSetColorArray)( GFXColor *pcol) = NULL; -void (*gfxDrawElements)( INDEX ctElem, INDEX *pidx) = NULL; +void (*gfxDrawElements)( INDEX ctElem, INDEX_T *pidx) = NULL; void (*gfxSetConstantColor)(COLOR col) = NULL; void (*gfxEnableColorArray)(void) = NULL; void (*gfxDisableColorArray)(void) = NULL; @@ -555,7 +555,7 @@ extern void gfxUnlockArrays(void) void AddQuadElements( const INDEX ctQuads) { const INDEX iStart = _aiCommonQuads.Count() /6*4; - INDEX *piQuads = _aiCommonQuads.Push(ctQuads*6); + INDEX_T *piQuads = _aiCommonQuads.Push(ctQuads*6); for( INDEX i=0; igl_eCurrentAPI==GAT_OGL); #ifndef NDEBUG @@ -1136,7 +1136,7 @@ static void ogl_DrawElements( INDEX ctElem, INDEX *pidx) // arrays or elements if( pidx==NULL) pglDrawArrays( GL_QUADS, 0, ctElem); - else pglDrawElements( GL_TRIANGLES, ctElem, GL_UNSIGNED_INT, pidx); + else pglDrawElements( GL_TRIANGLES, ctElem, INDEX_GL, pidx); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); diff --git a/Sources/Engine/Graphics/Shader.cpp b/Sources/Engine/Graphics/Shader.cpp old mode 100644 new mode 100755 index ea39eb5..e4b0830 --- a/Sources/Engine/Graphics/Shader.cpp +++ b/Sources/Engine/Graphics/Shader.cpp @@ -45,7 +45,7 @@ static GFXTexCoord *_paHazeUVMap = NULL; // UVMap for haze pass static GFXColor *_pacolVtxHaze = NULL; // array of vertex colors for haze static CTextureObject **_paTextures = NULL;// array of textures to chose from -static INDEX *_paIndices = NULL; // current array of triangle indices +static INDEX_T *_paIndices = NULL; // current array of triangle indices static GFXColor _colAmbient = 0x000000FF; // Ambient color static COLOR _colModel = 0x000000FF; // Model color @@ -352,7 +352,7 @@ void shaSetNormalArray(GFXNormal *paNormals) } // Set array of indices -void shaSetIndices(INDEX *paIndices,INDEX ctIndices) +void shaSetIndices(INDEX_T *paIndices,INDEX ctIndices) { ASSERT(paIndices!=NULL); ASSERT(ctIndices>0); @@ -576,7 +576,7 @@ GFXVertex4 *shaGetVertexArray(void) } // Get index array -INDEX *shaGetIndexArray(void) +INDEX_T *shaGetIndexArray(void) { return _paIndices; } diff --git a/Sources/Engine/Graphics/Shader.h b/Sources/Engine/Graphics/Shader.h old mode 100644 new mode 100755 index 14c57d3..b4901e2 --- a/Sources/Engine/Graphics/Shader.h +++ b/Sources/Engine/Graphics/Shader.h @@ -97,7 +97,7 @@ ENGINE_API void shaSetVertexArray(GFXVertex4 *paVertices,INDEX ctVertices); // Set array of normals ENGINE_API void shaSetNormalArray(GFXNormal *paNormals); // Set array of indices -ENGINE_API void shaSetIndices(INDEX *paIndices, INDEX ctIndices); +ENGINE_API void shaSetIndices(INDEX_T *paIndices, INDEX ctIndices); // Set array of texture objects for shader ENGINE_API void shaSetTextureArray(CTextureObject **paTextureObject, INDEX ctTextures); // Set array of uv maps @@ -159,7 +159,7 @@ ENGINE_API COLOR &shaGetCurrentColor(void); // Get vertex array ENGINE_API GFXVertex4 *shaGetVertexArray(void); // Get index array -ENGINE_API INDEX *shaGetIndexArray(void); +ENGINE_API INDEX_T *shaGetIndexArray(void); // Get normal array ENGINE_API GFXNormal *shaGetNormalArray(void); // Get uvmap array from array of uvmaps diff --git a/Sources/Engine/Graphics/ShadowMap.cpp b/Sources/Engine/Graphics/ShadowMap.cpp old mode 100644 new mode 100755 index 05d168f..08ba573 --- a/Sources/Engine/Graphics/ShadowMap.cpp +++ b/Sources/Engine/Graphics/ShadowMap.cpp @@ -251,7 +251,7 @@ void CShadowMap::MarkDrawn(void) ASSERT( sm_lnInGfx.IsLinked()); sm_lnInGfx.Remove(); // set time stamp - sm_tvLastDrawn = _pTimer->GetHighPrecisionTimer(); + sm_tvLastDrawn = _pTimer->GetLowPrecisionTimer(); // put at the end of the list _pGfx->gl_lhCachedShadows.AddTail(sm_lnInGfx); } diff --git a/Sources/Engine/Graphics/Texture.h b/Sources/Engine/Graphics/Texture.h index 01daf30..808e416 100644 --- a/Sources/Engine/Graphics/Texture.h +++ b/Sources/Engine/Graphics/Texture.h @@ -97,7 +97,7 @@ public: inline ULONG GetNoOfFineMips(void) const { return td_ctFineMipLevels; }; // mark that texture has been used - inline void MarkDrawn(void) { td_tvLastDrawn = _pTimer->GetHighPrecisionTimer(); }; + inline void MarkDrawn(void) { td_tvLastDrawn = _pTimer->GetLowPrecisionTimer(); }; // get string description of texture size, mips and parameters CTString GetDescription(void); diff --git a/Sources/Engine/Light/LightSource.cpp b/Sources/Engine/Light/LightSource.cpp index 24188ac..2e7d6bf 100644 --- a/Sources/Engine/Light/LightSource.cpp +++ b/Sources/Engine/Light/LightSource.cpp @@ -417,7 +417,7 @@ void CLightSource::FindShadowLayersPoint(BOOL bSelectedOnly) } // for each layer of the light source - DOUBLE3D dvOrigin = FLOATtoDOUBLE(*_pvOrigin); + FLOAT3D dvOrigin = *_pvOrigin; {FORDELETELIST(CBrushShadowLayer, bsl_lnInLightSource, ls_lhLayers, itbsl) { CBrushPolygon *pbpo = itbsl->bsl_pbsmShadowMap->GetBrushPolygon(); CEntity *penWithPolygon = pbpo->bpo_pbscSector->bsc_pbmBrushMip->bm_pbrBrush->br_penEntity; @@ -490,7 +490,7 @@ void CLightSource::FindShadowLayersPoint(BOOL bSelectedOnly) if (!itbsc->bsc_boxBoundingBox.HasContactWith(_boxLight) ||(itbsc->bsc_bspBSPTree.bt_pbnRoot!=NULL &&!(itbsc->bsc_bspBSPTree.TestSphere( - dvOrigin, FLOATtoDOUBLE(_rRange))>=0) )) { + dvOrigin, _rRange)>=0) )) { // skip it continue; } diff --git a/Sources/Engine/Math/AABBox.h b/Sources/Engine/Math/AABBox.h old mode 100644 new mode 100755 index bac1a94..bacc29f --- a/Sources/Engine/Math/AABBox.h +++ b/Sources/Engine/Math/AABBox.h @@ -400,6 +400,53 @@ inline FLOATaabbox3D DOUBLEtoFLOAT(const DOUBLEaabbox3D &pld) { return FLOATaabbox3D( DOUBLEtoFLOAT(pld.Min()), DOUBLEtoFLOAT(pld.Max())); } +/* Specialized copy for FLOATaabb3D */ + +/* Check if intersects or touches another bounding box. */ +template<> +inline BOOL AABBox::HasContactWith(const AABBox &b) const +{ + // if spans in any dimension don't have contact + if (maxvect(1)b.maxvect(1) + || maxvect(2)b.maxvect(2) + || maxvect(3)b.maxvect(3) + ) { + // whole bounding boxes don't have contact + return FALSE; + } + return TRUE; +} +/* Check if intersects or touches another bounding box. */ +template<> +inline BOOL AABBox::HasContactWith(const AABBox &b, FLOAT tEpsilon) const +{ + // if spans in any dimension don't have contact + if( (maxvect(1)+tEpsilonb.maxvect(1)) + || (maxvect(2)+tEpsilonb.maxvect(2)) + || (maxvect(3)+tEpsilonb.maxvect(3)) + ) { + // whole bounding boxes don't have contact + return FALSE; + } + return TRUE; +} +/* Check if intersects or touches a sphere. */ +template<> +inline BOOL AABBox::TouchesSphere( + const Vector &vSphereCenter, FLOAT fSphereRadius) const +{ + // if spans in any dimension don't have contact + if( (vSphereCenter(1)+fSphereRadiusmaxvect(1)) + || (vSphereCenter(2)+fSphereRadiusmaxvect(2)) + || (vSphereCenter(3)+fSphereRadiusmaxvect(3)) + ) { + // no contact + return FALSE; + } + return TRUE; +} + + #endif /* include-once check. */ diff --git a/Sources/Engine/Math/Clipping.inl b/Sources/Engine/Math/Clipping.inl old mode 100644 new mode 100755 diff --git a/Sources/Engine/Math/Matrix.h b/Sources/Engine/Math/Matrix.h old mode 100644 new mode 100755 diff --git a/Sources/Engine/Models/ModelData.h b/Sources/Engine/Models/ModelData.h old mode 100644 new mode 100755 index 41aa6c2..858281b --- a/Sources/Engine/Models/ModelData.h +++ b/Sources/Engine/Models/ModelData.h @@ -67,7 +67,7 @@ struct ENGINE_API ModelMipInfo CStaticArray mmpi_avBumpV; // bump directions for each surface vertex ULONG mmpi_ulLayerFlags; // all texture layers needed in this mip INDEX mmpi_ctTriangles; // total triangles in this mip - CStaticStackArray mmpi_aiElements; + CStaticStackArray mmpi_aiElements; void Clear(); // clears this mip model's arays and their sub-arrays, dealocates memory void Read_t( CTStream *istrFile, BOOL bReadPolygonalPatches, BOOL bReadPolygonsPerSurface, diff --git a/Sources/Engine/Models/RenderModel_View.cpp b/Sources/Engine/Models/RenderModel_View.cpp old mode 100644 new mode 100755 index e5cf4ce..1038ca8 --- a/Sources/Engine/Models/RenderModel_View.cpp +++ b/Sources/Engine/Models/RenderModel_View.cpp @@ -332,7 +332,7 @@ static void PrepareSurfaceElements( ModelMipInfo &mmi, MappingSurface &ms) // create elements ms.ms_ctSrfEl = ctTriangles*3; - INDEX *paiElements = mmi.mmpi_aiElements.Push(ms.ms_ctSrfEl); + INDEX_T *paiElements = mmi.mmpi_aiElements.Push(ms.ms_ctSrfEl); // dump all triangles //_RPT0(_CRT_WARN, "Result:\n"); INDEX iel = 0; @@ -587,7 +587,7 @@ static void SetCol(void) _icol = (_icol+1)%_ctcol; } -static void DrawStrips( const INDEX ct, const INDEX *pai) +static void DrawStrips( const INDEX ct, const INDEX_T *pai) { // set strip color pglDisableClientState( GL_COLOR_ARRAY); @@ -603,9 +603,9 @@ static void DrawStrips( const INDEX ct, const INDEX *pai) while( i0); // choose rendering mode @@ -2106,6 +2106,37 @@ vtxRest: vtxEnd: pop ebx } +#elif defined(__ARM_NEON__) + register float tc_u __asm__("s0") = fTexCorrU; + register float tc_v __asm__("s1") = fTexCorrV; + const void *tc_src = pvTexCoord->vector; + GFXTexCoord *tc_dst = ptexSrfBase; + int tc_cnt = ctSrfVx; + __asm__ __volatile__ ( + "vmov d1, d0\n" + "0:\n" + "subs %[c], #2\n" + "blt 1f\n" + "vld1.32 {d2}, [%[src]]\n" + "add %[src], %[src_s]\n" + "vld1.32 {d3}, [%[src]]\n" + "add %[src], %[src_s]\n" + "vmul.f32 q1, q1, q0\n" + "pld [%[src], #64]\n" + "vst1.32 {q1}, [%[dst]]!\n" + "b 0b\n" + "1:\n" + "tst %[c], #1\n" + "beq 2f\n" + "vld1.32 {d2}, [%[src]]\n" + "vmul.f32 d2, d2, d0\n" + "vst1.32 {d2}, [%[dst]]\n" + "2:\n" + : [c] "=&r"(tc_cnt), [src] "=&r"(tc_src), [dst] "=&r"(tc_dst) + : "[c]"(tc_cnt), "[src]"(tc_src), "[dst]"(tc_dst), + "t"(tc_u), "t"(tc_v), [src_s] "I"(sizeof(pvTexCoord[0])) + : "d1", "q1", "cc", "memory" + ); #else // setup texcoord array for( INDEX iSrfVx=0; iSrfVx=0) { + if( bsc.bsc_bspBSPTree.TestSphere(re_vdViewSphere, 0.01f)>=0) { // mark that viewer is in haze re_bViewerInHaze = TRUE; } diff --git a/Sources/Engine/Rendering/RenderAdding.cpp b/Sources/Engine/Rendering/RenderAdding.cpp index 807f428..db3178d 100644 --- a/Sources/Engine/Rendering/RenderAdding.cpp +++ b/Sources/Engine/Rendering/RenderAdding.cpp @@ -662,7 +662,7 @@ void CRenderer::AddZoningSectorsAroundEntity(CEntity *pen, const FLOAT3D &vEyesP ASSERT(!(pen->en_ulFlags&ENF_ZONING)); // make parameters for minimum sphere to add - re_vdViewSphere = FLOATtoDOUBLE(vEyesPos); + re_vdViewSphere = vEyesPos; re_dViewSphereR = re_prProjection->NearClipDistanceR()*1.5f; CListHead lhToAdd; @@ -751,7 +751,7 @@ void CRenderer::AddZoningSectorsAroundBox(const FLOATaabbox3D &boxNear) FLOAT3D vSphereCenter = boxNear.Center(); re_dViewSphereR = re_prProjection->NearClipDistanceR()*1.5f; - re_vdViewSphere = FLOATtoDOUBLE(vSphereCenter); + re_vdViewSphere = vSphereCenter; // for all entities in world FOREACHINDYNAMICCONTAINER(re_pwoWorld->wo_cenEntities, CEntity, iten) { @@ -792,7 +792,7 @@ void CRenderer::AddZoningSectorsAroundBox(const FLOATaabbox3D &boxNear) &&!((itbsc->bsc_ulFlags&BSCF_HIDDEN) && !re_bRenderingShadows)) { // if the sphere is inside the sector if (itbsc->bsc_bspBSPTree.TestSphere( - FLOATtoDOUBLE(vSphereCenter), FLOATtoDOUBLE(fSphereRadius))>=0) { + vSphereCenter, fSphereRadius)>=0) { // add that sector to active sectors AddActiveSector(itbsc.Current()); diff --git a/Sources/Engine/Rendering/Render_internal.h b/Sources/Engine/Rendering/Render_internal.h index a81f919..d9c3b38 100644 --- a/Sources/Engine/Rendering/Render_internal.h +++ b/Sources/Engine/Rendering/Render_internal.h @@ -287,8 +287,8 @@ public: CEntity *re_penViewer; // entity that is viewed from CDynamicContainer *re_pcspoViewPolygons; // polygons that is viewed from (for mirrors) CAnyProjection3D re_prProjection; // projection to viewer space - DOUBLE3D re_vdViewSphere; - DOUBLE re_dViewSphereR; + FLOAT3D re_vdViewSphere; + FLOAT re_dViewSphereR; // used for fixing problems with extra trapezoids generated on t-junctions FLOAT re_fEdgeOffsetI; diff --git a/Sources/Engine/Ska/Mesh.h b/Sources/Engine/Ska/Mesh.h old mode 100644 new mode 100755 index 37dcf7b..4d29f0e --- a/Sources/Engine/Ska/Mesh.h +++ b/Sources/Engine/Ska/Mesh.h @@ -117,7 +117,7 @@ struct ENGINE_API MeshSurface struct ENGINE_API MeshTriangle { - INDEX iVertex[3]; + INDEX_T iVertex[3]; }; static inline CTStream &operator>>(CTStream &strm, MeshTriangle &mt) diff --git a/Sources/Engine/Ska/RMRender.cpp b/Sources/Engine/Ska/RMRender.cpp old mode 100644 new mode 100755 index 576d1b8..82d1f28 --- a/Sources/Engine/Ska/RMRender.cpp +++ b/Sources/Engine/Ska/RMRender.cpp @@ -767,7 +767,7 @@ void RM_RenderGround(CTextureObject &to) GFXVertex vBoxVtxs[4]; GFXTexCoord tcBoxTex[4]; - INDEX aiIndices[6]; + INDEX_T aiIndices[6] = {0, 2, 1, 0 ,3 ,2}; // set ground vertices vBoxVtxs[0].x = vVtx(1); vBoxVtxs[0].y = vVtx(2); vBoxVtxs[0].z = -vVtx(3); @@ -783,8 +783,8 @@ void RM_RenderGround(CTextureObject &to) for(INDEX ivx=0;ivx<4;ivx++) { TransformVertex(vBoxVtxs[ivx],_mAbsToViewer); } - aiIndices[0] = 0; aiIndices[1] = 2; aiIndices[2] = 1; - aiIndices[3] = 0; aiIndices[4] = 3; aiIndices[5] = 2; + /*aiIndices[0] = 0; aiIndices[1] = 2; aiIndices[2] = 1; + aiIndices[3] = 0; aiIndices[4] = 3; aiIndices[5] = 2;*/ gfxSetVertexArray(vBoxVtxs,4); gfxSetTexCoordArray(tcBoxTex, FALSE); @@ -852,8 +852,21 @@ static void RenderBox(FLOAT3D vMinVtx, FLOAT3D vMaxVtx, COLOR col) for(INDEX iwx=0;iwx<8;iwx++) { TransformVertex(vBoxVtxs[iwx],_mObjToViewStretch); } - INDEX aiIndices[36]; - aiIndices[ 0] = 0; aiIndices[ 1] = 3; aiIndices[ 2] = 1; + INDEX_T aiIndices[36] = { + 0, 3, 1, + 0, 2, 3, + 5, 1, 3, + 7, 5, 3, + 2, 7, 3, + 6, 7, 2, + 4, 2, 0, + 4, 6, 2, + 5, 0, 1, + 5, 4, 0, + 4, 5, 7, + 6, 4, 7 + }; + /*aiIndices[ 0] = 0; aiIndices[ 1] = 3; aiIndices[ 2] = 1; aiIndices[ 3] = 0; aiIndices[ 4] = 2; aiIndices[ 5] = 3; aiIndices[ 6] = 5; aiIndices[ 7] = 1; aiIndices[ 8] = 3; aiIndices[ 9] = 7; aiIndices[10] = 5; aiIndices[11] = 3; @@ -864,7 +877,7 @@ static void RenderBox(FLOAT3D vMinVtx, FLOAT3D vMaxVtx, COLOR col) aiIndices[24] = 5; aiIndices[25] = 0; aiIndices[26] = 1; aiIndices[27] = 5; aiIndices[28] = 4; aiIndices[29] = 0; aiIndices[30] = 4; aiIndices[31] = 5; aiIndices[32] = 7; - aiIndices[33] = 6; aiIndices[34] = 4; aiIndices[35] = 7; + aiIndices[33] = 6; aiIndices[34] = 4; aiIndices[35] = 7;*/ gfxSetVertexArray(vBoxVtxs,8); gfxDrawElements(36,aiIndices); diff --git a/Sources/Engine/Ska/RMRenderMask.cpp b/Sources/Engine/Ska/RMRenderMask.cpp old mode 100644 new mode 100755 index 8fdce87..4aedd8a --- a/Sources/Engine/Ska/RMRenderMask.cpp +++ b/Sources/Engine/Ska/RMRenderMask.cpp @@ -40,7 +40,7 @@ extern void InternalShader_Mask(void) INDEX ctIdx = shaGetIndexCount(); INDEX ctVtx = shaGetVertexCount(); if( ctIdx==0 || ctVtx==0) return; - INDEX *pidx = shaGetIndexArray(); + INDEX_T *pidx = shaGetIndexArray(); GFXVertex4 *pvtx = shaGetVertexArray(); GFXTexCoord *ptex = shaGetUVMap(0); CTextureObject *pto = shaGetTexture(0); diff --git a/Sources/Engine/Templates/BSP.cpp b/Sources/Engine/Templates/BSP.cpp old mode 100644 new mode 100755 index 32dce0e..250365a --- a/Sources/Engine/Templates/BSP.cpp +++ b/Sources/Engine/Templates/BSP.cpp @@ -506,6 +506,310 @@ FLOAT BSPNode::TestSphere(const Vector &vS } } } +#define SPHERE_HACK +#ifdef SPHERE_HACK +// truncate doubles in d0-d3 to floats in d0-d1 +// destroys d2-d7 +#define doubles_to_floats \ + "vmov.i32 q3, #0xff800000\n" \ + "vshrn.i64 d4, q0, #29\n" \ + "vshrn.i64 d5, q1, #29\n" \ + "vshrn.i64 d0, q0, #32\n" \ + "vshrn.i64 d1, q1, #32\n" \ + "vsub.i32 q2, q3\n" \ + "vbic.i32 q3, #0xc0000000\n" \ + "vshl.i32 q1, q0, #1\n" \ + "vceq.i32 q1, q1, #0\n" \ + "vadd.i32 q2, q3\n" \ + "vorr.i32 q1, #0x80000000\n" \ + "vbif.32 q0, q2, q1\n" + +// params[6]: vec[3], -1, radius, -radius +template<> +int BSPNode::TestSphere_hack(const FLOAT *params) const +{ + const BSPNode *node, *next; + +#ifdef __arm__ + register double params_q8 __asm__("q8"); + __asm__ __volatile__ ( + "vld1.64 {d16,d17}, [%[prm], :64]\n" + : "=w"(params_q8) + : [prm] "r"(params) + ); +#endif + + node = this; + for (;;) + { +#ifdef __arm__ + register double vec_q0 __asm__("q0"); + register double vec_d2 __asm__("d2"); + __asm__ __volatile__ ( + "vld1.64 {d0,d1,d2}, [%[vec], :64]\n" + : "=w"(vec_q0), "=w"(vec_d2) + : [vec] "r"(node->vector) + ); +#endif + // if this is an inside node + if (node->bn_bnlLocation == BNL_INSIDE) { + // it is inside + return 1; + // if this is an outside node + } else if (node->bn_bnlLocation == BNL_OUTSIDE) { + // it is outside + return -1; + // if this is a branch + } else { + ASSERT(node->bn_bnlLocation == BNL_BRANCH); + // test the sphere against the split plane + //double tCenterDistance = node->PointDistance(vSphereCenter); +#ifdef __arm__ + register double dist_d3 __asm__("d3") = node->pl_distance; + + __asm__ __volatile__ ( + doubles_to_floats + "vmul.f32 q0, q0, q8\n" + "ldr r2, %[pbnF]\n" + "vldr d2, %[rad]\n" + "ldr r3, %[pbnB]\n" + "vpadd.f32 d0, d0, d1\n" + "vmov d3, r3, r2\n" // pbnF.pbnB + "vpadd.f32 d0, d0, d0\n" // tCenterDistance + "vcgt.f32 d4, d0, d2\n" // [0] tCenterDistance > radius + "vcgt.f32 d5, d2, d0\n" // [1] -radius > tCenterDistance + "vext.32 d0, d5, d4, #1\n" // [0].[1] + "vand d0, d3\n" + "vpadd.i32 d0, d3\n" + "vmov.i32 %[next], d0[0]\n" + : [next] "=r"(next), + "=w"(vec_q0), "=w"(vec_d2), "=w"(dist_d3) + : "w"(vec_q0), "w"(vec_d2), "w"(dist_d3), "w"(params_q8), + [pbnF] "m"(node->bn_pbnFront), + [pbnB] "m"(node->bn_pbnBack), + [rad] "m"(params[4]) + : "r2", "r3", "q2", "q3" + ); +#else + float tCenterDistance = + node->vector[0] * params[0] + + node->vector[1] * params[1] + + node->vector[2] * params[2] - node->pl_distance; + + // if the sphere is in front of the plane + if (tCenterDistance > +params[4]) { + next = node->bn_pbnFront; + // if the sphere is behind the plane + } else if (tCenterDistance < params[5]) { + next = node->bn_pbnBack; + // if the sphere is split by the plane + } else { + next = NULL; + } +#endif + if (next == NULL) + break; + node = next; + } + } + + // if front node touches + int iFront = node->bn_pbnFront->TestSphere_hack(params); + if (iFront==0) { + // it touches + return 0; + } + // if back node touches + int iBack = node->bn_pbnBack->TestSphere_hack(params); + if (iBack==0) { + // it touches + return 0; + } + // if front and back have same classification + if (iFront==iBack) { + // return it + return iFront; + // if front and back have different classification + } else { + // it touches + return 0; + } +} + +// _ZNK7BSPNodeIdLi3EE10TestSphereERK6VectorIdLi3EEd +template<> +FLOAT BSPNode::TestSphere(const Vector &vSphereCenter, double tSphereRadius) const +{ + float params[6] __attribute__((aligned(8))); + +#ifdef __arm__ + register double radius __asm__("d3") = tSphereRadius; + __asm__ __volatile__ ( + "vld1.64 {d0,d1,d2}, [%[vec], :64]\n" + doubles_to_floats + "vmov.i32 d4, #0\n" + "vmov.i32 d4[1], %[sgn]\n" + "vmov.f32 d3, #-1.0\n" + "vdup.32 d2, d1[1]\n" + "vsli.i64 d1, d3, #32\n" + "veor d2, d4\n" + "vst1.32 {d0,d1,d2}, [%[prm], :64]\n" + : "=w"(radius) + : [vec] "r"(vSphereCenter.vector), + [prm] "r"(params), + [sgn] "r"(0x80000000), + "w"(radius) + : "q0", "d2", "q2", "q3" + ); +#else + params[0] = vSphereCenter.vector[0]; + params[1] = vSphereCenter.vector[1]; + params[2] = vSphereCenter.vector[2]; + params[3] = -1.0f; + params[4] = tSphereRadius; + params[5] = -tSphereRadius; +#endif + + return TestSphere_hack(params); +} + +// params[6]: vec[3], -1, radius, -radius +template<> +int BSPNode::TestSphere_hack(const FLOAT *params) const +{ + const BSPNode *node = this; + +#ifdef __arm__ + register double params_q8 __asm__("q8"); + register double radius_d18 __asm__("d18"); + register double cdist_d6 __asm__("d6"); + __asm__ __volatile__ ( + "vld1.32 {d0,d1}, [%[vec]]\n" + "vldr s3, %[dist]\n" + "vld1.64 {d16,d17,d18}, [%[prm], :64]\n" + "vmul.f32 q0, q0, q8\n" + "vpadd.f32 d6, d0, d1\n" + : "=w"(cdist_d6), + "=w"(params_q8), + "=w"(radius_d18) + : [prm] "r"(params), + [vec] "r"(node->vector), + [dist] "m"(node->pl_distance) + ); +#endif + + for (;;) + { + // if this is an inside node + if (node->bn_bnlLocation == BNL_INSIDE) { + // it is inside + return 1; + // if this is an outside node + } else if (node->bn_bnlLocation == BNL_OUTSIDE) { + // it is outside + return -1; + // if this is a branch + } else { + ASSERT(node->bn_bnlLocation == BNL_BRANCH); + // test the sphere against the split plane + //float tCenterDistance = node->PointDistance(vSphereCenter); +#ifdef __arm__ + int gt_radius, lt_nradius; + __asm__ __volatile__ ( + "vpadd.f32 d6, d6, d6\n" // tCenterDistance + "vld1.32 {d0,d1}, [%[pbnFv]]\n" + "vldr s3, %[pbnFd]\n" + "vcgt.f32 d4, d6, d18\n" // [0] tCenterDistance > radius + "vcgt.f32 d5, d18, d6\n" // [1] -radius > tCenterDistance + "vld1.32 {d2,d3}, [%[pbnBv]]\n" + "vldr s7, %[pbnBd]\n" + "vmov.i32 %[gt], d4[0]\n" + "vmov.i32 %[lt], d5[1]\n" + + "vdup.i32 q2, d5[1]\n" + "vbit q0, q1, q2\n" + "vmul.f32 q0, q0, q8\n" + "vpadd.f32 d6, d0, d1\n" + : [gt] "=r"(gt_radius), [lt] "=r"(lt_nradius), + "=w"(cdist_d6) + : "w"(cdist_d6), "w"(params_q8), "w"(radius_d18), + [pbnFv] "r"(node->bn_pbnFront->vector), + [pbnFd] "m"(node->bn_pbnFront->pl_distance), + [pbnBv] "r"(node->bn_pbnBack->vector), + [pbnBd] "m"(node->bn_pbnBack->pl_distance) + : "q0", "q1", "q2", "d7" + ); + + // if the sphere is in front of the plane + if (gt_radius) { + node = node->bn_pbnFront; + // if the sphere is behind the plane + } else if (lt_nradius) { + node = node->bn_pbnBack; + // if the sphere is split by the plane + } else { + break; + } +#else + float tCenterDistance = + node->vector[0] * params[0] + + node->vector[1] * params[1] + + node->vector[2] * params[2] - node->pl_distance; + + // if the sphere is in front of the plane + if (tCenterDistance > +params[4]) { + node = node->bn_pbnFront; + // if the sphere is behind the plane + } else if (tCenterDistance < params[5]) { + node = node->bn_pbnBack; + // if the sphere is split by the plane + } else { + break; + } +#endif + } + } + + // if front node touches + int iFront = node->bn_pbnFront->TestSphere_hack(params); + if (iFront==0) { + // it touches + return 0; + } + // if back node touches + int iBack = node->bn_pbnBack->TestSphere_hack(params); + if (iBack==0) { + // it touches + return 0; + } + // if front and back have same classification + if (iFront==iBack) { + // return it + return iFront; + // if front and back have different classification + } else { + // it touches + return 0; + } +} + +template<> +FLOAT BSPNode::TestSphere(const Vector &vSphereCenter, float tSphereRadius) const +{ + float params[6] __attribute__((aligned(8))); + + params[0] = vSphereCenter.vector[0]; + params[1] = vSphereCenter.vector[1]; + params[2] = vSphereCenter.vector[2]; + params[3] = -1.0f; + params[4] = tSphereRadius; + params[5] = -tSphereRadius; + + return TestSphere_hack(params); +} + +#endif + /* Test if a box is inside, outside, or intersecting. (Just a trivial rejection test) */ template FLOAT BSPNode::TestBox(const OBBox &box) const @@ -1210,7 +1514,10 @@ void BSPTree::Read_t(CTStream &strm) // throw char * BSPNode &bn = bt_abnNodes[iNode]; // read it from disk //strm.Read_t(&(Plane&)bn, sizeof(Plane)); - strm >> ((Plane&)bn); + //strm >> ((Plane&)bn); + Plane tmp; + strm >> tmp; + ((Plane &)bn) = DOUBLEtoFLOAT(tmp); strm>>(INDEX&)bn.bn_bnlLocation; diff --git a/Sources/Engine/Templates/BSP.h b/Sources/Engine/Templates/BSP.h old mode 100644 new mode 100755 index 5d390ca..fd06b8a --- a/Sources/Engine/Templates/BSP.h +++ b/Sources/Engine/Templates/BSP.h @@ -60,9 +60,9 @@ public: Type &tMin, Type &tMax) const; /* Test if a sphere is inside, outside, or intersecting. (Just a trivial rejection test) */ - FLOAT TestSphere(const Vector &vSphereCenter, Type tSphereRadius) const; + FLOAT FASTMATH TestSphere(const Vector &vSphereCenter, Type tSphereRadius) const; /* Test if a box is inside, outside, or intersecting. (Just a trivial rejection test) */ - FLOAT TestBox(const OBBox &box) const; + FLOAT FASTMATH TestBox(const OBBox &box) const; /* Read/write entire bsp tree to disk. */ void Read_t(CTStream &strm); // throw char * void Write_t(CTStream &strm); // throw char * diff --git a/Sources/Engine/Templates/BSP_internal.h b/Sources/Engine/Templates/BSP_internal.h index 57ccbda..edeb047 100644 --- a/Sources/Engine/Templates/BSP_internal.h +++ b/Sources/Engine/Templates/BSP_internal.h @@ -169,6 +169,7 @@ public: /* Test if a sphere is inside, outside, or intersecting. (Just a trivial rejection test) */ FLOAT TestSphere(const Vector &vSphereCenter, Type tSphereRadius) const; + int TestSphere_hack(const FLOAT *params) const; /* Test if a box is inside, outside, or intersecting. (Just a trivial rejection test) */ FLOAT TestBox(const OBBox &box) const; }; diff --git a/Sources/Engine/Terrain/ArrayHolder.h b/Sources/Engine/Terrain/ArrayHolder.h old mode 100644 new mode 100755 index 9c96cbf..f0cc5b5 --- a/Sources/Engine/Terrain/ArrayHolder.h +++ b/Sources/Engine/Terrain/ArrayHolder.h @@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., struct TileLayer { - CStaticStackArray tl_auiIndices; // Array of indices for one layer + CStaticStackArray tl_auiIndices; // Array of indices for one layer CStaticStackArray tl_acColors; // Array of colors for one layer CStaticStackArray tl_atcTexCoords; // Array of texcoords for one layer CStaticStackArray tl_avVertices; // Array of vertices for one layer (used only if tile layer) @@ -48,7 +48,7 @@ struct TileArrays CStaticStackArray ta_auvTexCoords; // Array of texcoords for one tile (not used in highest lod) CStaticStackArray ta_auvShadowMap; // Array of texcoords for shadow map CStaticStackArray ta_auvDetailMap; // Array of texcoords for detail map - CStaticStackArray ta_auiIndices; // Array of indices for one tile + CStaticStackArray ta_auiIndices; // Array of indices for one tile CStaticStackArray ta_atlLayers; // Array if layers per tile (used only in highest lod) CTextureData *ta_ptdTopMap; // Pointer to tile top map }; diff --git a/Sources/Engine/Terrain/TerrainEditing.cpp b/Sources/Engine/Terrain/TerrainEditing.cpp old mode 100644 new mode 100755 index 6ca5265..eadbaf5 --- a/Sources/Engine/Terrain/TerrainEditing.cpp +++ b/Sources/Engine/Terrain/TerrainEditing.cpp @@ -150,7 +150,7 @@ void ShowSelectionInternal(CTerrain *ptrTerrain, Rect &rcExtract, CTextureData * bboxSelection.maxvect(2) = bboxAllTerrain.maxvect(2); GFXVertex *pavVertices; - INDEX *paiIndices; + INDEX_T *paiIndices; INDEX ctVertices; INDEX ctIndices; diff --git a/Sources/Engine/Terrain/TerrainMisc.cpp b/Sources/Engine/Terrain/TerrainMisc.cpp index 5b199d4..af36a30 100755 --- a/Sources/Engine/Terrain/TerrainMisc.cpp +++ b/Sources/Engine/Terrain/TerrainMisc.cpp @@ -36,7 +36,7 @@ extern CTerrain *_ptrTerrain; // Current terrain static FLOAT3D _vHitLocation = FLOAT3D(-100,-100,-100); CStaticStackArray _avExtVertices; -CStaticStackArray _aiExtIndices; +CStaticStackArray _aiExtIndices; CStaticStackArray _aiExtColors; CStaticStackArray _aiHitTiles; @@ -210,7 +210,7 @@ FLOAT GetExactHitLocation(INDEX iTileIndex, FLOAT3D &vOrigin, FLOAT3D &vTarget, QuadTreeNode &qtn = _ptrTerrain->tr_aqtnQuadTreeNodes[iTileIndex]; GFXVertex *pavVertices; - INDEX *paiIndices; + INDEX_T *paiIndices; INDEX ctVertices; INDEX ctIndices; @@ -222,7 +222,7 @@ FLOAT GetExactHitLocation(INDEX iTileIndex, FLOAT3D &vOrigin, FLOAT3D &vTarget, // for each triangle for(INDEX iTri=0;iTri> Remove Rect from ExtractPolygonsInBox") // Extract polygons in given box and returns clipped rectangle Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract, GFXVertex4 **pavVtx, - INDEX **paiInd, INDEX &ctVtx,INDEX &ctInd,BOOL bFixSize/*=FALSE*/) + INDEX_T **paiInd, INDEX &ctVtx,INDEX &ctInd,BOOL bFixSize/*=FALSE*/) { ASSERT(ptrTerrain!=NULL); @@ -310,10 +310,10 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract if(!bFixSize) { // max vector of bbox in incremented for one, because first vertex is at 0,0,0 in world and in heightmap is at 1,1 #ifdef __arm__ -#ifdef PANDORA +#ifdef PLATFORM_PANDORA #define Isinf(a) (((*(unsigned int*)&a)&0x7fffffff)==0x7f800000) #else - #define Isinf insif + #define Isinf isinff #endif rc.rc_iLeft = (Isinf(bbox.minvect(1)))?(INDEX)0:Clamp((INDEX)(bbox.minvect(1)-0),(INDEX)0,ptrTerrain->tr_pixHeightMapWidth); rc.rc_iTop = (Isinf(bbox.minvect(3)))?(INDEX)0:Clamp((INDEX)(bbox.minvect(3)-0),(INDEX)0,ptrTerrain->tr_pixHeightMapHeight); @@ -368,7 +368,7 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract _aiExtIndices.Push(ctIndices); GFXVertex4 *pavVertices = &_avExtVertices[0]; - INDEX *pauiIndices = &_aiExtIndices[0]; + INDEX_T *pauiIndices = &_aiExtIndices[0]; // for each row INDEX iy, ix; @@ -456,7 +456,7 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract } void ExtractVerticesInRect(CTerrain *ptrTerrain, Rect &rc, GFXVertex4 **pavVtx, - INDEX **paiInd, INDEX &ctVtx,INDEX &ctInd) + INDEX_T **paiInd, INDEX &ctVtx,INDEX &ctInd) { _avExtVertices.PopAll(); _aiExtIndices.PopAll(); @@ -497,7 +497,7 @@ void ExtractVerticesInRect(CTerrain *ptrTerrain, Rect &rc, GFXVertex4 **pavVtx, puwHeight+=iStepY; } - INDEX *pauiIndices = &_aiExtIndices[0]; + INDEX_T *pauiIndices = &_aiExtIndices[0]; INDEX ivx=0; //INDEX ind=0; INDEX iFacing=iFirstHeight; diff --git a/Sources/Engine/Terrain/TerrainMisc.h b/Sources/Engine/Terrain/TerrainMisc.h old mode 100644 new mode 100755 index 717a1c8..df01e3f --- a/Sources/Engine/Terrain/TerrainMisc.h +++ b/Sources/Engine/Terrain/TerrainMisc.h @@ -22,10 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #include // Extract polygons in given box and returns clipped rectangle Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bbox, GFXVertex4 **pavVtx, - INDEX **paiInd, INDEX &ctVtx,INDEX &ctInd,BOOL bFixSize=FALSE); + INDEX_T **paiInd, INDEX &ctVtx,INDEX &ctInd,BOOL bFixSize=FALSE); void ExtractVerticesInRect(CTerrain *ptrTerrain, Rect &rc, GFXVertex4 **pavVtx, - INDEX **paiInd, INDEX &ctVtx,INDEX &ctInd); + INDEX_T **paiInd, INDEX &ctVtx,INDEX &ctInd); // check whether a polygon is below given point, but not too far away diff --git a/Sources/Engine/Terrain/TerrainRayCasting.cpp b/Sources/Engine/Terrain/TerrainRayCasting.cpp old mode 100644 new mode 100755 index 4cbea47..8fe9eed --- a/Sources/Engine/Terrain/TerrainRayCasting.cpp +++ b/Sources/Engine/Terrain/TerrainRayCasting.cpp @@ -32,7 +32,7 @@ static FLOATplane3D _plHitPlane; // hit plane // TEMP static CStaticStackArray _avRCVertices; -static CStaticStackArray _aiRCIndices; +static CStaticStackArray _aiRCIndices; static FLOAT3D _vHitBegin; static FLOAT3D _vHitEnd; static FLOAT _fDistance; @@ -89,7 +89,7 @@ static FLOAT HitCheckQuad(const PIX ix, const PIX iz) (pvx[0].y<=_fMaxHeight || pvx[2].y<=_fMinHeight || pvx[1].y<=_fMinHeight) && ((pvx[0].shade + pvx[2].shade + pvx[1].shade == 255*3) | _bHitInvisibleTris)) { // Add this triangle - INDEX *pind = _aiRCIndices.Push(3); + INDEX_T *pind = _aiRCIndices.Push(3); pind[0] = ctVertices+0; pind[1] = ctVertices+2; pind[2] = ctVertices+1; @@ -100,7 +100,7 @@ static FLOAT HitCheckQuad(const PIX ix, const PIX iz) (pvx[1].y<=_fMaxHeight || pvx[2].y<=_fMaxHeight || pvx[3].y<=_fMaxHeight) && ((pvx[1].shade + pvx[2].shade + pvx[3].shade == 255*3) | _bHitInvisibleTris)) { // Add this triangle - INDEX *pind = _aiRCIndices.Push(3); + INDEX_T *pind = _aiRCIndices.Push(3); pind[0] = ctVertices+1; pind[1] = ctVertices+2; pind[2] = ctVertices+3; @@ -112,7 +112,7 @@ static FLOAT HitCheckQuad(const PIX ix, const PIX iz) (pvx[2].y<=_fMaxHeight || pvx[3].y<=_fMaxHeight || pvx[0].y<=_fMaxHeight) && ((pvx[2].shade + pvx[3].shade + pvx[0].shade == 255*3) | _bHitInvisibleTris)) { // Add this triangle - INDEX *pind = _aiRCIndices.Push(3); + INDEX_T *pind = _aiRCIndices.Push(3); pind[0] = ctVertices+2; pind[1] = ctVertices+3; pind[2] = ctVertices+0; @@ -123,7 +123,7 @@ static FLOAT HitCheckQuad(const PIX ix, const PIX iz) (pvx[0].y<=_fMaxHeight || pvx[3].y<=_fMaxHeight || pvx[1].y<=_fMaxHeight) && ((pvx[0].shade + pvx[3].shade + pvx[1].shade == 255*3) | _bHitInvisibleTris)) { // Add this triangle - INDEX *pind = _aiRCIndices.Push(3); + INDEX_T *pind = _aiRCIndices.Push(3); pind[0] = ctVertices+0; pind[1] = ctVertices+3; pind[2] = ctVertices+1; @@ -135,10 +135,10 @@ static FLOAT HitCheckQuad(const PIX ix, const PIX iz) return fDistance; } - INDEX *paiIndices = &_aiRCIndices[_aiRCIndices.Count() - ctIndices]; + INDEX_T *paiIndices = &_aiRCIndices[_aiRCIndices.Count() - ctIndices]; // for each triangle for(INDEX iTri=0;iTri _avLerpedTileLayerVertices; // Arrays for batch rendering of tiles is lowest mip static CStaticStackArray _avDelayedVertices; -static CStaticStackArray _aiDelayedIndices; +static CStaticStackArray _aiDelayedIndices; static CStaticStackArray _auvDelayedTexCoords; static CStaticStackArray _auvDelayedShadowMapTC; @@ -770,7 +770,7 @@ static void RenderBatchedTiles(void) GFXVertex4 *pavVertices = &_avDelayedVertices[0]; GFXTexCoord *pauvTexCoords = &_auvDelayedTexCoords[0]; GFXTexCoord *pauvShadowMapTC = &_auvDelayedShadowMapTC[0]; - INDEX *paiIndices = &_aiDelayedIndices[0]; + INDEX_T *paiIndices = &_aiDelayedIndices[0]; INDEX ctVertices = _avDelayedVertices.Count(); INDEX ctIndices = _aiDelayedIndices.Count(); @@ -826,12 +826,12 @@ static void BatchTile(INDEX itt) GFXVertex4 *pavVertices = &tt.GetVertices()[0]; GFXTexCoord *pauvTexCoords = &tt.GetTexCoords()[0]; GFXTexCoord *pauvShadowMapTC = &tt.GetShadowMapTC()[0]; - INDEX *paiIndices = &tt.GetIndices()[0]; + INDEX_T *paiIndices = &tt.GetIndices()[0]; GFXVertex4 *pavDelVertices = _avDelayedVertices.Push(9); GFXTexCoord *pauvDelTexCoords = _auvDelayedTexCoords.Push(9); GFXTexCoord *pauvDelShadowMapTC = _auvDelayedShadowMapTC.Push(9); - INDEX *paiDelIndices = _aiDelayedIndices.Push(24); + INDEX_T *paiDelIndices = _aiDelayedIndices.Push(24); // for each vertex in tile for(INDEX ivx=0;ivx<9;ivx++) { @@ -891,7 +891,7 @@ static void RenderFogLayer(INDEX itt) _fFogAddH = (_fog_vHDirAbs % vObjPosition) + _fog_fp.fp_fH3; GFXVertex *pvVtx; - INDEX *piIndices; + INDEX_T *piIndices; INDEX ctVertices; INDEX ctIndices; // if this is tile @@ -947,7 +947,7 @@ static void RenderHazeLayer(INDEX itt) _fHazeAdd += _vViewer(3) * (vObjPosition(3) - _aprProjection->pr_vViewerPosition(3)); GFXVertex *pvVtx; - INDEX *piIndices; + INDEX_T *piIndices; INDEX ctVertices; INDEX ctIndices; // if this is tile @@ -1103,7 +1103,7 @@ static void RenderTile(INDEX itt) gfxSetTextureMatrix2(NULL); INDEX ctIndices = tt.GetIndices().Count(); if(ctIndices>0) { - INDEX *paiIndices = &tt.GetIndices()[0]; + INDEX_T *paiIndices = &tt.GetIndices()[0]; // if detail map exists if(_ptrTerrain->tr_ptdDetailMap!=NULL) { @@ -1157,7 +1157,7 @@ static void RenderTile(INDEX itt) if(_wrpWorldRenderPrefs.wrp_shtShadows!=CWorldRenderPrefs::SHT_NONE) { gfxDepthFunc(GFX_EQUAL); INDEX ctIndices = tt.GetIndices().Count(); - INDEX *paiIndices = &tt.GetIndices()[0]; + INDEX_T *paiIndices = &tt.GetIndices()[0]; gfxSetTextureWrapping(GFX_CLAMP,GFX_CLAMP); gfxBlendFunc(GFX_DST_COLOR,GFX_SRC_COLOR); diff --git a/Sources/Engine/Terrain/TerrainTile.cpp b/Sources/Engine/Terrain/TerrainTile.cpp old mode 100644 new mode 100755 index 677551b..505f473 --- a/Sources/Engine/Terrain/TerrainTile.cpp +++ b/Sources/Engine/Terrain/TerrainTile.cpp @@ -164,7 +164,7 @@ inline void CTerrainTile::AddTriangle(INDEX iind1,INDEX iind2,INDEX iind3) } // Add one triangle - INDEX *pIndices = GetIndices().Push(3); + INDEX_T *pIndices = GetIndices().Push(3); pIndices[0] = iind1; pIndices[1] = iind2; pIndices[2] = iind3; @@ -181,14 +181,14 @@ inline void CTerrainTile::AddTriangle(INDEX iind1,INDEX iind2,INDEX iind3) COLOR ul = ttl.tl_acColors[iind1].ub.a + ttl.tl_acColors[iind2].ub.a + ttl.tl_acColors[iind3].ub.a; if(ul>0) { - INDEX *pIndices = ttl.tl_auiIndices.Push(3); + INDEX_T *pIndices = ttl.tl_auiIndices.Push(3); pIndices[0] = iind1; pIndices[1] = iind2; pIndices[2] = iind3; } } } else { - INDEX *pIndices = GetIndices().Push(3); + INDEX_T *pIndices = GetIndices().Push(3); pIndices[0] = iind1; pIndices[1] = iind2; pIndices[2] = iind3; @@ -309,7 +309,7 @@ void CTerrainTile::ReGenerateTileLayer(INDEX iTileLayer) ASSERT(ttl.tl_avVertices.Count()==0 && ttl.tl_atcTexCoords.Count()==0 && ttl.tl_auiIndices.Count()==0); GFXVertex *pvtx = ttl.tl_avVertices.Push(ctVertices); GFXTexCoord *ptc = ttl.tl_atcTexCoords.Push(ctVertices); - INDEX *pind = ttl.tl_auiIndices.Push(ctIndices); + INDEX_T *pind = ttl.tl_auiIndices.Push(ctIndices); UBYTE *pubMask = tl.tl_aubColors; INDEX ivx = 0; @@ -565,7 +565,7 @@ void CTerrainTile::UpdateQuadTreeNode() // resize aabox for this node FLOATaabbox3D bboxNewBox; GFXVertex4 *pavVertices; - INDEX *paiIndices; + INDEX_T *paiIndices; INDEX ctVertices; INDEX ctIndices; QuadTreeNode &qtn = _ptrTerrain->tr_aqtnQuadTreeNodes[tt_iIndex]; @@ -973,7 +973,7 @@ __forceinline CStaticStackArray &CTerrainTile::GetDetailTC() { TileArrays &ta = ah.ah_ataTileArrays[tt_iArrayIndex]; return ta.ta_auvDetailMap; } -__forceinline CStaticStackArray &CTerrainTile::GetIndices() { +__forceinline CStaticStackArray &CTerrainTile::GetIndices() { ASSERT(tt_iArrayIndex!=-1); ASSERT(tt_iLod!=-1); CArrayHolder &ah = _ptrTerrain->tr_aArrayHolders[tt_iLod]; diff --git a/Sources/Engine/Terrain/TerrainTile.h b/Sources/Engine/Terrain/TerrainTile.h old mode 100644 new mode 100755 index 9edb694..fb5569b --- a/Sources/Engine/Terrain/TerrainTile.h +++ b/Sources/Engine/Terrain/TerrainTile.h @@ -58,7 +58,7 @@ public: CStaticStackArray &GetTexCoords(); CStaticStackArray &GetShadowMapTC(); CStaticStackArray &GetDetailTC(); - CStaticStackArray &GetIndices(); + CStaticStackArray &GetIndices(); CStaticStackArray &GetTileLayers(); CTextureData *GetTopMap(); diff --git a/Sources/Engine/World/WorldCollision.cpp b/Sources/Engine/World/WorldCollision.cpp old mode 100644 new mode 100755 index 28e9842..bd90b80 --- a/Sources/Engine/World/WorldCollision.cpp +++ b/Sources/Engine/World/WorldCollision.cpp @@ -350,8 +350,12 @@ void CClipMove::ClipMovingSphereToBrushPolygon(const CMovingSphere &msMoving, // create an intersector CIntersector isIntersector(vHitPoint(iMajorAxis1), vHitPoint(iMajorAxis2)); // for all edges in the polygon - FOREACHINSTATICARRAY(pbpoPolygon->bpo_abpePolygonEdges, CBrushPolygonEdge, - itbpePolygonEdge) { + /*FOREACHINSTATICARRAY(pbpoPolygon->bpo_abpePolygonEdges, CBrushPolygonEdge, + itbpePolygonEdge) {*/ + CBrushPolygonEdge *itbpePolygonEdge = pbpoPolygon->bpo_abpePolygonEdges.sa_Array; + int i; + const int count = pbpoPolygon->bpo_abpePolygonEdges.sa_Count; + for (i = 0; i < count; i++, itbpePolygonEdge++) { // get edge vertices (edge direction is irrelevant here!) const FLOAT3D &vVertex0 = itbpePolygonEdge->bpe_pbedEdge->bed_pbvxVertex0->bvx_vRelative; const FLOAT3D &vVertex1 = itbpePolygonEdge->bpe_pbedEdge->bed_pbvxVertex1->bvx_vRelative; @@ -380,7 +384,11 @@ void CClipMove::ClipMovingSphereToBrushPolygon(const CMovingSphere &msMoving, } // for each edge in polygon - FOREACHINSTATICARRAY(pbpoPolygon->bpo_abpePolygonEdges, CBrushPolygonEdge, itbpe) { + //FOREACHINSTATICARRAY(pbpoPolygon->bpo_abpePolygonEdges, CBrushPolygonEdge, itbpe) { + CBrushPolygonEdge *itbpe = pbpoPolygon->bpo_abpePolygonEdges.sa_Array; + int i; + const int count = pbpoPolygon->bpo_abpePolygonEdges.sa_Count; + for (i = 0; i < count; i++, itbpe++) { // get edge vertices (edge direction is important here!) FLOAT3D vVertex0, vVertex1; itbpe->GetVertexCoordinatesRelative(vVertex0, vVertex1); @@ -509,8 +517,12 @@ void CClipMove::ClipMoveToTerrainPolygon(const FLOAT3D &v0, const FLOAT3D &v1, c { _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_CLIPMOVETOBRUSHPOLYGON); // for each sphere of entity A - FOREACHINSTATICARRAY(*cm_pamsA, CMovingSphere, itmsMoving) { - // clip moving sphere to the polygon + //FOREACHINSTATICARRAY(*cm_pamsA, CMovingSphere, itmsMoving) { + CMovingSphere *itmsMoving = cm_pamsA->sa_Array; + int i; + const int count = cm_pamsA->sa_Count; + for (i = 0; i < count; i++, itmsMoving++) { + // clip moving sphere to the polygon ClipMovingSphereToTerrainPolygon(*itmsMoving, v0, v1, v2); } _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_CLIPMOVETOBRUSHPOLYGON); @@ -523,7 +535,11 @@ void CClipMove::ClipMoveToBrushPolygon(CBrushPolygon *pbpoPolygon) { _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_CLIPMOVETOBRUSHPOLYGON); // for each sphere of entity A - FOREACHINSTATICARRAY(*cm_pamsA, CMovingSphere, itmsMoving) { + //FOREACHINSTATICARRAY(*cm_pamsA, CMovingSphere, itmsMoving) { + CMovingSphere *itmsMoving = cm_pamsA->sa_Array; + int i; + const int count = cm_pamsA->sa_Count; + for (i = 0; i < count; i++, itmsMoving++) { // clip moving sphere to the polygon ClipMovingSphereToBrushPolygon(*itmsMoving, pbpoPolygon); } @@ -869,10 +885,15 @@ void CClipMove::ClipToNonZoningSector(CBrushSector *pbsc) CPhysicsProfile::PTI_CLIPTONONZONINGSECTOR, pbsc->bsc_abpoPolygons.Count()); // for each polygon in the sector - FOREACHINSTATICARRAY(pbsc->bsc_abpoPolygons, CBrushPolygon, itbpo) { + //FOREACHINSTATICARRAY(pbsc->bsc_abpoPolygons, CBrushPolygon, itbpo) { + CBrushPolygon *itbpo = pbsc->bsc_abpoPolygons.sa_Array; + int i; + const int count = pbsc->bsc_abpoPolygons.sa_Count; + for (i = 0; i < count; i++, itbpo++) { // if its bbox has no contact with bbox of movement path, or it is passable - if (!itbpo->bpo_boxBoundingBox.HasContactWith(cm_boxMovementPath) - ||(itbpo->bpo_ulFlags&BPOF_PASSABLE)) { + __builtin_prefetch(&itbpo[1].bpo_ulFlags); + if ((itbpo->bpo_ulFlags&BPOF_PASSABLE) + ||!itbpo->bpo_boxBoundingBox.HasContactWith(cm_boxMovementPath)) { // skip it continue; } @@ -893,7 +914,7 @@ void CClipMove::ClipToTerrain(CEntity *pen) CTerrain &tr = *pen->en_ptrTerrain; GFXVertex4 *pavVertices; - INDEX *paiIndices; + INDEX_T *paiIndices; INDEX ctVertices,ctIndices; FLOAT3D vMin = cm_boxMovementPath.Min(); @@ -920,9 +941,9 @@ void CClipMove::ClipToTerrain(CEntity *pen) // for each triangle for(INDEX iTri=0;iTribsc_abpoPolygons, CBrushPolygon, itpoPolygon) { - CBrushPolygon &bpoPolygon = itpoPolygon.Current(); + // FOREACHINSTATICARRAY(pbscSector->bsc_abpoPolygons, CBrushPolygon, itpoPolygon) { + CBrushPolygon *itpoPolygon = pbscSector->bsc_abpoPolygons.sa_Array; + int i; + for (i = 0; i < pbscSector->bsc_abpoPolygons.sa_Count; i++, itpoPolygon++) { + CBrushPolygon &bpoPolygon = *itpoPolygon; if (&bpoPolygon==cr_pbpoIgnore) { continue; @@ -480,7 +486,7 @@ void CCastRay::TestBrushSector(CBrushSector *pbscSector) ULONG ulFlags = bpoPolygon.bpo_ulFlags; // if not testing recursively - if (cr_penOrigin==NULL) { + if (l_cr_penOrigin==NULL) { // if the polygon is portal if (ulFlags&BPOF_PORTAL) { // if it is translucent or selected @@ -506,13 +512,34 @@ void CCastRay::TestBrushSector(CBrushSector *pbscSector) continue; } } +#ifdef __ARM_NEON__ // get distances of ray points from the polygon plane + register FLOAT fDistance0 __asm__("s0") = bpoPolygon.bpo_pbplPlane->bpl_plAbsolute.PointDistance(cr_vOrigin); + register FLOAT fDistance1 __asm__("s2") = bpoPolygon.bpo_pbplPlane->bpl_plAbsolute.PointDistance(cr_vTarget); + FLOAT fFraction; + int gege; + __asm__ __volatile__ ( + "vcge.f32 d2, d0, #0\n" + "vcge.f32 d3, d0, d1\n" + "vand d2, d3\n" + "ldr %[gege], %[nnpptr]\n" // take the cache miss, slight chance of a crash + "pld %[nplane]\n" + "vmov %[gege], d2[0]\n" + : [gege] "=&r"(gege) + : [nnpptr] "m"(itpoPolygon[2].bpo_pbplPlane), + [nplane] "m"(*itpoPolygon[1].bpo_pbplPlane), + "t"(fDistance0), "t"(fDistance1) + : "d2", "d3" + ); + + if (gege) { +#else FLOAT fDistance0 = bpoPolygon.bpo_pbplPlane->bpl_plAbsolute.PointDistance(cr_vOrigin); FLOAT fDistance1 = bpoPolygon.bpo_pbplPlane->bpl_plAbsolute.PointDistance(cr_vTarget); - // if the ray hits the polygon plane if (fDistance0>=0 && fDistance0>=fDistance1) { // calculate fraction of line before intersection +#endif FLOAT fFraction = fDistance0/((fDistance0-fDistance1) + 0.0000001f/*correction*/); // calculate intersection coordinate FLOAT3D vHitPoint = cr_vOrigin+(cr_vTarget-cr_vOrigin)*fFraction; diff --git a/Sources/EntitiesMP/PlayerView.es b/Sources/EntitiesMP/PlayerView.es index cf9efa6..25b7653 100755 --- a/Sources/EntitiesMP/PlayerView.es +++ b/Sources/EntitiesMP/PlayerView.es @@ -103,7 +103,7 @@ functions: // 3rd person view FLOAT fDistance = 1.0f; CPlacement3D pl = ((CPlayerEntity&) *m_penOwner).en_plViewpoint; - BOOL bFollowCrossHair; + BOOL bFollowCrossHair = TRUE; if (m_iViewType == VT_3RDPERSONVIEW) { // little above player eyes so it can be seen where he is firing diff --git a/Sources/GameMP/Game.cpp b/Sources/GameMP/Game.cpp index 0b9a2dd..06584b6 100755 --- a/Sources/GameMP/Game.cpp +++ b/Sources/GameMP/Game.cpp @@ -1903,6 +1903,7 @@ static void PrintStats( CDrawPort *pdpDrawPort) // display nothing _iCheckNow = 0; _iCheckMax = 0; + STAT_Enable(FALSE); return; } @@ -1943,6 +1944,7 @@ static void PrintStats( CDrawPort *pdpDrawPort) if( hud_iStats==2 && hud_iEnableStats) { // display extensive statistics CTString strReport; + STAT_Enable(TRUE); STAT_Report(strReport); STAT_Reset(); @@ -1958,6 +1960,7 @@ static void PrintStats( CDrawPort *pdpDrawPort) pdpDrawPort->PutText( strFPS, 0, 40, C_WHITE|CT_OPAQUE); pdpDrawPort->PutText( strReport, 4, 65, C_GREEN|CT_OPAQUE); } + else STAT_Enable(FALSE); } diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp index 8e246b8..e21bf1d 100755 --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -477,6 +477,17 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine) SDL_Init(SDL_INIT_JOYSTICK); // don't care if this fails. #endif +#ifdef PLATFORM_PANDORA + // enable Cortex A8 RunFast + int v = 0; + __asm__ __volatile__ ( + "vmrs %0, fpscr\n" + "orr %0, #((1<<25)|(1<<24))\n" // default NaN, flush-to-zero + "vmsr fpscr, %0\n" + //"vmrs %0, fpscr\n" + : "=&r"(v)); +#endif + _hInstance = hInstance; ShowSplashScreen(hInstance);